@eclipse-glsp/client 2.4.0-next.409 → 2.4.0-next.413
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/lib/base/default.module.d.ts.map +1 -1
- package/lib/base/default.module.js +3 -0
- package/lib/base/default.module.js.map +1 -1
- package/lib/{features/accessibility/key-shortcut/accessible-key-shortcut.d.ts → base/shortcuts/available-shortcuts-extension.d.ts} +7 -29
- package/lib/base/shortcuts/available-shortcuts-extension.d.ts.map +1 -0
- package/lib/{features/accessibility/key-shortcut/accessible-key-shortcut.js → base/shortcuts/available-shortcuts-extension.js} +20 -36
- package/lib/base/shortcuts/available-shortcuts-extension.js.map +1 -0
- package/lib/{features/accessibility/key-shortcut/accessible-key-shortcut-tool.d.ts → base/shortcuts/available-shortcuts-tool.d.ts} +4 -6
- package/lib/base/shortcuts/available-shortcuts-tool.d.ts.map +1 -0
- package/lib/{features/accessibility/key-shortcut/accessible-key-shortcut-tool.js → base/shortcuts/available-shortcuts-tool.js} +14 -24
- package/lib/base/shortcuts/available-shortcuts-tool.js.map +1 -0
- package/lib/base/shortcuts/shortcuts-manager.d.ts +39 -0
- package/lib/base/shortcuts/shortcuts-manager.d.ts.map +1 -0
- package/lib/base/shortcuts/shortcuts-manager.js +55 -0
- package/lib/base/shortcuts/shortcuts-manager.js.map +1 -0
- package/lib/{features/accessibility/move-zoom/move-zoom-module.d.ts → base/shortcuts/shortcuts-module.d.ts} +7 -5
- package/lib/base/shortcuts/shortcuts-module.d.ts.map +1 -0
- package/lib/{features/accessibility/resize-key-tool/resize-key-module.js → base/shortcuts/shortcuts-module.js} +12 -14
- package/lib/base/shortcuts/shortcuts-module.js.map +1 -0
- package/lib/base/ui-extension/ui-extension.d.ts +3 -1
- package/lib/base/ui-extension/ui-extension.d.ts.map +1 -1
- package/lib/base/ui-extension/ui-extension.js +8 -0
- package/lib/base/ui-extension/ui-extension.js.map +1 -1
- package/lib/default-modules.d.ts +1 -1
- package/lib/default-modules.d.ts.map +1 -1
- package/lib/default-modules.js +3 -1
- package/lib/default-modules.js.map +1 -1
- package/lib/features/accessibility/accessibility-module.d.ts.map +1 -1
- package/lib/features/accessibility/accessibility-module.js +0 -6
- package/lib/features/accessibility/accessibility-module.js.map +1 -1
- package/lib/features/accessibility/element-navigation/diagram-navigation-tool.d.ts +8 -10
- package/lib/features/accessibility/element-navigation/diagram-navigation-tool.d.ts.map +1 -1
- package/lib/features/accessibility/element-navigation/diagram-navigation-tool.js +20 -44
- package/lib/features/accessibility/element-navigation/diagram-navigation-tool.js.map +1 -1
- package/lib/features/accessibility/global-keylistener-tool.d.ts +6 -8
- package/lib/features/accessibility/global-keylistener-tool.d.ts.map +1 -1
- package/lib/features/accessibility/global-keylistener-tool.js +10 -25
- package/lib/features/accessibility/global-keylistener-tool.js.map +1 -1
- package/lib/features/accessibility/search/search-tool.d.ts +7 -10
- package/lib/features/accessibility/search/search-tool.d.ts.map +1 -1
- package/lib/features/accessibility/search/search-tool.js +9 -20
- package/lib/features/accessibility/search/search-tool.js.map +1 -1
- package/lib/features/accessibility/view-key-tools/{zoom-key-tool.d.ts → grid-cell-zoom-key-tool.d.ts} +13 -21
- package/lib/features/accessibility/view-key-tools/grid-cell-zoom-key-tool.d.ts.map +1 -0
- package/lib/features/accessibility/view-key-tools/{zoom-key-tool.js → grid-cell-zoom-key-tool.js} +31 -82
- package/lib/features/accessibility/view-key-tools/grid-cell-zoom-key-tool.js.map +1 -0
- package/lib/features/accessibility/view-key-tools/view-key-tools-module.d.ts.map +1 -1
- package/lib/features/accessibility/view-key-tools/view-key-tools-module.js +7 -7
- package/lib/features/accessibility/view-key-tools/view-key-tools-module.js.map +1 -1
- package/lib/features/bounds/bounds-module.d.ts.map +1 -1
- package/lib/features/bounds/bounds-module.js +4 -0
- package/lib/features/bounds/bounds-module.js.map +1 -1
- package/lib/features/change-bounds/move-element-action.d.ts +52 -0
- package/lib/features/change-bounds/move-element-action.d.ts.map +1 -0
- package/lib/features/change-bounds/move-element-action.js +32 -0
- package/lib/features/change-bounds/move-element-action.js.map +1 -0
- package/lib/features/change-bounds/move-element-handler.d.ts +42 -0
- package/lib/features/change-bounds/move-element-handler.d.ts.map +1 -0
- package/lib/features/{accessibility/move-zoom/move-handler.js → change-bounds/move-element-handler.js} +12 -72
- package/lib/features/change-bounds/move-element-handler.js.map +1 -0
- package/lib/features/change-bounds/move-element-key-listener.d.ts +31 -0
- package/lib/features/change-bounds/move-element-key-listener.d.ts.map +1 -0
- package/lib/features/change-bounds/move-element-key-listener.js +71 -0
- package/lib/features/change-bounds/move-element-key-listener.js.map +1 -0
- package/lib/features/change-bounds/resize/resize-default-tool.d.ts +34 -0
- package/lib/features/change-bounds/resize/resize-default-tool.d.ts.map +1 -0
- package/lib/features/change-bounds/resize/resize-default-tool.js +89 -0
- package/lib/features/change-bounds/resize/resize-default-tool.js.map +1 -0
- package/lib/features/{accessibility/resize-key-tool/resize-key-handler.d.ts → change-bounds/resize/resize-handler.d.ts} +3 -7
- package/lib/features/change-bounds/resize/resize-handler.d.ts.map +1 -0
- package/lib/features/{accessibility/resize-key-tool/resize-key-handler.js → change-bounds/resize/resize-handler.js} +16 -24
- package/lib/features/change-bounds/resize/resize-handler.js.map +1 -0
- package/lib/features/{accessibility/resize-key-tool/resize-key-module.d.ts → change-bounds/resize/resize-module.d.ts} +9 -4
- package/lib/features/change-bounds/resize/resize-module.d.ts.map +1 -0
- package/lib/features/change-bounds/resize/resize-module.js +42 -0
- package/lib/features/change-bounds/resize/resize-module.js.map +1 -0
- package/lib/features/change-bounds/resize/resize-tool.d.ts +37 -0
- package/lib/features/change-bounds/resize/resize-tool.d.ts.map +1 -0
- package/lib/features/change-bounds/resize/resize-tool.js +123 -0
- package/lib/features/change-bounds/resize/resize-tool.js.map +1 -0
- package/lib/features/grid/grid-manager.js +1 -0
- package/lib/features/grid/grid-manager.js.map +1 -1
- package/lib/features/grid/grid-module.d.ts.map +1 -1
- package/lib/features/grid/grid-module.js +2 -1
- package/lib/features/grid/grid-module.js.map +1 -1
- package/lib/features/grid/grid-snapper.d.ts.map +1 -1
- package/lib/features/grid/grid-snapper.js +3 -2
- package/lib/features/grid/grid-snapper.js.map +1 -1
- package/lib/features/grid/grid.d.ts +3 -0
- package/lib/features/grid/grid.d.ts.map +1 -1
- package/lib/features/grid/grid.js +5 -0
- package/lib/features/grid/grid.js.map +1 -1
- package/lib/features/helper-lines/helper-line-manager.js +1 -0
- package/lib/features/helper-lines/helper-line-manager.js.map +1 -1
- package/lib/features/tools/base-tools.d.ts +8 -3
- package/lib/features/tools/base-tools.d.ts.map +1 -1
- package/lib/features/tools/base-tools.js +21 -12
- package/lib/features/tools/base-tools.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool.d.ts +8 -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 +23 -0
- package/lib/features/tools/change-bounds/change-bounds-tool.js.map +1 -1
- package/lib/features/tools/edge-creation/edge-creation-tool.js +1 -0
- package/lib/features/tools/edge-creation/edge-creation-tool.js.map +1 -1
- package/lib/features/tools/node-creation/node-creation-views.js +1 -0
- package/lib/features/tools/node-creation/node-creation-views.js.map +1 -1
- package/lib/features/viewport/viewport-handler.d.ts +20 -1
- package/lib/features/viewport/viewport-handler.d.ts.map +1 -1
- package/lib/features/viewport/viewport-handler.js +100 -1
- package/lib/features/viewport/viewport-handler.js.map +1 -1
- package/lib/features/viewport/viewport-key-listener.d.ts +36 -0
- package/lib/features/viewport/viewport-key-listener.d.ts.map +1 -0
- package/lib/features/viewport/viewport-key-listener.js +144 -0
- package/lib/features/viewport/viewport-key-listener.js.map +1 -0
- package/lib/features/viewport/viewport-modules.d.ts.map +1 -1
- package/lib/features/viewport/viewport-modules.js +11 -0
- package/lib/features/viewport/viewport-modules.js.map +1 -1
- package/lib/features/viewport/viewport-tool.d.ts +32 -0
- package/lib/features/viewport/viewport-tool.d.ts.map +1 -0
- package/lib/features/viewport/viewport-tool.js +67 -0
- package/lib/features/viewport/viewport-tool.js.map +1 -0
- package/lib/features/viewport/zoom-viewport-action.d.ts +50 -0
- package/lib/features/viewport/zoom-viewport-action.d.ts.map +1 -0
- package/lib/features/viewport/zoom-viewport-action.js +36 -0
- package/lib/features/viewport/zoom-viewport-action.js.map +1 -0
- package/lib/index.d.ts +13 -11
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +13 -11
- package/lib/index.js.map +1 -1
- package/lib/standalone-modules.d.ts +1 -1
- package/lib/standalone-modules.d.ts.map +1 -1
- package/lib/standalone-modules.js +4 -0
- package/lib/standalone-modules.js.map +1 -1
- package/lib/utils/viewpoint-util.js +2 -2
- package/lib/utils/viewpoint-util.js.map +1 -1
- package/package.json +3 -3
- package/src/base/default.module.ts +4 -0
- package/src/{features/accessibility/key-shortcut/accessible-key-shortcut.ts → base/shortcuts/available-shortcuts-extension.ts} +13 -46
- package/src/{features/accessibility/key-shortcut/accessible-key-shortcut-tool.ts → base/shortcuts/available-shortcuts-tool.ts} +9 -15
- package/src/base/shortcuts/shortcuts-manager.ts +64 -0
- package/src/{features/accessibility/resize-key-tool/resize-key-module.ts → base/shortcuts/shortcuts-module.ts} +12 -14
- package/src/base/ui-extension/ui-extension.ts +8 -1
- package/src/default-modules.ts +3 -1
- package/src/features/accessibility/accessibility-module.ts +0 -6
- package/src/features/accessibility/element-navigation/diagram-navigation-tool.ts +26 -50
- package/src/features/accessibility/global-keylistener-tool.ts +11 -28
- package/src/features/accessibility/search/search-tool.ts +15 -33
- package/src/features/accessibility/view-key-tools/{zoom-key-tool.ts → grid-cell-zoom-key-tool.ts} +27 -82
- package/src/features/accessibility/view-key-tools/view-key-tools-module.ts +7 -7
- package/src/features/bounds/bounds-module.ts +6 -0
- package/src/features/change-bounds/move-element-action.ts +55 -0
- package/src/features/{accessibility/move-zoom/move-handler.ts → change-bounds/move-element-handler.ts} +18 -113
- package/src/features/change-bounds/move-element-key-listener.ts +74 -0
- package/src/features/change-bounds/resize/resize-default-tool.ts +75 -0
- package/src/features/{accessibility/resize-key-tool/resize-key-handler.ts → change-bounds/resize/resize-handler.ts} +10 -19
- package/src/features/change-bounds/resize/resize-module.ts +48 -0
- package/src/features/change-bounds/resize/resize-tool.ts +114 -0
- package/src/features/grid/grid-module.ts +2 -1
- package/src/features/grid/grid-snapper.ts +2 -2
- package/src/features/grid/grid.ts +3 -0
- package/src/features/tools/base-tools.ts +12 -6
- package/src/features/tools/change-bounds/change-bounds-tool.ts +25 -1
- package/src/features/viewport/viewport-handler.ts +121 -1
- package/src/features/viewport/viewport-key-listener.ts +121 -0
- package/src/features/viewport/viewport-modules.ts +15 -1
- package/src/features/viewport/viewport-tool.ts +54 -0
- package/src/features/viewport/zoom-viewport-action.ts +54 -0
- package/src/index.ts +13 -11
- package/src/standalone-modules.ts +4 -0
- package/src/utils/viewpoint-util.ts +2 -2
- package/lib/features/accessibility/key-shortcut/accessible-key-shortcut-tool.d.ts.map +0 -1
- package/lib/features/accessibility/key-shortcut/accessible-key-shortcut-tool.js.map +0 -1
- package/lib/features/accessibility/key-shortcut/accessible-key-shortcut.d.ts.map +0 -1
- package/lib/features/accessibility/key-shortcut/accessible-key-shortcut.js.map +0 -1
- package/lib/features/accessibility/key-shortcut/shortcut-help-module.d.ts +0 -26
- package/lib/features/accessibility/key-shortcut/shortcut-help-module.d.ts.map +0 -1
- package/lib/features/accessibility/key-shortcut/shortcut-help-module.js +0 -37
- package/lib/features/accessibility/key-shortcut/shortcut-help-module.js.map +0 -1
- package/lib/features/accessibility/move-zoom/move-handler.d.ts +0 -97
- package/lib/features/accessibility/move-zoom/move-handler.d.ts.map +0 -1
- package/lib/features/accessibility/move-zoom/move-handler.js.map +0 -1
- package/lib/features/accessibility/move-zoom/move-zoom-module.d.ts.map +0 -1
- package/lib/features/accessibility/move-zoom/move-zoom-module.js +0 -40
- package/lib/features/accessibility/move-zoom/move-zoom-module.js.map +0 -1
- package/lib/features/accessibility/move-zoom/zoom-handler.d.ts +0 -73
- package/lib/features/accessibility/move-zoom/zoom-handler.d.ts.map +0 -1
- package/lib/features/accessibility/move-zoom/zoom-handler.js +0 -157
- package/lib/features/accessibility/move-zoom/zoom-handler.js.map +0 -1
- package/lib/features/accessibility/resize-key-tool/resize-key-handler.d.ts.map +0 -1
- package/lib/features/accessibility/resize-key-tool/resize-key-handler.js.map +0 -1
- package/lib/features/accessibility/resize-key-tool/resize-key-module.d.ts.map +0 -1
- package/lib/features/accessibility/resize-key-tool/resize-key-module.js.map +0 -1
- package/lib/features/accessibility/resize-key-tool/resize-key-tool.d.ts +0 -47
- package/lib/features/accessibility/resize-key-tool/resize-key-tool.d.ts.map +0 -1
- package/lib/features/accessibility/resize-key-tool/resize-key-tool.js +0 -154
- package/lib/features/accessibility/resize-key-tool/resize-key-tool.js.map +0 -1
- package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts +0 -53
- package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts.map +0 -1
- package/lib/features/accessibility/view-key-tools/movement-key-tool.js +0 -156
- package/lib/features/accessibility/view-key-tools/movement-key-tool.js.map +0 -1
- package/lib/features/accessibility/view-key-tools/zoom-key-tool.d.ts.map +0 -1
- package/lib/features/accessibility/view-key-tools/zoom-key-tool.js.map +0 -1
- package/src/features/accessibility/key-shortcut/shortcut-help-module.ts +0 -42
- package/src/features/accessibility/move-zoom/move-zoom-module.ts +0 -44
- package/src/features/accessibility/move-zoom/zoom-handler.ts +0 -182
- package/src/features/accessibility/resize-key-tool/resize-key-tool.ts +0 -139
- package/src/features/accessibility/view-key-tools/movement-key-tool.ts +0 -135
|
@@ -19,127 +19,28 @@ import {
|
|
|
19
19
|
ChangeBoundsOperation,
|
|
20
20
|
ElementAndBounds,
|
|
21
21
|
ElementMove,
|
|
22
|
-
GModelRoot,
|
|
23
22
|
IActionDispatcher,
|
|
24
23
|
IActionHandler,
|
|
25
24
|
ICommand,
|
|
26
25
|
ISnapper,
|
|
27
26
|
MoveAction,
|
|
27
|
+
MoveViewportAction,
|
|
28
28
|
Point,
|
|
29
|
-
SetViewportAction,
|
|
30
29
|
TYPES,
|
|
31
|
-
Viewport,
|
|
32
30
|
findParentByFeature,
|
|
33
31
|
isBoundsAware,
|
|
34
32
|
isViewport
|
|
35
33
|
} from '@eclipse-glsp/sprotty';
|
|
36
34
|
import { inject, injectable, optional, postConstruct } from 'inversify';
|
|
37
35
|
import { DebouncedFunc, debounce } from 'lodash';
|
|
38
|
-
import { EditorContextService } from '
|
|
39
|
-
import { IFeedbackActionDispatcher } from '
|
|
40
|
-
import { FeedbackEmitter } from '
|
|
41
|
-
import { SelectableBoundsAware, getElements, isSelectableAndBoundsAware } from '
|
|
42
|
-
import { isValidMove } from '
|
|
43
|
-
import { outsideOfViewport } from '
|
|
44
|
-
import { IMovementRestrictor } from '
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Action for triggering moving of the viewport.
|
|
48
|
-
*/
|
|
49
|
-
export interface MoveViewportAction extends Action {
|
|
50
|
-
kind: typeof MoveViewportAction.KIND;
|
|
51
|
-
/**
|
|
52
|
-
* used to specify the amount to be moved in the x-axis
|
|
53
|
-
*/
|
|
54
|
-
moveX: number;
|
|
55
|
-
/**
|
|
56
|
-
* used to specify the amount to be moved in the y-axis
|
|
57
|
-
*/
|
|
58
|
-
moveY: number;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export namespace MoveViewportAction {
|
|
62
|
-
export const KIND = 'moveViewportAction';
|
|
63
|
-
|
|
64
|
-
export function is(object: any): object is MoveViewportAction {
|
|
65
|
-
return Action.hasKind(object, KIND);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function create(moveX: number, moveY: number): MoveViewportAction {
|
|
69
|
-
return { kind: KIND, moveX, moveY };
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Action for triggering moving of elements.
|
|
75
|
-
*/
|
|
76
|
-
export interface MoveElementAction extends Action {
|
|
77
|
-
kind: typeof MoveElementAction.KIND;
|
|
78
|
-
/**
|
|
79
|
-
* used to specify the elements to be zoomed in/out
|
|
80
|
-
*/
|
|
81
|
-
elementIds: string[];
|
|
82
|
-
/**
|
|
83
|
-
* used to specify the amount to be moved in the x-axis
|
|
84
|
-
*/
|
|
85
|
-
moveX: number;
|
|
86
|
-
/**
|
|
87
|
-
* used to specify the amount to be moved in the y-axis
|
|
88
|
-
*/
|
|
89
|
-
moveY: number;
|
|
90
|
-
/**
|
|
91
|
-
* used to specify whether we should snap to the grid
|
|
92
|
-
*/
|
|
93
|
-
snap: boolean;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export namespace MoveElementAction {
|
|
97
|
-
export const KIND = 'moveElementAction';
|
|
98
|
-
|
|
99
|
-
export function is(object: any): object is MoveElementAction {
|
|
100
|
-
return Action.hasKind(object, KIND);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export function create(elementIds: string[], moveX: number, moveY: number, snap: boolean = true): MoveElementAction {
|
|
104
|
-
return { kind: KIND, elementIds, moveX, moveY, snap };
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Action handler for moving of the viewport.
|
|
110
|
-
*/
|
|
111
|
-
@injectable()
|
|
112
|
-
export class MoveViewportHandler implements IActionHandler {
|
|
113
|
-
@inject(EditorContextService)
|
|
114
|
-
protected editorContextService: EditorContextService;
|
|
115
|
-
@inject(TYPES.IActionDispatcher)
|
|
116
|
-
protected dispatcher: IActionDispatcher;
|
|
117
|
-
|
|
118
|
-
handle(action: Action): void | Action | ICommand {
|
|
119
|
-
if (MoveViewportAction.is(action)) {
|
|
120
|
-
this.handleMoveViewport(action);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
handleMoveViewport(action: MoveViewportAction): void {
|
|
125
|
-
const viewport = findParentByFeature(this.editorContextService.modelRoot, isViewport);
|
|
126
|
-
if (!viewport) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
this.dispatcher.dispatch(this.moveViewport(viewport, action.moveX, action.moveY));
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
protected moveViewport(viewport: GModelRoot & Viewport, offsetX: number, offSetY: number): SetViewportAction {
|
|
133
|
-
const newViewport: Viewport = {
|
|
134
|
-
scroll: {
|
|
135
|
-
x: viewport.scroll.x + offsetX,
|
|
136
|
-
y: viewport.scroll.y + offSetY
|
|
137
|
-
},
|
|
138
|
-
zoom: viewport.zoom
|
|
139
|
-
};
|
|
140
|
-
return SetViewportAction.create(viewport.id, newViewport, { animate: false });
|
|
141
|
-
}
|
|
142
|
-
}
|
|
36
|
+
import { EditorContextService } from '../../base/editor-context-service';
|
|
37
|
+
import { IFeedbackActionDispatcher } from '../../base/feedback/feedback-action-dispatcher';
|
|
38
|
+
import { FeedbackEmitter } from '../../base/feedback/feedback-emitter';
|
|
39
|
+
import { SelectableBoundsAware, getElements, isSelectableAndBoundsAware } from '../../utils/gmodel-util';
|
|
40
|
+
import { isValidMove } from '../../utils/layout-utils';
|
|
41
|
+
import { outsideOfViewport } from '../../utils/viewpoint-util';
|
|
42
|
+
import { IMovementRestrictor } from '../change-bounds/movement-restrictor';
|
|
43
|
+
import { MoveElementRelativeAction } from './move-element-action';
|
|
143
44
|
|
|
144
45
|
/**
|
|
145
46
|
* Action handler for moving elements.
|
|
@@ -172,12 +73,12 @@ export class MoveElementHandler implements IActionHandler {
|
|
|
172
73
|
}
|
|
173
74
|
|
|
174
75
|
handle(action: Action): void | Action | ICommand {
|
|
175
|
-
if (
|
|
76
|
+
if (MoveElementRelativeAction.is(action)) {
|
|
176
77
|
this.handleMoveElement(action);
|
|
177
78
|
}
|
|
178
79
|
}
|
|
179
80
|
|
|
180
|
-
handleMoveElement(action:
|
|
81
|
+
protected handleMoveElement(action: MoveElementRelativeAction): void {
|
|
181
82
|
const modelRoot = this.editorContextService.modelRoot;
|
|
182
83
|
const viewport = findParentByFeature(modelRoot, isViewport);
|
|
183
84
|
if (!viewport) {
|
|
@@ -197,8 +98,12 @@ export class MoveElementHandler implements IActionHandler {
|
|
|
197
98
|
},
|
|
198
99
|
toPosition: newPosition
|
|
199
100
|
});
|
|
200
|
-
|
|
201
|
-
|
|
101
|
+
|
|
102
|
+
const topLeftCorner = newPosition;
|
|
103
|
+
const bottomRightCorner = Point.add(newPosition, { x: element.bounds.width, y: element.bounds.height });
|
|
104
|
+
|
|
105
|
+
if (outsideOfViewport(topLeftCorner, viewport) || outsideOfViewport(bottomRightCorner, viewport)) {
|
|
106
|
+
viewportActions.push(MoveViewportAction.create({ moveX: action.moveX, moveY: action.moveY }));
|
|
202
107
|
}
|
|
203
108
|
}
|
|
204
109
|
|
|
@@ -209,7 +114,7 @@ export class MoveElementHandler implements IActionHandler {
|
|
|
209
114
|
this.scheduleChangeBounds(this.toElementAndBounds(elementMoves));
|
|
210
115
|
}
|
|
211
116
|
|
|
212
|
-
protected getTargetBounds(element: SelectableBoundsAware, action:
|
|
117
|
+
protected getTargetBounds(element: SelectableBoundsAware, action: MoveElementRelativeAction): Point {
|
|
213
118
|
let position = Point.add(element.bounds, { x: action.moveX, y: action.moveY });
|
|
214
119
|
if (this.snapper && action.snap) {
|
|
215
120
|
position = this.snapper.snap(position, element);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2025 EclipseSource 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 { isMoveable, KeyListener, matchesKeystroke, type Action, type GModelElement } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import type { SelectionService } from '../../base/selection-service';
|
|
19
|
+
import { Grid } from '../grid/grid';
|
|
20
|
+
import type { IChangeBoundsManager } from '../tools/change-bounds/change-bounds-manager';
|
|
21
|
+
import { MoveElementRelativeAction } from './move-element-action';
|
|
22
|
+
|
|
23
|
+
export class MoveElementKeyListener extends KeyListener {
|
|
24
|
+
constructor(
|
|
25
|
+
protected readonly selectionService: SelectionService,
|
|
26
|
+
protected readonly changeBoundsManager: IChangeBoundsManager,
|
|
27
|
+
protected readonly grid: Grid = Grid.DEFAULT
|
|
28
|
+
) {
|
|
29
|
+
super();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
override keyDown(_element: GModelElement, event: KeyboardEvent): Action[] {
|
|
33
|
+
const selectedElementIds = this.selectionService
|
|
34
|
+
.getSelectedElements()
|
|
35
|
+
.filter(element => isMoveable(element))
|
|
36
|
+
.map(element => element.id);
|
|
37
|
+
const snap = this.changeBoundsManager.usePositionSnap(event);
|
|
38
|
+
const offsetX = snap ? this.grid.x : 1;
|
|
39
|
+
const offsetY = snap ? this.grid.y : 1;
|
|
40
|
+
|
|
41
|
+
if (selectedElementIds.length > 0) {
|
|
42
|
+
if (this.matchesMoveUpKeystroke(event)) {
|
|
43
|
+
return [MoveElementRelativeAction.create({ elementIds: selectedElementIds, moveX: 0, moveY: -offsetY, snap })];
|
|
44
|
+
} else if (this.matchesMoveDownKeystroke(event)) {
|
|
45
|
+
return [MoveElementRelativeAction.create({ elementIds: selectedElementIds, moveX: 0, moveY: offsetY, snap })];
|
|
46
|
+
} else if (this.matchesMoveRightKeystroke(event)) {
|
|
47
|
+
return [MoveElementRelativeAction.create({ elementIds: selectedElementIds, moveX: offsetX, moveY: 0, snap })];
|
|
48
|
+
} else if (this.matchesMoveLeftKeystroke(event)) {
|
|
49
|
+
return [MoveElementRelativeAction.create({ elementIds: selectedElementIds, moveX: -offsetX, moveY: 0, snap })];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
protected matchesMoveUpKeystroke(event: KeyboardEvent): boolean {
|
|
56
|
+
const unsnap = this.changeBoundsManager.unsnapModifier();
|
|
57
|
+
return matchesKeystroke(event, 'ArrowUp') || (!!unsnap && matchesKeystroke(event, 'ArrowUp', unsnap));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
protected matchesMoveDownKeystroke(event: KeyboardEvent): boolean {
|
|
61
|
+
const unsnap = this.changeBoundsManager.unsnapModifier();
|
|
62
|
+
return matchesKeystroke(event, 'ArrowDown') || (!!unsnap && matchesKeystroke(event, 'ArrowDown', unsnap));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
protected matchesMoveRightKeystroke(event: KeyboardEvent): boolean {
|
|
66
|
+
const unsnap = this.changeBoundsManager.unsnapModifier();
|
|
67
|
+
return matchesKeystroke(event, 'ArrowRight') || (!!unsnap && matchesKeystroke(event, 'ArrowRight', unsnap));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
protected matchesMoveLeftKeystroke(event: KeyboardEvent): boolean {
|
|
71
|
+
const unsnap = this.changeBoundsManager.unsnapModifier();
|
|
72
|
+
return matchesKeystroke(event, 'ArrowLeft') || (!!unsnap && matchesKeystroke(event, 'ArrowLeft', unsnap));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2023 Business Informatics Group (TU Wien) 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 { KeyListener, matchesKeystroke, TYPES, type Action, type GModelElement, type IActionDispatcher } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import { inject, injectable } from 'inversify';
|
|
19
|
+
import { SelectionService } from '../../../base/selection-service';
|
|
20
|
+
import type { ShortcutManager } from '../../../base/shortcuts/shortcuts-manager';
|
|
21
|
+
import { EnableToolsAction } from '../../../base/tool-manager/tool';
|
|
22
|
+
import { BaseEditTool } from '../../tools/base-tools';
|
|
23
|
+
import { isResizable } from '../model';
|
|
24
|
+
import { ResizeKeyTool } from './resize-tool';
|
|
25
|
+
|
|
26
|
+
@injectable()
|
|
27
|
+
export class DefaultResizeKeyListener extends KeyListener {
|
|
28
|
+
@inject(TYPES.IActionDispatcher)
|
|
29
|
+
protected readonly actionDispatcher: IActionDispatcher;
|
|
30
|
+
@inject(SelectionService)
|
|
31
|
+
protected readonly selectionService: SelectionService;
|
|
32
|
+
|
|
33
|
+
override keyDown(element: GModelElement, event: KeyboardEvent): Action[] {
|
|
34
|
+
const selectedElementsIds = this.selectionService
|
|
35
|
+
.getSelectedElements()
|
|
36
|
+
.filter(isResizable)
|
|
37
|
+
.map(e => e.id);
|
|
38
|
+
|
|
39
|
+
if (selectedElementsIds.length > 0) {
|
|
40
|
+
if (this.matchesActivateResizeModeKeystroke(event)) {
|
|
41
|
+
return [EnableToolsAction.create([ResizeKeyTool.ID])];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
protected matchesActivateResizeModeKeystroke(event: KeyboardEvent): boolean {
|
|
49
|
+
return matchesKeystroke(event, 'KeyA', 'alt');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@injectable()
|
|
54
|
+
export class DefaultResizeKeyTool extends BaseEditTool {
|
|
55
|
+
static ID = 'glsp.default-resize-key-tool';
|
|
56
|
+
static TOKEN = Symbol.for(DefaultResizeKeyTool.name);
|
|
57
|
+
|
|
58
|
+
get id(): string {
|
|
59
|
+
return DefaultResizeKeyTool.ID;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@inject(TYPES.IShortcutManager)
|
|
63
|
+
protected readonly shortcutManager: ShortcutManager;
|
|
64
|
+
@inject(DefaultResizeKeyListener)
|
|
65
|
+
protected readonly keyListener: DefaultResizeKeyListener;
|
|
66
|
+
|
|
67
|
+
enable(): void {
|
|
68
|
+
this.toDisposeOnDisable.push(
|
|
69
|
+
this.keyTool.registerListener(this.keyListener),
|
|
70
|
+
this.shortcutManager.register(DefaultResizeKeyTool.TOKEN, [
|
|
71
|
+
{ shortcuts: ['ALT', 'A'], description: 'Activate resize mode for selected element', group: 'Resize', position: 0 }
|
|
72
|
+
])
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -64,37 +64,28 @@ export namespace ResizeElementAction {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
/*
|
|
68
|
-
|
|
67
|
+
/*
|
|
68
|
+
* The ResizeElementHandler class is an implementation of the IActionHandler interface that handles
|
|
69
|
+
* resizing of elements.
|
|
70
|
+
*/
|
|
69
71
|
@injectable()
|
|
70
72
|
export class ResizeElementHandler implements IActionHandler {
|
|
71
73
|
@inject(EditorContextService)
|
|
72
74
|
protected editorContextService: EditorContextService;
|
|
73
|
-
|
|
74
75
|
@inject(TYPES.IActionDispatcher)
|
|
75
76
|
protected dispatcher: IActionDispatcher;
|
|
76
|
-
|
|
77
77
|
@inject(TYPES.IFeedbackActionDispatcher)
|
|
78
78
|
protected feedbackDispatcher: IFeedbackActionDispatcher;
|
|
79
|
+
@inject(TYPES.Grid)
|
|
80
|
+
@optional()
|
|
81
|
+
protected grid: Grid = Grid.DEFAULT;
|
|
82
|
+
@inject(TYPES.ISnapper)
|
|
83
|
+
@optional()
|
|
84
|
+
protected readonly snapper?: ISnapper;
|
|
79
85
|
|
|
80
86
|
protected debouncedChangeBounds?: DebouncedFunc<() => void>;
|
|
81
87
|
protected resizeFeedback: FeedbackEmitter;
|
|
82
88
|
|
|
83
|
-
// Default x resize used if grid is not provided
|
|
84
|
-
static readonly defaultResizeX = 20;
|
|
85
|
-
|
|
86
|
-
// Default y resize used if grid is not provided
|
|
87
|
-
static readonly defaultResizeY = 20;
|
|
88
|
-
|
|
89
|
-
@inject(TYPES.Grid) @optional() protected grid: Grid = {
|
|
90
|
-
x: ResizeElementHandler.defaultResizeX,
|
|
91
|
-
y: ResizeElementHandler.defaultResizeY
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
protected isEditMode = false;
|
|
95
|
-
|
|
96
|
-
constructor(@inject(TYPES.ISnapper) @optional() protected readonly snapper?: ISnapper) {}
|
|
97
|
-
|
|
98
89
|
@postConstruct()
|
|
99
90
|
protected init(): void {
|
|
100
91
|
this.resizeFeedback = this.feedbackDispatcher.createEmitter();
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2023-2024 Business Informatics Group (TU Wien) 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 { FeatureModule, TYPES, bindAsService, configureActionHandler } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import { DefaultResizeKeyListener, DefaultResizeKeyTool } from './resize-default-tool';
|
|
19
|
+
import { ResizeElementAction, ResizeElementHandler } from './resize-handler';
|
|
20
|
+
import { ResizeKeyListener, ResizeKeyTool } from './resize-tool';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Handles resize actions.
|
|
24
|
+
*/
|
|
25
|
+
export const resizeModule = new FeatureModule(
|
|
26
|
+
(bind, unbind, isBound, rebind) => {
|
|
27
|
+
const context = { bind, unbind, isBound, rebind };
|
|
28
|
+
configureActionHandler(context, ResizeElementAction.KIND, ResizeElementHandler);
|
|
29
|
+
},
|
|
30
|
+
{ featureId: Symbol('resize') }
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Feature module that is intended for the standalone deployment of GLSP (i.e. plain webapp)
|
|
35
|
+
* When integrated into an application frame (e.g Theia/VS Code) this module is typically omitted and/or replaced
|
|
36
|
+
* with an application native module.
|
|
37
|
+
*/
|
|
38
|
+
export const standaloneResizeModule = new FeatureModule(
|
|
39
|
+
(bind, unbind, isBound, rebind) => {
|
|
40
|
+
const context = { bind, unbind, isBound, rebind };
|
|
41
|
+
|
|
42
|
+
bindAsService(context, TYPES.IDefaultTool, DefaultResizeKeyTool);
|
|
43
|
+
context.bind(DefaultResizeKeyListener).toSelf();
|
|
44
|
+
bindAsService(context, TYPES.ITool, ResizeKeyTool);
|
|
45
|
+
context.bind(ResizeKeyListener).toSelf();
|
|
46
|
+
},
|
|
47
|
+
{ featureId: Symbol('standaloneResize'), requires: resizeModule }
|
|
48
|
+
);
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2025 EclipseSource 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 { KeyListener, matchesKeystroke, TYPES, type Action, type GModelElement } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import { inject, injectable } from 'inversify';
|
|
19
|
+
import { Disposable } from 'vscode-jsonrpc';
|
|
20
|
+
import { SelectionService } from '../../../base/selection-service';
|
|
21
|
+
import type { ShortcutManager } from '../../../base/shortcuts/shortcuts-manager';
|
|
22
|
+
import * as messages from '../../accessibility/toast/messages.json';
|
|
23
|
+
import { ShowToastMessageAction } from '../../accessibility/toast/toast-handler';
|
|
24
|
+
import { BaseEditTool } from '../../tools/base-tools';
|
|
25
|
+
import { isResizable } from '../model';
|
|
26
|
+
import { ResizeElementAction, ResizeType } from './resize-handler';
|
|
27
|
+
|
|
28
|
+
@injectable()
|
|
29
|
+
export class ResizeKeyListener extends KeyListener {
|
|
30
|
+
@inject(SelectionService)
|
|
31
|
+
protected readonly selectionService: SelectionService;
|
|
32
|
+
|
|
33
|
+
override keyDown(element: GModelElement, event: KeyboardEvent): Action[] {
|
|
34
|
+
const actions = [];
|
|
35
|
+
const selectedElementsIds = this.selectionService
|
|
36
|
+
.getSelectedElements()
|
|
37
|
+
.filter(isResizable)
|
|
38
|
+
.map(e => e.id);
|
|
39
|
+
|
|
40
|
+
if (selectedElementsIds.length > 0) {
|
|
41
|
+
if (this.matchesIncreaseSizeKeystroke(event)) {
|
|
42
|
+
actions.push(ResizeElementAction.create(selectedElementsIds, ResizeType.Increase));
|
|
43
|
+
} else if (this.matchesDecreaseSizeKeystroke(event)) {
|
|
44
|
+
actions.push(ResizeElementAction.create(selectedElementsIds, ResizeType.Decrease));
|
|
45
|
+
} else if (this.matchesMinSizeKeystroke(event)) {
|
|
46
|
+
actions.push(ResizeElementAction.create(selectedElementsIds, ResizeType.MinSize));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return actions;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
enable(): Action[] {
|
|
53
|
+
return [
|
|
54
|
+
ShowToastMessageAction.create({
|
|
55
|
+
id: ResizeKeyTool.TOKEN,
|
|
56
|
+
message: messages.resize.resize_mode_activated
|
|
57
|
+
})
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
disable(): Action[] {
|
|
62
|
+
return [
|
|
63
|
+
ShowToastMessageAction.createWithTimeout({
|
|
64
|
+
id: ResizeKeyTool.TOKEN,
|
|
65
|
+
message: messages.resize.resize_mode_deactivated
|
|
66
|
+
})
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
protected matchesIncreaseSizeKeystroke(event: KeyboardEvent): boolean {
|
|
71
|
+
/** here event.key is used for '+', as keycode 187 is already declared for 'Equals' in {@link matchesKeystroke}.*/
|
|
72
|
+
return event.key === '+' || matchesKeystroke(event, 'NumpadAdd');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
protected matchesMinSizeKeystroke(event: KeyboardEvent): boolean {
|
|
76
|
+
return matchesKeystroke(event, 'Digit0', 'ctrl') || matchesKeystroke(event, 'Numpad0', 'ctrl');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
protected matchesDecreaseSizeKeystroke(event: KeyboardEvent): boolean {
|
|
80
|
+
return matchesKeystroke(event, 'Minus') || matchesKeystroke(event, 'NumpadSubtract');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@injectable()
|
|
85
|
+
export class ResizeKeyTool extends BaseEditTool {
|
|
86
|
+
static ID = 'glsp.resize-key-tool';
|
|
87
|
+
static TOKEN = Symbol.for(ResizeKeyTool.name);
|
|
88
|
+
|
|
89
|
+
get id(): string {
|
|
90
|
+
return ResizeKeyTool.ID;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@inject(TYPES.IShortcutManager)
|
|
94
|
+
protected readonly shortcutManager: ShortcutManager;
|
|
95
|
+
@inject(ResizeKeyListener)
|
|
96
|
+
protected readonly keyListener: ResizeKeyListener;
|
|
97
|
+
|
|
98
|
+
enable(): void {
|
|
99
|
+
this.dispatchActions(this.keyListener.enable());
|
|
100
|
+
|
|
101
|
+
this.toDisposeOnDisable.push(
|
|
102
|
+
this.keyTool.registerListener(this.keyListener),
|
|
103
|
+
this.shortcutManager.register(ResizeKeyTool.TOKEN, [
|
|
104
|
+
{ shortcuts: ['Escape'], description: 'Deactivate resize handler ', group: 'Resize', position: 0 },
|
|
105
|
+
{ shortcuts: ['+'], description: 'Increase size of element', group: 'Resize', position: 1 },
|
|
106
|
+
{ shortcuts: ['-'], description: 'Increase size of element', group: 'Resize', position: 2 },
|
|
107
|
+
{ shortcuts: ['CTRL', '0'], description: 'Set element size to default', group: 'Resize', position: 3 }
|
|
108
|
+
]),
|
|
109
|
+
Disposable.create(() => {
|
|
110
|
+
this.dispatchActions(this.keyListener.disable());
|
|
111
|
+
})
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { FeatureModule, TYPES, bindAsService, configureActionHandler, configureCommand } from '@eclipse-glsp/sprotty';
|
|
18
18
|
import '../../../css/grid.css';
|
|
19
|
+
import { Grid } from './grid';
|
|
19
20
|
import { GridManager } from './grid-manager';
|
|
20
21
|
import { ShowGridAction, ShowGridCommand } from './grid-model';
|
|
21
22
|
import { GridSnapper } from './grid-snapper';
|
|
@@ -24,7 +25,7 @@ export const gridModule = new FeatureModule(
|
|
|
24
25
|
(bind, unbind, isBound, rebind) => {
|
|
25
26
|
const context = { bind, unbind, isBound, rebind };
|
|
26
27
|
|
|
27
|
-
bind(TYPES.Grid).toConstantValue(
|
|
28
|
+
bind(TYPES.Grid).toConstantValue(Grid.DEFAULT);
|
|
28
29
|
|
|
29
30
|
configureCommand(context, ShowGridCommand);
|
|
30
31
|
|
|
@@ -36,7 +36,7 @@ import { Grid } from './grid';
|
|
|
36
36
|
*/
|
|
37
37
|
@injectable()
|
|
38
38
|
export class GridSnapper implements ISnapper {
|
|
39
|
-
constructor(@optional() @inject(TYPES.Grid) public readonly grid: Grid =
|
|
39
|
+
constructor(@optional() @inject(TYPES.Grid) public readonly grid: Grid = Grid.DEFAULT) {}
|
|
40
40
|
|
|
41
41
|
snap(position: Point, element: GModelElement): Point {
|
|
42
42
|
return Point.snapToGrid(position, this.grid);
|
|
@@ -45,7 +45,7 @@ export class GridSnapper implements ISnapper {
|
|
|
45
45
|
|
|
46
46
|
@injectable()
|
|
47
47
|
export class GLSPCenterGridSnapper extends CenterGridSnapper {
|
|
48
|
-
constructor(@optional() @inject(TYPES.Grid) public readonly grid: Grid =
|
|
48
|
+
constructor(@optional() @inject(TYPES.Grid) public readonly grid: Grid = Grid.DEFAULT) {
|
|
49
49
|
super();
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -53,10 +53,10 @@ export interface FeedbackAwareTool extends Tool {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* A reusable base implementation for {@link Tool}s.
|
|
57
57
|
*/
|
|
58
58
|
@injectable()
|
|
59
|
-
export abstract class
|
|
59
|
+
export abstract class BaseTool implements FeedbackAwareTool {
|
|
60
60
|
@inject(TYPES.IFeedbackActionDispatcher) protected feedbackDispatcher: IFeedbackActionDispatcher;
|
|
61
61
|
@inject(TYPES.IActionDispatcher) protected actionDispatcher: IActionDispatcher;
|
|
62
62
|
@inject(GLSPMouseTool) protected mouseTool: GLSPMouseTool;
|
|
@@ -73,10 +73,6 @@ export abstract class BaseEditTool implements FeedbackAwareTool {
|
|
|
73
73
|
|
|
74
74
|
abstract id: string;
|
|
75
75
|
|
|
76
|
-
get isEditTool(): boolean {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
76
|
dispatchActions(actions: Action[]): Promise<void> {
|
|
81
77
|
return this.actionDispatcher.dispatchAll(actions);
|
|
82
78
|
}
|
|
@@ -94,6 +90,16 @@ export abstract class BaseEditTool implements FeedbackAwareTool {
|
|
|
94
90
|
}
|
|
95
91
|
}
|
|
96
92
|
|
|
93
|
+
/**
|
|
94
|
+
* A reusable base implementation for edit {@link Tool}s.
|
|
95
|
+
*/
|
|
96
|
+
@injectable()
|
|
97
|
+
export abstract class BaseEditTool extends BaseTool {
|
|
98
|
+
get isEditTool(): boolean {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
97
103
|
@injectable()
|
|
98
104
|
export abstract class BaseCreationTool<T extends Action> extends BaseEditTool implements IActionHandler {
|
|
99
105
|
protected abstract isTriggerAction: (obj: any) => obj is T;
|