@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.
Files changed (207) hide show
  1. package/lib/base/default.module.d.ts.map +1 -1
  2. package/lib/base/default.module.js +3 -0
  3. package/lib/base/default.module.js.map +1 -1
  4. package/lib/{features/accessibility/key-shortcut/accessible-key-shortcut.d.ts → base/shortcuts/available-shortcuts-extension.d.ts} +7 -29
  5. package/lib/base/shortcuts/available-shortcuts-extension.d.ts.map +1 -0
  6. package/lib/{features/accessibility/key-shortcut/accessible-key-shortcut.js → base/shortcuts/available-shortcuts-extension.js} +20 -36
  7. package/lib/base/shortcuts/available-shortcuts-extension.js.map +1 -0
  8. package/lib/{features/accessibility/key-shortcut/accessible-key-shortcut-tool.d.ts → base/shortcuts/available-shortcuts-tool.d.ts} +4 -6
  9. package/lib/base/shortcuts/available-shortcuts-tool.d.ts.map +1 -0
  10. package/lib/{features/accessibility/key-shortcut/accessible-key-shortcut-tool.js → base/shortcuts/available-shortcuts-tool.js} +14 -24
  11. package/lib/base/shortcuts/available-shortcuts-tool.js.map +1 -0
  12. package/lib/base/shortcuts/shortcuts-manager.d.ts +39 -0
  13. package/lib/base/shortcuts/shortcuts-manager.d.ts.map +1 -0
  14. package/lib/base/shortcuts/shortcuts-manager.js +55 -0
  15. package/lib/base/shortcuts/shortcuts-manager.js.map +1 -0
  16. package/lib/{features/accessibility/move-zoom/move-zoom-module.d.ts → base/shortcuts/shortcuts-module.d.ts} +7 -5
  17. package/lib/base/shortcuts/shortcuts-module.d.ts.map +1 -0
  18. package/lib/{features/accessibility/resize-key-tool/resize-key-module.js → base/shortcuts/shortcuts-module.js} +12 -14
  19. package/lib/base/shortcuts/shortcuts-module.js.map +1 -0
  20. package/lib/base/ui-extension/ui-extension.d.ts +3 -1
  21. package/lib/base/ui-extension/ui-extension.d.ts.map +1 -1
  22. package/lib/base/ui-extension/ui-extension.js +8 -0
  23. package/lib/base/ui-extension/ui-extension.js.map +1 -1
  24. package/lib/default-modules.d.ts +1 -1
  25. package/lib/default-modules.d.ts.map +1 -1
  26. package/lib/default-modules.js +3 -1
  27. package/lib/default-modules.js.map +1 -1
  28. package/lib/features/accessibility/accessibility-module.d.ts.map +1 -1
  29. package/lib/features/accessibility/accessibility-module.js +0 -6
  30. package/lib/features/accessibility/accessibility-module.js.map +1 -1
  31. package/lib/features/accessibility/element-navigation/diagram-navigation-tool.d.ts +8 -10
  32. package/lib/features/accessibility/element-navigation/diagram-navigation-tool.d.ts.map +1 -1
  33. package/lib/features/accessibility/element-navigation/diagram-navigation-tool.js +20 -44
  34. package/lib/features/accessibility/element-navigation/diagram-navigation-tool.js.map +1 -1
  35. package/lib/features/accessibility/global-keylistener-tool.d.ts +6 -8
  36. package/lib/features/accessibility/global-keylistener-tool.d.ts.map +1 -1
  37. package/lib/features/accessibility/global-keylistener-tool.js +10 -25
  38. package/lib/features/accessibility/global-keylistener-tool.js.map +1 -1
  39. package/lib/features/accessibility/search/search-tool.d.ts +7 -10
  40. package/lib/features/accessibility/search/search-tool.d.ts.map +1 -1
  41. package/lib/features/accessibility/search/search-tool.js +9 -20
  42. package/lib/features/accessibility/search/search-tool.js.map +1 -1
  43. package/lib/features/accessibility/view-key-tools/{zoom-key-tool.d.ts → grid-cell-zoom-key-tool.d.ts} +13 -21
  44. package/lib/features/accessibility/view-key-tools/grid-cell-zoom-key-tool.d.ts.map +1 -0
  45. package/lib/features/accessibility/view-key-tools/{zoom-key-tool.js → grid-cell-zoom-key-tool.js} +31 -82
  46. package/lib/features/accessibility/view-key-tools/grid-cell-zoom-key-tool.js.map +1 -0
  47. package/lib/features/accessibility/view-key-tools/view-key-tools-module.d.ts.map +1 -1
  48. package/lib/features/accessibility/view-key-tools/view-key-tools-module.js +7 -7
  49. package/lib/features/accessibility/view-key-tools/view-key-tools-module.js.map +1 -1
  50. package/lib/features/bounds/bounds-module.d.ts.map +1 -1
  51. package/lib/features/bounds/bounds-module.js +4 -0
  52. package/lib/features/bounds/bounds-module.js.map +1 -1
  53. package/lib/features/change-bounds/move-element-action.d.ts +52 -0
  54. package/lib/features/change-bounds/move-element-action.d.ts.map +1 -0
  55. package/lib/features/change-bounds/move-element-action.js +32 -0
  56. package/lib/features/change-bounds/move-element-action.js.map +1 -0
  57. package/lib/features/change-bounds/move-element-handler.d.ts +42 -0
  58. package/lib/features/change-bounds/move-element-handler.d.ts.map +1 -0
  59. package/lib/features/{accessibility/move-zoom/move-handler.js → change-bounds/move-element-handler.js} +12 -72
  60. package/lib/features/change-bounds/move-element-handler.js.map +1 -0
  61. package/lib/features/change-bounds/move-element-key-listener.d.ts +31 -0
  62. package/lib/features/change-bounds/move-element-key-listener.d.ts.map +1 -0
  63. package/lib/features/change-bounds/move-element-key-listener.js +71 -0
  64. package/lib/features/change-bounds/move-element-key-listener.js.map +1 -0
  65. package/lib/features/change-bounds/resize/resize-default-tool.d.ts +34 -0
  66. package/lib/features/change-bounds/resize/resize-default-tool.d.ts.map +1 -0
  67. package/lib/features/change-bounds/resize/resize-default-tool.js +89 -0
  68. package/lib/features/change-bounds/resize/resize-default-tool.js.map +1 -0
  69. package/lib/features/{accessibility/resize-key-tool/resize-key-handler.d.ts → change-bounds/resize/resize-handler.d.ts} +3 -7
  70. package/lib/features/change-bounds/resize/resize-handler.d.ts.map +1 -0
  71. package/lib/features/{accessibility/resize-key-tool/resize-key-handler.js → change-bounds/resize/resize-handler.js} +16 -24
  72. package/lib/features/change-bounds/resize/resize-handler.js.map +1 -0
  73. package/lib/features/{accessibility/resize-key-tool/resize-key-module.d.ts → change-bounds/resize/resize-module.d.ts} +9 -4
  74. package/lib/features/change-bounds/resize/resize-module.d.ts.map +1 -0
  75. package/lib/features/change-bounds/resize/resize-module.js +42 -0
  76. package/lib/features/change-bounds/resize/resize-module.js.map +1 -0
  77. package/lib/features/change-bounds/resize/resize-tool.d.ts +37 -0
  78. package/lib/features/change-bounds/resize/resize-tool.d.ts.map +1 -0
  79. package/lib/features/change-bounds/resize/resize-tool.js +123 -0
  80. package/lib/features/change-bounds/resize/resize-tool.js.map +1 -0
  81. package/lib/features/grid/grid-manager.js +1 -0
  82. package/lib/features/grid/grid-manager.js.map +1 -1
  83. package/lib/features/grid/grid-module.d.ts.map +1 -1
  84. package/lib/features/grid/grid-module.js +2 -1
  85. package/lib/features/grid/grid-module.js.map +1 -1
  86. package/lib/features/grid/grid-snapper.d.ts.map +1 -1
  87. package/lib/features/grid/grid-snapper.js +3 -2
  88. package/lib/features/grid/grid-snapper.js.map +1 -1
  89. package/lib/features/grid/grid.d.ts +3 -0
  90. package/lib/features/grid/grid.d.ts.map +1 -1
  91. package/lib/features/grid/grid.js +5 -0
  92. package/lib/features/grid/grid.js.map +1 -1
  93. package/lib/features/helper-lines/helper-line-manager.js +1 -0
  94. package/lib/features/helper-lines/helper-line-manager.js.map +1 -1
  95. package/lib/features/tools/base-tools.d.ts +8 -3
  96. package/lib/features/tools/base-tools.d.ts.map +1 -1
  97. package/lib/features/tools/base-tools.js +21 -12
  98. package/lib/features/tools/base-tools.js.map +1 -1
  99. package/lib/features/tools/change-bounds/change-bounds-tool.d.ts +8 -2
  100. package/lib/features/tools/change-bounds/change-bounds-tool.d.ts.map +1 -1
  101. package/lib/features/tools/change-bounds/change-bounds-tool.js +23 -0
  102. package/lib/features/tools/change-bounds/change-bounds-tool.js.map +1 -1
  103. package/lib/features/tools/edge-creation/edge-creation-tool.js +1 -0
  104. package/lib/features/tools/edge-creation/edge-creation-tool.js.map +1 -1
  105. package/lib/features/tools/node-creation/node-creation-views.js +1 -0
  106. package/lib/features/tools/node-creation/node-creation-views.js.map +1 -1
  107. package/lib/features/viewport/viewport-handler.d.ts +20 -1
  108. package/lib/features/viewport/viewport-handler.d.ts.map +1 -1
  109. package/lib/features/viewport/viewport-handler.js +100 -1
  110. package/lib/features/viewport/viewport-handler.js.map +1 -1
  111. package/lib/features/viewport/viewport-key-listener.d.ts +36 -0
  112. package/lib/features/viewport/viewport-key-listener.d.ts.map +1 -0
  113. package/lib/features/viewport/viewport-key-listener.js +144 -0
  114. package/lib/features/viewport/viewport-key-listener.js.map +1 -0
  115. package/lib/features/viewport/viewport-modules.d.ts.map +1 -1
  116. package/lib/features/viewport/viewport-modules.js +11 -0
  117. package/lib/features/viewport/viewport-modules.js.map +1 -1
  118. package/lib/features/viewport/viewport-tool.d.ts +32 -0
  119. package/lib/features/viewport/viewport-tool.d.ts.map +1 -0
  120. package/lib/features/viewport/viewport-tool.js +67 -0
  121. package/lib/features/viewport/viewport-tool.js.map +1 -0
  122. package/lib/features/viewport/zoom-viewport-action.d.ts +50 -0
  123. package/lib/features/viewport/zoom-viewport-action.d.ts.map +1 -0
  124. package/lib/features/viewport/zoom-viewport-action.js +36 -0
  125. package/lib/features/viewport/zoom-viewport-action.js.map +1 -0
  126. package/lib/index.d.ts +13 -11
  127. package/lib/index.d.ts.map +1 -1
  128. package/lib/index.js +13 -11
  129. package/lib/index.js.map +1 -1
  130. package/lib/standalone-modules.d.ts +1 -1
  131. package/lib/standalone-modules.d.ts.map +1 -1
  132. package/lib/standalone-modules.js +4 -0
  133. package/lib/standalone-modules.js.map +1 -1
  134. package/lib/utils/viewpoint-util.js +2 -2
  135. package/lib/utils/viewpoint-util.js.map +1 -1
  136. package/package.json +3 -3
  137. package/src/base/default.module.ts +4 -0
  138. package/src/{features/accessibility/key-shortcut/accessible-key-shortcut.ts → base/shortcuts/available-shortcuts-extension.ts} +13 -46
  139. package/src/{features/accessibility/key-shortcut/accessible-key-shortcut-tool.ts → base/shortcuts/available-shortcuts-tool.ts} +9 -15
  140. package/src/base/shortcuts/shortcuts-manager.ts +64 -0
  141. package/src/{features/accessibility/resize-key-tool/resize-key-module.ts → base/shortcuts/shortcuts-module.ts} +12 -14
  142. package/src/base/ui-extension/ui-extension.ts +8 -1
  143. package/src/default-modules.ts +3 -1
  144. package/src/features/accessibility/accessibility-module.ts +0 -6
  145. package/src/features/accessibility/element-navigation/diagram-navigation-tool.ts +26 -50
  146. package/src/features/accessibility/global-keylistener-tool.ts +11 -28
  147. package/src/features/accessibility/search/search-tool.ts +15 -33
  148. package/src/features/accessibility/view-key-tools/{zoom-key-tool.ts → grid-cell-zoom-key-tool.ts} +27 -82
  149. package/src/features/accessibility/view-key-tools/view-key-tools-module.ts +7 -7
  150. package/src/features/bounds/bounds-module.ts +6 -0
  151. package/src/features/change-bounds/move-element-action.ts +55 -0
  152. package/src/features/{accessibility/move-zoom/move-handler.ts → change-bounds/move-element-handler.ts} +18 -113
  153. package/src/features/change-bounds/move-element-key-listener.ts +74 -0
  154. package/src/features/change-bounds/resize/resize-default-tool.ts +75 -0
  155. package/src/features/{accessibility/resize-key-tool/resize-key-handler.ts → change-bounds/resize/resize-handler.ts} +10 -19
  156. package/src/features/change-bounds/resize/resize-module.ts +48 -0
  157. package/src/features/change-bounds/resize/resize-tool.ts +114 -0
  158. package/src/features/grid/grid-module.ts +2 -1
  159. package/src/features/grid/grid-snapper.ts +2 -2
  160. package/src/features/grid/grid.ts +3 -0
  161. package/src/features/tools/base-tools.ts +12 -6
  162. package/src/features/tools/change-bounds/change-bounds-tool.ts +25 -1
  163. package/src/features/viewport/viewport-handler.ts +121 -1
  164. package/src/features/viewport/viewport-key-listener.ts +121 -0
  165. package/src/features/viewport/viewport-modules.ts +15 -1
  166. package/src/features/viewport/viewport-tool.ts +54 -0
  167. package/src/features/viewport/zoom-viewport-action.ts +54 -0
  168. package/src/index.ts +13 -11
  169. package/src/standalone-modules.ts +4 -0
  170. package/src/utils/viewpoint-util.ts +2 -2
  171. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut-tool.d.ts.map +0 -1
  172. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut-tool.js.map +0 -1
  173. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut.d.ts.map +0 -1
  174. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut.js.map +0 -1
  175. package/lib/features/accessibility/key-shortcut/shortcut-help-module.d.ts +0 -26
  176. package/lib/features/accessibility/key-shortcut/shortcut-help-module.d.ts.map +0 -1
  177. package/lib/features/accessibility/key-shortcut/shortcut-help-module.js +0 -37
  178. package/lib/features/accessibility/key-shortcut/shortcut-help-module.js.map +0 -1
  179. package/lib/features/accessibility/move-zoom/move-handler.d.ts +0 -97
  180. package/lib/features/accessibility/move-zoom/move-handler.d.ts.map +0 -1
  181. package/lib/features/accessibility/move-zoom/move-handler.js.map +0 -1
  182. package/lib/features/accessibility/move-zoom/move-zoom-module.d.ts.map +0 -1
  183. package/lib/features/accessibility/move-zoom/move-zoom-module.js +0 -40
  184. package/lib/features/accessibility/move-zoom/move-zoom-module.js.map +0 -1
  185. package/lib/features/accessibility/move-zoom/zoom-handler.d.ts +0 -73
  186. package/lib/features/accessibility/move-zoom/zoom-handler.d.ts.map +0 -1
  187. package/lib/features/accessibility/move-zoom/zoom-handler.js +0 -157
  188. package/lib/features/accessibility/move-zoom/zoom-handler.js.map +0 -1
  189. package/lib/features/accessibility/resize-key-tool/resize-key-handler.d.ts.map +0 -1
  190. package/lib/features/accessibility/resize-key-tool/resize-key-handler.js.map +0 -1
  191. package/lib/features/accessibility/resize-key-tool/resize-key-module.d.ts.map +0 -1
  192. package/lib/features/accessibility/resize-key-tool/resize-key-module.js.map +0 -1
  193. package/lib/features/accessibility/resize-key-tool/resize-key-tool.d.ts +0 -47
  194. package/lib/features/accessibility/resize-key-tool/resize-key-tool.d.ts.map +0 -1
  195. package/lib/features/accessibility/resize-key-tool/resize-key-tool.js +0 -154
  196. package/lib/features/accessibility/resize-key-tool/resize-key-tool.js.map +0 -1
  197. package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts +0 -53
  198. package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts.map +0 -1
  199. package/lib/features/accessibility/view-key-tools/movement-key-tool.js +0 -156
  200. package/lib/features/accessibility/view-key-tools/movement-key-tool.js.map +0 -1
  201. package/lib/features/accessibility/view-key-tools/zoom-key-tool.d.ts.map +0 -1
  202. package/lib/features/accessibility/view-key-tools/zoom-key-tool.js.map +0 -1
  203. package/src/features/accessibility/key-shortcut/shortcut-help-module.ts +0 -42
  204. package/src/features/accessibility/move-zoom/move-zoom-module.ts +0 -44
  205. package/src/features/accessibility/move-zoom/zoom-handler.ts +0 -182
  206. package/src/features/accessibility/resize-key-tool/resize-key-tool.ts +0 -139
  207. 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 '../../../base/editor-context-service';
