@eclipse-glsp/client 1.1.0-next.e193103.187 → 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 (184) 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/types.d.ts +2 -0
  21. package/lib/base/types.d.ts.map +1 -1
  22. package/lib/base/view/view-registry.js.map +1 -1
  23. package/lib/features/bounds/di.config.d.ts +20 -0
  24. package/lib/features/bounds/di.config.d.ts.map +1 -0
  25. package/lib/features/bounds/di.config.js +36 -0
  26. package/lib/features/bounds/di.config.js.map +1 -0
  27. package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts +34 -0
  28. package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts.map +1 -0
  29. package/lib/features/bounds/glsp-hidden-bounds-updater.js +98 -0
  30. package/lib/features/bounds/glsp-hidden-bounds-updater.js.map +1 -0
  31. package/lib/features/change-bounds/movement-restrictor.js.map +1 -1
  32. package/lib/features/change-bounds/snap.js.map +1 -1
  33. package/lib/features/command-palette/command-palette-tool.js +1 -1
  34. package/lib/features/command-palette/command-palette-tool.js.map +1 -1
  35. package/lib/features/command-palette/server-command-palette-provider.js.map +1 -1
  36. package/lib/features/context-menu/delete-element-context-menu.js.map +1 -1
  37. package/lib/features/context-menu/selection-service-aware-context-menu-mouse-listener.js.map +1 -1
  38. package/lib/features/context-menu/server-context-menu-provider.js.map +1 -1
  39. package/lib/features/copy-paste/copy-paste-context-menu.js.map +1 -1
  40. package/lib/features/copy-paste/copy-paste-handler.d.ts +2 -2
  41. package/lib/features/copy-paste/copy-paste-handler.d.ts.map +1 -1
  42. package/lib/features/copy-paste/copy-paste-handler.js +2 -3
  43. package/lib/features/copy-paste/copy-paste-handler.js.map +1 -1
  44. package/lib/features/decoration/decoration-placer.js.map +1 -1
  45. package/lib/features/edit-label/edit-label-tool.js.map +1 -1
  46. package/lib/features/edit-label/edit-label-validator.js.map +1 -1
  47. package/lib/features/export/di.config.d.ts +19 -0
  48. package/lib/features/export/di.config.d.ts.map +1 -0
  49. package/lib/features/export/di.config.js +29 -0
  50. package/lib/features/export/di.config.js.map +1 -0
  51. package/lib/features/export/glsp-svg-exporter.d.ts +22 -0
  52. package/lib/features/export/glsp-svg-exporter.d.ts.map +1 -0
  53. package/lib/features/export/glsp-svg-exporter.js +45 -0
  54. package/lib/features/export/glsp-svg-exporter.js.map +1 -0
  55. package/lib/features/hints/type-hints.js.map +1 -1
  56. package/lib/features/hover/hover.d.ts.map +1 -1
  57. package/lib/features/hover/hover.js +2 -1
  58. package/lib/features/hover/hover.js.map +1 -1
  59. package/lib/features/layout/freeform-layout.js.map +1 -1
  60. package/lib/features/layout/hbox-layout.js.map +1 -1
  61. package/lib/features/layout/layout-elements-action.d.ts +4 -4
  62. package/lib/features/layout/layout-elements-action.d.ts.map +1 -1
  63. package/lib/features/layout/layout-elements-action.js +2 -2
  64. package/lib/features/layout/layout-elements-action.js.map +1 -1
  65. package/lib/features/layout/layouter.js.map +1 -1
  66. package/lib/features/layout/tests/layouter-test-util.d.ts +1 -1
  67. package/lib/features/layout/tests/layouter-test-util.js +2 -2
  68. package/lib/features/layout/tests/layouter-test-util.js.map +1 -1
  69. package/lib/features/layout/vbox-layout.js.map +1 -1
  70. package/lib/features/mouse-tool/mouse-tool.d.ts +1 -1
  71. package/lib/features/mouse-tool/mouse-tool.d.ts.map +1 -1
  72. package/lib/features/mouse-tool/mouse-tool.js.map +1 -1
  73. package/lib/features/navigation/navigation-action-handler.js.map +1 -1
  74. package/lib/features/navigation/navigation-target-resolver.js.map +1 -1
  75. package/lib/features/save/model.d.ts +1 -1
  76. package/lib/features/select/select-feedback-action.js.map +1 -1
  77. package/lib/features/select/select-mouse-listener.d.ts +1 -1
  78. package/lib/features/select/select-mouse-listener.d.ts.map +1 -1
  79. package/lib/features/select/select-mouse-listener.js +2 -1
  80. package/lib/features/select/select-mouse-listener.js.map +1 -1
  81. package/lib/features/select/selection-service.js.map +1 -1
  82. package/lib/features/source-model-watcher/di.config.js +1 -1
  83. package/lib/features/source-model-watcher/source-model-changed-action-handler.js.map +1 -1
  84. package/lib/features/tool-feedback/change-bounds-tool-feedback.d.ts +2 -1
  85. package/lib/features/tool-feedback/change-bounds-tool-feedback.d.ts.map +1 -1
  86. package/lib/features/tool-feedback/change-bounds-tool-feedback.js +2 -1
  87. package/lib/features/tool-feedback/change-bounds-tool-feedback.js.map +1 -1
  88. package/lib/features/tool-feedback/creation-tool-feedback.d.ts.map +1 -1
  89. package/lib/features/tool-feedback/creation-tool-feedback.js +3 -2
  90. package/lib/features/tool-feedback/creation-tool-feedback.js.map +1 -1
  91. package/lib/features/tool-feedback/css-feedback.js.map +1 -1
  92. package/lib/features/tool-feedback/edge-edit-tool-feedback.d.ts.map +1 -1
  93. package/lib/features/tool-feedback/edge-edit-tool-feedback.js +4 -3
  94. package/lib/features/tool-feedback/edge-edit-tool-feedback.js.map +1 -1
  95. package/lib/features/tool-feedback/feedback-action-dispatcher.js.map +1 -1
  96. package/lib/features/tool-feedback/marquee-tool-feedback.js.map +1 -1
  97. package/lib/features/tool-feedback/view.js.map +1 -1
  98. package/lib/features/tool-palette/tool-palette.js.map +1 -1
  99. package/lib/features/tools/base-glsp-tool.js.map +1 -1
  100. package/lib/features/tools/change-bounds-tool.d.ts.map +1 -1
  101. package/lib/features/tools/change-bounds-tool.js +13 -10
  102. package/lib/features/tools/change-bounds-tool.js.map +1 -1
  103. package/lib/features/tools/delete-tool.js.map +1 -1
  104. package/lib/features/tools/di.config.d.ts.map +1 -1
  105. package/lib/features/tools/di.config.js +5 -2
  106. package/lib/features/tools/di.config.js.map +1 -1
  107. package/lib/features/tools/edge-creation-tool.js.map +1 -1
  108. package/lib/features/tools/edge-edit-tool.d.ts +2 -2
  109. package/lib/features/tools/edge-edit-tool.d.ts.map +1 -1
  110. package/lib/features/tools/edge-edit-tool.js +3 -2
  111. package/lib/features/tools/edge-edit-tool.js.map +1 -1
  112. package/lib/features/tools/enable-default-tools-on-focus-loss.js.map +1 -1
  113. package/lib/features/tools/glsp-manhattan-edge-router.d.ts +20 -0
  114. package/lib/features/tools/glsp-manhattan-edge-router.d.ts.map +1 -0
  115. package/lib/features/tools/glsp-manhattan-edge-router.js +69 -0
  116. package/lib/features/tools/glsp-manhattan-edge-router.js.map +1 -0
  117. package/lib/features/tools/marquee-mouse-tool.js.map +1 -1
  118. package/lib/features/tools/marquee-tool.js.map +1 -1
  119. package/lib/features/tools/node-creation-tool.js.map +1 -1
  120. package/lib/features/tools/view.js.map +1 -1
  121. package/lib/features/validation/issue-marker.d.ts +1 -1
  122. package/lib/features/validation/issue-marker.js +1 -1
  123. package/lib/features/validation/marker-navigator.d.ts +1 -1
  124. package/lib/features/validation/marker-navigator.d.ts.map +1 -1
  125. package/lib/features/validation/marker-navigator.js.map +1 -1
  126. package/lib/features/validation/validate.js.map +1 -1
  127. package/lib/features/viewport/glsp-scroll-mouse-listener.js.map +1 -1
  128. package/lib/lib/model.d.ts +7 -3
  129. package/lib/lib/model.d.ts.map +1 -1
  130. package/lib/lib/model.js +48 -1
  131. package/lib/lib/model.js.map +1 -1
  132. package/lib/model-source/glsp-diagram-server.js.map +1 -1
  133. package/lib/sprotty-reexport.d.ts +6 -6
  134. package/lib/sprotty-reexport.d.ts.map +1 -1
  135. package/lib/sprotty-reexport.js +19 -8
  136. package/lib/sprotty-reexport.js.map +1 -1
  137. package/lib/utils/html-utils.d.ts +1 -1
  138. package/lib/utils/html-utils.js +1 -1
  139. package/lib/utils/smodel-util.d.ts +35 -5
  140. package/lib/utils/smodel-util.d.ts.map +1 -1
  141. package/lib/utils/smodel-util.js +50 -2
  142. package/lib/utils/smodel-util.js.map +1 -1
  143. package/lib/views/base-view-module.js +1 -1
  144. package/lib/views/compartments.js.map +1 -1
  145. package/lib/views/glsp-edge-view.js.map +1 -1
  146. package/lib/views/glsp-projection-view.d.ts +1 -1
  147. package/lib/views/glsp-projection-view.d.ts.map +1 -1
  148. package/lib/views/glsp-projection-view.js +9 -3
  149. package/lib/views/glsp-projection-view.js.map +1 -1
  150. package/lib/views/index.d.ts +1 -1
  151. package/lib/views/index.js +1 -1
  152. package/lib/views/issue-marker-view.js.map +1 -1
  153. package/lib/views/rounded-corner-view.js.map +1 -1
  154. package/package.json +23 -23
  155. package/src/base/command-stack.ts +3 -3
  156. package/src/base/container-modules.ts +53 -9
  157. package/src/base/selection-clearing-mouse-listener.ts +1 -1
  158. package/src/features/bounds/di.config.ts +39 -0
  159. package/src/features/bounds/glsp-hidden-bounds-updater.ts +88 -0
  160. package/src/features/command-palette/command-palette-tool.ts +1 -1
  161. package/src/features/copy-paste/copy-paste-handler.ts +4 -8
  162. package/src/features/export/di.config.ts +28 -0
  163. package/src/features/export/glsp-svg-exporter.ts +50 -0
  164. package/src/features/hover/hover.ts +2 -1
  165. package/src/features/layout/layout-elements-action.ts +2 -1
  166. package/src/features/layout/tests/layouter-test-util.ts +3 -3
  167. package/src/features/save/model.ts +1 -1
  168. package/src/features/select/select-mouse-listener.ts +2 -2
  169. package/src/features/source-model-watcher/di.config.ts +1 -1
  170. package/src/features/tool-feedback/change-bounds-tool-feedback.ts +1 -1
  171. package/src/features/tool-feedback/creation-tool-feedback.ts +1 -1
  172. package/src/features/tool-feedback/edge-edit-tool-feedback.ts +1 -1
  173. package/src/features/tools/change-bounds-tool.ts +16 -13
  174. package/src/features/tools/di.config.ts +7 -3
  175. package/src/features/tools/edge-edit-tool.ts +5 -6
  176. package/src/features/tools/glsp-manhattan-edge-router.ts +57 -0
  177. package/src/features/validation/issue-marker.ts +1 -1
  178. package/src/lib/model.ts +35 -3
  179. package/src/sprotty-reexport.ts +17 -6
  180. package/src/utils/html-utils.ts +1 -1
  181. package/src/utils/smodel-util.ts +60 -4
  182. package/src/views/base-view-module.ts +1 -1
  183. package/src/views/glsp-projection-view.tsx +11 -4
  184. package/src/views/index.ts +1 -1
