@eclipse-glsp/client 0.10.0-next.e5fcffe.169 → 1.1.0-next.fe0b297.182
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/decoration.css +5 -1
- package/css/glsp-sprotty.css +39 -0
- package/css/tool-palette.css +2 -2
- package/lib/base/container-modules.d.ts.map +1 -1
- package/lib/base/container-modules.js +10 -9
- package/lib/base/container-modules.js.map +1 -1
- package/lib/base/editor-context-service.d.ts +2 -3
- package/lib/base/editor-context-service.d.ts.map +1 -1
- package/lib/base/editor-context-service.js +11 -12
- package/lib/base/editor-context-service.js.map +1 -1
- package/lib/base/model/update-model-command.d.ts +14 -7
- package/lib/base/model/update-model-command.d.ts.map +1 -1
- package/lib/base/model/update-model-command.js +31 -41
- package/lib/base/model/update-model-command.js.map +1 -1
- package/lib/base/source-uri-aware.d.ts +2 -17
- package/lib/base/source-uri-aware.d.ts.map +1 -1
- package/lib/base/source-uri-aware.js +4 -6
- package/lib/base/source-uri-aware.js.map +1 -1
- package/lib/features/change-bounds/movement-restrictor.d.ts +36 -6
- package/lib/features/change-bounds/movement-restrictor.d.ts.map +1 -1
- package/lib/features/change-bounds/movement-restrictor.js +54 -39
- package/lib/features/change-bounds/movement-restrictor.js.map +1 -1
- package/lib/features/change-bounds/snap.d.ts +20 -5
- package/lib/features/change-bounds/snap.d.ts.map +1 -1
- package/lib/features/change-bounds/snap.js +19 -8
- package/lib/features/change-bounds/snap.js.map +1 -1
- package/lib/features/context-menu/selection-service-aware-context-menu-mouse-listener.d.ts +5 -7
- package/lib/features/context-menu/selection-service-aware-context-menu-mouse-listener.d.ts.map +1 -1
- package/lib/features/context-menu/selection-service-aware-context-menu-mouse-listener.js +7 -14
- package/lib/features/context-menu/selection-service-aware-context-menu-mouse-listener.js.map +1 -1
- package/lib/features/hover/hover.d.ts +1 -2
- package/lib/features/hover/hover.d.ts.map +1 -1
- package/lib/features/hover/hover.js +2 -15
- package/lib/features/hover/hover.js.map +1 -1
- package/lib/features/layout/di.config.d.ts +2 -2
- package/lib/features/layout/di.config.d.ts.map +1 -1
- package/lib/features/layout/di.config.js +6 -5
- package/lib/features/layout/di.config.js.map +1 -1
- package/lib/features/layout/{layout-commands.d.ts → layout-elements-action.d.ts} +75 -57
- package/lib/features/layout/layout-elements-action.d.ts.map +1 -0
- package/lib/features/layout/{layout-commands.js → layout-elements-action.js} +153 -197
- package/lib/features/layout/layout-elements-action.js.map +1 -0
- package/lib/features/layout/layout-elements-action.spec.d.ts +3 -0
- package/lib/features/layout/layout-elements-action.spec.d.ts.map +1 -0
- package/lib/features/layout/{layout-commands.spec.js → layout-elements-action.spec.js} +63 -56
- package/lib/features/layout/layout-elements-action.spec.js.map +1 -0
- package/lib/features/mouse-tool/mouse-tool.d.ts +0 -1
- package/lib/features/mouse-tool/mouse-tool.d.ts.map +1 -1
- package/lib/features/mouse-tool/mouse-tool.js +9 -5
- package/lib/features/mouse-tool/mouse-tool.js.map +1 -1
- package/lib/features/select/select-mouse-listener.d.ts +3 -1
- package/lib/features/select/select-mouse-listener.d.ts.map +1 -1
- package/lib/features/select/select-mouse-listener.js +62 -0
- package/lib/features/select/select-mouse-listener.js.map +1 -1
- package/lib/features/select/selection-service.d.ts +12 -3
- package/lib/features/select/selection-service.d.ts.map +1 -1
- package/lib/features/select/selection-service.js +31 -45
- package/lib/features/select/selection-service.js.map +1 -1
- package/lib/features/select/selection-service.spec.js +1 -1
- package/lib/features/select/selection-service.spec.js.map +1 -1
- package/lib/features/source-model-watcher/di.config.d.ts +4 -0
- package/lib/features/{model-source-watcher → source-model-watcher}/di.config.d.ts.map +1 -1
- package/lib/features/{model-source-watcher → source-model-watcher}/di.config.js +4 -4
- package/lib/features/{model-source-watcher → source-model-watcher}/di.config.js.map +1 -1
- package/lib/features/{model-source-watcher/model-source-changed-action-handler.d.ts → source-model-watcher/source-model-changed-action-handler.d.ts} +9 -9
- package/lib/features/{model-source-watcher/model-source-changed-action-handler.d.ts.map → source-model-watcher/source-model-changed-action-handler.d.ts.map} +1 -1
- package/lib/features/{model-source-watcher/model-source-changed-action-handler.js → source-model-watcher/source-model-changed-action-handler.js} +19 -19
- package/lib/features/{model-source-watcher/model-source-changed-action-handler.js.map → source-model-watcher/source-model-changed-action-handler.js.map} +1 -1
- package/lib/features/tool-feedback/change-bounds-tool-feedback.js +1 -1
- package/lib/features/tool-feedback/change-bounds-tool-feedback.js.map +1 -1
- package/lib/features/tool-feedback/edge-edit-tool-feedback.d.ts +3 -2
- package/lib/features/tool-feedback/edge-edit-tool-feedback.d.ts.map +1 -1
- package/lib/features/tool-feedback/edge-edit-tool-feedback.js +13 -6
- package/lib/features/tool-feedback/edge-edit-tool-feedback.js.map +1 -1
- package/lib/features/tools/di.config.d.ts +9 -2
- package/lib/features/tools/di.config.d.ts.map +1 -1
- package/lib/features/tools/di.config.js +14 -3
- package/lib/features/tools/di.config.js.map +1 -1
- package/lib/features/tools/enable-default-tools-on-focus-loss.d.ts +26 -0
- package/lib/features/tools/enable-default-tools-on-focus-loss.d.ts.map +1 -0
- package/lib/features/tools/enable-default-tools-on-focus-loss.js +29 -0
- package/lib/features/tools/enable-default-tools-on-focus-loss.js.map +1 -0
- package/lib/features/validation/di.config.d.ts +0 -15
- package/lib/features/validation/di.config.d.ts.map +1 -1
- package/lib/features/validation/di.config.js +6 -4
- package/lib/features/validation/di.config.js.map +1 -1
- package/lib/features/validation/issue-marker.d.ts +11 -5
- package/lib/features/validation/issue-marker.d.ts.map +1 -1
- package/lib/features/validation/issue-marker.js +25 -5
- package/lib/features/validation/issue-marker.js.map +1 -1
- package/lib/features/validation/marker-navigator.d.ts +11 -17
- package/lib/features/validation/marker-navigator.d.ts.map +1 -1
- package/lib/features/validation/marker-navigator.js +32 -61
- package/lib/features/validation/marker-navigator.js.map +1 -1
- package/lib/features/validation/validate.d.ts +8 -19
- package/lib/features/validation/validate.d.ts.map +1 -1
- package/lib/features/validation/validate.js +29 -55
- package/lib/features/validation/validate.js.map +1 -1
- package/lib/index.d.ts +6 -6
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +16 -15
- package/lib/index.js.map +1 -1
- package/lib/lib/model.d.ts +1 -1
- package/lib/lib/model.d.ts.map +1 -1
- package/lib/lib/model.js +3 -3
- package/lib/lib/model.js.map +1 -1
- package/lib/model-source/glsp-diagram-server.d.ts +1 -1
- package/lib/model-source/glsp-diagram-server.d.ts.map +1 -1
- package/lib/model-source/glsp-diagram-server.js +1 -1
- package/lib/model-source/glsp-diagram-server.js.map +1 -1
- package/lib/utils/layout-utils.d.ts +4 -20
- package/lib/utils/layout-utils.d.ts.map +1 -1
- package/lib/utils/layout-utils.js +1 -1
- package/lib/utils/layout-utils.js.map +1 -1
- package/lib/views/base-view-module.d.ts.map +1 -1
- package/lib/views/base-view-module.js +3 -1
- package/lib/views/base-view-module.js.map +1 -1
- package/lib/views/glsp-projection-view.d.ts +30 -0
- package/lib/views/glsp-projection-view.d.ts.map +1 -0
- package/lib/views/glsp-projection-view.js +142 -0
- package/lib/views/glsp-projection-view.js.map +1 -0
- package/lib/views/index.d.ts +1 -0
- package/lib/views/index.d.ts.map +1 -1
- package/lib/views/index.js +1 -0
- package/lib/views/index.js.map +1 -1
- package/package.json +4 -4
- package/src/base/container-modules.ts +6 -5
- package/src/base/editor-context-service.ts +15 -7
- package/src/base/model/update-model-command.ts +48 -34
- package/src/base/source-uri-aware.ts +5 -4
- package/src/features/change-bounds/movement-restrictor.ts +73 -43
- package/src/features/change-bounds/snap.ts +15 -12
- package/src/features/context-menu/selection-service-aware-context-menu-mouse-listener.ts +19 -25
- package/src/features/hover/hover.ts +2 -24
- package/src/features/layout/di.config.ts +12 -6
- package/src/features/layout/{layout-commands.spec.ts → layout-elements-action.spec.ts} +56 -48
- package/src/features/layout/{layout-commands.ts → layout-elements-action.ts} +195 -207
- package/src/features/mouse-tool/mouse-tool.ts +8 -6
- package/src/features/select/select-mouse-listener.ts +81 -1
- package/src/features/select/selection-service.spec.ts +1 -1
- package/src/features/select/selection-service.ts +37 -50
- package/src/features/{model-source-watcher → source-model-watcher}/di.config.ts +5 -5
- package/src/features/{model-source-watcher/model-source-changed-action-handler.ts → source-model-watcher/source-model-changed-action-handler.ts} +12 -12
- package/src/features/tool-feedback/change-bounds-tool-feedback.ts +1 -1
- package/src/features/tool-feedback/edge-edit-tool-feedback.ts +14 -6
- package/src/features/tools/di.config.ts +13 -2
- package/src/features/tools/enable-default-tools-on-focus-loss.ts +33 -0
- package/src/features/validation/di.config.ts +10 -7
- package/src/features/validation/issue-marker.ts +34 -12
- package/src/features/validation/marker-navigator.ts +29 -66
- package/src/features/validation/validate.ts +36 -71
- package/src/index.ts +8 -7
- package/src/lib/model.ts +1 -1
- package/src/model-source/glsp-diagram-server.ts +1 -1
- package/src/utils/layout-utils.ts +7 -27
- package/src/views/base-view-module.ts +5 -1
- package/src/views/glsp-projection-view.tsx +166 -0
- package/src/views/index.ts +2 -0
- package/lib/features/layout/layout-commands.d.ts.map +0 -1
- package/lib/features/layout/layout-commands.js.map +0 -1
- package/lib/features/layout/layout-commands.spec.d.ts +0 -3
- package/lib/features/layout/layout-commands.spec.d.ts.map +0 -1
- package/lib/features/layout/layout-commands.spec.js.map +0 -1
- package/lib/features/model-source-watcher/di.config.d.ts +0 -4
|
@@ -16,12 +16,10 @@
|
|
|
16
16
|
import { Action, CenterAction, hasArrayProp, hasStringProp, Point, SelectAction } from '@eclipse-glsp/protocol';
|
|
17
17
|
import { inject, injectable } from 'inversify';
|
|
18
18
|
import {
|
|
19
|
+
ActionDispatcher,
|
|
19
20
|
BoundsAware,
|
|
20
|
-
CenterCommand,
|
|
21
|
-
Command,
|
|
22
|
-
CommandExecutionContext,
|
|
23
|
-
CommandReturn,
|
|
24
21
|
findParentByFeature,
|
|
22
|
+
IActionHandler,
|
|
25
23
|
IContextMenuItemProvider,
|
|
26
24
|
isBoundsAware,
|
|
27
25
|
isSelectable,
|
|
@@ -36,8 +34,8 @@ import {
|
|
|
36
34
|
import { matchesKeystroke } from 'sprotty/lib/utils/keyboard';
|
|
37
35
|
import { TYPES } from '../../base/types';
|
|
38
36
|
import { collectIssueMarkers, MarkerPredicates } from '../../utils/marker';
|
|
39
|
-
import { isSelectableAndBoundsAware } from '../../utils/smodel-util';
|
|
40
|
-
import {
|
|
37
|
+
import { getElements, isSelectableAndBoundsAware } from '../../utils/smodel-util';
|
|
38
|
+
import { SelectionService } from '../select/selection-service';
|
|
41
39
|
|
|
42
40
|
export interface NavigateToMarkerAction extends Action {
|
|
43
41
|
kind: typeof NavigateToMarkerAction.KIND;
|
|
@@ -106,7 +104,7 @@ export class MarkerNavigator {
|
|
|
106
104
|
protected markerComparator: SModelElementComparator;
|
|
107
105
|
|
|
108
106
|
next(
|
|
109
|
-
root: SModelRoot
|
|
107
|
+
root: Readonly<SModelRoot>,
|
|
110
108
|
current?: SModelElement & BoundsAware,
|
|
111
109
|
predicate: (marker: SIssueMarker) => boolean = MarkerPredicates.ALL
|
|
112
110
|
): SIssueMarker | undefined {
|
|
@@ -118,7 +116,7 @@ export class MarkerNavigator {
|
|
|
118
116
|
}
|
|
119
117
|
|
|
120
118
|
previous(
|
|
121
|
-
root: SModelRoot
|
|
119
|
+
root: Readonly<SModelRoot>,
|
|
122
120
|
current?: SModelElement & BoundsAware,
|
|
123
121
|
predicate: (marker: SIssueMarker) => boolean = MarkerPredicates.ALL
|
|
124
122
|
): SIssueMarker | undefined {
|
|
@@ -129,7 +127,7 @@ export class MarkerNavigator {
|
|
|
129
127
|
return markers[this.getPreviousIndex(current, markers) % markers.length];
|
|
130
128
|
}
|
|
131
129
|
|
|
132
|
-
protected getMarkers(root: SModelRoot
|
|
130
|
+
protected getMarkers(root: Readonly<SModelRoot>, predicate: (marker: SIssueMarker) => boolean): SIssueMarker[] {
|
|
133
131
|
const markers = collectIssueMarkers(root);
|
|
134
132
|
return markers.filter(predicate).sort(this.markerComparator.compare);
|
|
135
133
|
}
|
|
@@ -154,9 +152,7 @@ export class MarkerNavigator {
|
|
|
154
152
|
}
|
|
155
153
|
|
|
156
154
|
@injectable()
|
|
157
|
-
export class
|
|
158
|
-
static KIND = NavigateToMarkerAction.KIND;
|
|
159
|
-
|
|
155
|
+
export class NavigateToMarkerActionHandler implements IActionHandler {
|
|
160
156
|
@inject(SModelElementComparator)
|
|
161
157
|
protected markerComparator: SModelElementComparator;
|
|
162
158
|
|
|
@@ -166,73 +162,40 @@ export class NavigateToMarkerCommand extends Command {
|
|
|
166
162
|
@inject(TYPES.SelectionService)
|
|
167
163
|
protected selectionService: SelectionService;
|
|
168
164
|
|
|
169
|
-
|
|
170
|
-
protected
|
|
171
|
-
|
|
172
|
-
constructor(@inject(TYPES.Action) protected action: NavigateToMarkerAction) {
|
|
173
|
-
super();
|
|
174
|
-
}
|
|
165
|
+
@inject(TYPES.IActionDispatcher)
|
|
166
|
+
protected actionDispatcher: ActionDispatcher;
|
|
175
167
|
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
const target = this.getTarget(selected, root);
|
|
180
|
-
if (target === undefined) {
|
|
181
|
-
return root;
|
|
182
|
-
}
|
|
168
|
+
handle(action: NavigateToMarkerAction): void {
|
|
169
|
+
const selected = this.getSelectedElements(action);
|
|
170
|
+
const target = this.getTarget(action, selected);
|
|
183
171
|
|
|
184
|
-
const selectableTarget = findParentByFeature(target, isSelectable);
|
|
172
|
+
const selectableTarget = target ? findParentByFeature(target, isSelectable) : undefined;
|
|
185
173
|
if (selectableTarget) {
|
|
186
|
-
const
|
|
187
|
-
this.
|
|
188
|
-
|
|
189
|
-
this.selectionService
|
|
190
|
-
);
|
|
191
|
-
this.centerCommand = new CenterCommand(CenterAction.create([selectableTarget.id]));
|
|
192
|
-
this.centerCommand.execute(context);
|
|
193
|
-
return this.selectCommand.execute(context);
|
|
174
|
+
const deselectedElementsIDs = selected.map(e => e.id).filter(id => id !== selectableTarget.id);
|
|
175
|
+
this.actionDispatcher.dispatch(SelectAction.create({ selectedElementsIDs: [selectableTarget.id], deselectedElementsIDs }));
|
|
176
|
+
this.actionDispatcher.dispatch(CenterAction.create([selectableTarget.id]));
|
|
194
177
|
}
|
|
195
|
-
return root;
|
|
196
178
|
}
|
|
197
179
|
|
|
198
|
-
protected getSelectedElements(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
selectedIds = this.action.selectedElementIds;
|
|
202
|
-
} else {
|
|
203
|
-
return this.selectionService.getSelectedElements();
|
|
180
|
+
protected getSelectedElements(action: NavigateToMarkerAction): (SModelElement & Selectable)[] {
|
|
181
|
+
if (action.selectedElementIds && action.selectedElementIds.length > 0) {
|
|
182
|
+
return getElements(this.selectionService.getModelRoot().index, action.selectedElementIds, isSelectable);
|
|
204
183
|
}
|
|
205
|
-
return
|
|
206
|
-
SModelElement & Selectable
|
|
207
|
-
>;
|
|
184
|
+
return this.selectionService.getSelectedElements();
|
|
208
185
|
}
|
|
209
186
|
|
|
210
|
-
protected getTarget(selected: SModelElement[]
|
|
211
|
-
const
|
|
212
|
-
const
|
|
213
|
-
if (
|
|
214
|
-
return this.markerNavigator.previous(root,
|
|
187
|
+
protected getTarget(action: NavigateToMarkerAction, selected: SModelElement[]): SIssueMarker | undefined {
|
|
188
|
+
const root = this.selectionService.getModelRoot();
|
|
189
|
+
const target = selected.sort(this.markerComparator.compare).find(isBoundsAware);
|
|
190
|
+
if (action.direction === 'previous') {
|
|
191
|
+
return this.markerNavigator.previous(root, target, marker => this.matchesSeverities(action, marker));
|
|
215
192
|
} else {
|
|
216
|
-
return this.markerNavigator.next(root,
|
|
193
|
+
return this.markerNavigator.next(root, target, marker => this.matchesSeverities(action, marker));
|
|
217
194
|
}
|
|
218
195
|
}
|
|
219
196
|
|
|
220
|
-
protected matchesSeverities(marker: SIssueMarker): boolean {
|
|
221
|
-
return marker.issues.find(issue =>
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
undo(context: CommandExecutionContext): CommandReturn {
|
|
225
|
-
if (this.selectCommand) {
|
|
226
|
-
context.root = this.selectCommand.undo(context);
|
|
227
|
-
}
|
|
228
|
-
return this.centerCommand ? this.centerCommand.undo(context) : context.root;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
redo(context: CommandExecutionContext): CommandReturn {
|
|
232
|
-
if (this.selectCommand) {
|
|
233
|
-
context.root = this.selectCommand.redo(context);
|
|
234
|
-
}
|
|
235
|
-
return this.centerCommand ? this.centerCommand.redo(context) : context.root;
|
|
197
|
+
protected matchesSeverities(action: NavigateToMarkerAction, marker: SIssueMarker): boolean {
|
|
198
|
+
return marker.issues.find(issue => action.severities.includes(issue.severity)) !== undefined;
|
|
236
199
|
}
|
|
237
200
|
}
|
|
238
201
|
|
|
@@ -15,24 +15,13 @@
|
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import { Action, DeleteMarkersAction, hasArrayProp, Marker, SetMarkersAction } from '@eclipse-glsp/protocol';
|
|
17
17
|
import { inject, injectable, optional } from 'inversify';
|
|
18
|
-
import {
|
|
19
|
-
Command,
|
|
20
|
-
CommandExecutionContext,
|
|
21
|
-
CommandReturn,
|
|
22
|
-
IActionDispatcher,
|
|
23
|
-
SIssue,
|
|
24
|
-
SIssueMarker,
|
|
25
|
-
SModelElement,
|
|
26
|
-
SModelRoot,
|
|
27
|
-
SParentElement
|
|
28
|
-
} from 'sprotty';
|
|
18
|
+
import { CommandExecutionContext, CommandReturn, IActionDispatcher, IActionHandler, ICommand, SIssueMarker, SParentElement } from 'sprotty';
|
|
29
19
|
import { EditorContextService } from '../../base/editor-context-service';
|
|
30
20
|
import { TYPES } from '../../base/types';
|
|
31
21
|
import { removeCssClasses } from '../../utils/smodel-util';
|
|
32
|
-
import { getSeverity } from '../hover/hover';
|
|
33
22
|
import { IFeedbackActionDispatcher, IFeedbackEmitter } from '../tool-feedback/feedback-action-dispatcher';
|
|
34
23
|
import { FeedbackCommand } from '../tool-feedback/model';
|
|
35
|
-
import { createSIssue, getOrCreateSIssueMarker, getSIssueMarker } from './issue-marker';
|
|
24
|
+
import { createSIssue, getOrCreateSIssueMarker, getSeverity, getSIssueMarker, GIssueMarker } from './issue-marker';
|
|
36
25
|
|
|
37
26
|
/**
|
|
38
27
|
* Feedback emitter sending actions for visualizing model validation feedback and
|
|
@@ -94,43 +83,33 @@ export abstract class ExternalMarkerManager {
|
|
|
94
83
|
abstract setMarkers(markers: Marker[], sourceUri?: string): void;
|
|
95
84
|
}
|
|
96
85
|
|
|
97
|
-
/**
|
|
98
|
-
* Command for handling `SetMarkersAction`
|
|
99
|
-
*/
|
|
100
86
|
@injectable()
|
|
101
|
-
export class
|
|
102
|
-
@inject(ValidationFeedbackEmitter)
|
|
103
|
-
|
|
104
|
-
@inject(EditorContextService) protected editorContextService: EditorContextService;
|
|
87
|
+
export class SetMarkersActionHandler implements IActionHandler {
|
|
88
|
+
@inject(ValidationFeedbackEmitter)
|
|
89
|
+
protected validationFeedbackEmitter: ValidationFeedbackEmitter;
|
|
105
90
|
|
|
106
|
-
|
|
91
|
+
@inject(ExternalMarkerManager)
|
|
92
|
+
@optional()
|
|
93
|
+
protected externalMarkerManager?: ExternalMarkerManager;
|
|
107
94
|
|
|
108
|
-
|
|
109
|
-
|
|
95
|
+
@inject(EditorContextService)
|
|
96
|
+
protected editorContextService: EditorContextService;
|
|
97
|
+
|
|
98
|
+
handle(action: SetMarkersAction): void | Action | ICommand {
|
|
99
|
+
const markers: Marker[] = action.markers;
|
|
100
|
+
this.setMarkers(markers);
|
|
110
101
|
}
|
|
111
102
|
|
|
112
|
-
async
|
|
113
|
-
const markers: Marker[] = this.action.markers;
|
|
103
|
+
async setMarkers(markers: Marker[]): Promise<void> {
|
|
114
104
|
const uri = await this.editorContextService.getSourceUri();
|
|
115
|
-
|
|
116
|
-
this.externalMarkerManager.setMarkers(markers, uri);
|
|
117
|
-
}
|
|
105
|
+
this.externalMarkerManager?.setMarkers(markers, uri);
|
|
118
106
|
const applyMarkersAction = ApplyMarkersAction.create(markers);
|
|
119
107
|
this.validationFeedbackEmitter.registerValidationFeedbackAction(applyMarkersAction);
|
|
120
|
-
return context.root;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
undo(context: CommandExecutionContext): CommandReturn {
|
|
124
|
-
return context.root;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
redo(context: CommandExecutionContext): CommandReturn {
|
|
128
|
-
return this.execute(context);
|
|
129
108
|
}
|
|
130
109
|
}
|
|
131
110
|
|
|
132
111
|
/**
|
|
133
|
-
* Action for applying makers to
|
|
112
|
+
* Action for applying makers to the graphical model.
|
|
134
113
|
*/
|
|
135
114
|
export interface ApplyMarkersAction extends Action {
|
|
136
115
|
kind: typeof ApplyMarkersAction.KIND;
|
|
@@ -153,43 +132,36 @@ export namespace ApplyMarkersAction {
|
|
|
153
132
|
}
|
|
154
133
|
|
|
155
134
|
/**
|
|
156
|
-
*
|
|
135
|
+
* Handles {@link ApplyMarkersAction}s by creating the corresponding {@link SIssueMarker}s and
|
|
136
|
+
* adding them to the graphical model.
|
|
157
137
|
*/
|
|
158
138
|
@injectable()
|
|
159
139
|
export class ApplyMarkersCommand extends FeedbackCommand {
|
|
160
140
|
static KIND = ApplyMarkersAction.KIND;
|
|
161
|
-
override readonly priority = 0;
|
|
162
141
|
|
|
163
142
|
constructor(@inject(TYPES.Action) protected action: ApplyMarkersAction) {
|
|
164
143
|
super();
|
|
165
144
|
}
|
|
166
145
|
|
|
167
146
|
execute(context: CommandExecutionContext): CommandReturn {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const modelElement: SModelElement | undefined = context.root.index.getById(marker.elementId);
|
|
147
|
+
this.action.markers.forEach(marker => {
|
|
148
|
+
const modelElement = context.root.index.getById(marker.elementId);
|
|
171
149
|
if (modelElement instanceof SParentElement) {
|
|
172
|
-
const issueMarker
|
|
173
|
-
const issue
|
|
150
|
+
const issueMarker = getOrCreateSIssueMarker(modelElement);
|
|
151
|
+
const issue = createSIssue(marker);
|
|
174
152
|
issueMarker.issues.push(issue);
|
|
153
|
+
if (issueMarker instanceof GIssueMarker) {
|
|
154
|
+
issueMarker.computeProjectionCssClasses();
|
|
155
|
+
}
|
|
175
156
|
addMaxSeverityCSSClassToIssueParent(modelElement, issueMarker);
|
|
176
157
|
}
|
|
177
|
-
}
|
|
178
|
-
return context.root;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
override undo(context: CommandExecutionContext): CommandReturn {
|
|
158
|
+
});
|
|
182
159
|
return context.root;
|
|
183
160
|
}
|
|
184
|
-
|
|
185
|
-
override redo(context: CommandExecutionContext): CommandReturn {
|
|
186
|
-
return this.execute(context);
|
|
187
|
-
}
|
|
188
161
|
}
|
|
189
162
|
|
|
190
163
|
function addMaxSeverityCSSClassToIssueParent(modelElement: SParentElement, issueMarker: SIssueMarker): void {
|
|
191
164
|
const maxSeverityCSSClass = getSeverity(issueMarker);
|
|
192
|
-
|
|
193
165
|
if (!modelElement.cssClasses) {
|
|
194
166
|
modelElement.cssClasses = [maxSeverityCSSClass];
|
|
195
167
|
} else {
|
|
@@ -199,14 +171,15 @@ function addMaxSeverityCSSClassToIssueParent(modelElement: SParentElement, issue
|
|
|
199
171
|
}
|
|
200
172
|
|
|
201
173
|
function removeCSSClassFromIssueParent(modelElement: SParentElement, issueMarker: SIssueMarker): void {
|
|
202
|
-
|
|
174
|
+
const severity = getSeverity(issueMarker);
|
|
175
|
+
removeCssClasses(modelElement, [severity]);
|
|
203
176
|
}
|
|
204
177
|
|
|
205
178
|
/**
|
|
206
179
|
* Command for handling `DeleteMarkersAction`
|
|
207
180
|
*/
|
|
208
181
|
@injectable()
|
|
209
|
-
export class DeleteMarkersCommand extends
|
|
182
|
+
export class DeleteMarkersCommand extends FeedbackCommand {
|
|
210
183
|
static KIND = DeleteMarkersAction.KIND;
|
|
211
184
|
|
|
212
185
|
constructor(@inject(TYPES.Action) protected action: DeleteMarkersAction) {
|
|
@@ -214,15 +187,14 @@ export class DeleteMarkersCommand extends Command {
|
|
|
214
187
|
}
|
|
215
188
|
|
|
216
189
|
execute(context: CommandExecutionContext): CommandReturn {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const modelElement: SModelElement | undefined = context.root.index.getById(marker.elementId);
|
|
190
|
+
this.action.markers.forEach(marker => {
|
|
191
|
+
const modelElement = context.root.index.getById(marker.elementId);
|
|
220
192
|
if (modelElement instanceof SParentElement) {
|
|
221
|
-
const issueMarker
|
|
222
|
-
if (issueMarker
|
|
193
|
+
const issueMarker = getSIssueMarker(modelElement);
|
|
194
|
+
if (issueMarker) {
|
|
223
195
|
removeCSSClassFromIssueParent(modelElement, issueMarker);
|
|
224
196
|
for (let index = 0; index < issueMarker.issues.length; ++index) {
|
|
225
|
-
const issue
|
|
197
|
+
const issue = issueMarker.issues[index];
|
|
226
198
|
if (issue.message === marker.description) {
|
|
227
199
|
issueMarker.issues.splice(index--, 1);
|
|
228
200
|
}
|
|
@@ -234,15 +206,8 @@ export class DeleteMarkersCommand extends Command {
|
|
|
234
206
|
}
|
|
235
207
|
}
|
|
236
208
|
}
|
|
237
|
-
}
|
|
238
|
-
return context.root;
|
|
239
|
-
}
|
|
209
|
+
});
|
|
240
210
|
|
|
241
|
-
undo(context: CommandExecutionContext): CommandReturn {
|
|
242
211
|
return context.root;
|
|
243
212
|
}
|
|
244
|
-
|
|
245
|
-
redo(context: CommandExecutionContext): CommandReturn {
|
|
246
|
-
return this.execute(context);
|
|
247
|
-
}
|
|
248
213
|
}
|
package/src/index.ts
CHANGED
|
@@ -21,15 +21,15 @@ import glspDecorationModule from './features/decoration/di.config';
|
|
|
21
21
|
import glspEditLabelModule from './features/edit-label/di.config';
|
|
22
22
|
import modelHintsModule from './features/hints/di.config';
|
|
23
23
|
import glspHoverModule from './features/hover/di.config';
|
|
24
|
-
import
|
|
25
|
-
import modelSourceWatcherModule from './features/model-source-watcher/di.config';
|
|
24
|
+
import layoutModule from './features/layout/di.config';
|
|
26
25
|
import glspMouseToolModule from './features/mouse-tool/di.config';
|
|
27
26
|
import { navigationModule } from './features/navigation/di.config';
|
|
28
27
|
import saveModule from './features/save/di.config';
|
|
29
28
|
import glspSelectModule from './features/select/di.config';
|
|
29
|
+
import sourceModelWatcherModule from './features/source-model-watcher/di.config';
|
|
30
30
|
import toolFeedbackModule from './features/tool-feedback/di.config';
|
|
31
31
|
import paletteModule from './features/tool-palette/di.config';
|
|
32
|
-
import toolsModule from './features/tools/di.config';
|
|
32
|
+
import { enableDefaultToolsOnFocusLossModule, toolsModule } from './features/tools/di.config';
|
|
33
33
|
import { markerNavigatorModule, validationModule } from './features/validation/di.config';
|
|
34
34
|
import glspViewportModule from './features/viewport/di.config';
|
|
35
35
|
|
|
@@ -65,8 +65,7 @@ export * from './features/edit-label/edit-label-validator';
|
|
|
65
65
|
export * from './features/hints/model';
|
|
66
66
|
export * from './features/hints/type-hints';
|
|
67
67
|
export * from './features/hover/hover';
|
|
68
|
-
export * from './features/layout/layout-
|
|
69
|
-
export * from './features/model-source-watcher/model-source-changed-action-handler';
|
|
68
|
+
export * from './features/layout/layout-elements-action';
|
|
70
69
|
export * from './features/mouse-tool/mouse-tool';
|
|
71
70
|
export * from './features/navigation/navigation-action-handler';
|
|
72
71
|
export * from './features/navigation/navigation-target-resolver';
|
|
@@ -74,6 +73,7 @@ export * from './features/rank/model';
|
|
|
74
73
|
export * from './features/reconnect/model';
|
|
75
74
|
export * from './features/save/model';
|
|
76
75
|
export * from './features/save/save-keylistener';
|
|
76
|
+
export * from './features/source-model-watcher/source-model-changed-action-handler';
|
|
77
77
|
export * from './features/tool-feedback/change-bounds-tool-feedback';
|
|
78
78
|
export * from './features/tool-feedback/creation-tool-feedback';
|
|
79
79
|
export * from './features/tool-feedback/css-feedback';
|
|
@@ -113,13 +113,14 @@ export {
|
|
|
113
113
|
copyPasteContextMenuModule,
|
|
114
114
|
glspSelectModule,
|
|
115
115
|
glspMouseToolModule,
|
|
116
|
-
|
|
116
|
+
layoutModule,
|
|
117
117
|
glspEditLabelModule,
|
|
118
118
|
glspHoverModule,
|
|
119
119
|
toolsModule,
|
|
120
|
+
enableDefaultToolsOnFocusLossModule,
|
|
120
121
|
navigationModule,
|
|
121
122
|
markerNavigatorModule,
|
|
122
123
|
glspDecorationModule,
|
|
123
|
-
modelSourceWatcherModule,
|
|
124
|
+
sourceModelWatcherModule as modelSourceWatcherModule,
|
|
124
125
|
glspViewportModule
|
|
125
126
|
};
|
package/src/lib/model.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import { SModelElementSchema } from '@eclipse-glsp/protocol';
|
|
17
|
-
import { exportFeature, SGraph, SModelElement, viewportFeature } from 'sprotty
|
|
17
|
+
import { exportFeature, SGraph, SModelElement, viewportFeature } from 'sprotty';
|
|
18
18
|
import { Containable, containerFeature } from '../features/hints/model';
|
|
19
19
|
import { Saveable, saveFeature } from '../features/save/model';
|
|
20
20
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { Dimension, ElementAndBounds, Point } from '@eclipse-glsp/protocol';
|
|
16
|
+
import { Dimension, ElementAndBounds, Point, Writable } from '@eclipse-glsp/protocol';
|
|
17
17
|
import { BoundsAware, ElementMove, ModelLayoutOptions, SModelElement } from 'sprotty';
|
|
18
18
|
import { IMovementRestrictor } from '../features/change-bounds/movement-restrictor';
|
|
19
19
|
|
|
@@ -45,18 +45,18 @@ export function isValidSize(element: SModelElement & BoundsAware, size: Dimensio
|
|
|
45
45
|
return size.width >= minWidth(element) && size.height >= minHeight(element);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export function isValidMove(element: SModelElement & BoundsAware, newPosition
|
|
48
|
+
export function isValidMove(element: SModelElement & BoundsAware, newPosition?: Point, movementRestrictor?: IMovementRestrictor): boolean {
|
|
49
49
|
if (movementRestrictor) {
|
|
50
|
-
return movementRestrictor.validate(
|
|
50
|
+
return movementRestrictor.validate(element, newPosition);
|
|
51
51
|
}
|
|
52
52
|
return true;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export function toValidElementMove(
|
|
56
56
|
element: SModelElement & BoundsAware,
|
|
57
|
-
move:
|
|
57
|
+
move: ElementMove,
|
|
58
58
|
movementRestrictor?: IMovementRestrictor
|
|
59
|
-
):
|
|
59
|
+
): ElementMove | undefined {
|
|
60
60
|
if (!isValidMove(element, move.toPosition, movementRestrictor)) {
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
@@ -65,9 +65,9 @@ export function toValidElementMove(
|
|
|
65
65
|
|
|
66
66
|
export function toValidElementAndBounds(
|
|
67
67
|
element: SModelElement & BoundsAware,
|
|
68
|
-
bounds:
|
|
68
|
+
bounds: Writable<ElementAndBounds>,
|
|
69
69
|
movementRestrictor?: IMovementRestrictor
|
|
70
|
-
):
|
|
70
|
+
): ElementAndBounds | undefined {
|
|
71
71
|
if (!isValidMove(element, bounds.newPosition, movementRestrictor)) {
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
@@ -81,23 +81,3 @@ export function toValidElementAndBounds(
|
|
|
81
81
|
}
|
|
82
82
|
return bounds;
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
export interface WriteablePoint extends Point {
|
|
86
|
-
x: number;
|
|
87
|
-
y: number;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface WriteableElementMove extends ElementMove {
|
|
91
|
-
fromPosition?: WriteablePoint;
|
|
92
|
-
toPosition: WriteablePoint;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface WriteableDimension extends Dimension {
|
|
96
|
-
width: number;
|
|
97
|
-
height: number;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export interface WriteableElementAndBounds extends ElementAndBounds {
|
|
101
|
-
newPosition: WriteablePoint;
|
|
102
|
-
newSize: WriteableDimension;
|
|
103
|
-
}
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
ForeignObjectView,
|
|
27
27
|
HtmlRoot,
|
|
28
28
|
HtmlRootView,
|
|
29
|
+
moveFeature,
|
|
29
30
|
PreRenderedElement,
|
|
30
31
|
PreRenderedView,
|
|
31
32
|
RectangularNode,
|
|
@@ -34,6 +35,7 @@ import {
|
|
|
34
35
|
SCompartment,
|
|
35
36
|
SCompartmentView,
|
|
36
37
|
SEdge,
|
|
38
|
+
selectFeature,
|
|
37
39
|
SGraphView,
|
|
38
40
|
ShapedPreRenderedElement,
|
|
39
41
|
SIssueMarker,
|
|
@@ -66,7 +68,9 @@ export function configureDefaultModelElements(context: ContainerContext): void {
|
|
|
66
68
|
configureModelElement(context, DefaultTypes.HTML, HtmlRoot, HtmlRootView);
|
|
67
69
|
|
|
68
70
|
// generic elements
|
|
69
|
-
configureModelElement(context, DefaultTypes.FOREIGN_OBJECT, ForeignObjectElement, ForeignObjectView
|
|
71
|
+
configureModelElement(context, DefaultTypes.FOREIGN_OBJECT, ForeignObjectElement, ForeignObjectView, {
|
|
72
|
+
disable: [selectFeature, moveFeature]
|
|
73
|
+
});
|
|
70
74
|
configureModelElement(context, DefaultTypes.PRE_RENDERED, PreRenderedElement, PreRenderedView);
|
|
71
75
|
configureModelElement(context, DefaultTypes.SHAPE_PRE_RENDERED, ShapedPreRenderedElement, PreRenderedView);
|
|
72
76
|
|