@eclipse-glsp/client 1.1.0-next.ac7a617.192 → 1.1.0-next.c40feb3.207
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.
- package/lib/base/action-dispatcher.js.map +1 -1
- package/lib/base/command-stack.js.map +1 -1
- package/lib/base/container-modules.js +37 -36
- package/lib/base/container-modules.js.map +1 -1
- package/lib/base/editor-context-service.d.ts +1 -1
- package/lib/base/editor-context-service.d.ts.map +1 -1
- package/lib/base/editor-context-service.js.map +1 -1
- package/lib/base/focus-tracker.js.map +1 -1
- package/lib/base/model/model-registry.js.map +1 -1
- package/lib/base/model/update-model-command.js.map +1 -1
- package/lib/base/model-initialization-constraint.js.map +1 -1
- package/lib/base/selection-clearing-mouse-listener.js.map +1 -1
- package/lib/base/tool-manager/glsp-tool-manager.js.map +1 -1
- package/lib/base/view/view-registry.js.map +1 -1
- package/lib/features/bounds/di.config.d.ts +20 -0
- package/lib/features/bounds/di.config.d.ts.map +1 -0
- package/lib/features/bounds/di.config.js +36 -0
- package/lib/features/bounds/di.config.js.map +1 -0
- package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts +34 -0
- package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts.map +1 -0
- package/lib/features/bounds/glsp-hidden-bounds-updater.js +98 -0
- package/lib/features/bounds/glsp-hidden-bounds-updater.js.map +1 -0
- package/lib/features/change-bounds/movement-restrictor.js.map +1 -1
- package/lib/features/change-bounds/snap.js.map +1 -1
- package/lib/features/command-palette/command-palette-tool.js.map +1 -1
- package/lib/features/command-palette/server-command-palette-provider.js.map +1 -1
- package/lib/features/context-menu/delete-element-context-menu.js.map +1 -1
- package/lib/features/context-menu/selection-service-aware-context-menu-mouse-listener.js.map +1 -1
- package/lib/features/context-menu/server-context-menu-provider.js.map +1 -1
- package/lib/features/copy-paste/copy-paste-context-menu.js.map +1 -1
- package/lib/features/copy-paste/copy-paste-handler.d.ts +2 -2
- package/lib/features/copy-paste/copy-paste-handler.d.ts.map +1 -1
- package/lib/features/copy-paste/copy-paste-handler.js +2 -3
- package/lib/features/copy-paste/copy-paste-handler.js.map +1 -1
- package/lib/features/decoration/decoration-placer.js.map +1 -1
- package/lib/features/edit-label/edit-label-tool.js.map +1 -1
- package/lib/features/edit-label/edit-label-validator.js.map +1 -1
- package/lib/features/export/glsp-svg-exporter.js.map +1 -1
- package/lib/features/hints/type-hints.js.map +1 -1
- package/lib/features/hover/hover.js.map +1 -1
- package/lib/features/layout/freeform-layout.js.map +1 -1
- package/lib/features/layout/hbox-layout.js.map +1 -1
- package/lib/features/layout/layout-elements-action.d.ts +4 -4
- package/lib/features/layout/layout-elements-action.d.ts.map +1 -1
- package/lib/features/layout/layout-elements-action.js.map +1 -1
- package/lib/features/layout/layouter.js.map +1 -1
- package/lib/features/layout/vbox-layout.js.map +1 -1
- package/lib/features/mouse-tool/mouse-tool.d.ts +1 -1
- package/lib/features/mouse-tool/mouse-tool.d.ts.map +1 -1
- package/lib/features/mouse-tool/mouse-tool.js.map +1 -1
- package/lib/features/navigation/navigation-action-handler.js.map +1 -1
- package/lib/features/navigation/navigation-target-resolver.js.map +1 -1
- package/lib/features/select/select-feedback-action.js.map +1 -1
- package/lib/features/select/selection-service.js.map +1 -1
- package/lib/features/source-model-watcher/source-model-changed-action-handler.js.map +1 -1
- package/lib/features/tool-feedback/change-bounds-tool-feedback.js.map +1 -1
- package/lib/features/tool-feedback/creation-tool-feedback.js.map +1 -1
- package/lib/features/tool-feedback/css-feedback.js.map +1 -1
- package/lib/features/tool-feedback/edge-edit-tool-feedback.js.map +1 -1
- package/lib/features/tool-feedback/feedback-action-dispatcher.js.map +1 -1
- package/lib/features/tool-feedback/marquee-tool-feedback.js.map +1 -1
- package/lib/features/tool-feedback/view.js.map +1 -1
- package/lib/features/tool-palette/tool-palette.js.map +1 -1
- package/lib/features/tools/base-glsp-tool.js.map +1 -1
- package/lib/features/tools/change-bounds-tool.d.ts.map +1 -1
- package/lib/features/tools/change-bounds-tool.js +13 -10
- package/lib/features/tools/change-bounds-tool.js.map +1 -1
- package/lib/features/tools/delete-tool.js.map +1 -1
- package/lib/features/tools/di.config.d.ts.map +1 -1
- package/lib/features/tools/di.config.js +3 -0
- package/lib/features/tools/di.config.js.map +1 -1
- package/lib/features/tools/edge-creation-tool.js.map +1 -1
- package/lib/features/tools/edge-edit-tool.d.ts +2 -2
- package/lib/features/tools/edge-edit-tool.d.ts.map +1 -1
- package/lib/features/tools/edge-edit-tool.js +3 -2
- package/lib/features/tools/edge-edit-tool.js.map +1 -1
- package/lib/features/tools/enable-default-tools-on-focus-loss.js.map +1 -1
- package/lib/features/tools/glsp-manhattan-edge-router.d.ts +20 -0
- package/lib/features/tools/glsp-manhattan-edge-router.d.ts.map +1 -0
- package/lib/features/tools/glsp-manhattan-edge-router.js +69 -0
- package/lib/features/tools/glsp-manhattan-edge-router.js.map +1 -0
- package/lib/features/tools/marquee-mouse-tool.js.map +1 -1
- package/lib/features/tools/marquee-tool.js.map +1 -1
- package/lib/features/tools/node-creation-tool.js.map +1 -1
- package/lib/features/tools/view.js.map +1 -1
- package/lib/features/validation/marker-navigator.d.ts +1 -1
- package/lib/features/validation/marker-navigator.d.ts.map +1 -1
- package/lib/features/validation/marker-navigator.js.map +1 -1
- package/lib/features/validation/validate.js.map +1 -1
- package/lib/features/viewport/glsp-scroll-mouse-listener.js.map +1 -1
- package/lib/model-source/glsp-diagram-server.js.map +1 -1
- package/lib/utils/smodel-util.d.ts +35 -5
- package/lib/utils/smodel-util.d.ts.map +1 -1
- package/lib/utils/smodel-util.js +50 -2
- package/lib/utils/smodel-util.js.map +1 -1
- package/lib/views/compartments.js.map +1 -1
- package/lib/views/glsp-edge-view.js.map +1 -1
- package/lib/views/glsp-projection-view.js.map +1 -1
- package/lib/views/issue-marker-view.js.map +1 -1
- package/lib/views/rounded-corner-view.js.map +1 -1
- package/package.json +10 -12
- package/src/base/container-modules.ts +2 -2
- package/src/features/bounds/di.config.ts +39 -0
- package/src/features/bounds/glsp-hidden-bounds-updater.ts +88 -0
- package/src/features/copy-paste/copy-paste-handler.ts +4 -8
- package/src/features/tools/change-bounds-tool.ts +16 -13
- package/src/features/tools/di.config.ts +5 -1
- package/src/features/tools/edge-edit-tool.ts +5 -6
- package/src/features/tools/glsp-manhattan-edge-router.ts +57 -0
- package/src/utils/smodel-util.ts +60 -4
|
@@ -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
|
+
}
|
|
@@ -134,19 +134,15 @@ export class ServerCopyPasteHandler implements ICopyPasteHandler {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
protected shouldCopy(_event: ClipboardEvent): boolean
|
|
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
|
|
141
|
+
protected shouldPaste(_event: ClipboardEvent): boolean {
|
|
142
142
|
return this.isDiagramActive();
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
private isDiagramActive(): boolean
|
|
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
|
}
|
|
@@ -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
|
-
|
|
241
|
+
const routerRegistry = this.tool.edgeRouterRegistry;
|
|
242
|
+
if (routerRegistry) {
|
|
243
243
|
// If client routing is enabled -> delegate routingpoints of connected edges to server
|
|
244
|
-
|
|
245
|
-
element
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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
|
|
253
|
+
return newRoutingPoints.length > 0
|
|
254
|
+
? [ChangeRoutingPointsOperation.create(newRoutingPoints)]
|
|
255
|
+
: [];
|
|
253
256
|
}
|
|
254
257
|
|
|
255
258
|
protected handleResize(activeResizeHandle: SResizeHandle): Action[] {
|
|
@@ -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 { GLSPSvgExporter } from '../export/glsp-svg-exporter';
|
|
@@ -25,6 +25,7 @@ import { DelKeyDeleteTool, MouseDeleteTool } from './delete-tool';
|
|
|
25
25
|
import { EdgeCreationTool } from './edge-creation-tool';
|
|
26
26
|
import { EdgeEditTool } from './edge-edit-tool';
|
|
27
27
|
import { EnableDefaultToolsOnFocusLossHandler } from './enable-default-tools-on-focus-loss';
|
|
28
|
+
import { GSLPManhattanEdgeRouter } from './glsp-manhattan-edge-router';
|
|
28
29
|
import { MarqueeMouseTool } from './marquee-mouse-tool';
|
|
29
30
|
import { MarqueeTool } from './marquee-tool';
|
|
30
31
|
import { MarqueeNode } from './model';
|
|
@@ -54,6 +55,9 @@ export const toolsModule = new ContainerModule((bind, _unbind, isBound, rebind)
|
|
|
54
55
|
|
|
55
56
|
bind(GLSPSvgExporter).toSelf().inSingletonScope();
|
|
56
57
|
rebind(TYPES.SvgExporter).toService(GLSPSvgExporter);
|
|
58
|
+
|
|
59
|
+
bind(GSLPManhattanEdgeRouter).toSelf().inSingletonScope();
|
|
60
|
+
rebind(ManhattanEdgeRouter).toService(GSLPManhattanEdgeRouter);
|
|
57
61
|
});
|
|
58
62
|
|
|
59
63
|
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()
|
|
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
|
-
|
|
241
|
-
|
|
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,
|
|
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
|
+
}
|
package/src/utils/smodel-util.ts
CHANGED
|
@@ -13,14 +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 {
|
|
16
|
+
import {
|
|
17
|
+
distinctAdd, ElementAndBounds, ElementAndRoutingPoints, Point, remove, SModelElementSchema,
|
|
18
|
+
TypeGuard
|
|
19
|
+
} from '@eclipse-glsp/protocol';
|
|
17
20
|
import {
|
|
18
21
|
BoundsAware,
|
|
22
|
+
EdgeRouterRegistry,
|
|
19
23
|
isBoundsAware,
|
|
20
24
|
isMoveable,
|
|
21
25
|
isSelectable,
|
|
22
|
-
isSelected,
|
|
23
|
-
|
|
26
|
+
isSelected, ModelIndexImpl,
|
|
27
|
+
RoutedPoint,
|
|
24
28
|
Selectable,
|
|
25
29
|
SModelElement,
|
|
26
30
|
SRoutableElement,
|
|
@@ -214,7 +218,7 @@ export function toElementAndBounds(element: BoundsAwareModelElement): ElementAnd
|
|
|
214
218
|
|
|
215
219
|
/**
|
|
216
220
|
* Helper function to translate a given {@link SRoutableElement} into its corresponding
|
|
217
|
-
* {@ElementAndRoutingPoints
|
|
221
|
+
* {@link ElementAndRoutingPoints} representation.
|
|
218
222
|
* @param element The element to translate.
|
|
219
223
|
* @returns The corresponding {@link ElementAndRoutingPoints} for the given element.
|
|
220
224
|
*/
|
|
@@ -225,6 +229,57 @@ export function toElementAndRoutingPoints(element: SRoutableElement): ElementAnd
|
|
|
225
229
|
};
|
|
226
230
|
}
|
|
227
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
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Helper function to calculate the {@link ElementAndRoutingPoints} for a given {@link SRoutableElement}.
|
|
240
|
+
* If client layout is activated, i.e., the edge routing registry is given and has a router for the element, then the routing
|
|
241
|
+
* points from the calculated route are used, otherwise we use the already specified routing points of the {@link SRoutableElement}.
|
|
242
|
+
* @param element The element to translate.
|
|
243
|
+
* @param routerRegistry the edge router registry.
|
|
244
|
+
* @returns The corresponding {@link ElementAndRoutingPoints} for the given element.
|
|
245
|
+
*/
|
|
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));
|
|
281
|
+
}
|
|
282
|
+
|
|
228
283
|
/**
|
|
229
284
|
* Checks if the model is compatible with the passed type string.
|
|
230
285
|
* (either has the same type or a subtype of this type)
|
|
@@ -247,3 +302,4 @@ export function getElementTypeId(input: SModelElement | SModelElementSchema | st
|
|
|
247
302
|
return (input as any)['type'] as string;
|
|
248
303
|
}
|
|
249
304
|
}
|
|
305
|
+
|