@@ -0,0 +1,88 @@
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 {
18
+ Action, ComputedBoundsAction, Deferred, ElementAndRoutingPoints, RequestAction,
19
+ ResponseAction
20
+ } from '@eclipse-glsp/protocol';
21
+ import { inject, injectable, optional } from 'inversify';
22
+ import { VNode } from 'snabbdom';
23
+ import { EdgeRouterRegistry, HiddenBoundsUpdater, IActionDispatcher, SModelElement, SRoutableElement } from 'sprotty';
24
+ import { calcElementAndRoute, isRoutable } from '../../utils/smodel-util';
25
+
26
+ /**
27
+ * Grabs the bounds from hidden SVG DOM elements, applies layouts, collects routes and fires {@link ComputedBoundsAction}s.
28
+ *
29
+ * The actions will contain the bound, alignment, and routing points of elements.
30
+ */
31
+ @injectable()
32
+ export class GLSPHiddenBoundsUpdater extends HiddenBoundsUpdater {
33
+
34
+ @inject(EdgeRouterRegistry) @optional() protected readonly edgeRouterRegistry?: EdgeRouterRegistry;
35
+
36
+ protected element2route: ElementAndRoutingPoints[] = [];
37
+ protected edges: SRoutableElement[] = [];
38
+ protected nodes: VNode[] = [];
39
+
40
+ override decorate(vnode: VNode, element: SModelElement): VNode {
41
+ super.decorate(vnode, element);
42
+ if (isRoutable(element)) {
43
+ this.element2route.push(calcElementAndRoute(element, this.edgeRouterRegistry));
44
+ }
45
+ return vnode;
46
+ }
47
+
48
+ override postUpdate(cause?: Action): void {
49
+ const actions = this.captureActions(() => super.postUpdate(cause));
50
+ actions.filter(action => ComputedBoundsAction.is(action))
51
+ .forEach(action => this.actionDispatcher.dispatch(this.enhanceAction(action as ComputedBoundsAction)));
52
+ this.element2route = [];
53
+ }
54
+
55
+ protected captureActions(call: () => void): Action[] {
56
+ const capturingActionDispatcher = new CapturingActionDispatcher();
57
+ const actualActionDispatcher = this.actionDispatcher;
58
+ this.actionDispatcher = capturingActionDispatcher;
59
+ try {
60
+ call();
61
+ return capturingActionDispatcher.actions;
62
+ } finally {
63
+ this.actionDispatcher = actualActionDispatcher;
64
+ }
65
+ }
66
+
67
+ protected enhanceAction(action: ComputedBoundsAction): ComputedBoundsAction {
68
+ action.routes = this.element2route.length === 0 ? undefined : this.element2route;
69
+ return action;
70
+ }
71
+ }
72
+
73
+ class CapturingActionDispatcher implements IActionDispatcher {
74
+ readonly actions: Action[] = [];
75
+
76
+ async dispatch(action: Action): Promise<void> {
77
+ this.actions.push(action);
78
+ }
79
+
80
+ async dispatchAll(actions: Action[]): Promise<void> {
81
+ this.actions.push(...actions);
82
+ }
83
+
84
+ async request<Res extends ResponseAction>(action: RequestAction<Res>): Promise<Res> {
85
+ // ignore, not needed for our purposes
86
+ return new Deferred<Res>().promise;
87
+ }
88
+ }
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (c) 2020 EclipseSource and others.
2
+ * Copyright (c) 2019-2021 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
@@ -134,19 +134,15 @@ export class ServerCopyPasteHandler implements ICopyPasteHandler {
134
134
  }
