@eclipse-glsp/client 2.2.0-next.330 → 2.2.0-next.332

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 (180) hide show
  1. package/{lib/features/routing/glsp-manhattan-edge-router.d.ts → css/debug.css} +10 -5
  2. package/css/glsp-sprotty.css +5 -0
  3. package/css/grid.css +20 -0
  4. package/css/keyboard-tool-palette.css +0 -6
  5. package/css/tool-palette.css +30 -26
  6. package/lib/base/default.module.js +1 -1
  7. package/lib/base/default.module.js.map +1 -1
  8. package/lib/base/index.d.ts +1 -1
  9. package/lib/base/index.d.ts.map +1 -1
  10. package/lib/base/index.js +1 -1
  11. package/lib/base/index.js.map +1 -1
  12. package/lib/base/ui-extension/index.d.ts +18 -0
  13. package/lib/base/ui-extension/index.d.ts.map +1 -0
  14. package/lib/base/ui-extension/index.js +34 -0
  15. package/lib/base/ui-extension/index.js.map +1 -0
  16. package/lib/base/{ui-extension-registry.d.ts → ui-extension/ui-extension-registry.d.ts} +1 -1
  17. package/lib/base/ui-extension/ui-extension-registry.d.ts.map +1 -0
  18. package/lib/base/ui-extension/ui-extension-registry.js.map +1 -0
  19. package/lib/base/ui-extension/ui-extension.d.ts +39 -0
  20. package/lib/base/ui-extension/ui-extension.d.ts.map +1 -0
  21. package/lib/base/ui-extension/ui-extension.js +120 -0
  22. package/lib/base/ui-extension/ui-extension.js.map +1 -0
  23. package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.d.ts.map +1 -1
  24. package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.js +21 -7
  25. package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.js.map +1 -1
  26. package/lib/features/accessibility/resize-key-tool/resize-key-handler.d.ts +2 -4
  27. package/lib/features/accessibility/resize-key-tool/resize-key-handler.d.ts.map +1 -1
  28. package/lib/features/accessibility/resize-key-tool/resize-key-handler.js +11 -7
  29. package/lib/features/accessibility/resize-key-tool/resize-key-handler.js.map +1 -1
  30. package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts +5 -6
  31. package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts.map +1 -1
  32. package/lib/features/accessibility/view-key-tools/movement-key-tool.js +12 -8
  33. package/lib/features/accessibility/view-key-tools/movement-key-tool.js.map +1 -1
  34. package/lib/features/change-bounds/snap.d.ts +1 -22
  35. package/lib/features/change-bounds/snap.d.ts.map +1 -1
  36. package/lib/features/change-bounds/snap.js +1 -37
  37. package/lib/features/change-bounds/snap.js.map +1 -1
  38. package/lib/features/command-palette/command-palette.d.ts.map +1 -1
  39. package/lib/features/command-palette/command-palette.js +4 -3
  40. package/lib/features/command-palette/command-palette.js.map +1 -1
  41. package/lib/features/debug/debug-bounds-decorator.d.ts +35 -0
  42. package/lib/features/debug/debug-bounds-decorator.d.ts.map +1 -0
  43. package/lib/features/debug/debug-bounds-decorator.js +149 -0
  44. package/lib/features/debug/debug-bounds-decorator.js.map +1 -0
  45. package/lib/features/debug/debug-manager.d.ts +29 -0
  46. package/lib/features/debug/debug-manager.d.ts.map +1 -0
  47. package/lib/features/debug/debug-manager.js +72 -0
  48. package/lib/features/debug/debug-manager.js.map +1 -0
  49. package/lib/features/debug/debug-model.d.ts +37 -0
  50. package/lib/features/debug/debug-model.d.ts.map +1 -0
  51. package/lib/features/debug/debug-model.js +73 -0
  52. package/lib/features/debug/debug-model.js.map +1 -0
  53. package/lib/features/debug/debug-module.d.ts +19 -0
  54. package/lib/features/debug/debug-module.d.ts.map +1 -0
  55. package/lib/features/debug/debug-module.js +31 -0
  56. package/lib/features/debug/debug-module.js.map +1 -0
  57. package/lib/features/debug/index.d.ts +20 -0
  58. package/lib/features/debug/index.d.ts.map +1 -0
  59. package/lib/features/debug/index.js +36 -0
  60. package/lib/features/debug/index.js.map +1 -0
  61. package/lib/features/grid/grid-manager.d.ts +32 -0
  62. package/lib/features/grid/grid-manager.d.ts.map +1 -0
  63. package/lib/features/grid/grid-manager.js +74 -0
  64. package/lib/features/grid/grid-manager.js.map +1 -0
  65. package/lib/features/grid/grid-model.d.ts +37 -0
  66. package/lib/features/grid/grid-model.d.ts.map +1 -0
  67. package/lib/features/grid/grid-model.js +73 -0
  68. package/lib/features/grid/grid-model.js.map +1 -0
  69. package/lib/features/grid/grid-module.d.ts +19 -0
  70. package/lib/features/grid/grid-module.d.ts.map +1 -0
  71. package/lib/features/grid/grid-module.js +32 -0
  72. package/lib/features/grid/grid-module.js.map +1 -0
  73. package/lib/features/grid/grid-snapper.d.ts +45 -0
  74. package/lib/features/grid/grid-snapper.d.ts.map +1 -0
  75. package/lib/features/grid/grid-snapper.js +83 -0
  76. package/lib/features/grid/grid-snapper.js.map +1 -0
  77. package/lib/features/grid/grid.d.ts +18 -0
  78. package/lib/features/grid/grid.d.ts.map +1 -0
  79. package/lib/features/grid/grid.js +3 -0
  80. package/lib/features/grid/grid.js.map +1 -0
  81. package/lib/features/grid/index.d.ts +21 -0
  82. package/lib/features/grid/index.d.ts.map +1 -0
  83. package/lib/features/grid/index.js +37 -0
  84. package/lib/features/grid/index.js.map +1 -0
  85. package/lib/features/helper-lines/helper-line-manager-default.d.ts +4 -1
  86. package/lib/features/helper-lines/helper-line-manager-default.d.ts.map +1 -1
  87. package/lib/features/helper-lines/helper-line-manager-default.js +11 -1
  88. package/lib/features/helper-lines/helper-line-manager-default.js.map +1 -1
  89. package/lib/features/index.d.ts +2 -0
  90. package/lib/features/index.d.ts.map +1 -1
  91. package/lib/features/index.js +2 -0
  92. package/lib/features/index.js.map +1 -1
  93. package/lib/features/label-edit-ui/label-edit-ui.d.ts.map +1 -1
  94. package/lib/features/label-edit-ui/label-edit-ui.js +4 -3
  95. package/lib/features/label-edit-ui/label-edit-ui.js.map +1 -1
  96. package/lib/features/routing/edge-router.d.ts +30 -0
  97. package/lib/features/routing/edge-router.d.ts.map +1 -0
  98. package/lib/features/routing/edge-router.js +116 -0
  99. package/lib/features/routing/edge-router.js.map +1 -0
  100. package/lib/features/routing/index.d.ts +1 -1
  101. package/lib/features/routing/index.d.ts.map +1 -1
  102. package/lib/features/routing/index.js +1 -1
  103. package/lib/features/routing/index.js.map +1 -1
  104. package/lib/features/routing/routing-module.d.ts.map +1 -1
  105. package/lib/features/routing/routing-module.js +4 -4
  106. package/lib/features/routing/routing-module.js.map +1 -1
  107. package/lib/features/tool-palette/tool-palette.d.ts +7 -0
  108. package/lib/features/tool-palette/tool-palette.d.ts.map +1 -1
  109. package/lib/features/tool-palette/tool-palette.js +80 -2
  110. package/lib/features/tool-palette/tool-palette.js.map +1 -1
  111. package/lib/features/viewport/index.d.ts +1 -0
  112. package/lib/features/viewport/index.d.ts.map +1 -1
  113. package/lib/features/viewport/index.js +1 -0
  114. package/lib/features/viewport/index.js.map +1 -1
  115. package/lib/features/viewport/origin-viewport.d.ts +36 -0
  116. package/lib/features/viewport/origin-viewport.d.ts.map +1 -0
  117. package/lib/features/viewport/origin-viewport.js +75 -0
  118. package/lib/features/viewport/origin-viewport.js.map +1 -0
  119. package/lib/features/viewport/viewport-modules.d.ts.map +1 -1
  120. package/lib/features/viewport/viewport-modules.js +4 -2
  121. package/lib/features/viewport/viewport-modules.js.map +1 -1
  122. package/lib/views/base-view-module.d.ts.map +1 -1
  123. package/lib/views/base-view-module.js +3 -2
  124. package/lib/views/base-view-module.js.map +1 -1
  125. package/lib/views/ggraph-view.d.ts +26 -0
  126. package/lib/views/ggraph-view.d.ts.map +1 -0
  127. package/lib/views/ggraph-view.js +71 -0
  128. package/lib/views/ggraph-view.js.map +1 -0
  129. package/lib/views/glsp-projection-view.d.ts +6 -1
  130. package/lib/views/glsp-projection-view.d.ts.map +1 -1
  131. package/lib/views/glsp-projection-view.js +30 -6
  132. package/lib/views/glsp-projection-view.js.map +1 -1
  133. package/lib/views/index.d.ts +1 -0
  134. package/lib/views/index.d.ts.map +1 -1
  135. package/lib/views/index.js +1 -0
  136. package/lib/views/index.js.map +1 -1
  137. package/package.json +3 -3
  138. package/src/base/default.module.ts +1 -1
  139. package/src/base/index.ts +1 -1
  140. package/src/base/ui-extension/index.ts +17 -0
  141. package/src/base/{ui-extension-registry.ts → ui-extension/ui-extension-registry.ts} +1 -1
  142. package/src/base/ui-extension/ui-extension.ts +119 -0
  143. package/src/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.ts +24 -7
  144. package/src/features/accessibility/resize-key-tool/resize-key-handler.ts +9 -9
  145. package/src/features/accessibility/view-key-tools/movement-key-tool.ts +13 -11
  146. package/src/features/change-bounds/{snap.spec.ts → point-position-updater.spec.ts} +1 -12
  147. package/src/features/change-bounds/snap.ts +1 -24
  148. package/src/features/command-palette/command-palette.ts +2 -1
  149. package/src/features/debug/debug-bounds-decorator.tsx +171 -0
  150. package/src/features/debug/debug-manager.ts +56 -0
  151. package/src/features/debug/debug-model.ts +63 -0
  152. package/src/features/debug/debug-module.ts +32 -0
  153. package/src/features/debug/index.ts +19 -0
  154. package/src/features/grid/grid-manager.ts +60 -0
  155. package/src/features/grid/grid-model.ts +62 -0
  156. package/src/features/grid/grid-module.ts +34 -0
  157. package/src/features/grid/grid-snapper.spec.ts +30 -0
  158. package/src/features/grid/grid-snapper.ts +59 -0
  159. package/src/features/grid/grid.ts +18 -0
  160. package/src/features/grid/index.ts +20 -0
  161. package/src/features/helper-lines/helper-line-manager-default.ts +10 -2
  162. package/src/features/index.ts +2 -0
  163. package/src/features/label-edit-ui/label-edit-ui.ts +2 -1
  164. package/src/features/routing/{glsp-manhattan-edge-router.ts → edge-router.ts} +72 -2
  165. package/src/features/routing/index.ts +1 -1
  166. package/src/features/routing/routing-module.ts +3 -5
  167. package/src/features/tool-palette/tool-palette.ts +80 -3
  168. package/src/features/viewport/index.ts +1 -0
  169. package/src/features/viewport/origin-viewport.ts +68 -0
  170. package/src/features/viewport/viewport-modules.ts +4 -2
  171. package/src/views/base-view-module.ts +3 -3
  172. package/src/views/ggraph-view.tsx +56 -0
  173. package/src/views/glsp-projection-view.tsx +34 -7
  174. package/src/views/index.ts +1 -0
  175. package/lib/base/ui-extension-registry.d.ts.map +0 -1
  176. package/lib/base/ui-extension-registry.js.map +0 -1
  177. package/lib/features/routing/glsp-manhattan-edge-router.d.ts.map +0 -1
  178. package/lib/features/routing/glsp-manhattan-edge-router.js +0 -68
  179. package/lib/features/routing/glsp-manhattan-edge-router.js.map +0 -1
  180. /package/lib/base/{ui-extension-registry.js → ui-extension/ui-extension-registry.js} +0 -0
