@eclipse-glsp/client 1.1.0-next.4a5a0ee.195 → 1.1.0-next.a07a5f7.197
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/container-modules.js +37 -36
- package/lib/base/container-modules.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/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/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/utils/smodel-util.d.ts +24 -3
- package/lib/utils/smodel-util.d.ts.map +1 -1
- package/lib/utils/smodel-util.js +40 -7
- package/lib/utils/smodel-util.js.map +1 -1
- package/package.json +3 -3
- 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/tools/di.config.ts +5 -1
- package/src/features/tools/glsp-manhattan-edge-router.ts +57 -0
- package/src/utils/smodel-util.ts +48 -11
|
@@ -18,28 +18,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.createClientContainer = exports.DEFAULT_MODULES = void 0;
|
|
19
19
|
const inversify_1 = require("inversify");
|
|
20
20
|
const sprotty_1 = require("sprotty");
|
|
21
|
-
const di_config_1 = require("../features/
|
|
22
|
-
const di_config_2 = require("../features/
|
|
23
|
-
const di_config_3 = require("../features/
|
|
24
|
-
const di_config_4 = require("../features/
|
|
25
|
-
const di_config_5 = require("../features/
|
|
26
|
-
const di_config_6 = require("../features/
|
|
27
|
-
const di_config_7 = require("../features/
|
|
28
|
-
const di_config_8 = require("../features/
|
|
29
|
-
const di_config_9 = require("../features/
|
|
30
|
-
const di_config_10 = require("../features/
|
|
31
|
-
const di_config_11 = require("../features/
|
|
32
|
-
const di_config_12 = require("../features/
|
|
33
|
-
const di_config_13 = require("../features/
|
|
34
|
-
const di_config_14 = require("../features/tool-
|
|
35
|
-
const di_config_15 = require("../features/
|
|
36
|
-
const di_config_16 = require("../features/
|
|
37
|
-
const di_config_17 = require("../features/
|
|
38
|
-
const di_config_18 = require("
|
|
21
|
+
const di_config_1 = require("../features/bounds/di.config");
|
|
22
|
+
const di_config_2 = require("../features/command-palette/di.config");
|
|
23
|
+
const di_config_3 = require("../features/context-menu/di.config");
|
|
24
|
+
const di_config_4 = require("../features/copy-paste/di.config");
|
|
25
|
+
const di_config_5 = require("../features/decoration/di.config");
|
|
26
|
+
const di_config_6 = require("../features/edit-label/di.config");
|
|
27
|
+
const di_config_7 = require("../features/hints/di.config");
|
|
28
|
+
const di_config_8 = require("../features/hover/di.config");
|
|
29
|
+
const di_config_9 = require("../features/layout/di.config");
|
|
30
|
+
const di_config_10 = require("../features/mouse-tool/di.config");
|
|
31
|
+
const di_config_11 = require("../features/navigation/di.config");
|
|
32
|
+
const di_config_12 = require("../features/select/di.config");
|
|
33
|
+
const di_config_13 = require("../features/source-model-watcher/di.config");
|
|
34
|
+
const di_config_14 = require("../features/tool-feedback/di.config");
|
|
35
|
+
const di_config_15 = require("../features/tool-palette/di.config");
|
|
36
|
+
const di_config_16 = require("../features/tools/di.config");
|
|
37
|
+
const di_config_17 = require("../features/validation/di.config");
|
|
38
|
+
const di_config_18 = require("../features/viewport/di.config");
|
|
39
|
+
const di_config_19 = require("./di.config");
|
|
39
40
|
exports.DEFAULT_MODULES = [
|
|
40
41
|
sprotty_1.defaultModule,
|
|
41
|
-
|
|
42
|
-
sprotty_1.boundsModule,
|
|
42
|
+
di_config_19.default,
|
|
43
43
|
sprotty_1.buttonModule,
|
|
44
44
|
sprotty_1.edgeIntersectionModule,
|
|
45
45
|
sprotty_1.edgeLayoutModule,
|
|
@@ -48,27 +48,28 @@ exports.DEFAULT_MODULES = [
|
|
|
48
48
|
sprotty_1.fadeModule,
|
|
49
49
|
di_config_1.default,
|
|
50
50
|
di_config_2.default,
|
|
51
|
-
|
|
51
|
+
di_config_3.default,
|
|
52
52
|
di_config_5.default,
|
|
53
|
-
di_config_7.default,
|
|
54
|
-
di_config_9.default,
|
|
55
|
-
di_config_11.default,
|
|
56
|
-
di_config_3.glspServerCopyPasteModule,
|
|
57
|
-
di_config_17.default,
|
|
58
|
-
sprotty_1.labelEditUiModule,
|
|
59
|
-
di_config_8.default,
|
|
60
|
-
di_config_16.markerNavigatorModule,
|
|
61
53
|
di_config_6.default,
|
|
62
|
-
|
|
54
|
+
di_config_8.default,
|
|
55
|
+
di_config_10.default,
|
|
63
56
|
di_config_12.default,
|
|
64
|
-
|
|
57
|
+
di_config_4.glspServerCopyPasteModule,
|
|
58
|
+
di_config_18.default,
|
|
59
|
+
sprotty_1.labelEditUiModule,
|
|
60
|
+
di_config_9.default,
|
|
61
|
+
di_config_17.markerNavigatorModule,
|
|
62
|
+
di_config_7.default,
|
|
63
|
+
sprotty_1.modelSourceModule,
|
|
64
|
+
di_config_13.default,
|
|
65
|
+
di_config_11.navigationModule,
|
|
65
66
|
sprotty_1.openModule,
|
|
66
|
-
|
|
67
|
+
di_config_15.default,
|
|
67
68
|
sprotty_1.routingModule,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
di_config_14.default,
|
|
70
|
+
di_config_16.toolsModule,
|
|
71
|
+
di_config_16.enableDefaultToolsOnFocusLossModule,
|
|
72
|
+
di_config_17.validationModule,
|
|
72
73
|
sprotty_1.zorderModule
|
|
73
74
|
];
|
|
74
75
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container-modules.js","sourceRoot":"","sources":["../../src/base/container-modules.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAElF,yCAAuD;AACvD,
|
|
1
|
+
{"version":3,"file":"container-modules.js","sourceRoot":"","sources":["../../src/base/container-modules.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAElF,yCAAuD;AACvD,qCAaiB;AACjB,4DAA4D;AAC5D,qEAA6E;AAC7E,kEAAuE;AACvE,gEAA6E;AAC7E,gEAAoE;AACpE,gEAAmE;AACnE,2DAA2D;AAC3D,2DAA0D;AAC1D,4DAAwD;AACxD,iEAAmE;AACnE,iEAAoE;AACpE,6DAA4D;AAC5D,2EAAkF;AAClF,oEAAqE;AACrE,mEAAmE;AACnE,4DAA+F;AAC/F,iEAA2F;AAC3F,+DAAgE;AAChE,4CAA4C;AAE/B,QAAA,eAAe,GAAG;IAC3B,uBAAa;IACb,oBAAiB;IACjB,sBAAY;IACZ,gCAAsB;IACtB,0BAAgB;IAChB,sBAAY;IACZ,sBAAY;IACZ,oBAAU;IACV,mBAAgB;IAChB,mBAAwB;IACxB,mBAAqB;IACrB,mBAAoB;IACpB,mBAAmB;IACnB,mBAAe;IACf,oBAAmB;IACnB,oBAAgB;IAChB,qCAAyB;IACzB,oBAAkB;IAClB,2BAAiB;IACjB,mBAAY;IACZ,kCAAqB;IACrB,mBAAgB;IAChB,2BAAiB;IACjB,oBAAwB;IACxB,6BAAgB;IAChB,oBAAU;IACV,oBAAiB;IACjB,uBAAa;IACb,oBAAkB;IAClB,wBAAW;IACX,gDAAmC;IACnC,6BAAgB;IAChB,sBAAY;CACf,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,qBAAqB,CAAC,GAAG,OAA0B;IAC/D,MAAM,SAAS,GAAG,IAAI,qBAAS,EAAE,CAAC;IAClC,SAAS,CAAC,IAAI,CAAC,GAAG,uBAAe,EAAE,GAAG,OAAO,CAAC,CAAC;IAC/C,OAAO,SAAS,CAAC;AACrB,CAAC;AAJD,sDAIC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 { ContainerModule } from 'inversify';
|
|
17
|
+
import '../../../css/command-palette.css';
|
|
18
|
+
declare const glspBoundsModule: ContainerModule;
|
|
19
|
+
export default glspBoundsModule;
|
|
20
|
+
//# sourceMappingURL=di.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"di.config.d.ts","sourceRoot":"","sources":["../../../src/features/bounds/di.config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAK5C,OAAO,kCAAkC,CAAC;AAI1C,QAAA,MAAM,gBAAgB,iBAYpB,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/********************************************************************************
|
|
4
|
+
* Copyright (c) 2022 EclipseSource and others.
|
|
5
|
+
*
|
|
6
|
+
* This program and the accompanying materials are made available under the
|
|
7
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
8
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
9
|
+
*
|
|
10
|
+
* This Source Code may also be made available under the following Secondary
|
|
11
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
12
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
13
|
+
* with the GNU Classpath Exception which is available at
|
|
14
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
15
|
+
*
|
|
16
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
17
|
+
********************************************************************************/
|
|
18
|
+
const inversify_1 = require("inversify");
|
|
19
|
+
const sprotty_1 = require("sprotty");
|
|
20
|
+
require("../../../css/command-palette.css");
|
|
21
|
+
const types_1 = require("../../base/types");
|
|
22
|
+
const glsp_hidden_bounds_updater_1 = require("./glsp-hidden-bounds-updater");
|
|
23
|
+
const glspBoundsModule = new inversify_1.ContainerModule((bind, _unbind, isBound, _rebind) => {
|
|
24
|
+
(0, sprotty_1.configureCommand)({ bind, isBound }, sprotty_1.SetBoundsCommand);
|
|
25
|
+
(0, sprotty_1.configureCommand)({ bind, isBound }, sprotty_1.RequestBoundsCommand);
|
|
26
|
+
bind(sprotty_1.HiddenBoundsUpdater).toSelf().inSingletonScope();
|
|
27
|
+
bind(glsp_hidden_bounds_updater_1.GLSPHiddenBoundsUpdater).toSelf().inSingletonScope();
|
|
28
|
+
bind(types_1.TYPES.HiddenVNodePostprocessor).toService(glsp_hidden_bounds_updater_1.GLSPHiddenBoundsUpdater);
|
|
29
|
+
bind(types_1.TYPES.Layouter).to(sprotty_1.Layouter).inSingletonScope();
|
|
30
|
+
bind(types_1.TYPES.LayoutRegistry).to(sprotty_1.LayoutRegistry).inSingletonScope();
|
|
31
|
+
(0, sprotty_1.configureLayout)({ bind, isBound }, sprotty_1.VBoxLayouter.KIND, sprotty_1.VBoxLayouter);
|
|
32
|
+
(0, sprotty_1.configureLayout)({ bind, isBound }, sprotty_1.HBoxLayouter.KIND, sprotty_1.HBoxLayouter);
|
|
33
|
+
(0, sprotty_1.configureLayout)({ bind, isBound }, sprotty_1.StackLayouter.KIND, sprotty_1.StackLayouter);
|
|
34
|
+
});
|
|
35
|
+
exports.default = glspBoundsModule;
|
|
36
|
+
//# sourceMappingURL=di.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"di.config.js","sourceRoot":"","sources":["../../../src/features/bounds/di.config.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,yCAA4C;AAC5C,qCAGiB;AACjB,4CAA0C;AAC1C,4CAAyC;AACzC,6EAAuE;AAEvE,MAAM,gBAAgB,GAAG,IAAI,2BAAe,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IAC7E,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,0BAAgB,CAAC,CAAC;IACtD,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,8BAAoB,CAAC,CAAC;IAC1D,IAAI,CAAC,6BAAmB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACtD,IAAI,CAAC,oDAAuB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC1D,IAAI,CAAC,aAAK,CAAC,wBAAwB,CAAC,CAAC,SAAS,CAAC,oDAAuB,CAAC,CAAC;IACxE,IAAI,CAAC,aAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,kBAAQ,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACrD,IAAI,CAAC,aAAK,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,wBAAc,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAEjE,IAAA,yBAAe,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,sBAAY,CAAC,IAAI,EAAE,sBAAY,CAAC,CAAC;IACpE,IAAA,yBAAe,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,sBAAY,CAAC,IAAI,EAAE,sBAAY,CAAC,CAAC;IACpE,IAAA,yBAAe,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,uBAAa,CAAC,IAAI,EAAE,uBAAa,CAAC,CAAC;AAC1E,CAAC,CAAC,CAAC;AAEH,kBAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 { Action, ComputedBoundsAction, ElementAndRoutingPoints } from '@eclipse-glsp/protocol';
|
|
17
|
+
import { VNode } from 'snabbdom';
|
|
18
|
+
import { EdgeRouterRegistry, HiddenBoundsUpdater, SModelElement, SRoutableElement } from 'sprotty';
|
|
19
|
+
/**
|
|
20
|
+
* Grabs the bounds from hidden SVG DOM elements, applies layouts, collects routes and fires {@link ComputedBoundsAction}s.
|
|
21
|
+
*
|
|
22
|
+
* The actions will contain the bound, alignment, and routing points of elements.
|
|
23
|
+
*/
|
|
24
|
+
export declare class GLSPHiddenBoundsUpdater extends HiddenBoundsUpdater {
|
|
25
|
+
protected readonly edgeRouterRegistry?: EdgeRouterRegistry;
|
|
26
|
+
protected element2route: ElementAndRoutingPoints[];
|
|
27
|
+
protected edges: SRoutableElement[];
|
|
28
|
+
protected nodes: VNode[];
|
|
29
|
+
decorate(vnode: VNode, element: SModelElement): VNode;
|
|
30
|
+
postUpdate(cause?: Action): void;
|
|
31
|
+
protected captureActions(call: () => void): Action[];
|
|
32
|
+
protected enhanceAction(action: ComputedBoundsAction): ComputedBoundsAction;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=glsp-hidden-bounds-updater.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glsp-hidden-bounds-updater.d.ts","sourceRoot":"","sources":["../../../src/features/bounds/glsp-hidden-bounds-updater.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EACH,MAAM,EAAE,oBAAoB,EAAY,uBAAuB,EAElE,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAqB,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGtH;;;;GAIG;AACH,qBACa,uBAAwB,SAAQ,mBAAmB;IAEpB,SAAS,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IAEnG,SAAS,CAAC,aAAa,EAAE,uBAAuB,EAAE,CAAM;IACxD,SAAS,CAAC,KAAK,EAAE,gBAAgB,EAAE,CAAM;IACzC,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,CAAM;IAErB,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,GAAG,KAAK;IAQrD,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAOzC,SAAS,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,IAAI,GAAG,MAAM,EAAE;IAYpD,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB;CAI9E"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2022 EclipseSource and others.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made available under the
|
|
6
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
*
|
|
9
|
+
* This Source Code may also be made available under the following Secondary
|
|
10
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
* with the GNU Classpath Exception which is available at
|
|
13
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
*
|
|
15
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
+
********************************************************************************/
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.GLSPHiddenBoundsUpdater = void 0;
|
|
28
|
+
const protocol_1 = require("@eclipse-glsp/protocol");
|
|
29
|
+
const inversify_1 = require("inversify");
|
|
30
|
+
const sprotty_1 = require("sprotty");
|
|
31
|
+
const smodel_util_1 = require("../../utils/smodel-util");
|
|
32
|
+
/**
|
|
33
|
+
* Grabs the bounds from hidden SVG DOM elements, applies layouts, collects routes and fires {@link ComputedBoundsAction}s.
|
|
34
|
+
*
|
|
35
|
+
* The actions will contain the bound, alignment, and routing points of elements.
|
|
36
|
+
*/
|
|
37
|
+
let GLSPHiddenBoundsUpdater = class GLSPHiddenBoundsUpdater extends sprotty_1.HiddenBoundsUpdater {
|
|
38
|
+
constructor() {
|
|
39
|
+
super(...arguments);
|
|
40
|
+
this.element2route = [];
|
|
41
|
+
this.edges = [];
|
|
42
|
+
this.nodes = [];
|
|
43
|
+
}
|
|
44
|
+
decorate(vnode, element) {
|
|
45
|
+
super.decorate(vnode, element);
|
|
46
|
+
if ((0, smodel_util_1.isRoutable)(element)) {
|
|
47
|
+
this.element2route.push((0, smodel_util_1.calcElementAndRoute)(element, this.edgeRouterRegistry));
|
|
48
|
+
}
|
|
49
|
+
return vnode;
|
|
50
|
+
}
|
|
51
|
+
postUpdate(cause) {
|
|
52
|
+
const actions = this.captureActions(() => super.postUpdate(cause));
|
|
53
|
+
actions.filter(action => protocol_1.ComputedBoundsAction.is(action))
|
|
54
|
+
.forEach(action => this.actionDispatcher.dispatch(this.enhanceAction(action)));
|
|
55
|
+
this.element2route = [];
|
|
56
|
+
}
|
|
57
|
+
captureActions(call) {
|
|
58
|
+
const capturingActionDispatcher = new CapturingActionDispatcher();
|
|
59
|
+
const actualActionDispatcher = this.actionDispatcher;
|
|
60
|
+
this.actionDispatcher = capturingActionDispatcher;
|
|
61
|
+
try {
|
|
62
|
+
call();
|
|
63
|
+
return capturingActionDispatcher.actions;
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
this.actionDispatcher = actualActionDispatcher;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
enhanceAction(action) {
|
|
70
|
+
action.routes = this.element2route.length === 0 ? undefined : this.element2route;
|
|
71
|
+
return action;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, inversify_1.inject)(sprotty_1.EdgeRouterRegistry),
|
|
76
|
+
(0, inversify_1.optional)(),
|
|
77
|
+
__metadata("design:type", sprotty_1.EdgeRouterRegistry)
|
|
78
|
+
], GLSPHiddenBoundsUpdater.prototype, "edgeRouterRegistry", void 0);
|
|
79
|
+
GLSPHiddenBoundsUpdater = __decorate([
|
|
80
|
+
(0, inversify_1.injectable)()
|
|
81
|
+
], GLSPHiddenBoundsUpdater);
|
|
82
|
+
exports.GLSPHiddenBoundsUpdater = GLSPHiddenBoundsUpdater;
|
|
83
|
+
class CapturingActionDispatcher {
|
|
84
|
+
constructor() {
|
|
85
|
+
this.actions = [];
|
|
86
|
+
}
|
|
87
|
+
async dispatch(action) {
|
|
88
|
+
this.actions.push(action);
|
|
89
|
+
}
|
|
90
|
+
async dispatchAll(actions) {
|
|
91
|
+
this.actions.push(...actions);
|
|
92
|
+
}
|
|
93
|
+
async request(action) {
|
|
94
|
+
// ignore, not needed for our purposes
|
|
95
|
+
return new protocol_1.Deferred().promise;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=glsp-hidden-bounds-updater.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glsp-hidden-bounds-updater.js","sourceRoot":"","sources":["../../../src/features/bounds/glsp-hidden-bounds-updater.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;;;;AAElF,qDAGgC;AAChC,yCAAyD;AAEzD,qCAAsH;AACtH,yDAA0E;AAE1E;;;;GAIG;AAEH,IAAa,uBAAuB,GAApC,MAAa,uBAAwB,SAAQ,6B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AAM,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC;QACjF,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAA;AArC2C;IAAvC,IAAA,kBAAM,EAAC,4BAAkB,CAAC;IAAE,IAAA,oBAAQ,GAAE;8BAAyC,4BAAkB;mEAAC;AAF1F,uBAAuB;IADnC,IAAA,sBAAU,GAAE;GACA,uBAAuB,CAuCnC;AAvCY,0DAAuB;AAyCpC,MAAM,yBAAyB;IAA/B;QACa,YAAO,GAAa,EAAE,CAAC;IAcpC,CAAC;IAZG,KAAK,CAAC,QAAQ,CAAC,MAAc;QACzB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAiB;QAC/B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,OAAO,CAA6B,MAA0B;QAChE,sCAAsC;QACtC,OAAO,IAAI,mBAAQ,EAAO,CAAC,OAAO,CAAC;IACvC,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"di.config.d.ts","sourceRoot":"","sources":["../../../src/features/tools/di.config.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"di.config.d.ts","sourceRoot":"","sources":["../../../src/features/tools/di.config.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAkBxD;;;GAGG;AACH,eAAO,MAAM,WAAW,iBAsBtB,CAAC;AAEH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC;IAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAA;CAAE,GAAG,IAAI,CAI1G;AAED;;GAEG;AACH,eAAO,MAAM,mCAAmC,iBAE9C,CAAC"}
|
|
@@ -28,6 +28,7 @@ const delete_tool_1 = require("./delete-tool");
|
|
|
28
28
|
const edge_creation_tool_1 = require("./edge-creation-tool");
|
|
29
29
|
const edge_edit_tool_1 = require("./edge-edit-tool");
|
|
30
30
|
const enable_default_tools_on_focus_loss_1 = require("./enable-default-tools-on-focus-loss");
|
|
31
|
+
const glsp_manhattan_edge_router_1 = require("./glsp-manhattan-edge-router");
|
|
31
32
|
const marquee_mouse_tool_1 = require("./marquee-mouse-tool");
|
|
32
33
|
const marquee_tool_1 = require("./marquee-tool");
|
|
33
34
|
const model_1 = require("./model");
|
|
@@ -53,6 +54,8 @@ exports.toolsModule = new inversify_1.ContainerModule((bind, _unbind, isBound, r
|
|
|
53
54
|
(0, sprotty_1.configureActionHandler)({ bind, isBound }, protocol_1.TriggerEdgeCreationAction.KIND, edge_creation_tool_1.EdgeCreationTool);
|
|
54
55
|
bind(glsp_svg_exporter_1.GLSPSvgExporter).toSelf().inSingletonScope();
|
|
55
56
|
rebind(types_1.TYPES.SvgExporter).toService(glsp_svg_exporter_1.GLSPSvgExporter);
|
|
57
|
+
bind(glsp_manhattan_edge_router_1.GSLPManhattanEdgeRouter).toSelf().inSingletonScope();
|
|
58
|
+
rebind(sprotty_1.ManhattanEdgeRouter).toService(glsp_manhattan_edge_router_1.GSLPManhattanEdgeRouter);
|
|
56
59
|
});
|
|
57
60
|
function configureMarqueeTool(context) {
|
|
58
61
|
(0, sprotty_1.configureModelElement)(context, marquee_tool_feedback_1.MARQUEE, model_1.MarqueeNode, view_1.MarqueeView);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"di.config.js","sourceRoot":"","sources":["../../../src/features/tools/di.config.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,qDAA8F;AAC9F,yCAAwD;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AAC;IACxC,IAAA,gCAAsB,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,oCAAyB,CAAC,IAAI,EAAE,qCAAgB,CAAC,CAAC;IAC5F,IAAA,gCAAsB,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,oCAAyB,CAAC,IAAI,EAAE,qCAAgB,CAAC,CAAC;IAE5F,IAAI,CAAC,mCAAe,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAClD,MAAM,CAAC,aAAK,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,mCAAe,CAAC,CAAC;IAErD,IAAI,CAAC,oDAAuB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC1D,MAAM,CAAC,6BAAmB,CAAC,CAAC,SAAS,CAAC,oDAAuB,CAAC,CAAC;AACnE,CAAC,CAAC,CAAC;AAEH,SAAgB,oBAAoB,CAAC,OAA+D;IAChG,IAAA,+BAAqB,EAAC,OAAO,EAAE,+BAAO,EAAE,mBAAW,EAAE,kBAAW,CAAC,CAAC;IAClE,OAAO,CAAC,IAAI,CAAC,aAAK,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,0BAAW,CAAC,CAAC;IACjD,OAAO,CAAC,IAAI,CAAC,aAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,qCAAgB,CAAC,CAAC;AACnD,CAAC;AAJD,oDAIC;AAED;;GAEG;AACU,QAAA,mCAAmC,GAAG,IAAI,2BAAe,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IAC9F,IAAA,gCAAsB,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,6CAAuB,CAAC,IAAI,EAAE,yEAAoC,CAAC,CAAC;AAClH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 { ManhattanEdgeRouter, ResolvedHandleMove, SRoutableElement } from 'sprotty';
|
|
17
|
+
export declare class GSLPManhattanEdgeRouter extends ManhattanEdgeRouter {
|
|
18
|
+
protected applyInnerHandleMoves(edge: SRoutableElement, moves: ResolvedHandleMove[]): void;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=glsp-manhattan-edge-router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glsp-manhattan-edge-router.d.ts","sourceRoot":"","sources":["../../../src/features/tools/glsp-manhattan-edge-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAGlF,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEpF,qBAAa,uBAAwB,SAAQ,mBAAmB;cACzC,qBAAqB,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,kBAAkB,EAAE,GAAG,IAAI;CAoCtG"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2022 EclipseSource and others.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made available under the
|
|
6
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
*
|
|
9
|
+
* This Source Code may also be made available under the following Secondary
|
|
10
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
* with the GNU Classpath Exception which is available at
|
|
13
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
*
|
|
15
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
+
********************************************************************************/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.GSLPManhattanEdgeRouter = void 0;
|
|
19
|
+
const protocol_1 = require("@eclipse-glsp/protocol");
|
|
20
|
+
const sprotty_1 = require("sprotty");
|
|
21
|
+
class GSLPManhattanEdgeRouter extends sprotty_1.ManhattanEdgeRouter {
|
|
22
|
+
applyInnerHandleMoves(edge, moves) {
|
|
23
|
+
const route = this.route(edge);
|
|
24
|
+
const routingPoints = edge.routingPoints;
|
|
25
|
+
const minimalPointDistance = this.getOptions(edge).minimalPointDistance;
|
|
26
|
+
moves.forEach(move => {
|
|
27
|
+
const handle = move.handle;
|
|
28
|
+
const index = handle.pointIndex;
|
|
29
|
+
const correctedX = this.correctX(routingPoints, index, move.toPosition.x, minimalPointDistance);
|
|
30
|
+
const correctedY = this.correctY(routingPoints, index, move.toPosition.y, minimalPointDistance);
|
|
31
|
+
switch (handle.kind) {
|
|
32
|
+
case 'manhattan-50%':
|
|
33
|
+
if (index < 0) {
|
|
34
|
+
if (routingPoints.length === 0) {
|
|
35
|
+
routingPoints.push({ x: correctedX, y: correctedY });
|
|
36
|
+
move.handle.pointIndex = 0;
|
|
37
|
+
}
|
|
38
|
+
else if ((0, protocol_1.almostEquals)(route[0].x, route[1].x)) {
|
|
39
|
+
this.alignX(routingPoints, 0, correctedX);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.alignY(routingPoints, 0, correctedY);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else if (index < routingPoints.length - 1) {
|
|
46
|
+
if ((0, protocol_1.almostEquals)(routingPoints[index].x, routingPoints[index + 1].x)) {
|
|
47
|
+
this.alignX(routingPoints, index, correctedX);
|
|
48
|
+
this.alignX(routingPoints, index + 1, correctedX);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
this.alignY(routingPoints, index, correctedY);
|
|
52
|
+
this.alignY(routingPoints, index + 1, correctedY);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
if ((0, protocol_1.almostEquals)(route[route.length - 2].x, route[route.length - 1].x)) {
|
|
57
|
+
this.alignX(routingPoints, routingPoints.length - 1, correctedX);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.alignY(routingPoints, routingPoints.length - 1, correctedY);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.GSLPManhattanEdgeRouter = GSLPManhattanEdgeRouter;
|
|
69
|
+
//# sourceMappingURL=glsp-manhattan-edge-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glsp-manhattan-edge-router.js","sourceRoot":"","sources":["../../../src/features/tools/glsp-manhattan-edge-router.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAElF,qDAAsD;AACtD,qCAAoF;AAEpF,MAAa,uBAAwB,SAAQ,6BAAmB;IACzC,qBAAqB,CAAC,IAAsB,EAAE,KAA2B;QACxF,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/B,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACzC,MAAM,oBAAoB,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CA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I,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;4BAC9C,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;yBACrD;6BAAM;4BACH,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;4BAC9C,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;yBACrD;qBACJ;yBAAM;wBACH,IAAI,IAAA,uBAAY,EAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;4BACpE,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;yBACpE;6BACI;4BAAE,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;yBAAE;qBAC7E;oBACD,MAAM;aACb;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AArCD,0DAqCC"}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import { ElementAndBounds, ElementAndRoutingPoints, SModelElementSchema, TypeGuard } from '@eclipse-glsp/protocol';
|
|
17
|
-
import { BoundsAware, EdgeRouterRegistry, ModelIndexImpl, Selectable, SModelElement, SRoutableElement, SRoutingHandle } from 'sprotty';
|
|
17
|
+
import { BoundsAware, EdgeRouterRegistry, ModelIndexImpl, RoutedPoint, Selectable, SModelElement, SRoutableElement, SRoutingHandle } from 'sprotty';
|
|
18
18
|
import { FluentIterable } from 'sprotty/lib/utils/iterable';
|
|
19
19
|
/**
|
|
20
20
|
* Helper type to represent a filter predicate for {@link SModelElement}s. This is used to retrieve
|
|
@@ -132,15 +132,36 @@ export declare function toElementAndBounds(element: BoundsAwareModelElement): El
|
|
|
132
132
|
* @returns The corresponding {@link ElementAndRoutingPoints} for the given element.
|
|
133
133
|
*/
|
|
134
134
|
export declare function toElementAndRoutingPoints(element: SRoutableElement): ElementAndRoutingPoints;
|
|
135
|
+
/** Pure routing point data kinds. */
|
|
136
|
+
export declare const ROUTING_POINT_KINDS: string[];
|
|
137
|
+
/** Pure route data kinds. */
|
|
138
|
+
export declare const ROUTE_KINDS: string[];
|
|
135
139
|
/**
|
|
136
140
|
* Helper function to calculate the {@link ElementAndRoutingPoints} for a given {@link SRoutableElement}.
|
|
137
141
|
* If client layout is activated, i.e., the edge routing registry is given and has a router for the element, then the routing
|
|
138
142
|
* points from the calculated route are used, otherwise we use the already specified routing points of the {@link SRoutableElement}.
|
|
139
143
|
* @param element The element to translate.
|
|
140
|
-
* @param
|
|
144
|
+
* @param routerRegistry the edge router registry.
|
|
141
145
|
* @returns The corresponding {@link ElementAndRoutingPoints} for the given element.
|
|
142
146
|
*/
|
|
143
|
-
export declare function calcElementAndRoutingPoints(element: SRoutableElement,
|
|
147
|
+
export declare function calcElementAndRoutingPoints(element: SRoutableElement, routerRegistry?: EdgeRouterRegistry): ElementAndRoutingPoints;
|
|
148
|
+
/**
|
|
149
|
+
* Helper function to calculate the route for a given {@link SRoutableElement}.
|
|
150
|
+
* If client layout is activated, i.e., the edge routing registry is given and has a router for the element, then the points
|
|
151
|
+
* from the calculated route are used, otherwise we use the already specified routing points of the {@link SRoutableElement}.
|
|
152
|
+
* @param element The element to translate.
|
|
153
|
+
* @param routerRegistry the edge router registry.
|
|
154
|
+
* @returns The corresponding route for the given element.
|
|
155
|
+
*/
|
|
156
|
+
export declare function calcElementAndRoute(element: SRoutableElement, routerRegistry?: EdgeRouterRegistry): ElementAndRoutingPoints;
|
|
157
|
+
/**
|
|
158
|
+
* Helper function to calculate the route for a given {@link SRoutableElement}.
|
|
159
|
+
* @param element The element to translate.
|
|
160
|
+
* @param routerRegistry the edge router registry.
|
|
161
|
+
* @param pointKinds the routing point kinds that should be considered.
|
|
162
|
+
* @returns The corresponding route for the given element.
|
|
163
|
+
*/
|
|
164
|
+
export declare function calcRoute(element: SRoutableElement, routerRegistry: EdgeRouterRegistry, pointKinds?: string[]): RoutedPoint[] | undefined;
|
|
144
165
|
/**
|
|
145
166
|
* Checks if the model is compatible with the passed type string.
|
|
146
167
|
* (either has the same type or a subtype of this type)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smodel-util.d.ts","sourceRoot":"","sources":["../../src/utils/smodel-util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,
|
|
1
|
+
{"version":3,"file":"smodel-util.d.ts","sourceRoot":"","sources":["../../src/utils/smodel-util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EACU,gBAAgB,EAAE,uBAAuB,EAAiB,mBAAmB,EAC1F,SAAS,EACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACH,WAAW,EACX,kBAAkB,EAIN,cAAc,EAC1B,WAAW,EACX,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,cAAc,EACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D;;;;GAIG;AACH,oBAAY,oBAAoB,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,KAAK,YAAY,IAAI,aAAa,GAAG,CAAC,CAAC;AAEzG;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,aAAa,GAAG,CAAC,CAAC,CAEtH;AAED;;;;;;GAMG;AACH,w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,CAG5G;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,mBAAmB,GAAG,MAAM,GAAG,MAAM,CAM5F"}
|
package/lib/utils/smodel-util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getElementTypeId = exports.hasCompatibleType = exports.calcElementAndRoutingPoints = exports.toElementAndRoutingPoints = exports.toElementAndBounds = exports.isSelectableAndBoundsAware = exports.isRoutingHandle = exports.isRoutable = exports.isNonRoutableSelectedBoundsAware = exports.isNonRoutableSelectedMovableBoundsAware = exports.removeCssClasses = exports.addCssClasses = exports.isNotUndefined = exports.hasSelectedElements = exports.getSelectedElementCount = exports.getElements = exports.getMatchingElements = exports.forEachElement = exports.filter = void 0;
|
|
3
|
+
exports.getElementTypeId = exports.hasCompatibleType = exports.calcRoute = exports.calcElementAndRoute = exports.calcElementAndRoutingPoints = exports.ROUTE_KINDS = exports.ROUTING_POINT_KINDS = exports.toElementAndRoutingPoints = exports.toElementAndBounds = exports.isSelectableAndBoundsAware = exports.isRoutingHandle = exports.isRoutable = exports.isNonRoutableSelectedBoundsAware = exports.isNonRoutableSelectedMovableBoundsAware = exports.removeCssClasses = exports.addCssClasses = exports.isNotUndefined = exports.hasSelectedElements = exports.getSelectedElementCount = exports.getElements = exports.getMatchingElements = exports.forEachElement = exports.filter = void 0;
|
|
4
4
|
/********************************************************************************
|
|
5
5
|
* Copyright (c) 2019-2022 EclipseSource and others.
|
|
6
6
|
*
|
|
@@ -196,21 +196,54 @@ function toElementAndRoutingPoints(element) {
|
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
198
|
exports.toElementAndRoutingPoints = toElementAndRoutingPoints;
|
|
199
|
+
/** Pure routing point data kinds. */
|
|
200
|
+
exports.ROUTING_POINT_KINDS = ['linear', 'bezier-junction'];
|
|
201
|
+
/** Pure route data kinds. */
|
|
202
|
+
exports.ROUTE_KINDS = [...exports.ROUTING_POINT_KINDS, 'source', 'target'];
|
|
199
203
|
/**
|
|
200
204
|
* Helper function to calculate the {@link ElementAndRoutingPoints} for a given {@link SRoutableElement}.
|
|
201
205
|
* If client layout is activated, i.e., the edge routing registry is given and has a router for the element, then the routing
|
|
202
206
|
* points from the calculated route are used, otherwise we use the already specified routing points of the {@link SRoutableElement}.
|
|
203
207
|
* @param element The element to translate.
|
|
204
|
-
* @param
|
|
208
|
+
* @param routerRegistry the edge router registry.
|
|
205
209
|
* @returns The corresponding {@link ElementAndRoutingPoints} for the given element.
|
|
206
210
|
*/
|
|
207
|
-
function calcElementAndRoutingPoints(element,
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
const clientRoutingPoints = router === null || router === void 0 ? void 0 : router.route(element).filter((point, idx, route) => idx === route.findIndex(otherPoint => otherPoint.x === point.x && otherPoint.y === point.y)).filter(point => point.kind === 'linear' || point.kind === 'bezier-junction');
|
|
211
|
-
return { elementId: element.id, newRoutingPoints: clientRoutingPoints || element.routingPoints };
|
|
211
|
+
function calcElementAndRoutingPoints(element, routerRegistry) {
|
|
212
|
+
const newRoutingPoints = routerRegistry ? calcRoute(element, routerRegistry, exports.ROUTING_POINT_KINDS) : element.routingPoints;
|
|
213
|
+
return { elementId: element.id, newRoutingPoints };
|
|
212
214
|
}
|
|
213
215
|
exports.calcElementAndRoutingPoints = calcElementAndRoutingPoints;
|
|
216
|
+
/**
|
|
217
|
+
* Helper function to calculate the route for a given {@link SRoutableElement}.
|
|
218
|
+
* If client layout is activated, i.e., the edge routing registry is given and has a router for the element, then the points
|
|
219
|
+
* from the calculated route are used, otherwise we use the already specified routing points of the {@link SRoutableElement}.
|
|
220
|
+
* @param element The element to translate.
|
|
221
|
+
* @param routerRegistry the edge router registry.
|
|
222
|
+
* @returns The corresponding route for the given element.
|
|
223
|
+
*/
|
|
224
|
+
function calcElementAndRoute(element, routerRegistry) {
|
|
225
|
+
var _a, _b;
|
|
226
|
+
let route = routerRegistry ? calcRoute(element, routerRegistry, exports.ROUTE_KINDS) : undefined;
|
|
227
|
+
if (!route) {
|
|
228
|
+
// add source and target to the routing points
|
|
229
|
+
route = [...element.routingPoints];
|
|
230
|
+
route.splice(0, 0, ((_a = element.source) === null || _a === void 0 ? void 0 : _a.position) || protocol_1.Point.ORIGIN);
|
|
231
|
+
route.push(((_b = element.target) === null || _b === void 0 ? void 0 : _b.position) || protocol_1.Point.ORIGIN);
|
|
232
|
+
}
|
|
233
|
+
return { elementId: element.id, newRoutingPoints: route };
|
|
234
|
+
}
|
|
235
|
+
exports.calcElementAndRoute = calcElementAndRoute;
|
|
236
|
+
/**
|
|
237
|
+
* Helper function to calculate the route for a given {@link SRoutableElement}.
|
|
238
|
+
* @param element The element to translate.
|
|
239
|
+
* @param routerRegistry the edge router registry.
|
|
240
|
+
* @param pointKinds the routing point kinds that should be considered.
|
|
241
|
+
* @returns The corresponding route for the given element.
|
|
242
|
+
*/
|
|
243
|
+
function calcRoute(element, routerRegistry, pointKinds) {
|
|
244
|
+
return routerRegistry === null || routerRegistry === void 0 ? void 0 : routerRegistry.get(element.routerKind).route(element).filter((point, idx, fullRoute) => idx === fullRoute.findIndex(otherPoint => otherPoint.x === point.x && otherPoint.y === point.y)).filter(point => !pointKinds || pointKinds.includes(point.kind));
|
|
245
|
+
}
|
|
246
|
+
exports.calcRoute = calcRoute;
|
|
214
247
|
/**
|
|
215
248
|
* Checks if the model is compatible with the passed type string.
|
|
216
249
|
* (either has the same type or a subtype of this type)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smodel-util.js","sourceRoot":"","sources":["../../src/utils/smodel-util.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,
|
|
1
|
+
{"version":3,"file":"smodel-util.js","sourceRoot":"","sources":["../../src/utils/smodel-util.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,qDAGgC;AAChC,qCAY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E,CAAC,CAAC,UAAU,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AACzE,CAAC;AAJD,8BAIC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,KAAmD,EAAE,IAAY;IAC/F,MAAM,SAAS,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC1C,OAAO,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC3E,CAAC;AAHD,8CAGC;AAED;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,KAAmD;IAChF,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,OAAO,KAAe,CAAC;KAC1B;SAAM;QACH,OAAQ,KAAa,CAAC,MAAM,CAAW,CAAC;KAC3C;AACL,CAAC;AAND,4CAMC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eclipse-glsp/client",
|
|
3
|
-
"version": "1.1.0-next.
|
|
3
|
+
"version": "1.1.0-next.a07a5f7.197+a07a5f7",
|
|
4
4
|
"description": "A sprotty-based client for GLSP",
|
|
5
5
|
"license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",
|
|
6
6
|
"keywords": [
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"css"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@eclipse-glsp/protocol": "1.1.0-next.
|
|
37
|
+
"@eclipse-glsp/protocol": "1.1.0-next.a07a5f7.197+a07a5f7",
|
|
38
38
|
"autocompleter": "5.1.0",
|
|
39
39
|
"sprotty": "0.13.0-next.1c4343c.328"
|
|
40
40
|
},
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
},
|
|
59
59
|
"main": "lib/index",
|
|
60
60
|
"types": "lib/index",
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "a07a5f7b4431c017641a824a9f54d1e228ab473a"
|
|
62
62
|
}
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
|
|
17
17
|
import { Container, ContainerModule } from 'inversify';
|
|
18
18
|
import {
|
|
19
|
-
boundsModule,
|
|
20
19
|
buttonModule,
|
|
21
20
|
defaultModule,
|
|
22
21
|
edgeIntersectionModule,
|
|
@@ -30,6 +29,7 @@ import {
|
|
|
30
29
|
routingModule,
|
|
31
30
|
zorderModule
|
|
32
31
|
} from 'sprotty';
|
|
32
|
+
import glspBoundsModule from '../features/bounds/di.config';
|
|
33
33
|
import glspCommandPaletteModule from '../features/command-palette/di.config';
|
|
34
34
|
import glspContextMenuModule from '../features/context-menu/di.config';
|
|
35
35
|
import { glspServerCopyPasteModule } from '../features/copy-paste/di.config';
|
|
@@ -52,13 +52,13 @@ import defaultGLSPModule from './di.config';
|
|
|
52
52
|
export const DEFAULT_MODULES = [
|
|
53
53
|
defaultModule,
|
|
54
54
|
defaultGLSPModule,
|
|
55
|
-
boundsModule,
|
|
56
55
|
buttonModule,
|
|
57
56
|
edgeIntersectionModule,
|
|
58
57
|
edgeLayoutModule,
|
|
59
58
|
expandModule,
|
|
60
59
|
exportModule,
|
|
61
60
|
fadeModule,
|
|
61
|
+
glspBoundsModule,
|
|
62
62
|
glspCommandPaletteModule,
|
|
63
63
|
glspContextMenuModule,
|
|
64
64
|
glspDecorationModule,
|
|
@@ -0,0 +1,39 @@
|
|
|
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 { ContainerModule } from 'inversify';
|
|
17
|
+
import {
|
|
18
|
+
configureCommand, configureLayout, HBoxLayouter, HiddenBoundsUpdater, Layouter,
|
|
19
|
+
LayoutRegistry, RequestBoundsCommand, SetBoundsCommand, StackLayouter, VBoxLayouter
|
|
20
|
+
} from 'sprotty';
|
|
21
|
+
import '../../../css/command-palette.css';
|
|
22
|
+
import { TYPES } from '../../base/types';
|
|
23
|
+
import { GLSPHiddenBoundsUpdater } from './glsp-hidden-bounds-updater';
|
|
24
|
+
|
|
25
|
+
const glspBoundsModule = new ContainerModule((bind, _unbind, isBound, _rebind) => {
|
|
26
|
+
configureCommand({ bind, isBound }, SetBoundsCommand);
|
|
27
|
+
configureCommand({ bind, isBound }, RequestBoundsCommand);
|
|
28
|
+
bind(HiddenBoundsUpdater).toSelf().inSingletonScope();
|
|
29
|
+
bind(GLSPHiddenBoundsUpdater).toSelf().inSingletonScope();
|
|
30
|
+
bind(TYPES.HiddenVNodePostprocessor).toService(GLSPHiddenBoundsUpdater);
|
|
31
|
+
bind(TYPES.Layouter).to(Layouter).inSingletonScope();
|
|
32
|
+
bind(TYPES.LayoutRegistry).to(LayoutRegistry).inSingletonScope();
|
|
33
|
+
|
|
34
|
+
configureLayout({ bind, isBound }, VBoxLayouter.KIND, VBoxLayouter);
|
|
35
|
+
configureLayout({ bind, isBound }, HBoxLayouter.KIND, HBoxLayouter);
|
|
36
|
+
configureLayout({ bind, isBound }, StackLayouter.KIND, StackLayouter);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export default glspBoundsModule;
|
|
@@ -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
|
+
}
|
|
@@ -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 {
|
|
@@ -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,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 {
|
|
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
|
-
|
|
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
|
|
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,
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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
|
/**
|