@eclipse-glsp/client 2.2.0-next.329 → 2.2.0-next.331
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/change-bounds.css +15 -0
- package/css/glsp-sprotty.css +22 -0
- package/lib/base/default.module.js +1 -1
- package/lib/base/default.module.js.map +1 -1
- package/lib/base/drag-aware-mouse-listener.d.ts +5 -2
- package/lib/base/drag-aware-mouse-listener.d.ts.map +1 -1
- package/lib/base/drag-aware-mouse-listener.js +11 -0
- package/lib/base/drag-aware-mouse-listener.js.map +1 -1
- package/lib/base/feedback/css-feedback.d.ts +4 -0
- package/lib/base/feedback/css-feedback.d.ts.map +1 -1
- package/lib/base/feedback/css-feedback.js +4 -0
- package/lib/base/feedback/css-feedback.js.map +1 -1
- package/lib/base/feedback/feeback-emitter.d.ts +67 -0
- package/lib/base/feedback/feeback-emitter.d.ts.map +1 -0
- package/lib/base/feedback/feeback-emitter.js +109 -0
- package/lib/base/feedback/feeback-emitter.js.map +1 -0
- package/lib/base/feedback/feedback-action-dispatcher.d.ts +17 -5
- package/lib/base/feedback/feedback-action-dispatcher.d.ts.map +1 -1
- package/lib/base/feedback/feedback-action-dispatcher.js +23 -3
- package/lib/base/feedback/feedback-action-dispatcher.js.map +1 -1
- package/lib/base/feedback/index.d.ts +1 -0
- package/lib/base/feedback/index.d.ts.map +1 -1
- package/lib/base/feedback/index.js +1 -0
- package/lib/base/feedback/index.js.map +1 -1
- package/lib/base/index.d.ts +1 -1
- package/lib/base/index.d.ts.map +1 -1
- package/lib/base/index.js +1 -1
- package/lib/base/index.js.map +1 -1
- package/lib/base/selection-service.d.ts +3 -2
- package/lib/base/selection-service.d.ts.map +1 -1
- package/lib/base/selection-service.js.map +1 -1
- package/lib/{features/routing/glsp-manhattan-edge-router.d.ts → base/ui-extension/index.d.ts} +4 -6
- package/lib/base/ui-extension/index.d.ts.map +1 -0
- package/lib/base/ui-extension/index.js +34 -0
- package/lib/base/ui-extension/index.js.map +1 -0
- package/lib/base/{ui-extension-registry.d.ts → ui-extension/ui-extension-registry.d.ts} +1 -1
- package/lib/base/ui-extension/ui-extension-registry.d.ts.map +1 -0
- package/lib/base/ui-extension/ui-extension-registry.js.map +1 -0
- package/lib/base/ui-extension/ui-extension.d.ts +39 -0
- package/lib/base/ui-extension/ui-extension.d.ts.map +1 -0
- package/lib/base/ui-extension/ui-extension.js +120 -0
- package/lib/base/ui-extension/ui-extension.js.map +1 -0
- package/lib/features/accessibility/element-navigation/local-element-navigator.d.ts +3 -3
- package/lib/features/accessibility/element-navigation/local-element-navigator.d.ts.map +1 -1
- package/lib/features/accessibility/element-navigation/local-element-navigator.js.map +1 -1
- package/lib/features/accessibility/move-zoom/move-handler.d.ts +4 -2
- package/lib/features/accessibility/move-zoom/move-handler.d.ts.map +1 -1
- package/lib/features/accessibility/move-zoom/move-handler.js +10 -4
- package/lib/features/accessibility/move-zoom/move-handler.js.map +1 -1
- package/lib/features/accessibility/resize-key-tool/resize-key-handler.d.ts +4 -2
- package/lib/features/accessibility/resize-key-tool/resize-key-handler.d.ts.map +1 -1
- package/lib/features/accessibility/resize-key-tool/resize-key-handler.js +11 -3
- package/lib/features/accessibility/resize-key-tool/resize-key-handler.js.map +1 -1
- package/lib/features/change-bounds/model.d.ts +8 -8
- package/lib/features/change-bounds/model.d.ts.map +1 -1
- package/lib/features/change-bounds/model.js +17 -5
- package/lib/features/change-bounds/model.js.map +1 -1
- package/lib/features/change-bounds/movement-restrictor.d.ts +3 -2
- package/lib/features/change-bounds/movement-restrictor.d.ts.map +1 -1
- package/lib/features/change-bounds/movement-restrictor.js.map +1 -1
- package/lib/features/command-palette/command-palette.d.ts.map +1 -1
- package/lib/features/command-palette/command-palette.js +4 -3
- package/lib/features/command-palette/command-palette.js.map +1 -1
- package/lib/features/element-template/mouse-tracking-element-position-listener.d.ts +15 -5
- 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 +27 -38
- package/lib/features/element-template/mouse-tracking-element-position-listener.js.map +1 -1
- package/lib/features/helper-lines/helper-line-manager-default.d.ts +4 -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 +8 -12
- package/lib/features/helper-lines/helper-line-manager-default.js.map +1 -1
- package/lib/features/hints/type-hint-provider.d.ts +3 -0
- package/lib/features/hints/type-hint-provider.d.ts.map +1 -1
- package/lib/features/hints/type-hint-provider.js +10 -1
- package/lib/features/hints/type-hint-provider.js.map +1 -1
- package/lib/features/label-edit-ui/label-edit-ui.d.ts.map +1 -1
- package/lib/features/label-edit-ui/label-edit-ui.js +4 -3
- package/lib/features/label-edit-ui/label-edit-ui.js.map +1 -1
- package/lib/features/routing/edge-router.d.ts +30 -0
- package/lib/features/routing/edge-router.d.ts.map +1 -0
- package/lib/features/routing/edge-router.js +116 -0
- package/lib/features/routing/edge-router.js.map +1 -0
- package/lib/features/routing/index.d.ts +1 -1
- package/lib/features/routing/index.d.ts.map +1 -1
- package/lib/features/routing/index.js +1 -1
- package/lib/features/routing/index.js.map +1 -1
- package/lib/features/routing/routing-module.d.ts.map +1 -1
- package/lib/features/routing/routing-module.js +4 -4
- package/lib/features/routing/routing-module.js.map +1 -1
- package/lib/features/select/select-mouse-listener.d.ts +4 -3
- package/lib/features/select/select-mouse-listener.d.ts.map +1 -1
- package/lib/features/select/select-mouse-listener.js.map +1 -1
- package/lib/features/tools/base-tools.d.ts +23 -4
- package/lib/features/tools/base-tools.d.ts.map +1 -1
- package/lib/features/tools/base-tools.js +11 -6
- package/lib/features/tools/base-tools.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-feedback.d.ts +1 -35
- 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 +5 -206
- package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-module.d.ts +1 -0
- package/lib/features/tools/change-bounds/change-bounds-tool-module.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-module.js +1 -0
- 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 +67 -0
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.d.ts.map +1 -0
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js +227 -0
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js.map +1 -0
- package/lib/features/tools/change-bounds/change-bounds-tool.d.ts +34 -24
- package/lib/features/tools/change-bounds/change-bounds-tool.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool.js +172 -180
- package/lib/features/tools/change-bounds/change-bounds-tool.js.map +1 -1
- package/lib/features/tools/change-bounds/index.d.ts +1 -0
- package/lib/features/tools/change-bounds/index.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/index.js +1 -0
- package/lib/features/tools/change-bounds/index.js.map +1 -1
- package/lib/features/tools/change-bounds/view.d.ts +1 -1
- package/lib/features/tools/change-bounds/view.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/view.js +3 -0
- package/lib/features/tools/change-bounds/view.js.map +1 -1
- package/lib/features/tools/deletion/delete-tool.d.ts +16 -1
- package/lib/features/tools/deletion/delete-tool.d.ts.map +1 -1
- package/lib/features/tools/deletion/delete-tool.js +5 -2
- package/lib/features/tools/deletion/delete-tool.js.map +1 -1
- package/lib/features/tools/edge-creation/dangling-edge-feedback.d.ts +17 -1
- package/lib/features/tools/edge-creation/dangling-edge-feedback.d.ts.map +1 -1
- package/lib/features/tools/edge-creation/dangling-edge-feedback.js +3 -1
- package/lib/features/tools/edge-creation/dangling-edge-feedback.js.map +1 -1
- package/lib/features/tools/edge-creation/edge-creation-tool-feedback.d.ts +3 -1
- package/lib/features/tools/edge-creation/edge-creation-tool-feedback.d.ts.map +1 -1
- package/lib/features/tools/edge-creation/edge-creation-tool-feedback.js +4 -7
- package/lib/features/tools/edge-creation/edge-creation-tool-feedback.js.map +1 -1
- package/lib/features/tools/edge-creation/edge-creation-tool.d.ts +20 -2
- package/lib/features/tools/edge-creation/edge-creation-tool.d.ts.map +1 -1
- package/lib/features/tools/edge-creation/edge-creation-tool.js +23 -18
- 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 +3 -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 +5 -8
- 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 +4 -4
- package/lib/features/tools/edge-edit/edge-edit-tool.d.ts.map +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool.js +27 -44
- package/lib/features/tools/edge-edit/edge-edit-tool.js.map +1 -1
- package/lib/features/tools/marquee-selection/marquee-mouse-tool.d.ts +3 -2
- package/lib/features/tools/marquee-selection/marquee-mouse-tool.d.ts.map +1 -1
- package/lib/features/tools/marquee-selection/marquee-mouse-tool.js +4 -2
- package/lib/features/tools/marquee-selection/marquee-mouse-tool.js.map +1 -1
- package/lib/features/tools/node-creation/node-creation-tool.d.ts +14 -5
- package/lib/features/tools/node-creation/node-creation-tool.d.ts.map +1 -1
- package/lib/features/tools/node-creation/node-creation-tool.js +58 -24
- package/lib/features/tools/node-creation/node-creation-tool.js.map +1 -1
- package/lib/features/validation/marker-navigator.d.ts +7 -6
- package/lib/features/validation/marker-navigator.d.ts.map +1 -1
- package/lib/features/validation/marker-navigator.js.map +1 -1
- package/lib/features/validation/validate.d.ts +2 -5
- package/lib/features/validation/validate.d.ts.map +1 -1
- package/lib/features/validation/validate.js +4 -16
- package/lib/features/validation/validate.js.map +1 -1
- package/lib/utils/gmodel-util.d.ts +27 -2
- package/lib/utils/gmodel-util.d.ts.map +1 -1
- package/lib/utils/gmodel-util.js +30 -1
- package/lib/utils/gmodel-util.js.map +1 -1
- package/lib/utils/layout-utils.d.ts +8 -7
- package/lib/utils/layout-utils.d.ts.map +1 -1
- package/lib/utils/layout-utils.js +2 -4
- package/lib/utils/layout-utils.js.map +1 -1
- package/lib/utils/viewpoint-util.d.ts +4 -4
- package/lib/utils/viewpoint-util.d.ts.map +1 -1
- package/lib/utils/viewpoint-util.js.map +1 -1
- package/package.json +3 -3
- package/src/base/default.module.ts +1 -1
- package/src/base/drag-aware-mouse-listener.ts +16 -2
- package/src/base/feedback/css-feedback.ts +4 -0
- package/src/base/feedback/feeback-emitter.ts +112 -0
- package/src/base/feedback/feedback-action-dispatcher.ts +41 -6
- package/src/base/feedback/index.ts +1 -0
- package/src/base/index.ts +1 -1
- package/src/base/selection-service.spec.ts +5 -0
- package/src/base/selection-service.ts +2 -3
- package/src/base/ui-extension/index.ts +17 -0
- package/src/base/{ui-extension-registry.ts → ui-extension/ui-extension-registry.ts} +1 -1
- package/src/base/ui-extension/ui-extension.ts +119 -0
- package/src/features/accessibility/element-navigation/local-element-navigator.ts +4 -4
- package/src/features/accessibility/move-zoom/move-handler.ts +10 -5
- package/src/features/accessibility/resize-key-tool/resize-key-handler.ts +11 -7
- package/src/features/change-bounds/model.ts +25 -13
- package/src/features/change-bounds/movement-restrictor.ts +5 -4
- package/src/features/command-palette/command-palette.ts +2 -1
- package/src/features/element-template/mouse-tracking-element-position-listener.ts +44 -44
- package/src/features/helper-lines/helper-line-manager-default.ts +12 -21
- package/src/features/hints/type-hint-provider.spec.ts +4 -1
- package/src/features/hints/type-hint-provider.ts +9 -2
- package/src/features/label-edit-ui/label-edit-ui.ts +2 -1
- package/src/features/routing/{glsp-manhattan-edge-router.ts → edge-router.ts} +72 -2
- package/src/features/routing/index.ts +1 -1
- package/src/features/routing/routing-module.ts +3 -5
- package/src/features/select/select-mouse-listener.ts +4 -3
- package/src/features/tools/base-tools.ts +15 -8
- package/src/features/tools/change-bounds/change-bounds-tool-feedback.ts +6 -232
- package/src/features/tools/change-bounds/change-bounds-tool-module.ts +1 -0
- package/src/features/tools/change-bounds/change-bounds-tool-move-feedback.ts +254 -0
- package/src/features/tools/change-bounds/change-bounds-tool.ts +217 -226
- package/src/features/tools/change-bounds/index.ts +1 -0
- package/src/features/tools/change-bounds/view.tsx +4 -1
- package/src/features/tools/deletion/delete-tool.ts +6 -6
- package/src/features/tools/edge-creation/dangling-edge-feedback.ts +7 -4
- package/src/features/tools/edge-creation/edge-creation-tool-feedback.ts +9 -9
- package/src/features/tools/edge-creation/edge-creation-tool.ts +33 -23
- package/src/features/tools/edge-edit/edge-edit-tool-feedback.ts +8 -8
- package/src/features/tools/edge-edit/edge-edit-tool.ts +42 -49
- package/src/features/tools/marquee-selection/marquee-mouse-tool.ts +7 -6
- package/src/features/tools/node-creation/node-creation-tool.ts +69 -25
- package/src/features/validation/marker-navigator.ts +6 -8
- package/src/features/validation/validate.ts +5 -20
- package/src/utils/gmodel-util.ts +44 -1
- package/src/utils/layout-utils.ts +9 -20
- package/src/utils/viewpoint-util.ts +3 -4
- package/lib/base/ui-extension-registry.d.ts.map +0 -1
- package/lib/base/ui-extension-registry.js.map +0 -1
- package/lib/features/routing/glsp-manhattan-edge-router.d.ts.map +0 -1
- package/lib/features/routing/glsp-manhattan-edge-router.js +0 -68
- package/lib/features/routing/glsp-manhattan-edge-router.js.map +0 -1
- /package/lib/base/{ui-extension-registry.js → ui-extension/ui-extension-registry.js} +0 -0
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
Action,
|
|
19
19
|
ChangeBoundsOperation,
|
|
20
20
|
Dimension,
|
|
21
|
-
DisposableCollection,
|
|
22
21
|
ElementAndBounds,
|
|
23
22
|
GModelElement,
|
|
24
23
|
GParentElement,
|
|
@@ -30,13 +29,13 @@ import {
|
|
|
30
29
|
SetBoundsAction,
|
|
31
30
|
TYPES
|
|
32
31
|
} from '@eclipse-glsp/sprotty';
|
|
33
|
-
import { inject, injectable, optional } from 'inversify';
|
|
32
|
+
import { inject, injectable, optional, postConstruct } from 'inversify';
|
|
34
33
|
import { DebouncedFunc, debounce } from 'lodash';
|
|
34
|
+
import { FeedbackEmitter } from '../../../base';
|
|
35
35
|
import { EditorContextService } from '../../../base/editor-context-service';
|
|
36
36
|
import { IFeedbackActionDispatcher } from '../../../base/feedback/feedback-action-dispatcher';
|
|
37
|
-
import { SelectableBoundsAware, getElements, isSelectableAndBoundsAware, toElementAndBounds } from '../../../utils/gmodel-util';
|
|
37
|
+
import { Resizable, SelectableBoundsAware, getElements, isSelectableAndBoundsAware, toElementAndBounds } from '../../../utils/gmodel-util';
|
|
38
38
|
import { isValidMove, isValidSize, minHeight, minWidth } from '../../../utils/layout-utils';
|
|
39
|
-
import { Resizable } from '../../change-bounds/model';
|
|
40
39
|
import { GridSnapper } from '../../change-bounds/snap';
|
|
41
40
|
|
|
42
41
|
export enum ResizeType {
|
|
@@ -79,7 +78,7 @@ export class ResizeElementHandler implements IActionHandler {
|
|
|
79
78
|
protected feedbackDispatcher: IFeedbackActionDispatcher;
|
|
80
79
|
|
|
81
80
|
protected debouncedChangeBounds?: DebouncedFunc<() => void>;
|
|
82
|
-
protected
|
|
81
|
+
protected resizeFeedback: FeedbackEmitter;
|
|
83
82
|
|
|
84
83
|
// Default x resize used if GridSnapper is not provided
|
|
85
84
|
static readonly defaultResizeX = 20;
|
|
@@ -96,6 +95,11 @@ export class ResizeElementHandler implements IActionHandler {
|
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
97
|
|
|
98
|
+
@postConstruct()
|
|
99
|
+
protected init(): void {
|
|
100
|
+
this.resizeFeedback = this.feedbackDispatcher.createEmitter();
|
|
101
|
+
}
|
|
102
|
+
|
|
99
103
|
handle(action: Action): void | Action | ICommand {
|
|
100
104
|
if (ResizeElementAction.is(action)) {
|
|
101
105
|
this.handleResizeElement(action);
|
|
@@ -106,11 +110,11 @@ export class ResizeElementHandler implements IActionHandler {
|
|
|
106
110
|
const elements = getElements(this.editorContextService.modelRoot.index, action.elementIds, isSelectableAndBoundsAware);
|
|
107
111
|
const elementAndBounds = this.computeElementAndBounds(elements, action);
|
|
108
112
|
|
|
109
|
-
this.
|
|
113
|
+
this.resizeFeedback.add(SetBoundsAction.create(elementAndBounds)).submit();
|
|
110
114
|
|
|
111
115
|
this.debouncedChangeBounds?.cancel();
|
|
112
116
|
this.debouncedChangeBounds = debounce(() => {
|
|
113
|
-
this.
|
|
117
|
+
this.resizeFeedback.dispose();
|
|
114
118
|
this.dispatcher.dispatchAll([ChangeBoundsOperation.create(elementAndBounds)]);
|
|
115
119
|
this.debouncedChangeBounds = undefined;
|
|
116
120
|
}, 300);
|
|
@@ -14,24 +14,20 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import {
|
|
17
|
-
BoundsAware,
|
|
18
17
|
GChildElement,
|
|
19
18
|
GModelElement,
|
|
20
19
|
GParentElement,
|
|
21
20
|
Hoverable,
|
|
22
|
-
Locateable,
|
|
23
|
-
Selectable,
|
|
24
21
|
hoverFeedbackFeature,
|
|
25
22
|
isBoundsAware,
|
|
26
23
|
isMoveable,
|
|
27
24
|
isSelectable
|
|
28
25
|
} from '@eclipse-glsp/sprotty';
|
|
26
|
+
import { BoundsAwareModelElement, MoveableElement, ResizableModelElement } from '../../utils';
|
|
29
27
|
|
|
30
28
|
export const resizeFeature = Symbol('resizeFeature');
|
|
31
29
|
|
|
32
|
-
export
|
|
33
|
-
|
|
34
|
-
export function isResizable(element: GModelElement): element is GParentElement & Resizable {
|
|
30
|
+
export function isResizable(element: GModelElement): element is ResizableModelElement {
|
|
35
31
|
return isBoundsAware(element) && isSelectable(element) && element instanceof GParentElement && element.hasFeature(resizeFeature);
|
|
36
32
|
}
|
|
37
33
|
|
|
@@ -43,15 +39,17 @@ export enum ResizeHandleLocation {
|
|
|
43
39
|
BottomRight = 'bottom-right'
|
|
44
40
|
}
|
|
45
41
|
|
|
46
|
-
export function isBoundsAwareMoveable(element: GModelElement): element is
|
|
42
|
+
export function isBoundsAwareMoveable(element: GModelElement): element is BoundsAwareModelElement & MoveableElement {
|
|
47
43
|
return isMoveable(element) && isBoundsAware(element);
|
|
48
44
|
}
|
|
49
45
|
|
|
50
46
|
export class SResizeHandle extends GChildElement implements Hoverable {
|
|
51
47
|
static readonly TYPE = 'resize-handle';
|
|
52
48
|
|
|
49
|
+
override readonly parent: ResizableModelElement;
|
|
50
|
+
|
|
53
51
|
constructor(
|
|
54
|
-
readonly location
|
|
52
|
+
readonly location: ResizeHandleLocation,
|
|
55
53
|
override readonly type: string = SResizeHandle.TYPE,
|
|
56
54
|
readonly hoverFeedback: boolean = false
|
|
57
55
|
) {
|
|
@@ -87,11 +85,25 @@ export class SResizeHandle extends GChildElement implements Hoverable {
|
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
87
|
|
|
90
|
-
export function addResizeHandles(
|
|
91
|
-
element
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
export function addResizeHandles(
|
|
89
|
+
element: ResizableModelElement,
|
|
90
|
+
locations: ResizeHandleLocation[] = [
|
|
91
|
+
ResizeHandleLocation.TopLeft,
|
|
92
|
+
ResizeHandleLocation.TopRight,
|
|
93
|
+
ResizeHandleLocation.BottomLeft,
|
|
94
|
+
ResizeHandleLocation.BottomRight
|
|
95
|
+
]
|
|
96
|
+
): void {
|
|
97
|
+
for (const location of Object.values(ResizeHandleLocation)) {
|
|
98
|
+
const existing = element.children.find(child => child instanceof SResizeHandle && child.location === location);
|
|
99
|
+
if (locations.includes(location) && !existing) {
|
|
100
|
+
// add missing handle
|
|
101
|
+
element.add(new SResizeHandle(location));
|
|
102
|
+
} else if (!locations.includes(location) && existing) {
|
|
103
|
+
// remove existing handle
|
|
104
|
+
element.remove(existing);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
95
107
|
}
|
|
96
108
|
|
|
97
109
|
export function removeResizeHandles(element: GParentElement): void {
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { Bounds,
|
|
16
|
+
import { Bounds, GModelElement, GNode, GParentElement, Point } from '@eclipse-glsp/sprotty';
|
|
17
17
|
import { injectable } from 'inversify';
|
|
18
18
|
import { ModifyCSSFeedbackAction } from '../../base/feedback/css-feedback';
|
|
19
|
+
import { BoundsAwareModelElement } from '../../utils';
|
|
19
20
|
import { toAbsoluteBounds } from '../../utils/viewpoint-util';
|
|
20
21
|
import { SResizeHandle, isBoundsAwareMoveable } from './model';
|
|
21
22
|
|
|
@@ -51,7 +52,7 @@ export class NoOverlapMovementRestrictor implements IMovementRestrictor {
|
|
|
51
52
|
return false;
|
|
52
53
|
}
|
|
53
54
|
// Create ghost element at the newLocation
|
|
54
|
-
const ghostElement = Object.create(element) as
|
|
55
|
+
const ghostElement = Object.create(element) as BoundsAwareModelElement;
|
|
55
56
|
ghostElement.bounds = {
|
|
56
57
|
x: newLocation.x,
|
|
57
58
|
y: newLocation.y,
|
|
@@ -64,11 +65,11 @@ export class NoOverlapMovementRestrictor implements IMovementRestrictor {
|
|
|
64
65
|
element.root.index
|
|
65
66
|
.all()
|
|
66
67
|
.filter(e => e.id !== ghostElement.id && e !== ghostElement.root && e instanceof GNode)
|
|
67
|
-
.map(e => e as
|
|
68
|
+
.map(e => e as BoundsAwareModelElement)
|
|
68
69
|
).some(e => this.areOverlapping(e, ghostElement));
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
protected areOverlapping(element1:
|
|
72
|
+
protected areOverlapping(element1: BoundsAwareModelElement, element2: BoundsAwareModelElement): boolean {
|
|
72
73
|
return Bounds.overlap(toAbsoluteBounds(element1), toAbsoluteBounds(element2));
|
|
73
74
|
}
|
|
74
75
|
}
|
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { CommandPalette } from '@eclipse-glsp/sprotty';
|
|
18
18
|
import { injectable } from 'inversify';
|
|
19
|
+
import { CSS_HIDDEN_EXTENSION_CLASS, CSS_UI_EXTENSION_CLASS } from '../../base/ui-extension/ui-extension';
|
|
19
20
|
|
|
20
21
|
@injectable()
|
|
21
22
|
export class GlspCommandPalette extends CommandPalette {
|
|
@@ -18,8 +18,8 @@ import {
|
|
|
18
18
|
Action,
|
|
19
19
|
Dimension,
|
|
20
20
|
Disposable,
|
|
21
|
+
ElementMove,
|
|
21
22
|
GModelElement,
|
|
22
|
-
Locateable,
|
|
23
23
|
MoveAction,
|
|
24
24
|
Point,
|
|
25
25
|
isBoundsAware,
|
|
@@ -28,8 +28,10 @@ import {
|
|
|
28
28
|
import { injectable } from 'inversify';
|
|
29
29
|
import { DragAwareMouseListener } from '../../base/drag-aware-mouse-listener';
|
|
30
30
|
import { CSS_HIDDEN, ModifyCSSFeedbackAction } from '../../base/feedback/css-feedback';
|
|
31
|
+
import { FeedbackEmitter } from '../../base/feedback/feeback-emitter';
|
|
31
32
|
import { IFeedbackEmitter } from '../../base/feedback/feedback-action-dispatcher';
|
|
32
33
|
import { Tool } from '../../base/tool-manager/tool';
|
|
34
|
+
import { MoveableElement } from '../../utils';
|
|
33
35
|
import { getAbsolutePosition } from '../../utils/viewpoint-util';
|
|
34
36
|
import {
|
|
35
37
|
IMovementRestrictor,
|
|
@@ -39,20 +41,28 @@ import {
|
|
|
39
41
|
import { PointPositionUpdater } from '../change-bounds/point-position-updater';
|
|
40
42
|
import { PositionSnapper } from '../change-bounds/position-snapper';
|
|
41
43
|
import { useSnap } from '../change-bounds/snap';
|
|
44
|
+
import { MoveFinishedEventAction } from '../tools';
|
|
42
45
|
|
|
43
46
|
export interface PositioningTool extends Tool {
|
|
44
47
|
readonly positionSnapper: PositionSnapper;
|
|
45
48
|
readonly movementRestrictor?: IMovementRestrictor;
|
|
46
49
|
|
|
50
|
+
createFeedbackEmitter(): FeedbackEmitter;
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated It is recommended to create a {@link createFeedbackEmitter dedicated emitter} per feedback instead of using the tool.
|
|
53
|
+
*/
|
|
47
54
|
registerFeedback(feedbackActions: Action[], feedbackEmitter?: IFeedbackEmitter, cleanupActions?: Action[]): Disposable;
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated It is recommended to create a {@link createFeedbackEmitter dedicated emitter} per feedback and dispose it like that.
|
|
57
|
+
*/
|
|
48
58
|
deregisterFeedback(feedbackEmitter?: IFeedbackEmitter, cleanupActions?: Action[]): void;
|
|
49
59
|
}
|
|
50
60
|
|
|
51
61
|
@injectable()
|
|
52
62
|
export class MouseTrackingElementPositionListener extends DragAwareMouseListener {
|
|
53
|
-
currentPosition?: Point;
|
|
54
|
-
|
|
55
63
|
protected positionUpdater: PointPositionUpdater;
|
|
64
|
+
protected moveGhostFeedback: FeedbackEmitter;
|
|
65
|
+
protected currentPosition?: Point;
|
|
56
66
|
|
|
57
67
|
constructor(
|
|
58
68
|
protected elementId: string,
|
|
@@ -61,6 +71,7 @@ export class MouseTrackingElementPositionListener extends DragAwareMouseListener
|
|
|
61
71
|
) {
|
|
62
72
|
super();
|
|
63
73
|
this.positionUpdater = new PointPositionUpdater(this.tool.positionSnapper);
|
|
74
|
+
this.moveGhostFeedback = this.tool.createFeedbackEmitter();
|
|
64
75
|
}
|
|
65
76
|
|
|
66
77
|
override mouseMove(target: GModelElement, event: MouseEvent): Action[] {
|
|
@@ -69,59 +80,48 @@ export class MouseTrackingElementPositionListener extends DragAwareMouseListener
|
|
|
69
80
|
if (!element || !isMoveable(element)) {
|
|
70
81
|
return [];
|
|
71
82
|
}
|
|
72
|
-
let targetPosition = this.getTargetPosition(target, event, element);
|
|
73
83
|
if (this.positionUpdater.isLastDragPositionUndefined()) {
|
|
74
|
-
this.positionUpdater.updateLastDragPosition(
|
|
84
|
+
this.positionUpdater.updateLastDragPosition(element.position);
|
|
75
85
|
}
|
|
76
|
-
const
|
|
86
|
+
const mousePosition = getAbsolutePosition(target, event);
|
|
87
|
+
const delta = this.positionUpdater.updatePosition(element, mousePosition, useSnap(event));
|
|
77
88
|
if (!delta) {
|
|
78
89
|
return [];
|
|
79
90
|
}
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
],
|
|
89
|
-
{ animate: false, finished: false }
|
|
90
|
-
);
|
|
91
|
-
this.currentPosition = targetPosition;
|
|
92
|
-
this.tool.registerFeedback([moveGhostElement], this);
|
|
93
|
-
return element.cssClasses?.includes(CSS_HIDDEN)
|
|
94
|
-
? [ModifyCSSFeedbackAction.create({ elements: [element.id], remove: [CSS_HIDDEN] })]
|
|
95
|
-
: [];
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
protected getTargetPosition(target: GModelElement, event: MouseEvent, element: GModelElement & Locateable): Point {
|
|
99
|
-
let targetPosition = getAbsolutePosition(target, event);
|
|
100
|
-
if (this.cursorPosition === 'middle' && isBoundsAware(element)) {
|
|
101
|
-
targetPosition = Point.subtract(targetPosition, Dimension.center(element.bounds));
|
|
102
|
-
}
|
|
103
|
-
return targetPosition;
|
|
91
|
+
const toPosition = this.getElementTargetPosition(mousePosition, element, event);
|
|
92
|
+
const elementMove = { elementId: element.id, toPosition: toPosition };
|
|
93
|
+
this.addMoveFeeback(element, elementMove);
|
|
94
|
+
this.currentPosition = toPosition;
|
|
95
|
+
// since we are moving a ghost element that is feedback-only and will be removed anyway,
|
|
96
|
+
// we just send a MoveFinishedEventAction instead of reseting the position with a MoveAction and the finished flag set to true.
|
|
97
|
+
this.moveGhostFeedback.add(MoveAction.create([elementMove], { animate: false }), MoveFinishedEventAction.create()).submit();
|
|
98
|
+
return [];
|
|
104
99
|
}
|
|
105
100
|
|
|
106
|
-
protected
|
|
107
|
-
|
|
101
|
+
protected getElementTargetPosition(mousePosition: Point, element: MoveableElement, event: MouseEvent): Point {
|
|
102
|
+
const unsnappedPosition =
|
|
103
|
+
this.cursorPosition === 'middle' && isBoundsAware(element)
|
|
104
|
+
? Point.subtract(mousePosition, Dimension.center(element.bounds))
|
|
105
|
+
: mousePosition;
|
|
106
|
+
return this.tool.positionSnapper.snapPosition(unsnappedPosition, element, useSnap(event));
|
|
108
107
|
}
|
|
109
108
|
|
|
110
|
-
protected
|
|
111
|
-
let newPosition = toPosition;
|
|
109
|
+
protected addMoveFeeback(element: MoveableElement, elementMove: ElementMove): void {
|
|
112
110
|
if (this.tool.movementRestrictor) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
newPosition = startPosition;
|
|
119
|
-
}
|
|
111
|
+
if (!this.tool.movementRestrictor.validate(element, elementMove.toPosition)) {
|
|
112
|
+
this.moveGhostFeedback.add(
|
|
113
|
+
createMovementRestrictionFeedback(element, this.tool.movementRestrictor),
|
|
114
|
+
removeMovementRestrictionFeedback(element, this.tool.movementRestrictor)
|
|
115
|
+
);
|
|
120
116
|
} else {
|
|
121
|
-
|
|
117
|
+
this.moveGhostFeedback.add(removeMovementRestrictionFeedback(element, this.tool.movementRestrictor));
|
|
122
118
|
}
|
|
123
|
-
this.tool.registerFeedback([action], this, [removeMovementRestrictionFeedback(element, this.tool.movementRestrictor)]);
|
|
124
119
|
}
|
|
125
|
-
|
|
120
|
+
this.moveGhostFeedback.add(ModifyCSSFeedbackAction.create({ elements: [element.id], remove: [CSS_HIDDEN] }));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
override dispose(): void {
|
|
124
|
+
this.moveGhostFeedback.dispose();
|
|
125
|
+
super.dispose();
|
|
126
126
|
}
|
|
127
127
|
}
|
|
@@ -13,18 +13,9 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import {
|
|
17
|
-
Action,
|
|
18
|
-
DisposableCollection,
|
|
19
|
-
GModelElement,
|
|
20
|
-
GModelRoot,
|
|
21
|
-
IActionHandler,
|
|
22
|
-
MoveAction,
|
|
23
|
-
Point,
|
|
24
|
-
SetBoundsAction,
|
|
25
|
-
TYPES
|
|
26
|
-
} from '@eclipse-glsp/sprotty';
|
|
16
|
+
import { Action, GModelElement, GModelRoot, IActionHandler, MoveAction, Point, SetBoundsAction, TYPES } from '@eclipse-glsp/sprotty';
|
|
27
17
|
import { inject, injectable, optional, postConstruct } from 'inversify';
|
|
18
|
+
import { FeedbackEmitter } from '../../base';
|
|
28
19
|
import { IFeedbackActionDispatcher } from '../../base/feedback/feedback-action-dispatcher';
|
|
29
20
|
import { ISelectionListener, SelectionService } from '../../base/selection-service';
|
|
30
21
|
import { SetBoundsFeedbackAction } from '../bounds/set-bounds-feedback-command';
|
|
@@ -95,10 +86,11 @@ export class HelperLineManager implements IActionHandler, ISelectionListener, IH
|
|
|
95
86
|
@optional() @inject(TYPES.IHelperLineOptions) protected userOptions?: IHelperLineOptions;
|
|
96
87
|
|
|
97
88
|
protected options: Required<IHelperLineOptions>;
|
|
98
|
-
protected feedback:
|
|
89
|
+
protected feedback: FeedbackEmitter;
|
|
99
90
|
|
|
100
91
|
@postConstruct()
|
|
101
92
|
protected init(): void {
|
|
93
|
+
this.feedback = this.feedbackDispatcher.createEmitter();
|
|
102
94
|
this.options = { ...DEFAULT_HELPER_LINE_OPTIONS, ...this.userOptions };
|
|
103
95
|
this.selectionService.onSelectionChanged(change =>
|
|
104
96
|
this.selectionChanged(change.root, change.selectedElements, change.deselectedElements)
|
|
@@ -118,9 +110,7 @@ export class HelperLineManager implements IActionHandler, ISelectionListener, IH
|
|
|
118
110
|
}
|
|
119
111
|
|
|
120
112
|
protected handleMoveInitializedAction(_action: MoveInitializedEventAction): void {
|
|
121
|
-
this.
|
|
122
|
-
const feedback = this.createHelperLineFeedback(this.selectionService.getSelectedElementIDs());
|
|
123
|
-
this.feedback.push(this.feedbackDispatcher.registerFeedback(this, [feedback], [RemoveHelperLinesFeedbackAction.create()]));
|
|
113
|
+
this.submitHelperLineFeedback();
|
|
124
114
|
}
|
|
125
115
|
|
|
126
116
|
protected handleMoveFinishedAction(_action: MoveFinishedEventAction): void {
|
|
@@ -129,22 +119,23 @@ export class HelperLineManager implements IActionHandler, ISelectionListener, IH
|
|
|
129
119
|
|
|
130
120
|
protected handleMoveAction(action: MoveAction): void {
|
|
131
121
|
if (!action.finished) {
|
|
132
|
-
|
|
133
|
-
const feedback = this.createHelperLineFeedback(elementIds);
|
|
134
|
-
this.feedback.push(this.feedbackDispatcher.registerFeedback(this, [feedback], [RemoveHelperLinesFeedbackAction.create()]));
|
|
122
|
+
this.submitHelperLineFeedback(action.moves.map(move => move.elementId));
|
|
135
123
|
} else {
|
|
136
124
|
this.feedback.dispose();
|
|
137
125
|
}
|
|
138
126
|
}
|
|
139
127
|
|
|
128
|
+
protected submitHelperLineFeedback(elementIds: string[] = this.selectionService.getSelectedElementIDs()): void {
|
|
129
|
+
const feedback = this.createHelperLineFeedback(elementIds);
|
|
130
|
+
this.feedback.add(feedback, [RemoveHelperLinesFeedbackAction.create()]).submit();
|
|
131
|
+
}
|
|
132
|
+
|
|
140
133
|
protected createHelperLineFeedback(elementIds: string[]): DrawHelperLinesFeedbackAction {
|
|
141
134
|
return DrawHelperLinesFeedbackAction.create({ elementIds, ...this.options });
|
|
142
135
|
}
|
|
143
136
|
|
|
144
137
|
protected handleSetBoundsAction(action: SetBoundsAction | SetBoundsFeedbackAction): void {
|
|
145
|
-
|
|
146
|
-
const feedback = this.createHelperLineFeedback(elementIds);
|
|
147
|
-
this.feedback.push(this.feedbackDispatcher.registerFeedback(this, [feedback], [RemoveHelperLinesFeedbackAction.create()]));
|
|
138
|
+
this.submitHelperLineFeedback(action.bounds.map(bound => bound.elementId));
|
|
148
139
|
}
|
|
149
140
|
|
|
150
141
|
selectionChanged(root: Readonly<GModelRoot>, selectedElements: string[], deselectedElements?: string[] | undefined): void {
|
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
import { expect } from 'chai';
|
|
36
36
|
import { Container } from 'inversify';
|
|
37
37
|
import * as sinon from 'sinon';
|
|
38
|
+
import { FeedbackEmitter } from '../../base';
|
|
38
39
|
import { GLSPActionDispatcher } from '../../base/action-dispatcher';
|
|
39
40
|
import { FeedbackActionDispatcher } from '../../base/feedback/feedback-action-dispatcher';
|
|
40
41
|
import { GEdge } from '../../model';
|
|
@@ -45,7 +46,9 @@ import { ApplyTypeHintsAction, ApplyTypeHintsCommand, ITypeHintProvider, TypeHin
|
|
|
45
46
|
describe('TypeHintProvider', () => {
|
|
46
47
|
const container = new Container();
|
|
47
48
|
container.bind(GLSPActionDispatcher).toConstantValue(sinon.createStubInstance(GLSPActionDispatcher));
|
|
48
|
-
|
|
49
|
+
const stub = sinon.createStubInstance(FeedbackActionDispatcher);
|
|
50
|
+
stub.createEmitter.returns(new FeedbackEmitter(stub));
|
|
51
|
+
container.bind(TYPES.IFeedbackActionDispatcher).toConstantValue(stub);
|
|
49
52
|
const typeHintProvider = container.resolve(TypeHintProvider);
|
|
50
53
|
|
|
51
54
|
describe('getShapeTypeHint', () => {
|
|
@@ -35,8 +35,9 @@ import {
|
|
|
35
35
|
isConnectable,
|
|
36
36
|
moveFeature
|
|
37
37
|
} from '@eclipse-glsp/sprotty';
|
|
38
|
-
import { inject, injectable } from 'inversify';
|
|
38
|
+
import { inject, injectable, postConstruct } from 'inversify';
|
|
39
39
|
|
|
40
|
+
import { FeedbackEmitter } from '../../base';
|
|
40
41
|
import { GLSPActionDispatcher } from '../../base/action-dispatcher';
|
|
41
42
|
import { IFeedbackActionDispatcher } from '../../base/feedback/feedback-action-dispatcher';
|
|
42
43
|
import { FeedbackCommand } from '../../base/feedback/feedback-command';
|
|
@@ -204,15 +205,21 @@ export class TypeHintProvider implements IActionHandler, ITypeHintProvider, IDia
|
|
|
204
205
|
@inject(GLSPActionDispatcher)
|
|
205
206
|
protected actionDispatcher: GLSPActionDispatcher;
|
|
206
207
|
|
|
208
|
+
protected typeHintsFeedback: FeedbackEmitter;
|
|
207
209
|
protected shapeHints: Map<string, ShapeTypeHint> = new Map();
|
|
208
210
|
protected edgeHints: Map<string, EdgeTypeHint> = new Map();
|
|
209
211
|
|
|
212
|
+
@postConstruct()
|
|
213
|
+
protected init(): void {
|
|
214
|
+
this.typeHintsFeedback = this.feedbackActionDispatcher.createEmitter();
|
|
215
|
+
}
|
|
216
|
+
|
|
210
217
|
handle(action: SetTypeHintsAction): void {
|
|
211
218
|
this.shapeHints.clear();
|
|
212
219
|
this.edgeHints.clear();
|
|
213
220
|
action.shapeHints.forEach(hint => this.shapeHints.set(hint.elementTypeId, hint));
|
|
214
221
|
action.edgeHints.forEach(hint => this.edgeHints.set(hint.elementTypeId, hint));
|
|
215
|
-
this.
|
|
222
|
+
this.typeHintsFeedback.add(ApplyTypeHintsAction.create()).submit();
|
|
216
223
|
}
|
|
217
224
|
|
|
218
225
|
getShapeTypeHint(input: GModelElement | GModelElementSchema | string): ShapeTypeHint | undefined {
|
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import {
|
|
16
|
+
import { EditLabelUI } from '@eclipse-glsp/sprotty';
|
|
17
17
|
import { injectable } from 'inversify';
|
|
18
|
+
import { CSS_HIDDEN_EXTENSION_CLASS, CSS_UI_EXTENSION_CLASS } from '../../base/ui-extension/ui-extension';
|
|
18
19
|
|
|
19
20
|
@injectable()
|
|
20
21
|
export class GlspEditLabelUI extends EditLabelUI {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) 2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -14,9 +14,64 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
AbstractEdgeRouter,
|
|
19
|
+
BezierEdgeRouter,
|
|
20
|
+
GConnectableElement,
|
|
21
|
+
GParentElement,
|
|
22
|
+
GRoutableElement,
|
|
23
|
+
ManhattanEdgeRouter,
|
|
24
|
+
Point,
|
|
25
|
+
PolylineEdgeRouter,
|
|
26
|
+
ResolvedHandleMove,
|
|
27
|
+
almostEquals
|
|
28
|
+
} from '@eclipse-glsp/sprotty';
|
|
29
|
+
import { injectable } from 'inversify';
|
|
18
30
|
|
|
31
|
+
@injectable()
|
|
32
|
+
export abstract class GLSPAbstractEdgeRouter extends AbstractEdgeRouter {
|
|
33
|
+
override getTranslatedAnchor(
|
|
34
|
+
connectable: GConnectableElement,
|
|
35
|
+
refPoint: Point,
|
|
36
|
+
refContainer: GParentElement,
|
|
37
|
+
edge: GRoutableElement,
|
|
38
|
+
anchorCorrection?: number | undefined
|
|
39
|
+
): Point {
|
|
40
|
+
// users may define all kinds of anchors and anchor computers, we want to make sure we return a valid one in any case
|
|
41
|
+
const anchor = super.getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection);
|
|
42
|
+
return Point.isValid(anchor) ? anchor : refPoint;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@injectable()
|
|
47
|
+
export class GLSPPolylineEdgeRouter extends PolylineEdgeRouter {
|
|
48
|
+
override getTranslatedAnchor(
|
|
49
|
+
connectable: GConnectableElement,
|
|
50
|
+
refPoint: Point,
|
|
51
|
+
refContainer: GParentElement,
|
|
52
|
+
edge: GRoutableElement,
|
|
53
|
+
anchorCorrection?: number | undefined
|
|
54
|
+
): Point {
|
|
55
|
+
// users may define all kinds of anchors and anchor computers, we want to make sure we return a valid one in any case
|
|
56
|
+
const anchor = super.getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection);
|
|
57
|
+
return Point.isValid(anchor) ? anchor : refPoint;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@injectable()
|
|
19
62
|
export class GLSPManhattanEdgeRouter extends ManhattanEdgeRouter {
|
|
63
|
+
override getTranslatedAnchor(
|
|
64
|
+
connectable: GConnectableElement,
|
|
65
|
+
refPoint: Point,
|
|
66
|
+
refContainer: GParentElement,
|
|
67
|
+
edge: GRoutableElement,
|
|
68
|
+
anchorCorrection?: number | undefined
|
|
69
|
+
): Point {
|
|
70
|
+
// users may define all kinds of anchors and anchor computers, we want to make sure we return a valid one in any case
|
|
71
|
+
const anchor = super.getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection);
|
|
72
|
+
return Point.isValid(anchor) ? anchor : refPoint;
|
|
73
|
+
}
|
|
74
|
+
|
|
20
75
|
protected override applyInnerHandleMoves(edge: GRoutableElement, moves: ResolvedHandleMove[]): void {
|
|
21
76
|
const route = this.route(edge);
|
|
22
77
|
const routingPoints = edge.routingPoints;
|
|
@@ -57,3 +112,18 @@ export class GLSPManhattanEdgeRouter extends ManhattanEdgeRouter {
|
|
|
57
112
|
});
|
|
58
113
|
}
|
|
59
114
|
}
|
|
115
|
+
|
|
116
|
+
@injectable()
|
|
117
|
+
export class GLSPBezierEdgeRouter extends BezierEdgeRouter {
|
|
118
|
+
override getTranslatedAnchor(
|
|
119
|
+
connectable: GConnectableElement,
|
|
120
|
+
refPoint: Point,
|
|
121
|
+
refContainer: GParentElement,
|
|
122
|
+
edge: GRoutableElement,
|
|
123
|
+
anchorCorrection?: number | undefined
|
|
124
|
+
): Point {
|
|
125
|
+
// users may define all kinds of anchors and anchor computers, we want to make sure we return a valid one in any case
|
|
126
|
+
const anchor = super.getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection);
|
|
127
|
+
return Point.isValid(anchor) ? anchor : refPoint;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
export * from './
|
|
16
|
+
export * from './edge-router';
|
|
17
17
|
export * from './routing-module';
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
AddRemoveBezierSegmentCommand,
|
|
18
18
|
AnchorComputerRegistry,
|
|
19
19
|
BezierDiamondAnchor,
|
|
20
|
-
BezierEdgeRouter,
|
|
21
20
|
BezierEllipseAnchor,
|
|
22
21
|
BezierRectangleAnchor,
|
|
23
22
|
DiamondAnchor,
|
|
@@ -27,13 +26,12 @@ import {
|
|
|
27
26
|
ManhattanDiamondAnchor,
|
|
28
27
|
ManhattanEllipticAnchor,
|
|
29
28
|
ManhattanRectangularAnchor,
|
|
30
|
-
PolylineEdgeRouter,
|
|
31
29
|
RectangleAnchor,
|
|
32
30
|
TYPES,
|
|
33
31
|
bindAsService,
|
|
34
32
|
configureCommand
|
|
35
33
|
} from '@eclipse-glsp/sprotty';
|
|
36
|
-
import { GLSPManhattanEdgeRouter } from './
|
|
34
|
+
import { GLSPBezierEdgeRouter, GLSPManhattanEdgeRouter, GLSPPolylineEdgeRouter } from './edge-router';
|
|
37
35
|
|
|
38
36
|
export const routingModule = new FeatureModule((bind, unbind, isBound, rebind) => {
|
|
39
37
|
const context = { bind, unbind, isBound, rebind };
|
|
@@ -45,12 +43,12 @@ export const routingModule = new FeatureModule((bind, unbind, isBound, rebind) =
|
|
|
45
43
|
bindAsService(context, TYPES.IAnchorComputer, ManhattanRectangularAnchor);
|
|
46
44
|
bindAsService(context, TYPES.IAnchorComputer, ManhattanDiamondAnchor);
|
|
47
45
|
|
|
48
|
-
bindAsService(context, TYPES.IEdgeRouter,
|
|
46
|
+
bindAsService(context, TYPES.IEdgeRouter, GLSPPolylineEdgeRouter);
|
|
49
47
|
bindAsService(context, TYPES.IAnchorComputer, EllipseAnchor);
|
|
50
48
|
bindAsService(context, TYPES.IAnchorComputer, RectangleAnchor);
|
|
51
49
|
bindAsService(context, TYPES.IAnchorComputer, DiamondAnchor);
|
|
52
50
|
|
|
53
|
-
bindAsService(context, TYPES.IEdgeRouter,
|
|
51
|
+
bindAsService(context, TYPES.IEdgeRouter, GLSPBezierEdgeRouter);
|
|
54
52
|
bindAsService(context, TYPES.IAnchorComputer, BezierEllipseAnchor);
|
|
55
53
|
bindAsService(context, TYPES.IAnchorComputer, BezierRectangleAnchor);
|
|
56
54
|
bindAsService(context, TYPES.IAnchorComputer, BezierDiamondAnchor);
|
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { Action, BringToFrontAction, GModelElement, SelectAction, SelectMouseListener
|
|
16
|
+
import { Action, BringToFrontAction, GModelElement, SelectAction, SelectMouseListener } from '@eclipse-glsp/sprotty';
|
|
17
17
|
import { Ranked } from '../../base/ranked';
|
|
18
|
+
import { SelectableElement } from '../../utils';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Ranked select mouse listener that is executed before default mouse listeners when using the RankedMouseTool.
|
|
@@ -24,7 +25,7 @@ export class RankedSelectMouseListener extends SelectMouseListener implements Ra
|
|
|
24
25
|
rank: number = Ranked.DEFAULT_RANK - 100; /* we want to be executed before all default mouse listeners */
|
|
25
26
|
|
|
26
27
|
protected override handleSelectTarget(
|
|
27
|
-
selectableTarget:
|
|
28
|
+
selectableTarget: SelectableElement,
|
|
28
29
|
deselectedElements: GModelElement[],
|
|
29
30
|
event: MouseEvent
|
|
30
31
|
): (Action | Promise<Action>)[] {
|
|
@@ -40,7 +41,7 @@ export class RankedSelectMouseListener extends SelectMouseListener implements Ra
|
|
|
40
41
|
return result;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
protected override handleDeselectTarget(selectableTarget:
|
|
44
|
+
protected override handleDeselectTarget(selectableTarget: SelectableElement, event: MouseEvent): (Action | Promise<Action>)[] {
|
|
44
45
|
const result: Action[] = [];
|
|
45
46
|
result.push(SelectAction.create({ selectedElementsIDs: [], deselectedElementsIDs: [selectableTarget.id] }));
|
|
46
47
|
return result;
|