@@ -0,0 +1,20 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2024 Axon Ivy AG and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+ export * from './grid';
17
+ export * from './grid-manager';
18
+ export * from './grid-model';
19
+ export * from './grid-module';
20
+ export * from './grid-snapper';
@@ -19,6 +19,7 @@ import { FeedbackEmitter } from '../../base';
19
19
  import { IFeedbackActionDispatcher } from '../../base/feedback/feedback-action-dispatcher';
20
20
  import { ISelectionListener, SelectionService } from '../../base/selection-service';
21
21
  import { SetBoundsFeedbackAction } from '../bounds/set-bounds-feedback-command';
22
+ import { Grid } from '../grid';
22
23
  import { MoveFinishedEventAction, MoveInitializedEventAction } from '../tools/change-bounds/change-bounds-tool-feedback';
23
24
  import {
24
25
  AlignmentElementFilter,
@@ -47,7 +48,7 @@ export interface IHelperLineOptions {
47
48
  viewportLines?: ViewportLineType[];
48
49
  /**
49
50
  * The minimum difference between two coordinates
50
- * Defaults to 1.
51
+ * Defaults to 1 or zero (perfect match) if the optional grid module is loaded.
51
52
  */
52
53
  alignmentEpsilon?: number;
53
54
  /**
@@ -58,6 +59,7 @@ export interface IHelperLineOptions {
58
59
  /**
59
60
  * The minimum move delta that is necessary for an element to break through a helper line.
60
61
  * Defaults to { x: 1, y: 1 } whereas the x represents the horizontal distance and y represents the vertical distance.
62
+ * If the optional grid module is loaded, defaults to twice the grid size, i.e., two grid moves to break through a helper line.
61
63
  */
62
64
  minimumMoveDelta?: Point;
63
65
 
@@ -84,6 +86,7 @@ export class HelperLineManager implements IActionHandler, ISelectionListener, IH
84
86
  @inject(TYPES.IFeedbackActionDispatcher) protected feedbackDispatcher: IFeedbackActionDispatcher;
85
87
  @inject(SelectionService) protected selectionService: SelectionService;
86
88
  @optional() @inject(TYPES.IHelperLineOptions) protected userOptions?: IHelperLineOptions;
89
+ @optional() @inject(TYPES.Grid) protected grid?: Grid;
87
90
 
88
91
  protected options: Required<IHelperLineOptions>;
89
92
  protected feedback: FeedbackEmitter;
@@ -91,7 +94,12 @@ export class HelperLineManager implements IActionHandler, ISelectionListener, IH
91
94
  @postConstruct()
92
95
  protected init(): void {
93
96
  this.feedback = this.feedbackDispatcher.createEmitter();
94
- this.options = { ...DEFAULT_HELPER_LINE_OPTIONS, ...this.userOptions };
97
+ const dynamicOptions: IHelperLineOptions = {};
98
+ if (this.grid) {
99
+ dynamicOptions.alignmentEpsilon = 0;
100
+ dynamicOptions.minimumMoveDelta = Point.multiplyScalar(this.grid, 2);
101
+ }
102
+ this.options = { ...DEFAULT_HELPER_LINE_OPTIONS, ...dynamicOptions, ...this.userOptions };
95
103
  this.selectionService.onSelectionChanged(change =>
96
104
  this.selectionChanged(change.root, change.selectedElements, change.deselectedElements)
97
105
  );
@@ -19,9 +19,11 @@ export * from './change-bounds';
19
19
  export * from './command-palette';
20
20
  export * from './context-menu';
21
21
  export * from './copy-paste';
22
+ export * from './debug';
22
23
  export * from './decoration';
23
24
  export * from './element-template';
24
25
  export * from './export';
26
+ export * from './grid';
25
27
  export * from './helper-lines';
26
28
  export * from './hints';
27
29
  export * from './hover';
@@ -13,8 +13,9 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { CSS_HIDDEN_EXTENSION_CLASS, CSS_UI_EXTENSION_CLASS, EditLabelUI } from '@eclipse-glsp/sprotty';
16
+ import { EditLabelUI } from '@eclipse-glsp/sprotty';
17
17
  import { injectable } from 'inversify';
18
+ import { CSS_HIDDEN_EXTENSION_CLASS, CSS_UI_EXTENSION_CLASS } from '../../base/ui-extension/ui-extension';
18
19
 
19
20
  @injectable()
20
21
  export class GlspEditLabelUI extends EditLabelUI {
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (c) 2022-2023 EclipseSource and others.
2
+ * Copyright (c) 2024 EclipseSource and others.
3
3
  *
4
4
  * This program and the accompanying materials are made available under the
5
5
  * terms of the Eclipse Public License v. 2.0 which is available at
@@ -14,9 +14,64 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
- import { ManhattanEdgeRouter, ResolvedHandleMove, GRoutableElement, almostEquals } from '@eclipse-glsp/sprotty';
17
+ import {
18
+ AbstractEdgeRouter,
19
+ BezierEdgeRouter,
20
+ GConnectableElement,
21
+ GParentElement,
22
+ GRoutableElement,
23
+ ManhattanEdgeRouter,
24
+ Point,
25
+ PolylineEdgeRouter,
26
+ ResolvedHandleMove,
27
+ almostEquals
28
+ } from '@eclipse-glsp/sprotty';
29
+ import { injectable } from 'inversify';
18
30
 
31
+ @injectable()
32
+ export abstract class GLSPAbstractEdgeRouter extends AbstractEdgeRouter {
33
+ override getTranslatedAnchor(
34
+ connectable: GConnectableElement,
35
+ refPoint: Point,
36
+ refContainer: GParentElement,
37
+ edge: GRoutableElement,
38
+ anchorCorrection?: number | undefined
39
+ ): Point {
40
+ // users may define all kinds of anchors and anchor computers, we want to make sure we return a valid one in any case
41
+ const anchor = super.getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection);
42
+ return Point.isValid(anchor) ? anchor : refPoint;
43
+ }
44
+ }
45
+
46
+ @injectable()
47
+ export class GLSPPolylineEdgeRouter extends PolylineEdgeRouter {
48
+ override getTranslatedAnchor(
49
+ connectable: GConnectableElement,
50
+ refPoint: Point,
51
+ refContainer: GParentElement,
52
+ edge: GRoutableElement,
53
+ anchorCorrection?: number | undefined
54
+ ): Point {
55
+ // users may define all kinds of anchors and anchor computers, we want to make sure we return a valid one in any case
56
+ const anchor = super.getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection);
57
+ return Point.isValid(anchor) ? anchor : refPoint;
58
+ }
59
+ }
60
+
61
+ @injectable()
19
62
  export class GLSPManhattanEdgeRouter extends ManhattanEdgeRouter {
63
+ override getTranslatedAnchor(
64
+ connectable: GConnectableElement,
65
+ refPoint: Point,
66
+ refContainer: GParentElement,
67
+ edge: GRoutableElement,
68
+ anchorCorrection?: number | undefined
69
+ ): Point {
70
+ // users may define all kinds of anchors and anchor computers, we want to make sure we return a valid one in any case
71
+ const anchor = super.getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection);
72
+ return Point.isValid(anchor) ? anchor : refPoint;
73
+ }
74
+
20
75
  protected override applyInnerHandleMoves(edge: GRoutableElement, moves: ResolvedHandleMove[]): void {
21
76
  const route = this.route(edge);
22
77
  const routingPoints = edge.routingPoints;
@@ -57,3 +112,18 @@ export class GLSPManhattanEdgeRouter extends ManhattanEdgeRouter {
57
112
  });
58
113
  }
59
114
  }
