@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
@@ -1,182 +0,0 @@
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 { inject, injectable } from 'inversify';
18
- import { throttle } from 'lodash';
19
- import {
20
- Action,
21
- Bounds,
22
- GChildElement,
23
- IActionDispatcher,
24
- IActionHandler,
25
- ICommand,
26
- Point,
27
- GModelElement,
28
- GModelRoot,
29
- SetViewportAction,
30
- TYPES,
31
- Viewport,
32
- findParentByFeature,
33
- isViewport
34
- } from '@eclipse-glsp/sprotty';
35
- import { EditorContextService } from '../../../base/editor-context-service';
36
- import { SelectableBoundsAware, getElements, isSelectableAndBoundsAware } from '../../../utils/gmodel-util';
37
-
38
- /**
39
- * Action for triggering zooming of the viewport.
40
- */
41
- export interface ZoomViewportAction extends Action {
42
- kind: typeof ZoomViewportAction.KIND;
43
- /**
44
- * used to specify the amount by which the viewport should be zoomed
45
- */
46
- zoomFactor: number;
47
- }
48
-
49
- export namespace ZoomViewportAction {
50
- export const KIND = 'zoomViewportAction';
51
-
52
- export function is(object: any): object is ZoomViewportAction {
53
- return Action.hasKind(object, KIND);
54
- }
55
-
56
- export function create(zoomFactor: number): ZoomViewportAction {
57
- return { kind: KIND, zoomFactor };
58
- }
59
- }
60
-
61
- /**
62
- * Action for triggering zooming of the elements..
63
- */
64
- export interface ZoomElementAction extends Action {
65
- kind: typeof ZoomElementAction.KIND;
66
- /**
67
- * used to specify the elements to be zoomed in/out
68
- */
69
- elementIds: string[];
70
- /**
71
- * used to specify the amount by which the viewport should be zoomed
72
- */
73
- zoomFactor: number;
74
- }
75
-
76
- export namespace ZoomElementAction {
77
- export const KIND = 'zoomElementAction';
78
-
79
- export function is(object: any): object is ZoomElementAction {
80
- return Action.hasKind(object, KIND);
81
- }
82
-
83
- export function create(elementIds: string[], zoomFactor: number): ZoomElementAction {
84
- return { kind: KIND, elementIds, zoomFactor };
85
- }
86
- }
87
-
88
- /* The ZoomViewportHandler class is an implementation of the IActionHandler interface that handles
89
- zooming in and out of a viewport. */
90
- @injectable()
91
- export class ZoomViewportHandler implements IActionHandler {
92
- @inject(EditorContextService)
93
- protected editorContextService: EditorContextService;
94
-
95
- static readonly defaultZoomInFactor = 1.1;
96
- static readonly defaultZoomOutFactor = 0.9;
97
-
98
- @inject(TYPES.IActionDispatcher) protected dispatcher: IActionDispatcher;
99
- protected readonly throttledHandleViewportZoom = throttle((action: ZoomViewportAction) => this.handleZoomViewport(action), 150);
100
-
101
- handle(action: Action): void {
102
- if (ZoomViewportAction.is(action)) {
103
- this.throttledHandleViewportZoom(action);
104
- }
105
- }
106
-
107
- handleZoomViewport(action: ZoomViewportAction): void {
108
- const viewport = findParentByFeature(this.editorContextService.modelRoot, isViewport);
109
- if (!viewport) {
110
- return;
111
- }
112
- this.dispatcher.dispatch(this.setNewZoomFactor(viewport, action.zoomFactor));
113
- }
114
-
115
- protected setNewZoomFactor(viewport: GModelRoot & Viewport, zoomFactor: number): SetViewportAction {
116
- const newZoom = viewport.zoom * zoomFactor;
117
-
118
- const newViewport = {
119
- scroll: viewport.scroll,
120
- zoom: newZoom
121
- };
122
-
123
- return SetViewportAction.create(viewport.id, newViewport, { animate: true });
124
- }
125
- }
126
-
127
- /* The ZoomElementHandler class is an implementation of the IActionHandler interface that handles
128
- zooming in and out of elements. */
129
- @injectable()
130
- export class ZoomElementHandler implements IActionHandler {
131
- @inject(EditorContextService)
132
- protected editorContextService: EditorContextService;
133
- @inject(TYPES.IActionDispatcher) protected dispatcher: IActionDispatcher;
134
- protected readonly throttledHandleElementZoom = throttle((action: ZoomElementAction) => this.handleZoomElement(action), 150);
135
-
136
- handle(action: Action): void | Action | ICommand {
137
- if (ZoomElementAction.is(action)) {
138
- this.throttledHandleElementZoom(action);
139
- }
140
- }
141
-
142
- handleZoomElement(action: ZoomElementAction): void {
143
- const viewport = findParentByFeature(this.editorContextService.modelRoot, isViewport);
144
- if (!viewport) {
145
- return;
146
- }
147
-
148
- const elements = getElements(this.editorContextService.modelRoot.index, action.elementIds, isSelectableAndBoundsAware);
149
- const center = this.getCenter(viewport, elements);
150
- this.dispatcher.dispatch(this.setNewZoomFactor(viewport, action.zoomFactor, center));
151
- }
152
-
153
- protected getCenter(viewport: GModelRoot & Viewport, selectedElements: SelectableBoundsAware[]): Point {
154
- // Get bounds of elements based on the viewport
155
- const allBounds = selectedElements.map(e => this.boundsInViewport(viewport, e, e.bounds));
156
- const mergedBounds = allBounds.reduce((b0, b1) => Bounds.combine(b0, b1));
157
- return Bounds.center(mergedBounds);
158
- }
159
-
160
- // copy from center-fit.ts, translates the children bounds to the viewport bounds
161
- protected boundsInViewport(viewport: GModelRoot & Viewport, element: GModelElement, bounds: Bounds): Bounds {
162
- if (element instanceof GChildElement && element.parent !== viewport) {
163
- return this.boundsInViewport(viewport, element.parent, element.parent.localToParent(bounds) as Bounds);
164
- } else {
165
- return bounds;
166
- }
167
- }
168
-
169
- protected setNewZoomFactor(viewport: GModelRoot & Viewport, zoomFactor: number, point: Point): SetViewportAction {
170
- const newZoom = viewport.zoom * zoomFactor;
171
-
172
- const newViewport = {
173
- scroll: {
174
- x: point.x - (0.5 * viewport.canvasBounds.width) / newZoom,
175
- y: point.y - (0.5 * viewport.canvasBounds.height) / newZoom
176
- },
177
- zoom: newZoom
178
- };
179
-
180
- return SetViewportAction.create(viewport.id, newViewport, { animate: true });
181
- }
182
- }
@@ -1,139 +0,0 @@
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 { Action, GModelElement, IActionDispatcher, ISnapper, KeyListener, KeyTool, matchesKeystroke, TYPES } from '@eclipse-glsp/sprotty';
18
- import { inject, injectable, optional } from 'inversify';
19
- import { SelectionService } from '../../../base/selection-service';
20
- import { EnableDefaultToolsAction, EnableToolsAction, Tool } from '../../../base/tool-manager/tool';
21
- import { IMovementRestrictor } from '../../change-bounds/movement-restrictor';
22
- import { AccessibleKeyShortcutProvider, SetAccessibleKeyShortcutAction } from '../key-shortcut/accessible-key-shortcut';
23
- import * as messages from '../toast/messages.json';
24
- import { ShowToastMessageAction } from '../toast/toast-handler';
25
- import { ResizeElementAction, ResizeType } from './resize-key-handler';
26
-
27
- @injectable()
28
- export class ResizeKeyTool implements Tool {
29
- static ID = 'glsp.resize-key-tool';
30
-
31
- isEditTool = true;
32
-
33
- @inject(KeyTool) protected readonly keytool: KeyTool;
34
- @inject(TYPES.IMovementRestrictor) @optional() readonly movementRestrictor?: IMovementRestrictor;
35
- @inject(TYPES.ISnapper) @optional() readonly snapper?: ISnapper;
36
- @inject(TYPES.IActionDispatcher) readonly actionDispatcher: IActionDispatcher;
37
- @inject(SelectionService) readonly selectionService: SelectionService;
38
-
39
- protected resizeKeyListener: ResizeKeyListener = new ResizeKeyListener(this);
40
-
41
- get id(): string {
42
- return ResizeKeyTool.ID;
43
- }
44
-
45
- enable(): void {
46
- this.keytool.register(this.resizeKeyListener);
47
- this.resizeKeyListener.registerShortcutKey();
48
- }
49
-
50
- disable(): void {
51
- this.keytool.deregister(this.resizeKeyListener);
52
- }
53
- }
54
- @injectable()
55
- export class ResizeKeyListener extends KeyListener implements AccessibleKeyShortcutProvider {
56
- protected isEditMode = false;
57
- protected readonly token = ResizeKeyListener.name;
58
-
59
- constructor(protected readonly tool: ResizeKeyTool) {
60
- super();
61
- }
62
-
63
- registerShortcutKey(): void {
64
- this.tool.actionDispatcher.dispatchOnceModelInitialized(
65
- SetAccessibleKeyShortcutAction.create({
66
- token: this.token,
67
- keys: [
68
- { shortcuts: ['ALT', 'A'], description: 'Activate resize mode for selected element', group: 'Resize', position: 0 },
69
- { shortcuts: ['+'], description: 'Increase size of element', group: 'Resize', position: 1 },
70
- { shortcuts: ['-'], description: 'Increase size of element', group: 'Resize', position: 2 },
71
- { shortcuts: ['CTRL', '0'], description: 'Set element size to default', group: 'Resize', position: 3 }
72
- ]
73
- })
74
- );
75
- }
76
-
77
- override keyDown(element: GModelElement, event: KeyboardEvent): Action[] {
78
- const actions = [];
79
- const selectedElementsIds = this.tool.selectionService.getSelectedElementIDs();
80
-
81
- if (this.isEditMode && this.matchesDeactivateResizeModeKeystroke(event)) {
82
- this.isEditMode = false;
83
-
84
- this.tool.actionDispatcher.dispatch(
85
- ShowToastMessageAction.createWithTimeout({
86
- id: Symbol.for(ResizeKeyListener.name),
87
- message: messages.resize.resize_mode_deactivated
88
- })
89
- );
90
-
91
- actions.push(EnableDefaultToolsAction.create());
92
- }
93
-
94
- if (selectedElementsIds.length > 0) {
95
- if (!this.isEditMode && this.matchesActivateResizeModeKeystroke(event)) {
96
- this.isEditMode = true;
97
- this.tool.actionDispatcher.dispatch(
98
- ShowToastMessageAction.create({
99
- id: Symbol.for(ResizeKeyListener.name),
100
- message: messages.resize.resize_mode_activated
101
- })
102
- );
103
- actions.push(EnableToolsAction.create([ResizeKeyTool.ID]));
104
- }
105
-
106
- if (this.isEditMode) {
107
- if (this.matchesIncreaseSizeKeystroke(event)) {
108
- actions.push(ResizeElementAction.create(selectedElementsIds, ResizeType.Increase));
109
- } else if (this.matchesDecreaseSizeKeystroke(event)) {
110
- actions.push(ResizeElementAction.create(selectedElementsIds, ResizeType.Decrease));
111
- } else if (this.matchesMinSizeKeystroke(event)) {
112
- actions.push(ResizeElementAction.create(selectedElementsIds, ResizeType.MinSize));
113
- }
114
- }
115
- }
116
- return actions;
117
- }
118
-
119
- protected matchesIncreaseSizeKeystroke(event: KeyboardEvent): boolean {
120
- /** here event.key is used for '+', as keycode 187 is already declared for 'Equals' in {@link matchesKeystroke}.*/
121
- return event.key === '+' || matchesKeystroke(event, 'NumpadAdd');
122
- }
123
-
124
- protected matchesActivateResizeModeKeystroke(event: KeyboardEvent): boolean {
125
- return matchesKeystroke(event, 'KeyA', 'alt');
126
- }
127
-
128
- protected matchesDeactivateResizeModeKeystroke(event: KeyboardEvent): boolean {
129
- return matchesKeystroke(event, 'Escape');
130
- }
131
-
132
- protected matchesMinSizeKeystroke(event: KeyboardEvent): boolean {
133
- return matchesKeystroke(event, 'Digit0', 'ctrl') || matchesKeystroke(event, 'Numpad0', 'ctrl');
134
- }
135
-
136
- protected matchesDecreaseSizeKeystroke(event: KeyboardEvent): boolean {
137
- return matchesKeystroke(event, 'Minus') || matchesKeystroke(event, 'NumpadSubtract');
138
- }
139
- }
@@ -1,135 +0,0 @@
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 { Action, GModelElement, IActionDispatcher, ISnapper, KeyListener, KeyTool, matchesKeystroke, TYPES } from '@eclipse-glsp/sprotty';
18
- import { inject, injectable, optional } from 'inversify';
19
- import { SelectionService } from '../../../base/selection-service';
20
- import { Tool } from '../../../base/tool-manager/tool';
21
- import { Grid } from '../../grid/grid';
22
- import { IChangeBoundsManager } from '../../tools/change-bounds/change-bounds-manager';
23
- import { AccessibleKeyShortcutProvider, SetAccessibleKeyShortcutAction } from '../key-shortcut/accessible-key-shortcut';
24
- import { MoveElementAction, MoveViewportAction } from '../move-zoom/move-handler';
25
-
26
- /**
27
- * Moves viewport and elements when its focused and arrow keys are hit.
28
- */
29
- @injectable()
30
- export class MovementKeyTool implements Tool {
31
- static ID = 'glsp.movement-key-tool';
32
-
33
- isEditTool = true;
34
-
35
- protected movementKeyListener: MoveKeyListener;
36
-
37
- @inject(KeyTool) protected readonly keytool: KeyTool;
38
- @inject(SelectionService) selectionService: SelectionService;
39
- @inject(TYPES.ISnapper) @optional() readonly snapper?: ISnapper;
40
- @inject(TYPES.IActionDispatcher) readonly actionDispatcher: IActionDispatcher;
41
- @inject(TYPES.Grid) @optional() protected grid: Grid;
42
- @inject(TYPES.IChangeBoundsManager) readonly changeBoundsManager: IChangeBoundsManager;
43
-
44
- get id(): string {
45
- return MovementKeyTool.ID;
46
- }
47
-
48
- enable(): void {
49
- if (!this.movementKeyListener) {
50
- this.movementKeyListener = new MoveKeyListener(this, this.grid);
51
- }
52
- this.keytool.register(this.movementKeyListener);
53
- this.movementKeyListener.registerShortcutKey();
54
- }
55
-
56
- disable(): void {
57
- this.keytool.deregister(this.movementKeyListener);
58
- }
59
- }
60
-
61
- export class MoveKeyListener extends KeyListener implements AccessibleKeyShortcutProvider {
62
- // Default x distance used if grid is not provided
63
- static readonly defaultMoveX = 20;
64
-
65
- // Default y distance used if grid is not provided
66
- static readonly defaultMoveY = 20;
67
-
68
- protected readonly token = MoveKeyListener.name;
69
-
70
- constructor(
71
- protected readonly tool: MovementKeyTool,
72
- protected grid: Grid = { x: MoveKeyListener.defaultMoveX, y: MoveKeyListener.defaultMoveY }
73
- ) {
74
- super();
75
- }
76
-
77
- registerShortcutKey(): void {
78
- this.tool.actionDispatcher.dispatchOnceModelInitialized(
79
- SetAccessibleKeyShortcutAction.create({
80
- token: this.token,
81
- keys: [{ shortcuts: ['⬅ ⬆ ➡ ⬇'], description: 'Move element or viewport', group: 'Move', position: 0 }]
82
- })
83
- );
84
- }
85
-
86
- override keyDown(_element: GModelElement, event: KeyboardEvent): Action[] {
87
- const selectedElementIds = this.tool.selectionService.getSelectedElementIDs();
88
- const snap = this.tool.changeBoundsManager.usePositionSnap(event);
89
- const offsetX = snap ? this.grid.x : 1;
90
- const offsetY = snap ? this.grid.y : 1;
91
-
92
- if (selectedElementIds.length > 0) {
93
- if (this.matchesMoveUpKeystroke(event)) {
94
- return [MoveElementAction.create(selectedElementIds, 0, -offsetY, snap)];
95
- } else if (this.matchesMoveDownKeystroke(event)) {
96
- return [MoveElementAction.create(selectedElementIds, 0, offsetY, snap)];
97
- } else if (this.matchesMoveRightKeystroke(event)) {
98
- return [MoveElementAction.create(selectedElementIds, offsetX, 0, snap)];
99
- } else if (this.matchesMoveLeftKeystroke(event)) {
100
- return [MoveElementAction.create(selectedElementIds, -offsetX, 0, snap)];
101
- }
102
- } else {
103
- if (this.matchesMoveUpKeystroke(event)) {
104
- return [MoveViewportAction.create(0, -offsetY)];
105
- } else if (this.matchesMoveDownKeystroke(event)) {
106
- return [MoveViewportAction.create(0, offsetY)];
107
- } else if (this.matchesMoveRightKeystroke(event)) {
108
- return [MoveViewportAction.create(offsetX, 0)];
109
- } else if (this.matchesMoveLeftKeystroke(event)) {
110
- return [MoveViewportAction.create(-offsetX, 0)];
111
- }
112
- }
113
- return [];
114
- }
115
-
116
- protected matchesMoveUpKeystroke(event: KeyboardEvent): boolean {
117
- const unsnap = this.tool.changeBoundsManager.unsnapModifier();
118
- return matchesKeystroke(event, 'ArrowUp') || (!!unsnap && matchesKeystroke(event, 'ArrowUp', unsnap));
119
- }
120
-
121
- protected matchesMoveDownKeystroke(event: KeyboardEvent): boolean {
122
- const unsnap = this.tool.changeBoundsManager.unsnapModifier();
123
- return matchesKeystroke(event, 'ArrowDown') || (!!unsnap && matchesKeystroke(event, 'ArrowDown', unsnap));
124
- }
125
-
126
- protected matchesMoveRightKeystroke(event: KeyboardEvent): boolean {
127
- const unsnap = this.tool.changeBoundsManager.unsnapModifier();
128
- return matchesKeystroke(event, 'ArrowRight') || (!!unsnap && matchesKeystroke(event, 'ArrowRight', unsnap));
129
- }
130
-
131
- protected matchesMoveLeftKeystroke(event: KeyboardEvent): boolean {
132
- const unsnap = this.tool.changeBoundsManager.unsnapModifier();
133
- return matchesKeystroke(event, 'ArrowLeft') || (!!unsnap && matchesKeystroke(event, 'ArrowLeft', unsnap));
134
- }
135
- }