@eclipse-glsp/client 0.10.0-next.e5fcffe.169 → 1.1.0-next.26c3266.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/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 +10 -5
- package/lib/features/validation/issue-marker.d.ts.map +1 -1
- package/lib/features/validation/issue-marker.js +12 -4
- 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 +28 -53
- 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/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 +22 -12
- package/src/features/validation/marker-navigator.ts +29 -66
- package/src/features/validation/validate.ts +36 -70
- 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,14 @@
|
|
|
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
22
|
import { getSeverity } from '../hover/hover';
|
|
33
23
|
import { IFeedbackActionDispatcher, IFeedbackEmitter } from '../tool-feedback/feedback-action-dispatcher';
|
|
34
24
|
import { FeedbackCommand } from '../tool-feedback/model';
|
|
35
|
-
import { createSIssue, getOrCreateSIssueMarker, getSIssueMarker } from './issue-marker';
|
|
25
|
+
import { createSIssue, getOrCreateSIssueMarker, getSIssueMarker, GIssueMarker } from './issue-marker';
|
|
36
26
|
|
|
37
27
|
/**
|
|
38
28
|
* Feedback emitter sending actions for visualizing model validation feedback and
|
|
@@ -94,43 +84,33 @@ export abstract class ExternalMarkerManager {
|
|
|
94
84
|
abstract setMarkers(markers: Marker[], sourceUri?: string): void;
|
|
95
85
|
}
|
|
96
86
|
|
|
97
|
-
/**
|
|
98
|
-
* Command for handling `SetMarkersAction`
|
|
99
|
-
*/
|
|
100
87
|
@injectable()
|
|
101
|
-
export class
|
|
102
|
-
@inject(ValidationFeedbackEmitter)
|
|
103
|
-
|
|
104
|
-
@inject(EditorContextService) protected editorContextService: EditorContextService;
|
|
88
|
+
export class SetMarkersActionHandler implements IActionHandler {
|
|
89
|
+
@inject(ValidationFeedbackEmitter)
|
|
90
|
+
protected validationFeedbackEmitter: ValidationFeedbackEmitter;
|
|
105
91
|
|
|
106
|
-
|
|
92
|
+
@inject(ExternalMarkerManager)
|
|
93
|
+
@optional()
|
|
94
|
+
protected externalMarkerManager?: ExternalMarkerManager;
|
|
107
95
|
|
|
108
|
-
|
|
109
|
-
|
|
96
|
+
@inject(EditorContextService)
|
|
97
|
+
protected editorContextService: EditorContextService;
|
|
98
|
+
|
|
99
|
+
handle(action: SetMarkersAction): void | Action | ICommand {
|
|
100
|
+
const markers: Marker[] = action.markers;
|
|
101
|
+
this.setMarkers(markers);
|
|
110
102
|
}
|
|
111
103
|
|
|
112
|
-
async
|
|
113
|
-
const markers: Marker[] = this.action.markers;
|
|
104
|
+
async setMarkers(markers: Marker[]): Promise<void> {
|
|
114
105
|
const uri = await this.editorContextService.getSourceUri();
|
|
115
|
-
|
|
116
|
-
this.externalMarkerManager.setMarkers(markers, uri);
|
|
117
|
-
}
|
|
106
|
+
this.externalMarkerManager?.setMarkers(markers, uri);
|
|
118
107
|
const applyMarkersAction = ApplyMarkersAction.create(markers);
|
|
119
108
|
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
109
|
}
|
|
130
110
|
}
|
|
131
111
|
|
|
132
112
|
/**
|
|
133
|
-
* Action for applying makers to
|
|
113
|
+
* Action for applying makers to the graphical model.
|
|
134
114
|
*/
|
|
135
115
|
export interface ApplyMarkersAction extends Action {
|
|
136
116
|
kind: typeof ApplyMarkersAction.KIND;
|
|
@@ -153,43 +133,36 @@ export namespace ApplyMarkersAction {
|
|
|
153
133
|
}
|
|
154
134
|
|
|
155
135
|
/**
|
|
156
|
-
*
|
|
136
|
+
* Handles {@link ApplyMarkersAction}s by creating the corresponding {@link SIssueMarker}s and
|
|
137
|
+
* adding them to the graphical model.
|
|
157
138
|
*/
|
|
158
139
|
@injectable()
|
|
159
140
|
export class ApplyMarkersCommand extends FeedbackCommand {
|
|
160
141
|
static KIND = ApplyMarkersAction.KIND;
|
|
161
|
-
override readonly priority = 0;
|
|
162
142
|
|
|
163
143
|
constructor(@inject(TYPES.Action) protected action: ApplyMarkersAction) {
|
|
164
144
|
super();
|
|
165
145
|
}
|
|
166
146
|
|
|
167
147
|
execute(context: CommandExecutionContext): CommandReturn {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const modelElement: SModelElement | undefined = context.root.index.getById(marker.elementId);
|
|
148
|
+
this.action.markers.forEach(marker => {
|
|
149
|
+
const modelElement = context.root.index.getById(marker.elementId);
|
|
171
150
|
if (modelElement instanceof SParentElement) {
|
|
172
|
-
const issueMarker
|
|
173
|
-
const issue
|
|
151
|
+
const issueMarker = getOrCreateSIssueMarker(modelElement);
|
|
152
|
+
const issue = createSIssue(marker);
|
|
174
153
|
issueMarker.issues.push(issue);
|
|
154
|
+
if (issueMarker instanceof GIssueMarker) {
|
|
155
|
+
issueMarker.computeProjectionCssClasses();
|
|
156
|
+
}
|
|
175
157
|
addMaxSeverityCSSClassToIssueParent(modelElement, issueMarker);
|
|
176
158
|
}
|
|
177
|
-
}
|
|
178
|
-
return context.root;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
override undo(context: CommandExecutionContext): CommandReturn {
|
|
159
|
+
});
|
|
182
160
|
return context.root;
|
|
183
161
|
}
|
|
184
|
-
|
|
185
|
-
override redo(context: CommandExecutionContext): CommandReturn {
|
|
186
|
-
return this.execute(context);
|
|
187
|
-
}
|
|
188
162
|
}
|
|
189
163
|
|
|
190
164
|
function addMaxSeverityCSSClassToIssueParent(modelElement: SParentElement, issueMarker: SIssueMarker): void {
|
|
191
165
|
const maxSeverityCSSClass = getSeverity(issueMarker);
|
|
192
|
-
|
|
193
166
|
if (!modelElement.cssClasses) {
|
|
194
167
|
modelElement.cssClasses = [maxSeverityCSSClass];
|
|
195
168
|
} else {
|
|
@@ -199,14 +172,15 @@ function addMaxSeverityCSSClassToIssueParent(modelElement: SParentElement, issue
|
|
|
199
172
|
}
|
|
200
173
|
|
|
201
174
|
function removeCSSClassFromIssueParent(modelElement: SParentElement, issueMarker: SIssueMarker): void {
|
|
202
|
-
|
|
175
|
+
const severity = getSeverity(issueMarker);
|
|
176
|
+
removeCssClasses(modelElement, [severity]);
|
|
203
177
|
}
|
|
204
178
|
|
|
205
179
|
/**
|
|
206
180
|
* Command for handling `DeleteMarkersAction`
|
|
207
181
|
*/
|
|
208
182
|
@injectable()
|
|
209
|
-
export class DeleteMarkersCommand extends
|
|
183
|
+
export class DeleteMarkersCommand extends FeedbackCommand {
|
|
210
184
|
static KIND = DeleteMarkersAction.KIND;
|
|
211
185
|
|
|
212
186
|
constructor(@inject(TYPES.Action) protected action: DeleteMarkersAction) {
|
|
@@ -214,15 +188,14 @@ export class DeleteMarkersCommand extends Command {
|
|
|
214
188
|
}
|
|
215
189
|
|
|
216
190
|
execute(context: CommandExecutionContext): CommandReturn {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const modelElement: SModelElement | undefined = context.root.index.getById(marker.elementId);
|
|
191
|
+
this.action.markers.forEach(marker => {
|
|
192
|
+
const modelElement = context.root.index.getById(marker.elementId);
|
|
220
193
|
if (modelElement instanceof SParentElement) {
|
|
221
|
-
const issueMarker
|
|
222
|
-
if (issueMarker
|
|
194
|
+
const issueMarker = getSIssueMarker(modelElement);
|
|
195
|
+
if (issueMarker) {
|
|
223
196
|
removeCSSClassFromIssueParent(modelElement, issueMarker);
|
|
224
197
|
for (let index = 0; index < issueMarker.issues.length; ++index) {
|
|
225
|
-
const issue
|
|
198
|
+
const issue = issueMarker.issues[index];
|
|
226
199
|
if (issue.message === marker.description) {
|
|
227
200
|
issueMarker.issues.splice(index--, 1);
|
|
228
201
|
}
|
|
@@ -234,15 +207,8 @@ export class DeleteMarkersCommand extends Command {
|
|
|
234
207
|
}
|
|
235
208
|
}
|
|
236
209
|
}
|
|
237
|
-
}
|
|
238
|
-
return context.root;
|
|
239
|
-
}
|
|
210
|
+
});
|
|
240
211
|
|
|
241
|
-
undo(context: CommandExecutionContext): CommandReturn {
|
|
242
212
|
return context.root;
|
|
243
213
|
}
|
|
244
|
-
|
|
245
|
-
redo(context: CommandExecutionContext): CommandReturn {
|
|
246
|
-
return this.execute(context);
|
|
247
|
-
}
|
|
248
214
|
}
|
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
|
|