@eclipse-glsp/client 1.1.0-next.c8b4f65.194 → 1.1.0-next.ee71b2a.218

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 (169) hide show
  1. package/README.md +1 -1
  2. package/css/glsp-sprotty.css +18 -18
  3. package/lib/base/action-dispatcher.js.map +1 -1
  4. package/lib/base/command-stack.js +2 -2
  5. package/lib/base/command-stack.js.map +1 -1
  6. package/lib/base/container-modules.d.ts +32 -2
  7. package/lib/base/container-modules.d.ts.map +1 -1
  8. package/lib/base/container-modules.js +78 -39
  9. package/lib/base/container-modules.js.map +1 -1
  10. package/lib/base/editor-context-service.d.ts +1 -1
  11. package/lib/base/editor-context-service.d.ts.map +1 -1
  12. package/lib/base/editor-context-service.js.map +1 -1
  13. package/lib/base/focus-tracker.js.map +1 -1
  14. package/lib/base/model/model-registry.js.map +1 -1
  15. package/lib/base/model/update-model-command.js.map +1 -1
  16. package/lib/base/model-initialization-constraint.js.map +1 -1
  17. package/lib/base/selection-clearing-mouse-listener.js +1 -1
  18. package/lib/base/selection-clearing-mouse-listener.js.map +1 -1
  19. package/lib/base/tool-manager/glsp-tool-manager.js.map +1 -1
  20. package/lib/base/view/view-registry.js.map +1 -1
  21. package/lib/features/bounds/di.config.d.ts +20 -0
  22. package/lib/features/bounds/di.config.d.ts.map +1 -0
  23. package/lib/features/bounds/di.config.js +36 -0
  24. package/lib/features/bounds/di.config.js.map +1 -0
  25. package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts +34 -0
  26. package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts.map +1 -0
  27. package/lib/features/bounds/glsp-hidden-bounds-updater.js +98 -0
  28. package/lib/features/bounds/glsp-hidden-bounds-updater.js.map +1 -0
  29. package/lib/features/change-bounds/movement-restrictor.js.map +1 -1
  30. package/lib/features/change-bounds/snap.js.map +1 -1
  31. package/lib/features/command-palette/command-palette-tool.js +1 -1
  32. package/lib/features/command-palette/command-palette-tool.js.map +1 -1
  33. package/lib/features/command-palette/server-command-palette-provider.js.map +1 -1
  34. package/lib/features/context-menu/delete-element-context-menu.js.map +1 -1
  35. package/lib/features/context-menu/selection-service-aware-context-menu-mouse-listener.js.map +1 -1
  36. package/lib/features/context-menu/server-context-menu-provider.js.map +1 -1
  37. package/lib/features/copy-paste/copy-paste-context-menu.js.map +1 -1
  38. package/lib/features/copy-paste/copy-paste-handler.d.ts +2 -2
  39. package/lib/features/copy-paste/copy-paste-handler.d.ts.map +1 -1
  40. package/lib/features/copy-paste/copy-paste-handler.js +2 -3
  41. package/lib/features/copy-paste/copy-paste-handler.js.map +1 -1
  42. package/lib/features/decoration/decoration-placer.js.map +1 -1
  43. package/lib/features/edit-label/edit-label-tool.js.map +1 -1
  44. package/lib/features/edit-label/edit-label-validator.js.map +1 -1
  45. package/lib/features/export/di.config.d.ts +19 -0
  46. package/lib/features/export/di.config.d.ts.map +1 -0
  47. package/lib/features/export/di.config.js +29 -0
  48. package/lib/features/export/di.config.js.map +1 -0
  49. package/lib/features/export/glsp-svg-exporter.js.map +1 -1
  50. package/lib/features/hints/type-hints.js.map +1 -1
  51. package/lib/features/hover/hover.d.ts.map +1 -1
  52. package/lib/features/hover/hover.js +2 -1
  53. package/lib/features/hover/hover.js.map +1 -1
  54. package/lib/features/layout/freeform-layout.js.map +1 -1
  55. package/lib/features/layout/hbox-layout.js.map +1 -1
  56. package/lib/features/layout/layout-elements-action.d.ts +4 -4
  57. package/lib/features/layout/layout-elements-action.d.ts.map +1 -1
  58. package/lib/features/layout/layout-elements-action.js +2 -2
  59. package/lib/features/layout/layout-elements-action.js.map +1 -1
  60. package/lib/features/layout/layouter.js.map +1 -1
  61. package/lib/features/layout/tests/layouter-test-util.d.ts +1 -1
  62. package/lib/features/layout/tests/layouter-test-util.js +2 -2
  63. package/lib/features/layout/tests/layouter-test-util.js.map +1 -1
  64. package/lib/features/layout/vbox-layout.js.map +1 -1
  65. package/lib/features/mouse-tool/mouse-tool.d.ts +1 -1
  66. package/lib/features/mouse-tool/mouse-tool.d.ts.map +1 -1
  67. package/lib/features/mouse-tool/mouse-tool.js.map +1 -1
  68. package/lib/features/navigation/navigation-action-handler.js.map +1 -1
  69. package/lib/features/navigation/navigation-target-resolver.js.map +1 -1
  70. package/lib/features/save/model.d.ts +1 -1
  71. package/lib/features/select/select-feedback-action.js.map +1 -1
  72. package/lib/features/select/select-mouse-listener.d.ts +1 -1
  73. package/lib/features/select/select-mouse-listener.d.ts.map +1 -1
  74. package/lib/features/select/select-mouse-listener.js +2 -1
  75. package/lib/features/select/select-mouse-listener.js.map +1 -1
  76. package/lib/features/select/selection-service.js.map +1 -1
  77. package/lib/features/source-model-watcher/di.config.js +1 -1
  78. package/lib/features/source-model-watcher/source-model-changed-action-handler.js.map +1 -1
  79. package/lib/features/tool-feedback/change-bounds-tool-feedback.d.ts +2 -1
  80. package/lib/features/tool-feedback/change-bounds-tool-feedback.d.ts.map +1 -1
  81. package/lib/features/tool-feedback/change-bounds-tool-feedback.js +2 -1
  82. package/lib/features/tool-feedback/change-bounds-tool-feedback.js.map +1 -1
  83. package/lib/features/tool-feedback/creation-tool-feedback.d.ts.map +1 -1
  84. package/lib/features/tool-feedback/creation-tool-feedback.js +3 -2
  85. package/lib/features/tool-feedback/creation-tool-feedback.js.map +1 -1
  86. package/lib/features/tool-feedback/css-feedback.js.map +1 -1
  87. package/lib/features/tool-feedback/edge-edit-tool-feedback.d.ts.map +1 -1
  88. package/lib/features/tool-feedback/edge-edit-tool-feedback.js +4 -3
  89. package/lib/features/tool-feedback/edge-edit-tool-feedback.js.map +1 -1
  90. package/lib/features/tool-feedback/feedback-action-dispatcher.js.map +1 -1
  91. package/lib/features/tool-feedback/marquee-tool-feedback.js.map +1 -1
  92. package/lib/features/tool-feedback/view.js.map +1 -1
  93. package/lib/features/tool-palette/tool-palette.js.map +1 -1
  94. package/lib/features/tools/base-glsp-tool.js.map +1 -1
  95. package/lib/features/tools/change-bounds-tool.js.map +1 -1
  96. package/lib/features/tools/delete-tool.js.map +1 -1
  97. package/lib/features/tools/di.config.js +4 -4
  98. package/lib/features/tools/di.config.js.map +1 -1
  99. package/lib/features/tools/edge-creation-tool.js.map +1 -1
  100. package/lib/features/tools/edge-edit-tool.js.map +1 -1
  101. package/lib/features/tools/enable-default-tools-on-focus-loss.js.map +1 -1
  102. package/lib/features/tools/glsp-manhattan-edge-router.d.ts +20 -0
  103. package/lib/features/tools/glsp-manhattan-edge-router.d.ts.map +1 -0
  104. package/lib/features/tools/glsp-manhattan-edge-router.js +69 -0
  105. package/lib/features/tools/glsp-manhattan-edge-router.js.map +1 -0
  106. package/lib/features/tools/marquee-mouse-tool.js.map +1 -1
  107. package/lib/features/tools/marquee-tool.js.map +1 -1
  108. package/lib/features/tools/node-creation-tool.js.map +1 -1
  109. package/lib/features/tools/view.js.map +1 -1
  110. package/lib/features/validation/issue-marker.d.ts +1 -1
  111. package/lib/features/validation/issue-marker.js +1 -1
  112. package/lib/features/validation/marker-navigator.d.ts +1 -1
  113. package/lib/features/validation/marker-navigator.d.ts.map +1 -1
  114. package/lib/features/validation/marker-navigator.js.map +1 -1
  115. package/lib/features/validation/validate.js.map +1 -1
  116. package/lib/features/viewport/glsp-scroll-mouse-listener.js.map +1 -1
  117. package/lib/lib/model.d.ts +7 -3
  118. package/lib/lib/model.d.ts.map +1 -1
  119. package/lib/lib/model.js +48 -1
  120. package/lib/lib/model.js.map +1 -1
  121. package/lib/model-source/glsp-diagram-server.js.map +1 -1
  122. package/lib/sprotty-reexport.d.ts +5 -5
  123. package/lib/sprotty-reexport.d.ts.map +1 -1
  124. package/lib/sprotty-reexport.js +16 -7
  125. package/lib/sprotty-reexport.js.map +1 -1
  126. package/lib/utils/html-utils.d.ts +1 -1
  127. package/lib/utils/html-utils.js +1 -1
  128. package/lib/utils/smodel-util.d.ts +27 -6
  129. package/lib/utils/smodel-util.d.ts.map +1 -1
  130. package/lib/utils/smodel-util.js +40 -7
  131. package/lib/utils/smodel-util.js.map +1 -1
  132. package/lib/views/base-view-module.js +1 -1
  133. package/lib/views/compartments.js.map +1 -1
  134. package/lib/views/glsp-edge-view.js.map +1 -1
  135. package/lib/views/glsp-projection-view.d.ts +1 -1
  136. package/lib/views/glsp-projection-view.js +1 -1
  137. package/lib/views/glsp-projection-view.js.map +1 -1
  138. package/lib/views/index.d.ts +1 -1
  139. package/lib/views/index.js +1 -1
  140. package/lib/views/issue-marker-view.js.map +1 -1
  141. package/lib/views/rounded-corner-view.js.map +1 -1
  142. package/package.json +23 -24
  143. package/src/base/command-stack.ts +3 -3
  144. package/src/base/container-modules.ts +53 -9
  145. package/src/base/selection-clearing-mouse-listener.ts +1 -1
  146. package/src/features/bounds/di.config.ts +39 -0
  147. package/src/features/bounds/glsp-hidden-bounds-updater.ts +88 -0
  148. package/src/features/command-palette/command-palette-tool.ts +1 -1
  149. package/src/features/copy-paste/copy-paste-handler.ts +4 -8
  150. package/src/features/export/di.config.ts +28 -0
  151. package/src/features/hover/hover.ts +2 -1
  152. package/src/features/layout/layout-elements-action.ts +2 -1
  153. package/src/features/layout/tests/layouter-test-util.ts +3 -3
  154. package/src/features/save/model.ts +1 -1
  155. package/src/features/select/select-mouse-listener.ts +2 -2
  156. package/src/features/source-model-watcher/di.config.ts +1 -1
  157. package/src/features/tool-feedback/change-bounds-tool-feedback.ts +1 -1
  158. package/src/features/tool-feedback/creation-tool-feedback.ts +1 -1
  159. package/src/features/tool-feedback/edge-edit-tool-feedback.ts +1 -1
  160. package/src/features/tools/di.config.ts +5 -5
  161. package/src/features/tools/glsp-manhattan-edge-router.ts +57 -0
  162. package/src/features/validation/issue-marker.ts +1 -1
  163. package/src/lib/model.ts +35 -3
  164. package/src/sprotty-reexport.ts +11 -5
  165. package/src/utils/html-utils.ts +1 -1
  166. package/src/utils/smodel-util.ts +48 -11
  167. package/src/views/base-view-module.ts +1 -1
  168. package/src/views/glsp-projection-view.tsx +1 -1
  169. package/src/views/index.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (c) 2019-2022 EclipseSource and others.