115
+
116
+ @injectable()
117
+ export class GLSPBezierEdgeRouter extends BezierEdgeRouter {
118
+ override getTranslatedAnchor(
119
+ connectable: GConnectableElement,
120
+ refPoint: Point,
121
+ refContainer: GParentElement,
122
+ edge: GRoutableElement,
123
+ anchorCorrection?: number | undefined
124
+ ): Point {
125
+ // users may define all kinds of anchors and anchor computers, we want to make sure we return a valid one in any case
126
+ const anchor = super.getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection);
127
+ return Point.isValid(anchor) ? anchor : refPoint;
128
+ }
129
+ }
@@ -13,5 +13,5 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- export * from './glsp-manhattan-edge-router';
16
+ export * from './edge-router';
17
17
  export * from './routing-module';
@@ -17,7 +17,6 @@ import {
17
17
  AddRemoveBezierSegmentCommand,
18
18
  AnchorComputerRegistry,
19
19
  BezierDiamondAnchor,
20
- BezierEdgeRouter,
21
20
  BezierEllipseAnchor,
22
21
  BezierRectangleAnchor,
23
22
  DiamondAnchor,
@@ -27,13 +26,12 @@ import {
27
26
  ManhattanDiamondAnchor,
28
27
  ManhattanEllipticAnchor,
29
28
  ManhattanRectangularAnchor,
30
- PolylineEdgeRouter,
31
29
  RectangleAnchor,
32
30
  TYPES,
33
31
  bindAsService,
34
32
  configureCommand
35
33
  } from '@eclipse-glsp/sprotty';
36
- import { GLSPManhattanEdgeRouter } from './glsp-manhattan-edge-router';
34
+ import { GLSPBezierEdgeRouter, GLSPManhattanEdgeRouter, GLSPPolylineEdgeRouter } from './edge-router';
37
35
 
38
36
  export const routingModule = new FeatureModule((bind, unbind, isBound, rebind) => {
39
37
  const context = { bind, unbind, isBound, rebind };
@@ -45,12 +43,12 @@ export const routingModule = new FeatureModule((bind, unbind, isBound, rebind) =
45
43
  bindAsService(context, TYPES.IAnchorComputer, ManhattanRectangularAnchor);
46
44
  bindAsService(context, TYPES.IAnchorComputer, ManhattanDiamondAnchor);
47
45
 
48
- bindAsService(context, TYPES.IEdgeRouter, PolylineEdgeRouter);
46
+ bindAsService(context, TYPES.IEdgeRouter, GLSPPolylineEdgeRouter);
49
47
  bindAsService(context, TYPES.IAnchorComputer, EllipseAnchor);
50
48
  bindAsService(context, TYPES.IAnchorComputer, RectangleAnchor);
51
49
  bindAsService(context, TYPES.IAnchorComputer, DiamondAnchor);
52
50
 
53
- bindAsService(context, TYPES.IEdgeRouter, BezierEdgeRouter);
51
+ bindAsService(context, TYPES.IEdgeRouter, GLSPBezierEdgeRouter);
54
52
  bindAsService(context, TYPES.IAnchorComputer, BezierEllipseAnchor);
55
53
  bindAsService(context, TYPES.IAnchorComputer, BezierRectangleAnchor);
56
54
  bindAsService(context, TYPES.IAnchorComputer, BezierDiamondAnchor);
@@ -26,23 +26,27 @@ import {
26
26
  SetContextActions,
27
27
  SetModelAction,
28
28
  SetUIExtensionVisibilityAction,
29
+ TYPES,
29
30
  TriggerNodeCreationAction,
30
31
  UpdateModelAction,
31
32
  codiconCSSClasses,
32
33
  matchesKeystroke
33
34
  } from '@eclipse-glsp/sprotty';
34
- import { inject, injectable, postConstruct } from 'inversify';
35
+ import { inject, injectable, optional, postConstruct } from 'inversify';
35
36
  import { GLSPActionDispatcher } from '../../base/action-dispatcher';
36
37
  import { EditorContextService, IEditModeListener } from '../../base/editor-context-service';
37
38
  import { FocusTracker } from '../../base/focus/focus-tracker';
38
39
  import { IDiagramStartup } from '../../base/model/diagram-loader';
39
40
  import { EnableDefaultToolsAction, EnableToolsAction } from '../../base/tool-manager/tool';
41
+ import { DebugManager } from '../debug';
42
+ import { GridManager } from '../grid';
40
43
  import { MouseDeleteTool } from '../tools/deletion/delete-tool';
41
44
  import { MarqueeMouseTool } from '../tools/marquee-selection/marquee-mouse-tool';
45
+ import { OriginViewportAction } from '../viewport';
42
46
 
43
47
  const CLICKED_CSS_CLASS = 'clicked';
44
48
  const SEARCH_ICON_ID = 'search';
45
- const PALETTE_ICON_ID = 'symbol-color';
49
+ const PALETTE_ICON_ID = 'tools';
46
50
  const CHEVRON_DOWN_ICON_ID = 'chevron-right';
47
51
  const PALETTE_HEIGHT = '500px';
48
52
 
@@ -74,6 +78,14 @@ export class ToolPalette extends AbstractUIExtension implements IActionHandler,
74
78
  @inject(FocusTracker)
75
79
  protected focusTracker: FocusTracker;
76
80
 
81
+ @inject(TYPES.IGridManager)
82
+ @optional()
83
+ protected gridManager?: GridManager;
84
+
85
+ @inject(TYPES.IDebugManager)
86
+ @optional()
87
+ protected debugManager?: DebugManager;
88
+
77
89
  protected paletteItems: PaletteItem[];
78
90
  protected paletteItemsCopy: PaletteItem[] = [];
79
91
  protected dynamic = false;
@@ -202,6 +214,19 @@ export class ToolPalette extends AbstractUIExtension implements IActionHandler,
202
214
  const validateActionButton = this.createValidateButton();
203
215
  headerTools.appendChild(validateActionButton);
204
216
 
217
+ const resetViewportButton = this.createResetViewportButton();
218
+ headerTools.appendChild(resetViewportButton);
219
+
220
+ if (this.gridManager) {
221
+ const toggleGridButton = this.createToggleGridButton();
222
+ headerTools.appendChild(toggleGridButton);
223
+ }
224
+
225
+ if (this.debugManager) {
226
+ const toggleDebugButton = this.createToggleDebugButton();
227
+ headerTools.appendChild(toggleDebugButton);
228
+ }
229
+
205
230
  // Create button for Search
206
231
  const searchIcon = this.createSearchButton();
207
232
  headerTools.appendChild(searchIcon);
@@ -250,6 +275,58 @@ export class ToolPalette extends AbstractUIExtension implements IActionHandler,
250
275
  return validateActionButton;
251
276
  }
252
277
 
278
+ protected createResetViewportButton(): HTMLElement {
279
+ const resetViewportButton = createIcon('screen-normal');
280
+ resetViewportButton.title = 'Reset Viewport';
281
+ resetViewportButton.onclick = _event => {
282
+ this.actionDispatcher.dispatch(OriginViewportAction.create());
283
+ resetViewportButton.focus();
284
+ };
285
+ resetViewportButton.ariaLabel = resetViewportButton.title;
286
+ resetViewportButton.tabIndex = 1;
287
+ return resetViewportButton;
288
+ }
289
+
290
+ protected createToggleGridButton(): HTMLElement {
291
+ const toggleGridButton = createIcon('symbol-numeric');
292
+ toggleGridButton.title = 'Toggle Grid';
293
+ toggleGridButton.onclick = () => {
294
+ if (this.gridManager?.isGridVisible) {
295
+ toggleGridButton.classList.remove(CLICKED_CSS_CLASS);
296
+ this.gridManager?.setGridVisible(false);
297
+ } else {
298
+ toggleGridButton.classList.add(CLICKED_CSS_CLASS);
299
+ this.gridManager?.setGridVisible(true);
300
+ }
301
+ };
302
+ if (this.gridManager?.isGridVisible) {
303
+ toggleGridButton.classList.add(CLICKED_CSS_CLASS);
304
+ }
305
+ toggleGridButton.ariaLabel = toggleGridButton.title;
306
+ toggleGridButton.tabIndex = 1;
307
+ return toggleGridButton;
308
+ }
309
+
310
+ protected createToggleDebugButton(): HTMLElement {
311
+ const toggleDebugButton = createIcon('debug');
312
+ toggleDebugButton.title = 'Debug Mode';
313
+ toggleDebugButton.onclick = () => {
314
+ if (this.debugManager?.isDebugEnabled) {
315
+ toggleDebugButton.classList.remove(CLICKED_CSS_CLASS);
316
+ this.debugManager?.setDebugEnabled(false);
317
+ } else {
318
+ toggleDebugButton.classList.add(CLICKED_CSS_CLASS);
319
+ this.debugManager?.setDebugEnabled(true);
320
+ }
321
+ };
322
+ if (this.debugManager?.isDebugEnabled) {
323
+ toggleDebugButton.classList.add(CLICKED_CSS_CLASS);
324
+ }
325
+ toggleDebugButton.ariaLabel = toggleDebugButton.title;
326
+ toggleDebugButton.tabIndex = 1;
327
+ return toggleDebugButton;
328
+ }
329
+
253
330
  protected createSearchButton(): HTMLElement {
254
331
  const searchIcon = createIcon(SEARCH_ICON_ID);
255
332
  searchIcon.onclick = _ev => {
@@ -275,7 +352,7 @@ export class ToolPalette extends AbstractUIExtension implements IActionHandler,
275
352
  searchField.classList.add('search-input');
276
353
  searchField.id = this.containerElement.id + '_search_field';
277
354
  searchField.type = 'text';
278
- searchField.placeholder = ' Search...';
355
+ searchField.placeholder = 'Search...';
279
356
  searchField.style.display = 'none';
280
357
  searchField.onkeyup = () => this.requestFilterUpdate(this.searchField.value);
281
358
  searchField.onkeydown = ev => this.clearOnEscape(ev);
@@ -14,6 +14,7 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
  export * from './glsp-scroll-mouse-listener';
17
+ export * from './origin-viewport';
17
18
  export * from './reposition';
18
19
  export * from './viewport-handler';
19
20
  export * from './viewport-modules';
@@ -0,0 +1,68 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2024 Axon Ivy AG and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+
17
+ import { Action, Bounds, BoundsAwareViewportCommand, GModelRoot, TYPES, Viewport, isViewport, limitViewport } from '@eclipse-glsp/sprotty';
18
+ import { inject, injectable } from 'inversify';
19
+
20
+ export interface OriginViewportAction extends Action {
21
+ kind: typeof OriginViewportAction.KIND;
22
+ animate: boolean;
23
+ }
24
+
25
+ export namespace OriginViewportAction {
26
+ export const KIND = 'originViewport';
27
+
28
+ export function is(object: any): object is OriginViewportAction {
29
+ return Action.hasKind(object, KIND);
30
+ }
31
+
32
+ export function create(options: { animate?: boolean } = {}): OriginViewportAction {
33
+ return {
34
+ kind: KIND,
35
+ animate: true,
36
+ ...options
37
+ };
38
+ }
39
+ }
40
+
41
+ @injectable()
42
+ export class OriginViewportCommand extends BoundsAwareViewportCommand {
43
+ static readonly KIND = OriginViewportAction.KIND;
44
+
45
+ constructor(@inject(TYPES.Action) protected action: OriginViewportAction) {
46
+ super(action.animate);
47
+ }
48
+
49
+ getElementIds(): string[] {
50
+ return [];
51
+ }
52
+
53
+ protected override initialize(model: GModelRoot): void {
54
+ if (!isViewport(model)) {
55
+ return;
56
+ }
57
+ this.oldViewport = { scroll: model.scroll, zoom: model.zoom };
58
+ const newViewport = this.getNewViewport(Bounds.EMPTY, model);
59
+ if (newViewport) {
60
+ const { zoomLimits, horizontalScrollLimits, verticalScrollLimits } = this.viewerOptions;
61
+ this.newViewport = limitViewport(newViewport, model.canvasBounds, horizontalScrollLimits, verticalScrollLimits, zoomLimits);
62
+ }
63
+ }
64
+
65
+ getNewViewport(_bounds: Bounds, _model: GModelRoot): Viewport | undefined {
66
+ return { zoom: 1, scroll: { x: 0, y: 0 } };
67
+ }
68
+ }
@@ -27,10 +27,11 @@ import {
27
27
  ZoomMouseListener
28
28
  } from '@eclipse-glsp/sprotty';
29
29
  import { EnableDefaultToolsAction, EnableToolsAction } from '../../base/tool-manager/tool';
30
+ import { FocusDomAction } from '../accessibility/actions';
30
31
  import { GLSPScrollMouseListener } from './glsp-scroll-mouse-listener';
31
- import { RestoreViewportHandler } from './viewport-handler';
32
+ import { OriginViewportCommand } from './origin-viewport';
32
33
  import { RepositionCommand } from './reposition';
33
- import { FocusDomAction } from '../accessibility/actions';
34
+ import { RestoreViewportHandler } from './viewport-handler';
34
35
 
35
36
  export const viewportModule = new FeatureModule((bind, _unbind, isBound) => {
36
37
  const context = { bind, isBound };
@@ -39,6 +40,7 @@ export const viewportModule = new FeatureModule((bind, _unbind, isBound) => {
39
40
  configureCommand(context, GetViewportCommand);
40
41
  configureCommand(context, SetViewportCommand);
41
42
  configureCommand(context, RepositionCommand);
43
+ configureCommand(context, OriginViewportCommand);
42
44
 
43
45
  bindAsService(context, TYPES.MouseListener, ZoomMouseListener);
44
46
  bindAsService(context, TYPES.MouseListener, GLSPScrollMouseListener);
@@ -27,9 +27,9 @@ import {
27
27
  GCompartment,
28
28
  GCompartmentView,
29
29
  GForeignObjectElement,
30
- GGraphView,
31
30
  GHtmlRoot,
32
31
  GLabel,
32
+ GLabelView,
33
33
  GNode,
34
34
  GPort,
35
35
  GPreRenderedElement,
@@ -41,17 +41,17 @@ import {
41
41
  PreRenderedView,
42
42
  RectangularNode,
43
43
  RectangularNodeView,
44
- GLabelView,
45
44
  SvgViewportView,
46
45
  configureModelElement,
47
46
  moveFeature,
48
47
  selectFeature
49
48
  } from '@eclipse-glsp/sprotty';
50
49
  import { GIssueMarker } from '../features/validation/issue-marker';
50
+ import { GEdge, GGraph } from '../model';
51
51
  import { GEdgeView } from './gedge-view';
52
+ import { GGraphView } from './ggraph-view';
52
53
  import { GIssueMarkerView } from './issue-marker-view';
53
54
  import { RoundedCornerNodeView } from './rounded-corner-view';
54
- import { GEdge, GGraph } from '../model';
55
55
 
56
56
  export const baseViewModule = new FeatureModule((bind, unbind, isBound, rebind) => {
57
57
  const context = { bind, unbind, isBound, rebind };
@@ -0,0 +1,56 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2024 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
+ import { Bounds, Dimension, Point, RenderingContext, SGraphImpl, SGraphView, TYPES, Writable } from '@eclipse-glsp/sprotty';
17
+ import { inject, injectable, optional } from 'inversify';
18
+ import { VNode } from 'snabbdom';
19
+ import { GridManager, GridStyle } from '../features';
20
+
21
+ @injectable()
22
+ export class GGraphView extends SGraphView {
23
+ @inject(TYPES.IGridManager) @optional() protected gridManager?: GridManager;
24
+
25
+ override render(model: Readonly<SGraphImpl>, context: RenderingContext): VNode {
26
+ const graph = super.render(model, context);
27
+ if (graph.data) {
28
+ graph.data.style = { ...graph.data.style, ...this.getGridStyle(model, context) };
29
+ }
30
+ return graph;
31
+ }
32
+
33
+ protected getGridStyle(model: Readonly<SGraphImpl>, context: RenderingContext): GridStyle {
34
+ if (!this.gridManager?.isGridVisible) {
35
+ return {};
36
+ }
37
+ const bounds = this.getBackgroundBounds(model, context, this.gridManager);
38
+ return {
39
+ backgroundPosition: `${bounds.x}px ${bounds.y}px`,
40
+ backgroundSize: `${bounds.width}px ${bounds.height}px`,
41
+ // we do not set the background image directly in the style object, because we want to toggle it on and off via CSS
42
+ '--grid-background-image': this.getBackgroundImage(model, context, this.gridManager)
43
+ };
44
+ }
45
+
46
+ protected getBackgroundBounds(viewport: Readonly<SGraphImpl>, context: RenderingContext, gridManager: GridManager): Writable<Bounds> {
47
+ const position = Point.multiplyScalar(Point.subtract(gridManager.grid, viewport.scroll), viewport.zoom);
48
+ const size = Dimension.fromPoint(Point.multiplyScalar(gridManager.grid, viewport.zoom));
49
+ return { ...position, ...size };
50
+ }
51
+
52
+ protected getBackgroundImage(model: Readonly<SGraphImpl>, context: RenderingContext, gridManager: GridManager): string {
53
+ // eslint-disable-next-line max-len
54
+ return `url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${gridManager.grid.x} ${gridManager.grid.y}"><rect width="${gridManager.grid.x}" height="${gridManager.grid.y}" x="0" y="0" fill="none" stroke="black" stroke-width="1" stroke-opacity="0.10" /></svg>')`;
55
+ }
56
+ }
@@ -16,19 +16,25 @@
16
16
 
17
17
  import {
18
18
  Bounds,
19
+ Dimension,
19
20
  EdgeRouterRegistry,
20
21
  GViewportRootElement,
21
22
  IViewArgs,
23
+ Point,
22
24
  ProjectedViewportView,
23
25
  ProjectionParams,
24
26
  RenderingContext,
27
+ SGraphImpl,
28
+ TYPES,
25
29
  ViewProjection,
30
+ Writable,
26
31
  html,
27
32
  setAttr,
28
33
  setClass
29
34
  } from '@eclipse-glsp/sprotty';
30
- import { inject, injectable } from 'inversify';
35
+ import { inject, injectable, optional } from 'inversify';
31
36
  import { VNode, VNodeStyle, h } from 'snabbdom';
37
+ import { GridManager, GridStyle } from '../features';
32
38
 
33
39
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
34
40
  const JSX = { createElement: html };
@@ -39,15 +45,12 @@ const JSX = { createElement: html };
39
45
  @injectable()
40
46
  export class GLSPProjectionView extends ProjectedViewportView {
41
47
  @inject(EdgeRouterRegistry) edgeRouterRegistry: EdgeRouterRegistry;
48
+ @inject(TYPES.IGridManager) @optional() protected gridManager?: GridManager;
42
49
 
43
50
  override render(model: Readonly<GViewportRootElement>, context: RenderingContext, args?: IViewArgs): VNode {
44
- const svgElem = this.renderSvg(model, context, args);
45
- if (svgElem.data) {
46
- svgElem.data!.class = { 'sprotty-graph': true };
47
- }
48
51
  const rootNode: VNode = (
49
52
  <div class-sprotty-graph={false} style={{ width: '100%', height: '100%' }}>
50
- {svgElem}
53
+ {this.renderSvg(model, context, args)}
51
54
  {this.renderProjections(model, context, args)}
52
55
  </div>
53
56
  );
@@ -63,12 +66,36 @@ export class GLSPProjectionView extends ProjectedViewportView {
63
66
  const ns = 'http://www.w3.org/2000/svg';
64
67
  const svg = h(
65
68
  'svg',
66
- { ns, style: { height: '100%' } },
69
+ { ns, style: { height: '100%', ...this.getGridStyle(model, context) }, class: { 'sprotty-graph': true } },
67
70
  h('g', { ns, attrs: { transform } }, context.renderChildren(model, { edgeRouting }))
68
71
  );
69
72
  return svg;
70
73
  }
71
74
 
75
+ protected getGridStyle(model: Readonly<SGraphImpl>, context: RenderingContext): GridStyle {
76
+ if (!this.gridManager?.isGridVisible) {
77
+ return {};
78
+ }
79
+ const bounds = this.getBackgroundBounds(model, context, this.gridManager);
80
+ return {
81
+ backgroundPosition: `${bounds.x}px ${bounds.y}px`,
82
+ backgroundSize: `${bounds.width}px ${bounds.height}px`,
83
+ // we do not set the background image directly in the style object, because we want to toggle it on and off via CSS
84
+ '--grid-background-image': this.getBackgroundImage(model, context, this.gridManager)
85
+ };
86
+ }
87
+
88
+ protected getBackgroundBounds(viewport: Readonly<SGraphImpl>, context: RenderingContext, gridManager: GridManager): Writable<Bounds> {
89
+ const position = Point.multiplyScalar(Point.subtract(gridManager.grid, viewport.scroll), viewport.zoom);
90
+ const size = Dimension.fromPoint(Point.multiplyScalar(gridManager.grid, viewport.zoom));
91
+ return { ...position, ...size };
92
+ }
93
+
94
+ protected getBackgroundImage(model: Readonly<SGraphImpl>, context: RenderingContext, gridManager: GridManager): string {
95
+ // eslint-disable-next-line max-len
96
+ return `url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${gridManager.grid.x} ${gridManager.grid.y}"><rect width="${gridManager.grid.x}" height="${gridManager.grid.y}" x="0" y="0" fill="none" stroke="black" stroke-width="1" stroke-opacity="0.10" /></svg>')`;
97
+ }
98
+
72
99
  protected override renderProjectionBar(
73
100
  projections: ViewProjection[],
74
101
  model: Readonly<GViewportRootElement>,
@@ -16,6 +16,7 @@
16
16
  export * from './base-view-module';
17
17
  export * from './compartments';
18
18
  export * from './gedge-view';
19
+ export * from './ggraph-view';
19
20
  export * from './glsp-projection-view';
20
21
  export * from './issue-marker-view';
21
22
  export * from './rounded-corner';
@@ -1 +0,0 @@
1
- {"version":3,"file":"ui-extension-registry.d.ts","sourceRoot":"","sources":["../../src/base/ui-extension-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAS,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE7G,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,qBACa,uBAAwB,SAAQ,mBAAoB,YAAW,eAAe;IAEvF,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC;gBAEb,UAAU,GAAE,YAAY,EAAO;IAIvD,cAAc,IAAI,YAAY,CAAC,IAAI,CAAC;CAGvC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ui-extension-registry.js","sourceRoot":"","sources":["../../src/base/ui-extension-registry.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;;;;;;;AAElF,mDAA6G;AAC7G,yCAAyD;AAIlD,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,6BAAmB;IAI5D,YAAwB,aAA6B,EAAE;QACnD,KAAK,CAAC,UAAU,CAAC,CAAC;IACtB,CAAC;IAED,cAAc;QACV,IAAI,CAAC,YAAY,CAAC,MAAM,CAAe,eAAK,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;IAC9H,CAAC;CACJ,CAAA;AAXY,0DAAuB;AAEtB;IADT,IAAA,kBAAM,EAAC,sBAAY,CAAC;;6DACgB;kCAF5B,uBAAuB;IADnC,IAAA,sBAAU,GAAE;IAKI,WAAA,IAAA,oBAAQ,GAAE,CAAA;;GAJd,uBAAuB,CAWnC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"glsp-manhattan-edge-router.d.ts","sourceRoot":"","sources":["../../../src/features/routing/glsp-manhattan-edge-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,gBAAgB,EAAgB,MAAM,uBAAuB,CAAC;AAEhH,qBAAa,uBAAwB,SAAQ,mBAAmB;cACzC,qBAAqB,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,kBAAkB,EAAE,GAAG,IAAI;CAuCtG"}