@eclipse-glsp/client 2.2.0-next.336 → 2.2.0-next.337
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/ghost-element.css +7 -0
- package/lib/base/default.module.d.ts.map +1 -1
- package/lib/base/default.module.js +1 -2
- package/lib/base/default.module.js.map +1 -1
- package/lib/base/drag-aware-mouse-listener.d.ts +4 -1
- package/lib/base/drag-aware-mouse-listener.d.ts.map +1 -1
- package/lib/base/drag-aware-mouse-listener.js +12 -2
- package/lib/base/drag-aware-mouse-listener.js.map +1 -1
- package/lib/base/feedback/feedback-action-dispatcher-default.d.ts +34 -0
- package/lib/base/feedback/feedback-action-dispatcher-default.d.ts.map +1 -0
- package/lib/base/feedback/feedback-action-dispatcher-default.js +120 -0
- package/lib/base/feedback/feedback-action-dispatcher-default.js.map +1 -0
- package/lib/base/feedback/feedback-action-dispatcher.d.ts +2 -17
- package/lib/base/feedback/feedback-action-dispatcher.d.ts.map +1 -1
- package/lib/base/feedback/feedback-action-dispatcher.js +1 -100
- package/lib/base/feedback/feedback-action-dispatcher.js.map +1 -1
- package/lib/base/feedback/{feeback-emitter.d.ts → feedback-emitter.d.ts} +8 -1
- package/lib/base/feedback/feedback-emitter.d.ts.map +1 -0
- package/lib/base/feedback/{feeback-emitter.js → feedback-emitter.js} +21 -6
- package/lib/base/feedback/feedback-emitter.js.map +1 -0
- package/lib/base/feedback/index.d.ts +2 -1
- package/lib/base/feedback/index.d.ts.map +1 -1
- package/lib/base/feedback/index.js +2 -1
- package/lib/base/feedback/index.js.map +1 -1
- package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts.map +1 -1
- package/lib/features/accessibility/view-key-tools/movement-key-tool.js +1 -1
- package/lib/features/accessibility/view-key-tools/movement-key-tool.js.map +1 -1
- package/lib/features/change-bounds/model.d.ts +5 -1
- package/lib/features/change-bounds/model.d.ts.map +1 -1
- package/lib/features/change-bounds/model.js +36 -10
- package/lib/features/change-bounds/model.js.map +1 -1
- package/lib/features/change-bounds/movement-restrictor.d.ts +1 -0
- package/lib/features/change-bounds/movement-restrictor.d.ts.map +1 -1
- package/lib/features/change-bounds/movement-restrictor.js +8 -9
- package/lib/features/change-bounds/movement-restrictor.js.map +1 -1
- package/lib/features/debug/debug-bounds-decorator.d.ts.map +1 -1
- package/lib/features/debug/debug-bounds-decorator.js +6 -6
- package/lib/features/debug/debug-bounds-decorator.js.map +1 -1
- package/lib/features/debug/debug-module.js +1 -1
- package/lib/features/debug/debug-module.js.map +1 -1
- package/lib/features/element-template/mouse-tracking-element-position-listener.d.ts +6 -4
- package/lib/features/element-template/mouse-tracking-element-position-listener.d.ts.map +1 -1
- package/lib/features/element-template/mouse-tracking-element-position-listener.js +11 -12
- package/lib/features/element-template/mouse-tracking-element-position-listener.js.map +1 -1
- package/lib/features/grid/grid-module.d.ts.map +1 -1
- package/lib/features/grid/grid-module.js +1 -1
- package/lib/features/grid/grid-module.js.map +1 -1
- package/lib/features/helper-lines/helper-line-manager-default.d.ts +14 -2
- package/lib/features/helper-lines/helper-line-manager-default.d.ts.map +1 -1
- package/lib/features/helper-lines/helper-line-manager-default.js +56 -15
- package/lib/features/helper-lines/helper-line-manager-default.js.map +1 -1
- package/lib/features/hints/model.d.ts +5 -1
- package/lib/features/hints/model.d.ts.map +1 -1
- package/lib/features/hints/model.js.map +1 -1
- package/lib/features/select/select-mouse-listener.d.ts.map +1 -1
- package/lib/features/select/select-mouse-listener.js +1 -1
- package/lib/features/select/select-mouse-listener.js.map +1 -1
- package/lib/features/tool-palette/tool-palette.d.ts.map +1 -1
- package/lib/features/tool-palette/tool-palette.js +2 -2
- package/lib/features/tool-palette/tool-palette.js.map +1 -1
- package/lib/features/tools/base-tools.d.ts +1 -1
- package/lib/features/tools/base-tools.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-manager.d.ts +11 -4
- package/lib/features/tools/change-bounds/change-bounds-manager.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-manager.js +46 -13
- package/lib/features/tools/change-bounds/change-bounds-manager.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-feedback.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js +3 -3
- package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-module.js +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-module.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.d.ts +2 -2
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js +3 -6
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool.d.ts +3 -2
- package/lib/features/tools/change-bounds/change-bounds-tool.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool.js +7 -27
- package/lib/features/tools/change-bounds/change-bounds-tool.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tracker.d.ts +8 -2
- package/lib/features/tools/change-bounds/change-bounds-tracker.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tracker.js +22 -5
- package/lib/features/tools/change-bounds/change-bounds-tracker.js.map +1 -1
- package/lib/features/tools/edge-creation/edge-creation-tool.d.ts +4 -1
- package/lib/features/tools/edge-creation/edge-creation-tool.d.ts.map +1 -1
- package/lib/features/tools/edge-creation/edge-creation-tool.js +12 -10
- package/lib/features/tools/edge-creation/edge-creation-tool.js.map +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool-feedback.d.ts +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool-feedback.d.ts.map +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool-feedback.js +3 -3
- package/lib/features/tools/edge-edit/edge-edit-tool-feedback.js.map +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool.d.ts +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool.d.ts.map +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool.js +3 -3
- package/lib/features/tools/edge-edit/edge-edit-tool.js.map +1 -1
- package/lib/features/tools/node-creation/container-manager.d.ts +41 -0
- package/lib/features/tools/node-creation/container-manager.d.ts.map +1 -0
- package/lib/features/tools/node-creation/container-manager.js +73 -0
- package/lib/features/tools/node-creation/container-manager.js.map +1 -0
- package/lib/features/tools/node-creation/index.d.ts +3 -0
- package/lib/features/tools/node-creation/index.d.ts.map +1 -1
- package/lib/features/tools/node-creation/index.js +3 -0
- package/lib/features/tools/node-creation/index.js.map +1 -1
- package/lib/features/tools/node-creation/insert-indicator.d.ts +30 -0
- package/lib/features/tools/node-creation/insert-indicator.d.ts.map +1 -0
- package/lib/features/tools/node-creation/insert-indicator.js +40 -0
- package/lib/features/tools/node-creation/insert-indicator.js.map +1 -0
- package/lib/features/tools/node-creation/node-creation-module.d.ts.map +1 -1
- package/lib/features/tools/node-creation/node-creation-module.js +5 -0
- package/lib/features/tools/node-creation/node-creation-module.js.map +1 -1
- package/lib/features/tools/node-creation/node-creation-tool.d.ts +23 -14
- package/lib/features/tools/node-creation/node-creation-tool.d.ts.map +1 -1
- package/lib/features/tools/node-creation/node-creation-tool.js +79 -75
- package/lib/features/tools/node-creation/node-creation-tool.js.map +1 -1
- package/lib/features/tools/node-creation/node-creation-views.d.ts +25 -0
- package/lib/features/tools/node-creation/node-creation-views.d.ts.map +1 -0
- package/lib/features/tools/node-creation/node-creation-views.js +60 -0
- package/lib/features/tools/node-creation/node-creation-views.js.map +1 -0
- package/lib/utils/gmodel-util.d.ts +2 -0
- package/lib/utils/gmodel-util.d.ts.map +1 -1
- package/lib/utils/gmodel-util.js.map +1 -1
- package/lib/views/ggraph-view.d.ts.map +1 -1
- package/lib/views/ggraph-view.js +2 -2
- package/lib/views/ggraph-view.js.map +1 -1
- package/lib/views/glsp-projection-view.d.ts.map +1 -1
- package/lib/views/glsp-projection-view.js +2 -2
- package/lib/views/glsp-projection-view.js.map +1 -1
- package/package.json +3 -3
- package/src/base/default.module.ts +1 -2
- package/src/base/drag-aware-mouse-listener.ts +17 -1
- package/src/base/feedback/feedback-action-dispatcher-default.ts +119 -0
- package/src/base/feedback/feedback-action-dispatcher.ts +2 -106
- package/src/base/feedback/feedback-emitter.spec.ts +176 -0
- package/src/base/feedback/{feeback-emitter.ts → feedback-emitter.ts} +24 -5
- package/src/base/feedback/index.ts +2 -1
- package/src/base/selection-service.spec.ts +1 -1
- package/src/features/accessibility/view-key-tools/movement-key-tool.ts +1 -1
- package/src/features/change-bounds/model.ts +38 -13
- package/src/features/change-bounds/movement-restrictor.ts +11 -11
- package/src/features/debug/debug-bounds-decorator.tsx +7 -7
- package/src/features/debug/debug-module.ts +1 -1
- package/src/features/element-template/mouse-tracking-element-position-listener.ts +14 -22
- package/src/features/grid/grid-module.ts +2 -2
- package/src/features/helper-lines/helper-line-manager-default.ts +66 -10
- package/src/features/hints/model.ts +6 -1
- package/src/features/hints/type-hint-provider.spec.ts +1 -1
- package/src/features/select/select-mouse-listener.ts +2 -2
- package/src/features/tool-palette/tool-palette.ts +2 -3
- package/src/features/tools/base-tools.ts +1 -1
- package/src/features/tools/change-bounds/change-bounds-manager.ts +71 -13
- package/src/features/tools/change-bounds/change-bounds-tool-feedback.ts +5 -2
- package/src/features/tools/change-bounds/change-bounds-tool-module.ts +1 -1
- package/src/features/tools/change-bounds/change-bounds-tool-move-feedback.ts +4 -8
- package/src/features/tools/change-bounds/change-bounds-tool.ts +9 -55
- package/src/features/tools/change-bounds/change-bounds-tracker.ts +26 -5
- package/src/features/tools/edge-creation/edge-creation-tool.ts +13 -6
- package/src/features/tools/edge-edit/edge-edit-tool-feedback.ts +1 -1
- package/src/features/tools/edge-edit/edge-edit-tool.ts +2 -3
- package/src/features/tools/node-creation/container-manager.ts +76 -0
- package/src/features/tools/node-creation/index.ts +3 -0
- package/src/features/tools/node-creation/insert-indicator.ts +41 -0
- package/src/features/tools/node-creation/node-creation-module.ts +13 -1
- package/src/features/tools/node-creation/node-creation-tool.ts +98 -90
- package/src/features/tools/node-creation/node-creation-views.tsx +49 -0
- package/src/utils/gmodel-util.ts +4 -1
- package/src/views/ggraph-view.tsx +3 -3
- package/src/views/glsp-projection-view.tsx +2 -3
- package/lib/base/feedback/feeback-emitter.d.ts.map +0 -1
- package/lib/base/feedback/feeback-emitter.js.map +0 -1
|
@@ -16,13 +16,14 @@
|
|
|
16
16
|
import {
|
|
17
17
|
Action,
|
|
18
18
|
CreateNodeOperation,
|
|
19
|
+
Disposable,
|
|
20
|
+
DisposableCollection,
|
|
19
21
|
GModelElement,
|
|
20
|
-
GNode,
|
|
21
22
|
GhostElement,
|
|
23
|
+
IModelFactory,
|
|
22
24
|
Point,
|
|
23
25
|
TYPES,
|
|
24
26
|
TriggerNodeCreationAction,
|
|
25
|
-
findParentByFeature,
|
|
26
27
|
isCtrlOrCmd,
|
|
27
28
|
isMoveable
|
|
28
29
|
} from '@eclipse-glsp/sprotty';
|
|
@@ -32,14 +33,14 @@ import { FeedbackEmitter } from '../../../base';
|
|
|
32
33
|
import { DragAwareMouseListener } from '../../../base/drag-aware-mouse-listener';
|
|
33
34
|
import { CSS_GHOST_ELEMENT, CSS_HIDDEN, CursorCSS, cursorFeedbackAction } from '../../../base/feedback/css-feedback';
|
|
34
35
|
import { EnableDefaultToolsAction } from '../../../base/tool-manager/tool';
|
|
35
|
-
import { MoveableElement
|
|
36
|
-
import { getAbsolutePosition } from '../../../utils/viewpoint-util';
|
|
37
|
-
import { RemoveTemplateElementsAction } from '../../element-template';
|
|
36
|
+
import { MoveableElement } from '../../../utils/gmodel-util';
|
|
38
37
|
import { AddTemplateElementsAction, getTemplateElementId } from '../../element-template/add-template-element';
|
|
39
38
|
import { MouseTrackingElementPositionListener, PositioningTool } from '../../element-template/mouse-tracking-element-position-listener';
|
|
40
|
-
import {
|
|
39
|
+
import { RemoveTemplateElementsAction } from '../../element-template/remove-template-element';
|
|
41
40
|
import { BaseCreationTool } from '../base-tools';
|
|
42
|
-
import { ChangeBoundsManager } from '../change-bounds';
|
|
41
|
+
import { ChangeBoundsManager, TrackedMove } from '../change-bounds';
|
|
42
|
+
import { ContainerManager, TrackedInsert } from './container-manager';
|
|
43
|
+
import { InsertIndicator } from './insert-indicator';
|
|
43
44
|
|
|
44
45
|
@injectable()
|
|
45
46
|
export class NodeCreationTool extends BaseCreationTool<TriggerNodeCreationAction> implements PositioningTool {
|
|
@@ -47,52 +48,80 @@ export class NodeCreationTool extends BaseCreationTool<TriggerNodeCreationAction
|
|
|
47
48
|
|
|
48
49
|
protected isTriggerAction = TriggerNodeCreationAction.is;
|
|
49
50
|
|
|
50
|
-
@inject(
|
|
51
|
+
@inject(ChangeBoundsManager) readonly changeBoundsManager: ChangeBoundsManager;
|
|
52
|
+
@inject(ContainerManager) readonly containerManager: ContainerManager;
|
|
53
|
+
@inject(TYPES.IModelFactory) modelFactory: IModelFactory;
|
|
51
54
|
|
|
52
55
|
get id(): string {
|
|
53
56
|
return NodeCreationTool.ID;
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
doEnable(): void {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
this.toDisposeOnDisable.push(trackingListener, this.mouseTool.registerListener(trackingListener));
|
|
63
|
-
}
|
|
60
|
+
const ghostElement = this.triggerAction.ghostElement ?? { template: this.modelFactory.createSchema(this.createInsertIndicator()) };
|
|
61
|
+
this.toDisposeOnDisable.push(this.createGhostElementTracker(ghostElement, 'middle'));
|
|
62
|
+
this.toDisposeOnDisable.push(this.createNodeCreationListener(ghostElement));
|
|
63
|
+
this.toDisposeOnDisable.push(this.createNodeCreationCursorFeedback().submit());
|
|
64
|
+
}
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
protected createInsertIndicator(): GModelElement {
|
|
67
|
+
return new InsertIndicator();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
protected createGhostElementTracker(ghostElement: GhostElement, position: 'top-left' | 'middle'): Disposable {
|
|
71
|
+
const trackingListener = new NodeInsertTrackingListener(
|
|
72
|
+
getTemplateElementId(ghostElement.template),
|
|
73
|
+
this.triggerAction.elementTypeId,
|
|
74
|
+
this,
|
|
75
|
+
position
|
|
70
76
|
);
|
|
77
|
+
return new DisposableCollection(trackingListener, this.mouseTool.registerListener(trackingListener));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
protected createNodeCreationListener(ghostElement: GhostElement): Disposable {
|
|
81
|
+
const toolListener = new NodeCreationToolMouseListener(this.triggerAction, this, ghostElement);
|
|
82
|
+
return new DisposableCollection(toolListener, this.mouseTool.registerListener(toolListener));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
protected createNodeCreationCursorFeedback(): FeedbackEmitter {
|
|
86
|
+
return this.createFeedbackEmitter().add(cursorFeedbackAction(CursorCSS.NODE_CREATION), cursorFeedbackAction());
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export class NodeInsertTrackingListener extends MouseTrackingElementPositionListener {
|
|
91
|
+
constructor(
|
|
92
|
+
elementId: string,
|
|
93
|
+
protected elementTypeId: string,
|
|
94
|
+
protected override tool: NodeCreationTool,
|
|
95
|
+
cursorPosition: 'top-left' | 'middle' = 'top-left'
|
|
96
|
+
) {
|
|
97
|
+
super(elementId, tool, cursorPosition);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
protected override addMoveFeedback(move: TrackedMove, ctx: GModelElement, event: MouseEvent): void {
|
|
101
|
+
super.addMoveFeedback(move, ctx, event);
|
|
102
|
+
|
|
103
|
+
const element = move.elementMoves[0].element;
|
|
104
|
+
const location = move.elementMoves[0].toPosition;
|
|
105
|
+
const insert = this.tool.containerManager.insert(element, location, this.elementTypeId, { evt: event });
|
|
106
|
+
this.tool.containerManager.addInsertFeedback(this.moveGhostFeedback, insert, ctx, event);
|
|
71
107
|
}
|
|
72
108
|
}
|
|
73
109
|
|
|
74
110
|
export class NodeCreationToolMouseListener extends DragAwareMouseListener {
|
|
75
|
-
protected container?: GModelElement & Containable;
|
|
76
111
|
protected cursorFeedback: FeedbackEmitter;
|
|
77
112
|
protected ghostElementFeedback: FeedbackEmitter;
|
|
78
|
-
protected ghostElementId
|
|
113
|
+
protected ghostElementId: string;
|
|
79
114
|
|
|
80
115
|
constructor(
|
|
81
116
|
protected triggerAction: TriggerNodeCreationAction,
|
|
82
117
|
protected tool: NodeCreationTool,
|
|
83
|
-
protected ghostElement
|
|
118
|
+
protected ghostElement: GhostElement
|
|
84
119
|
) {
|
|
85
120
|
super();
|
|
86
121
|
this.cursorFeedback = tool.createFeedbackEmitter();
|
|
87
122
|
this.ghostElementFeedback = tool.createFeedbackEmitter();
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
this.createGhostElement();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
protected creationAllowed(elementTypeId: string): boolean | undefined {
|
|
95
|
-
return this.container && this.container.isContainableElement(elementTypeId);
|
|
123
|
+
this.ghostElementId = getTemplateElementId(ghostElement.template);
|
|
124
|
+
this.createGhostElement(ghostElement);
|
|
96
125
|
}
|
|
97
126
|
|
|
98
127
|
get elementTypeId(): string {
|
|
@@ -101,78 +130,57 @@ export class NodeCreationToolMouseListener extends DragAwareMouseListener {
|
|
|
101
130
|
|
|
102
131
|
override nonDraggingMouseUp(target: GModelElement, event: MouseEvent): Action[] {
|
|
103
132
|
const result: Action[] = [];
|
|
104
|
-
|
|
105
|
-
|
|
133
|
+
|
|
134
|
+
const insert = this.getTrackedInsert(target, event);
|
|
135
|
+
if (insert.valid) {
|
|
136
|
+
result.push(
|
|
137
|
+
CreateNodeOperation.create(this.elementTypeId, {
|
|
138
|
+
location: insert.location,
|
|
139
|
+
containerId: insert.container?.id,
|
|
140
|
+
args: this.triggerAction.args
|
|
141
|
+
})
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
if (isCtrlOrCmd(event)) {
|
|
145
|
+
// we continue in stamp mode so we keep the ghost but dispose everything else
|
|
146
|
+
this.disposeAllButGhostElement();
|
|
147
|
+
return result;
|
|
106
148
|
}
|
|
107
149
|
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
if (!isCtrlOrCmd(event)) {
|
|
115
|
-
// we no longer want to show the ghost element AFTER the next update
|
|
116
|
-
this.ghostElementFeedback.discard();
|
|
117
|
-
result.push(EnableDefaultToolsAction.create());
|
|
118
|
-
} else {
|
|
119
|
-
// we continue in stamp mode so we keep the ghost but dispose everything else
|
|
120
|
-
this.disposeAllButGhostElement();
|
|
121
|
-
}
|
|
150
|
+
if (insert.valid) {
|
|
151
|
+
// we keep the ghost element until the next update to avoid flickering during insert
|
|
152
|
+
this.ghostElementFeedback.discard();
|
|
153
|
+
} else {
|
|
154
|
+
this.dispose();
|
|
122
155
|
}
|
|
156
|
+
result.push(EnableDefaultToolsAction.create());
|
|
123
157
|
return result;
|
|
124
158
|
}
|
|
125
159
|
|
|
126
|
-
protected createGhostElement():
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
protected getGhostElement(): MoveableElement | undefined {
|
|
140
|
-
if (!this.ghostElementId) {
|
|
141
|
-
return undefined;
|
|
142
|
-
}
|
|
143
|
-
const ghostElement = this.container?.index.getById(this.ghostElementId);
|
|
160
|
+
protected createGhostElement(ghostElement: GhostElement): string {
|
|
161
|
+
const templates = [ghostElement.template];
|
|
162
|
+
this.ghostElementFeedback.add(
|
|
163
|
+
AddTemplateElementsAction.create({ templates, addClasses: [CSS_HIDDEN, CSS_GHOST_ELEMENT] }),
|
|
164
|
+
RemoveTemplateElementsAction.create({ templates })
|
|
165
|
+
);
|
|
166
|
+
this.ghostElementFeedback.submit();
|
|
167
|
+
return getTemplateElementId(ghostElement.template);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
protected getGhostElement(ctx: GModelElement, event: MouseEvent): MoveableElement | undefined {
|
|
171
|
+
const ghostElement = ctx.index.getById(this.ghostElementId);
|
|
144
172
|
return ghostElement && isMoveable(ghostElement) ? ghostElement : undefined;
|
|
145
173
|
}
|
|
146
174
|
|
|
147
|
-
protected
|
|
148
|
-
const ghostElement = this.getGhostElement();
|
|
149
|
-
if (ghostElement) {
|
|
150
|
-
return
|
|
151
|
-
? ghostElement.position
|
|
152
|
-
: undefined;
|
|
153
|
-
}
|
|
154
|
-
const location = getAbsolutePosition(target, event);
|
|
155
|
-
|
|
156
|
-
// Create a 0-bounds proxy element for snapping
|
|
157
|
-
const elementProxy = new GNode();
|
|
158
|
-
elementProxy.size = { width: 0, height: 0 };
|
|
159
|
-
return this.tool.changeBoundsManager.snapPosition(elementProxy, location);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
override mouseOver(target: GModelElement, event: MouseEvent): Action[] {
|
|
163
|
-
const currentContainer = findParentByFeature(target, isContainable);
|
|
164
|
-
if (!this.container || currentContainer !== this.container) {
|
|
165
|
-
this.container = currentContainer;
|
|
166
|
-
const feedback = this.creationAllowed(this.elementTypeId)
|
|
167
|
-
? cursorFeedbackAction(CursorCSS.NODE_CREATION)
|
|
168
|
-
: cursorFeedbackAction(CursorCSS.OPERATION_NOT_ALLOWED);
|
|
169
|
-
this.cursorFeedback.add(feedback).submit();
|
|
175
|
+
protected getTrackedInsert(ctx: GModelElement, event: MouseEvent): TrackedInsert {
|
|
176
|
+
const ghostElement = this.getGhostElement(ctx, event);
|
|
177
|
+
if (!ghostElement) {
|
|
178
|
+
return { elementTypeId: this.elementTypeId, location: Point.ORIGIN, valid: false };
|
|
170
179
|
}
|
|
171
|
-
return
|
|
180
|
+
return this.tool.containerManager.insert(ghostElement, ghostElement.position, this.elementTypeId, { evt: event });
|
|
172
181
|
}
|
|
173
182
|
|
|
174
183
|
protected disposeAllButGhostElement(): void {
|
|
175
|
-
this.cursorFeedback.dispose();
|
|
176
184
|
super.dispose();
|
|
177
185
|
}
|
|
178
186
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2024 Axon Ivy AG and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
|
|
17
|
+
import { IView, RenderingContext, TYPES, setClass, svg } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import { inject, injectable, optional } from 'inversify';
|
|
19
|
+
import { VNode } from 'snabbdom';
|
|
20
|
+
import { GArgument } from '../../../utils';
|
|
21
|
+
import { Grid } from '../../grid';
|
|
22
|
+
import { ARG_LENGTH, InsertIndicator } from './insert-indicator';
|
|
23
|
+
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
25
|
+
const JSX = { createElement: svg };
|
|
26
|
+
|
|
27
|
+
@injectable()
|
|
28
|
+
export class InsertIndicatorView implements IView {
|
|
29
|
+
@optional() @inject(TYPES.Grid) protected grid?: Grid;
|
|
30
|
+
|
|
31
|
+
render(model: Readonly<InsertIndicator>, context: RenderingContext): VNode | undefined {
|
|
32
|
+
if (context.targetKind === 'hidden') {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const size = this.getSize(model);
|
|
36
|
+
const node = (
|
|
37
|
+
<g>
|
|
38
|
+
<polyline class-sprotty-node={true} class-insert-indicator={true} points={`0,${-size / 2} 0,${size / 2}`}></polyline>
|
|
39
|
+
<polyline class-sprotty-node={true} class-insert-indicator={true} points={`${-size / 2},0 ${size / 2},0`}></polyline>
|
|
40
|
+
</g>
|
|
41
|
+
);
|
|
42
|
+
model.cssClasses.forEach(cl => setClass(node, cl, true));
|
|
43
|
+
return node;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
protected getSize(model: Readonly<InsertIndicator>): number {
|
|
47
|
+
return GArgument.getNumber(model, ARG_LENGTH) ?? this.grid?.x ?? 10;
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/utils/gmodel-util.ts
CHANGED
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
isSelected,
|
|
41
41
|
remove
|
|
42
42
|
} from '@eclipse-glsp/sprotty';
|
|
43
|
+
import { ResizeHandleLocation } from '../features';
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
46
|
* Helper type to represent a filter predicate for {@link GModelElement}s. This is used to retrieve
|
|
@@ -253,7 +254,9 @@ export type MoveableElement = GModelElement & Locateable;
|
|
|
253
254
|
|
|
254
255
|
export interface Resizable extends BoundsAware, Selectable {}
|
|
255
256
|
|
|
256
|
-
export interface ResizableModelElement extends GParentElement, Resizable {
|
|
257
|
+
export interface ResizableModelElement extends GParentElement, Resizable {
|
|
258
|
+
resizeLocations?: ResizeHandleLocation[];
|
|
259
|
+
}
|
|
257
260
|
|
|
258
261
|
/**
|
|
259
262
|
* Helper function to translate a given {@link GModelElement} into its corresponding {@link ElementAndBounds} representation.
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { Bounds, Dimension, Point, RenderingContext, SGraphImpl, SGraphView,
|
|
16
|
+
import { Bounds, Dimension, Point, RenderingContext, SGraphImpl, SGraphView, Writable } from '@eclipse-glsp/sprotty';
|
|
17
17
|
import { inject, injectable, optional } from 'inversify';
|
|
18
18
|
import { VNode } from 'snabbdom';
|
|
19
19
|
import { GridManager, GridStyle } from '../features';
|
|
20
20
|
|
|
21
21
|
@injectable()
|
|
22
22
|
export class GGraphView extends SGraphView {
|
|
23
|
-
@inject(
|
|
23
|
+
@inject(GridManager) @optional() protected gridManager?: GridManager;
|
|
24
24
|
|
|
25
25
|
override render(model: Readonly<SGraphImpl>, context: RenderingContext): VNode {
|
|
26
26
|
const graph = super.render(model, context);
|
|
@@ -31,7 +31,7 @@ export class GGraphView extends SGraphView {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
protected getGridStyle(model: Readonly<SGraphImpl>, context: RenderingContext): GridStyle {
|
|
34
|
-
if (!this.gridManager?.isGridVisible) {
|
|
34
|
+
if (context.targetKind === 'hidden' || !this.gridManager?.isGridVisible) {
|
|
35
35
|
return {};
|
|
36
36
|
}
|
|
37
37
|
const bounds = this.getBackgroundBounds(model, context, this.gridManager);
|
|
@@ -25,7 +25,6 @@ import {
|
|
|
25
25
|
ProjectionParams,
|
|
26
26
|
RenderingContext,
|
|
27
27
|
SGraphImpl,
|
|
28
|
-
TYPES,
|
|
29
28
|
ViewProjection,
|
|
30
29
|
Writable,
|
|
31
30
|
html,
|
|
@@ -45,7 +44,7 @@ const JSX = { createElement: html };
|
|
|
45
44
|
@injectable()
|
|
46
45
|
export class GLSPProjectionView extends ProjectedViewportView {
|
|
47
46
|
@inject(EdgeRouterRegistry) edgeRouterRegistry: EdgeRouterRegistry;
|
|
48
|
-
@inject(
|
|
47
|
+
@inject(GridManager) @optional() protected gridManager?: GridManager;
|
|
49
48
|
|
|
50
49
|
override render(model: Readonly<GViewportRootElement>, context: RenderingContext, args?: IViewArgs): VNode {
|
|
51
50
|
const rootNode: VNode = (
|
|
@@ -73,7 +72,7 @@ export class GLSPProjectionView extends ProjectedViewportView {
|
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
protected getGridStyle(model: Readonly<SGraphImpl>, context: RenderingContext): GridStyle {
|
|
76
|
-
if (!this.gridManager?.isGridVisible) {
|
|
75
|
+
if (context.targetKind === 'hidden' || !this.gridManager?.isGridVisible) {
|
|
77
76
|
return {};
|
|
78
77
|
}
|
|
79
78
|
const bounds = this.getBackgroundBounds(model, context, this.gridManager);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"feeback-emitter.d.ts","sourceRoot":"","sources":["../../../src/base/feedback/feeback-emitter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAE,MAAM,EAAE,UAAU,EAAW,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEzG;;GAEG;AACH,qBAAa,eAAgB,YAAW,gBAAgB,EAAE,UAAU;IAKpD,SAAS,CAAC,kBAAkB,EAAE,yBAAyB;IAJnE,SAAS,CAAC,eAAe,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAM;IACvD,SAAS,CAAC,cAAc,EAAE,YAAY,EAAE,CAAM;IAC9C,SAAS,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC;gBAEhB,kBAAkB,EAAE,yBAAyB;IAEnE;;;;;;OAMG;IACH,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,YAAY,GAAG,IAAI;IAYxD;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAS5B;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;OAEG;IACH,MAAM,IAAI,IAAI;IASd;;;OAGG;IACH,OAAO,IAAI,IAAI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