135
135
  }
136
136
 
137
- protected shouldCopy(_event: ClipboardEvent): boolean | null {
137
+ protected shouldCopy(_event: ClipboardEvent): boolean {
138
138
  return this.editorContext.get().selectedElementIds.length > 0 && this.isDiagramActive();
139
139
  }
140
140
 
141
- protected shouldPaste(_event: ClipboardEvent): boolean | null {
141
+ protected shouldPaste(_event: ClipboardEvent): boolean {
142
142
  return this.isDiagramActive();
143
143
  }
144
144
 
145
- private isDiagramActive(): boolean | null {
146
- return (
147
- document.activeElement instanceof SVGElement &&
148
- document.activeElement.parentElement &&
149
- document.activeElement.parentElement.id === this.viewerOptions.baseDiv
150
- );
145
+ private isDiagramActive(): boolean {
146
+ return document.activeElement?.parentElement?.id === this.viewerOptions.baseDiv;
151
147
  }
152
148
  }
@@ -0,0 +1,28 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2023 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 { ContainerModule } from 'inversify';
17
+ import { configureCommand, ExportSvgCommand, ExportSvgKeyListener, ExportSvgPostprocessor, TYPES } from 'sprotty';
18
+ import { GLSPSvgExporter } from './glsp-svg-exporter';
19
+
20
+ const glspExportSvgModule = new ContainerModule((bind, _unbind, isBound) => {
21
+ bind(ExportSvgKeyListener).toSelf().inSingletonScope();
22
+ bind(TYPES.KeyListener).toService(ExportSvgKeyListener);
23
+ bind(TYPES.HiddenVNodePostprocessor).to(ExportSvgPostprocessor).inSingletonScope();
24
+ configureCommand({ bind, isBound }, ExportSvgCommand);
25
+ bind(TYPES.SvgExporter).to(GLSPSvgExporter).inSingletonScope();
26
+ });
27
+
28
+ export default glspExportSvgModule;
@@ -0,0 +1,50 @@
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
+ import { RequestAction } from '@eclipse-glsp/protocol';
17
+ import { injectable } from 'inversify';
18
+ import { ExportSvgAction, SModelRoot, SvgExporter } from 'sprotty';
19
+ import { v4 as uuid } from 'uuid';
20
+
21
+ @injectable()
22
+ export class GLSPSvgExporter extends SvgExporter {
23
+ override export(root: SModelRoot, _request?: RequestAction<ExportSvgAction>): void {
24
+ if (typeof document !== 'undefined') {
25
+ const svgElement = this.findSvgElement();
26
+ if (svgElement) {
27
+ // createSvg requires the svg to have a non-empty id, so we generate one if necessary
28
+ const originalId = svgElement.id;
29
+ try {
30
+ svgElement.id = originalId || uuid();
31
+ // provide generated svg code with respective sizing for proper viewing in browser and remove undesired border
32
+ const bounds = this.getBounds(root);
33
+ const svg = this.createSvg(svgElement, root)
34
+ .replace('style="',
35
+ `style="width: ${bounds.width}px !important;height: ${bounds.height}px !important;border: none !important;`);
36
+ // do not give request/response id here as otherwise the action is treated as an unrequested response
37
+ this.actionDispatcher.dispatch(ExportSvgAction.create(svg, ''));
38
+ } finally {
39
+ svgElement.id = originalId;
40
+ }
41
+ }
42
+ }
43
+ }
44
+
45
+ protected findSvgElement(): SVGSVGElement | null {
46
+ const div = document.getElementById(this.options.hiddenDiv);
47
+ // search for first svg element as hierarchy within Sprotty might change
48
+ return div && div.querySelector('svg');
49
+ }
50
+ }
@@ -23,7 +23,8 @@ import {
23
23
  SModelRootSchema
24
24
  } from '@eclipse-glsp/protocol';
25
25
  import { injectable } from 'inversify';
26
- import { EMPTY_ROOT, HoverFeedbackAction, HoverMouseListener, IActionHandler, ICommand, SModelElement } from 'sprotty';
26
+ import { EMPTY_ROOT, HoverMouseListener, IActionHandler, ICommand, SModelElement } from 'sprotty';
27
+ import { HoverFeedbackAction } from 'sprotty-protocol/lib/actions';
27
28
  import { FocusStateChangedAction } from '../../base/actions/focus-change-action';
28
29
  import { EnableDefaultToolsAction, EnableToolsAction } from '../../base/tool-manager/tool-actions';
29
30
  import { EdgeCreationTool } from '../tools/edge-creation-tool';
@@ -24,7 +24,8 @@ import {
24
24
  Writable
25
25
  } from '@eclipse-glsp/protocol';
26
26
  import { inject, injectable, optional } from 'inversify';
27
- import { ElementMove, IActionDispatcher, IActionHandler, ICommand, MoveAction, SModelElement } from 'sprotty';
27
+ import { ElementMove, IActionDispatcher, IActionHandler, ICommand, SModelElement } from 'sprotty';
28
+ import { MoveAction } from 'sprotty-protocol/lib/actions';
28
29
  import { TYPES } from '../../base/types';
29
30
  import { toValidElementAndBounds, toValidElementMove } from '../../utils/layout-utils';
30
31
  import { BoundsAwareModelElement, getElements } from '../../utils/smodel-util';
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (c) 2022 STMicroelectronics and others.
2
+ * Copyright (c) 2022-2023 STMicroelectronics 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
@@ -30,7 +30,7 @@ import {
30
30
  SParentElement,
31
31
  TYPES
32
32
  } from 'sprotty';
33
- import { createClientContainer } from '../../../base/container-modules';
33
+ import { createDiagramContainer } from '../../../base/container-modules';
34
34
  import { GLSPGraph } from '../../../lib/model';
35
35
  import { StatefulLayouterExt } from '../layouter';
36
36
 
@@ -117,6 +117,6 @@ export function layout(
117
117
  export function setupLayoutRegistry(): LayoutRegistry {
118
118
  // Generic Test setup
119
119
  // create client container that registers all default modules including the layoutModule
120
- const layoutContainer = createClientContainer();
120
+ const layoutContainer = createDiagramContainer();
121
121
  return layoutContainer.get<LayoutRegistry>(TYPES.LayoutRegistry);
122
122
  }
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (c) 2019 EclipseSource and others.
2
+ * Copyright (c) 2019-2021 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,7 +15,6 @@
15
15
  ********************************************************************************/
16
16
  import { Action, SelectAction } from '@eclipse-glsp/protocol';
17
17
  import {
18
- BringToFrontAction,
19
18
  findParentByFeature,
20
19
  isCtrlOrCmd,
21
20
  isSelectable,
@@ -27,6 +26,7 @@ import {
27
26
  SRoutingHandle,
28
27
  SwitchEditModeAction
29
28
  } from 'sprotty';
29
+ import { BringToFrontAction } from 'sprotty-protocol/lib/actions';
30
30
  import { toArray } from 'sprotty/lib/utils/iterable';
31
31
  import { DEFAULT_RANK, Ranked } from '../rank/model';
32
32
 
@@ -37,7 +37,7 @@ import { DEFAULT_RANK, Ranked } from '../rank/model';
37
37
  export class RankedSelectMouseListener extends SelectMouseListener implements Ranked {
38
38
  rank: number = DEFAULT_RANK - 1; /* we want to be executed before all default mouse listeners */
39
39
 
40
- override mouseDown(target: SModelElement, event: MouseEvent): Action[] {
40
+ override mouseDown(target: SModelElement, event: MouseEvent): (Action | Promise<Action>)[] {
41
41
  const result: Action[] = [];
42
42
  if (this.buttonHandlerRegistry !== undefined && target instanceof SButton && target.enabled) {
43
43
  const buttonHandler = this.buttonHandlerRegistry.get(target.type);
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (c) 2020-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
@@ -25,12 +25,12 @@ import {
25
25
  isSelectable,
26
26
  isViewport,
27
27
  MouseListener,
28
- MoveAction,
29
28
  SChildElement,
30
29
  SModelElement,
31
30
  SModelRoot,
32
31
  TYPES
33
32
  } from 'sprotty';
33
+ import { MoveAction } from 'sprotty-protocol/lib/actions';
34
34
  import { forEachElement } from '../../utils/smodel-util';
35
35
  import { addResizeHandles, isResizable, removeResizeHandles, SResizeHandle } from '../change-bounds/model';
36
36
  import { createMovementRestrictionFeedback, removeMovementRestrictionFeedback } from '../change-bounds/movement-restrictor';
@@ -24,7 +24,6 @@ import {
24
24
  isBoundsAware,
25
25
  isConnectable,
26
26
  MouseListener,
27
- MoveAction,
28
27
  PolylineEdgeRouter,
29
28
  SChildElement,
30
29
  SConnectableElement,
@@ -35,6 +34,7 @@ import {
35
34
  SRoutableElement,
36
35
  TYPES
37
36
  } from 'sprotty';
37
+ import { MoveAction } from 'sprotty-protocol/lib/actions';
38
38
  import { BoundsAwareModelElement, isRoutable } from '../../utils/smodel-util';
39
39
  import { getAbsolutePosition, toAbsoluteBounds, toAbsolutePosition } from '../../utils/viewpoint-util';
40
40
  import { FeedbackCommand } from './model';
@@ -29,7 +29,6 @@ import {
29
29
  ISnapper,
30
30
  isSelected,
31
31
  MouseListener,
32
- MoveAction,
33
32
  PolylineEdgeRouter,
34
33
  SConnectableElement,
35
34
  SModelElement,
@@ -39,6 +38,7 @@ import {
39
38
  SwitchEditModeCommand,
40
39
  TYPES
41
40
  } from 'sprotty';
41
+ import { MoveAction } from 'sprotty-protocol/lib/actions';
42
42
  import { forEachElement, isRoutable, isRoutingHandle } from '../../utils/smodel-util';
43
43
  import { getAbsolutePosition, toAbsoluteBounds } from '../../utils/viewpoint-util';
44
44
  import { PointPositionUpdater } from '../change-bounds/snap';
@@ -13,7 +13,7 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import {
16
+ import {
17
17
  Action,
18
18
  Bounds,
19
19
  ChangeBoundsOperation,
@@ -44,10 +44,10 @@ import { DragAwareMouseListener } from '../../base/drag-aware-mouse-listener';
44
44
  import { TYPES } from '../../base/types';
45
45
  import { isValidMove, isValidSize } from '../../utils/layout-utils';
46
46
  import {
47
+ calcElementAndRoutingPoints,
47
48
  forEachElement,
48
49
  isNonRoutableSelectedMovableBoundsAware,
49
- toElementAndBounds,
50
- toElementAndRoutingPoints
50
+ toElementAndBounds
51
51
  } from '../../utils/smodel-util';
52
52
  import { isBoundsAwareMoveable, isResizable, Resizable, ResizeHandleLocation, SResizeHandle } from '../change-bounds/model';
53
53
  import {
@@ -237,19 +237,22 @@ export class ChangeBoundsListener extends DragAwareMouseListener implements Sele
237
237
  }
238
238
 
239
239
  protected handleMoveRoutingPointsOnServer(target: SModelElement): Operation[] {
240
- const result: Operation[] = [];
241
240
  const newRoutingPoints: ElementAndRoutingPoints[] = [];
242
- forEachElement(target.index, isNonRoutableSelectedMovableBoundsAware, element => {
241
+ const routerRegistry = this.tool.edgeRouterRegistry;
242
+ if (routerRegistry) {
243
243
  // If client routing is enabled -> delegate routingpoints of connected edges to server
244
- if (this.tool.edgeRouterRegistry && element instanceof SConnectableElement) {
245
- element.incomingEdges.map(toElementAndRoutingPoints).forEach(ear => newRoutingPoints.push(ear));
246
- element.outgoingEdges.map(toElementAndRoutingPoints).forEach(ear => newRoutingPoints.push(ear));
247
- }
248
- });
249
- if (newRoutingPoints.length > 0) {
250
- result.push(ChangeRoutingPointsOperation.create(newRoutingPoints));
244
+ forEachElement(target.index, isNonRoutableSelectedMovableBoundsAware, element => {
245
+ if (element instanceof SConnectableElement) {
246
+ element.incomingEdges.map(connectable => calcElementAndRoutingPoints(connectable, routerRegistry))
247
+ .forEach(ear => newRoutingPoints.push(ear));
248
+ element.outgoingEdges.map(connectable => calcElementAndRoutingPoints(connectable, routerRegistry))
249
+ .forEach(ear => newRoutingPoints.push(ear));
250
+ }
251
+ });
251
252
  }
252
- return result;
253
+ return newRoutingPoints.length > 0
254
+ ? [ChangeRoutingPointsOperation.create(newRoutingPoints)]
255
+ : [];
253
256
  }
254
257
 
255
258
  protected handleResize(activeResizeHandle: SResizeHandle): Action[] {
@@ -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,7 +15,7 @@
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
21
  import { MARQUEE } from '../tool-feedback/marquee-tool-feedback';
@@ -24,6 +24,7 @@ import { DelKeyDeleteTool, MouseDeleteTool } from './delete-tool';
24
24
  import { EdgeCreationTool } from './edge-creation-tool';
25
25
  import { EdgeEditTool } from './edge-edit-tool';
26
26
  import { EnableDefaultToolsOnFocusLossHandler } from './enable-default-tools-on-focus-loss';
27
+ import { GSLPManhattanEdgeRouter } from './glsp-manhattan-edge-router';
27
28
  import { MarqueeMouseTool } from './marquee-mouse-tool';
28
29
  import { MarqueeTool } from './marquee-tool';
29
30
  import { MarqueeNode } from './model';
@@ -34,7 +35,7 @@ import { MarqueeView } from './view';
34
35
  * Registers the default tools of GLSP (node and edge creation, changing bounds, edge editing, deletion)
35
36
  * and adds the marquee selection tool.
36
37
  */
37
- export const toolsModule = new ContainerModule((bind, _unbind, isBound) => {
38
+ export const toolsModule = new ContainerModule((bind, _unbind, isBound, rebind) => {
38
39
  // Register default tools
39
40
  bind(TYPES.IDefaultTool).to(ChangeBoundsTool);
40
41
  bind(TYPES.IDefaultTool).to(EdgeEditTool);
@@ -50,6 +51,9 @@ export const toolsModule = new ContainerModule((bind, _unbind, isBound) => {
50
51
  configureMarqueeTool({ bind, isBound });
51
52
  configureActionHandler({ bind, isBound }, TriggerNodeCreationAction.KIND, NodeCreationTool);
52
53
  configureActionHandler({ bind, isBound }, TriggerEdgeCreationAction.KIND, EdgeCreationTool);
54
+
55
+ bind(GSLPManhattanEdgeRouter).toSelf().inSingletonScope();
56
+ rebind(ManhattanEdgeRouter).toService(GSLPManhattanEdgeRouter);
53
57
  });
54
58
 
55
59
  export function configureMarqueeTool(context: { bind: interfaces.Bind; isBound: interfaces.IsBound }): void {
@@ -31,7 +31,7 @@ import {
31
31
  } from 'sprotty';
32
32
  import { DragAwareMouseListener } from '../../base/drag-aware-mouse-listener';
33
33
  import { TYPES } from '../../base/types';
34
- import { isRoutable, isRoutingHandle } from '../../utils/smodel-util';
34
+ import { calcElementAndRoutingPoints, isRoutable, isRoutingHandle } from '../../utils/smodel-util';
35
35
  import { isReconnectable, isReconnectHandle, isSourceRoutingHandle, isTargetRoutingHandle, SReconnectHandle } from '../reconnect/model';
36
36
  import { SelectionListener, SelectionService } from '../select/selection-service';
37
37
  import { DrawFeedbackEdgeAction, feedbackEdgeId, RemoveFeedbackEdgeAction } from '../tool-feedback/creation-tool-feedback';
@@ -53,7 +53,7 @@ export class EdgeEditTool extends BaseGLSPTool {
53
53
 
54
54
  @inject(TYPES.SelectionService) protected selectionService: SelectionService;
55
55
  @inject(AnchorComputerRegistry) protected anchorRegistry: AnchorComputerRegistry;
56
- @inject(EdgeRouterRegistry) @optional() protected edgeRouterRegistry?: EdgeRouterRegistry;
56
+ @inject(EdgeRouterRegistry) @optional() readonly edgeRouterRegistry?: EdgeRouterRegistry;
57
57
  @inject(TYPES.ISnapper) @optional() readonly snapper?: ISnapper;
58
58
 
59
59
  protected feedbackEdgeSourceMovingListener: FeedbackEdgeSourceMovingMouseListener;
@@ -237,16 +237,15 @@ class EdgeEditListener extends DragAwareMouseListener implements SelectionListen
237
237
  // reroute actions
238
238
  const latestEdge = target.index.getById(this.edge.id);
239
239
  if (latestEdge && isRoutable(latestEdge)) {
240
- result.push(
241
- ChangeRoutingPointsOperation.create([{ elementId: latestEdge.id, newRoutingPoints: latestEdge.routingPoints }])
242
- );
240
+ const newRoutingPoints = calcElementAndRoutingPoints(latestEdge, this.tool.edgeRouterRegistry);
241
+ result.push(ChangeRoutingPointsOperation.create([newRoutingPoints]));
243
242
  this.routingHandle = undefined;
244
243
  }
245
244
  }
246
245
  return result;
247
246
  }
248
247
 
249
- override mouseOver(target: SModelElement, event: MouseEvent): Action[] {
248
+ override mouseOver(target: SModelElement, _event: MouseEvent): Action[] {
250
249
  if (this.edge && this.isReconnecting()) {
251
250
  const currentTarget = findParentByFeature(target, isConnectable);
252
251
  if (!this.newConnectable || currentTarget !== this.newConnectable) {
@@ -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
+ }