2
+ * Copyright (c) 2019-2023 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
@@ -15,16 +15,16 @@
15
15
  ********************************************************************************/
16
16
  import { TriggerEdgeCreationAction, TriggerNodeCreationAction } from '@eclipse-glsp/protocol';
17
17
  import { ContainerModule, interfaces } from 'inversify';
18
- import { configureActionHandler, configureModelElement } from 'sprotty';
18
+ import { configureActionHandler, configureModelElement, ManhattanEdgeRouter } from 'sprotty';
19
19
  import { FocusStateChangedAction } from '../../base/actions/focus-change-action';
20
20
  import { TYPES } from '../../base/types';
21
- import { GLSPSvgExporter } from '../export/glsp-svg-exporter';
22
21
  import { MARQUEE } from '../tool-feedback/marquee-tool-feedback';
23
22
  import { ChangeBoundsTool } from './change-bounds-tool';
24
23
  import { DelKeyDeleteTool, MouseDeleteTool } from './delete-tool';
25
24
  import { EdgeCreationTool } from './edge-creation-tool';
26
25
  import { EdgeEditTool } from './edge-edit-tool';
27
26
  import { EnableDefaultToolsOnFocusLossHandler } from './enable-default-tools-on-focus-loss';
27
+ import { GSLPManhattanEdgeRouter } from './glsp-manhattan-edge-router';
28
28
  import { MarqueeMouseTool } from './marquee-mouse-tool';