39
- import { IFeedbackActionDispatcher } from '../../../base/feedback/feedback-action-dispatcher';
40
- import { FeedbackEmitter } from '../../../base/feedback/feedback-emitter';
41
- import { SelectableBoundsAware, getElements, isSelectableAndBoundsAware } from '../../../utils/gmodel-util';
42
- import { isValidMove } from '../../../utils/layout-utils';
43
- import { outsideOfViewport } from '../../../utils/viewpoint-util';
44
- import { IMovementRestrictor } from '../../change-bounds/movement-restrictor';
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 (MoveElementAction.is(action)) {
76
+ if (MoveElementRelativeAction.is(action)) {
176
77
  this.handleMoveElement(action);
177
78
  }
178
79
  }
179
80
 
180
- handleMoveElement(action: MoveElementAction): void {
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
- if (outsideOfViewport(newPosition, viewport)) {
201
- viewportActions.push(MoveViewportAction.create(action.moveX, action.moveY));
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: MoveElementAction): Point {
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
- /* The ResizeElementHandler class is an implementation of the IActionHandler interface that handles
68
- resizing of elements. */
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({ x: 10, y: 10 });
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 = { x: 10, y: 10 }) {}
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 = { x: 10, y: 10 }) {
48
+ constructor(@optional() @inject(TYPES.Grid) public readonly grid: Grid = Grid.DEFAULT) {
49
49
  super();
50
50
  }
51
51
 
@@ -16,3 +16,6 @@
16
16
  import { Point } from '@eclipse-glsp/sprotty';
17
17
 
18
18
  export type Grid = Point;
19
+ export namespace Grid {
20
+ export const DEFAULT: Grid = { x: 10, y: 10 };
21
+ }
@@ -53,10 +53,10 @@ export interface FeedbackAwareTool extends Tool {
53
53
  }
54
54
 
55
55
  /**
56
- * A reusable base implementation for edit {@link Tool}s.
56
+ * A reusable base implementation for {@link Tool}s.
57
57
  */
58
58
  @injectable()
59
- export abstract class BaseEditTool implements FeedbackAwareTool {
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;