29
29
  import { MarqueeTool } from './marquee-tool';
30
30
  import { MarqueeNode } from './model';
@@ -52,8 +52,8 @@ export const toolsModule = new ContainerModule((bind, _unbind, isBound, rebind)
52
52
  configureActionHandler({ bind, isBound }, TriggerNodeCreationAction.KIND, NodeCreationTool);
53
53
  configureActionHandler({ bind, isBound }, TriggerEdgeCreationAction.KIND, EdgeCreationTool);
54
54
 
55
- bind(GLSPSvgExporter).toSelf().inSingletonScope();
56
- rebind(TYPES.SvgExporter).toService(GLSPSvgExporter);
55
+ bind(GSLPManhattanEdgeRouter).toSelf().inSingletonScope();
56
+ rebind(ManhattanEdgeRouter).toService(GSLPManhattanEdgeRouter);
57
57
  });
58
58
 
59
59
  export function configureMarqueeTool(context: { bind: interfaces.Bind; isBound: interfaces.IsBound }): void {
@@ -0,0 +1,57 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2022 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 { almostEquals } from '@eclipse-glsp/protocol';
18
+ import { ManhattanEdgeRouter, ResolvedHandleMove, SRoutableElement } from 'sprotty';
19
+
20
+ export class GSLPManhattanEdgeRouter extends ManhattanEdgeRouter {
21
+ protected override applyInnerHandleMoves(edge: SRoutableElement, moves: ResolvedHandleMove[]): void {
22
+ const route = this.route(edge);
23
+ const routingPoints = edge.routingPoints;
24
+ const minimalPointDistance = this.getOptions(edge).minimalPointDistance;
25
+ moves.forEach(move => {
26
+ const handle = move.handle;
27
+ const index = handle.pointIndex;
28
+ const correctedX = this.correctX(routingPoints, index, move.toPosition.x, minimalPointDistance);
29
+ const correctedY = this.correctY(routingPoints, index, move.toPosition.y, minimalPointDistance);
30
+ switch (handle.kind) {
31
+ case 'manhattan-50%':
32
+ if (index < 0) {
33
+ if (routingPoints.length === 0) {
34
+ routingPoints.push({ x: correctedX, y: correctedY });
35
+ move.handle.pointIndex = 0;
36
+ }
37
+ else if (almostEquals(route[0].x, route[1].x)) { this.alignX(routingPoints, 0, correctedX); }
38
+ else { this.alignY(routingPoints, 0, correctedY); }
39
+ } else if (index < routingPoints.length - 1) {
40
+ if (almostEquals(routingPoints[index].x, routingPoints[index + 1].x)) {
41
+ this.alignX(routingPoints, index, correctedX);
42
+ this.alignX(routingPoints, index + 1, correctedX);
43
+ } else {
44
+ this.alignY(routingPoints, index, correctedY);
45
+ this.alignY(routingPoints, index + 1, correctedY);
46
+ }
47
+ } else {
48
+ if (almostEquals(route[route.length - 2].x, route[route.length - 1].x)) {
49
+ this.alignX(routingPoints, routingPoints.length - 1, correctedX);
50
+ }
51
+ else { this.alignY(routingPoints, routingPoints.length - 1, correctedY); }
52
+ }
53
+ break;
54
+ }
55
+ });
56
+ }
57
+ }
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (c) 2019-2021 EclipseSource and others.
2
+ * Copyright (c) 2019-2022 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
package/src/lib/model.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (c) 2019-2022 EclipseSource and others.
2
+ * Copyright (c) 2019-2023 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
@@ -13,8 +13,8 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { SModelElementSchema } from '@eclipse-glsp/protocol';
17
- import { exportFeature, SGraph, SModelElement, viewportFeature } from 'sprotty';
16
+ import { Bounds, isBounds, Point, SModelElementSchema } from '@eclipse-glsp/protocol';
17
+ import { exportFeature, getRouteBounds, SEdge, SGraph, SModelElement, viewportFeature } from 'sprotty';
18
18
  import { Containable, containerFeature } from '../features/hints/model';
19
19
  import { Saveable, saveFeature } from '../features/save/model';
20
20
 
@@ -25,3 +25,35 @@ export class GLSPGraph extends SGraph implements Saveable, Containable {
25
25
  return true;
26
26
  }
27
27
  }
28
+
29
+ export class GEdge extends SEdge {
30
+ override localToParent(point: Point | Bounds): Bounds {
31
+ const bounds = getRouteBounds(this.routingPoints);
32
+ const result = {
33
+ x: point.x + bounds.x,
34
+ y: point.y + bounds.y,
35
+ width: -1,
36
+ height: -1
37
+ };
38
+ if (isBounds(point)) {
39
+ result.width = point.width;
40
+ result.height = point.height;
41
+ }
42
+ return result;
43
+ }
44
+
45
+ override parentToLocal(point: Point | Bounds): Bounds {
46
+ const bounds = getRouteBounds(this.routingPoints);
47
+ const result = {
48
+ x: point.x - bounds.x,
49
+ y: point.y - bounds.y,
50
+ width: -1,
51
+ height: -1
52
+ };
53
+ if (isBounds(point)) {
54
+ result.width = point.width;
55
+ result.height = point.height;
56
+ }
57
+ return result;
58
+ }
59
+ }
@@ -22,7 +22,10 @@
22
22
 
23
23
  export * from '@eclipse-glsp/protocol';
24
24
  // sprotty-protocol
25
- export { CollapseExpandAction, CollapseExpandAllAction, ElementAndAlignment, SetBoundsAction } from 'sprotty-protocol/lib/actions';
25
+ export {
26
+ BringToFrontAction, CollapseExpandAction, CollapseExpandAllAction,
27
+ ElementAndAlignment, HoverFeedbackAction, MoveAction, SetBoundsAction
28
+ } from 'sprotty-protocol/lib/actions';
26
29
  export { Viewport } from 'sprotty-protocol/lib/model';
27
30
  // ------------------ Base ------------------
28
31
  export * from 'sprotty/lib/base/actions/action-dispatcher';
@@ -144,7 +147,6 @@ export * from 'sprotty/lib/features/fade/model';
144
147
  export {
145
148
  AbstractHoverMouseListener,
146
149
  ClosePopupActionHandler,
147
- HoverFeedbackAction,
148
150
  HoverFeedbackCommand,
149
151
  HoverKeyListener,
150
152
  HoverMouseListener,
@@ -154,7 +156,10 @@ export {
154
156
  } from 'sprotty/lib/features/hover/hover';
155
157
  export * from 'sprotty/lib/features/hover/model';
156
158
  export * from 'sprotty/lib/features/move/model';
157
- export * from 'sprotty/lib/features/move/move';
159
+ export {
160
+ ElementMove, LocationPostprocessor, MorphEdgesAnimation, MoveAnimation,
161
+ MoveCommand, MoveMouseListener, ResolvedElementMove, ResolvedHandleMove
162
+ } from 'sprotty/lib/features/move/move';
158
163
  export * from 'sprotty/lib/features/move/snap';
159
164
  export * from 'sprotty/lib/features/nameable/model';
160
165
  export * from 'sprotty/lib/features/open/model';
@@ -182,7 +187,7 @@ export {
182
187
  SelectKeyboardListener,
183
188
  SelectMouseListener
184
189
  } from 'sprotty/lib/features/select/select';
185
- export * from 'sprotty/lib/features/undo-redo/undo-redo';
190
+ export { UndoRedoKeyListener } from 'sprotty/lib/features/undo-redo/undo-redo';
186
191
  export * from 'sprotty/lib/features/update/model-matching';
187
192
  export { UpdateAnimationData, UpdateModelCommand } from 'sprotty/lib/features/update/update-model';
188
193
  export {
@@ -202,7 +207,7 @@ export {
202
207
  } from 'sprotty/lib/features/viewport/viewport';
203
208
  export * from 'sprotty/lib/features/viewport/viewport-root';
204
209
  export * from 'sprotty/lib/features/viewport/zoom';
205
- export * from 'sprotty/lib/features/zorder/zorder';
210
+ export { BringToFrontCommand, ZOrderElement } from 'sprotty/lib/features/zorder/zorder';
206
211
  export { SCompartment, SEdge, SGraph, SGraphIndex, SLabel, SNode, SPort } from 'sprotty/lib/graph/sgraph';
207
212
  // ------------------ Graph ------------------
208
213
  export * from 'sprotty/lib/graph/sgraph-factory';
@@ -286,3 +291,4 @@ import viewportModule from 'sprotty/lib/features/viewport/di.config';
286
291
  import zorderModule from 'sprotty/lib/features/zorder/di.config';
287
292
  import graphModule from 'sprotty/lib/graph/di.config';
288
293
  import modelSourceModule from 'sprotty/lib/model-source/di.config';
294
+
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (c) 2019 EclipseSource and others.
2
+ * Copyright (c) 2019-2020 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
@@ -13,15 +13,18 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { distinctAdd, ElementAndBounds, ElementAndRoutingPoints, remove, SModelElementSchema, TypeGuard } from '@eclipse-glsp/protocol';
16
+ import {
17
+ distinctAdd, ElementAndBounds, ElementAndRoutingPoints, Point, remove, SModelElementSchema,
18
+ TypeGuard
19
+ } from '@eclipse-glsp/protocol';
17
20
  import {
18
21
  BoundsAware,
19
22
  EdgeRouterRegistry,
20
23
  isBoundsAware,
21
24
  isMoveable,
22
25
  isSelectable,
23
- isSelected,
24
- ModelIndexImpl,
26
+ isSelected, ModelIndexImpl,
27
+ RoutedPoint,
25
28
  Selectable,
26
29
  SModelElement,
27
30
  SRoutableElement,
@@ -226,21 +229,55 @@ export function toElementAndRoutingPoints(element: SRoutableElement): ElementAnd
226
229
  };
227
230
  }
228
231
 
232
+ /** Pure routing point data kinds. */
233
+ export const ROUTING_POINT_KINDS = ['linear', 'bezier-junction'];
234
+
235
+ /** Pure route data kinds. */
236
+ export const ROUTE_KINDS = [...ROUTING_POINT_KINDS, 'source', 'target'];
237
+
229
238
  /**
230
239
  * Helper function to calculate the {@link ElementAndRoutingPoints} for a given {@link SRoutableElement}.
231
240
  * If client layout is activated, i.e., the edge routing registry is given and has a router for the element, then the routing
232
241
  * points from the calculated route are used, otherwise we use the already specified routing points of the {@link SRoutableElement}.
233
242
  * @param element The element to translate.
234
- * @param edgeRouterRegistry the edge router registry
243
+ * @param routerRegistry the edge router registry.
235
244
  * @returns The corresponding {@link ElementAndRoutingPoints} for the given element.
236
245
  */
237
- export function calcElementAndRoutingPoints(element: SRoutableElement, edgeRouterRegistry?: EdgeRouterRegistry): ElementAndRoutingPoints {
238
- const router = edgeRouterRegistry?.get(element.routerKind);
239
- // filter duplicate points (same x,y coordinates) and only keep actual routing points (no start or target, no volatile points)
240
- const clientRoutingPoints = router?.route(element)
241
- .filter((point, idx, route) => idx === route.findIndex(otherPoint => otherPoint.x === point.x && otherPoint.y === point.y))
242
- .filter(point => point.kind === 'linear' || point.kind === 'bezier-junction');
243
- return { elementId: element.id, newRoutingPoints: clientRoutingPoints || element.routingPoints };
246
+ export function calcElementAndRoutingPoints(element: SRoutableElement, routerRegistry?: EdgeRouterRegistry): ElementAndRoutingPoints {
247
+ const newRoutingPoints = routerRegistry ? calcRoute(element, routerRegistry, ROUTING_POINT_KINDS) : element.routingPoints;
248
+ return { elementId: element.id, newRoutingPoints };
249
+ }
250
+
251
+ /**
252
+ * Helper function to calculate the route for a given {@link SRoutableElement}.
253
+ * If client layout is activated, i.e., the edge routing registry is given and has a router for the element, then the points
254
+ * from the calculated route are used, otherwise we use the already specified routing points of the {@link SRoutableElement}.
255
+ * @param element The element to translate.
256
+ * @param routerRegistry the edge router registry.
257
+ * @returns The corresponding route for the given element.
258
+ */
259
+ export function calcElementAndRoute(element: SRoutableElement, routerRegistry?: EdgeRouterRegistry): ElementAndRoutingPoints {
260
+ let route: Point[] | undefined = routerRegistry ? calcRoute(element, routerRegistry, ROUTE_KINDS) : undefined;
261
+ if (!route) {
262
+ // add source and target to the routing points
263
+ route = [...element.routingPoints];
264
+ route.splice(0, 0, element.source?.position || Point.ORIGIN);
265
+ route.push(element.target?.position || Point.ORIGIN);
266
+ }
267
+ return { elementId: element.id, newRoutingPoints: route };
268
+ }
269
+
270
+ /**
271
+ * Helper function to calculate the route for a given {@link SRoutableElement}.
272
+ * @param element The element to translate.
273
+ * @param routerRegistry the edge router registry.
274
+ * @param pointKinds the routing point kinds that should be considered.
275
+ * @returns The corresponding route for the given element.
276
+ */
277
+ export function calcRoute(element: SRoutableElement, routerRegistry: EdgeRouterRegistry, pointKinds?: string[]): RoutedPoint[] | undefined {
278
+ return routerRegistry?.get(element.routerKind).route(element)
279
+ .filter((point, idx, fullRoute) => idx === fullRoute.findIndex(otherPoint => otherPoint.x === point.x && otherPoint.y === point.y))
280
+ .filter(point => !pointKinds || pointKinds.includes(point.kind));
244
281
  }
245
282
 
246
283
  /**
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (c) 2021 EclipseSource and others.
2
+ * Copyright (c) 2021-2022 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
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (c) 2017-2018 TypeFox and others.
2
+ * Copyright (c) 2017-2022 TypeFox 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
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (c) 2021 EclipseSource and others.
2
+ * Copyright (c) 2019-2022 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