@eclipse-glsp/client 2.7.0-next.2 → 2.7.0-next.21
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.d.ts.map +1 -1
- package/lib/base/action-dispatcher.js +9 -3
- package/lib/base/action-dispatcher.js.map +1 -1
- package/lib/base/default.module.d.ts.map +1 -1
- package/lib/base/default.module.js +2 -0
- package/lib/base/default.module.js.map +1 -1
- package/lib/base/editor-context-service.d.ts +4 -3
- package/lib/base/editor-context-service.d.ts.map +1 -1
- package/lib/base/editor-context-service.js +11 -1
- package/lib/base/editor-context-service.js.map +1 -1
- package/lib/base/model/glsp-model-source.d.ts +5 -2
- package/lib/base/model/glsp-model-source.d.ts.map +1 -1
- package/lib/base/model/glsp-model-source.js +28 -1
- package/lib/base/model/glsp-model-source.js.map +1 -1
- package/lib/base/selection-service.d.ts +4 -3
- package/lib/base/selection-service.d.ts.map +1 -1
- package/lib/base/selection-service.js +6 -1
- package/lib/base/selection-service.js.map +1 -1
- package/lib/base/shortcuts/available-shortcuts-extension.d.ts +1 -1
- package/lib/base/shortcuts/available-shortcuts-extension.d.ts.map +1 -1
- package/lib/base/shortcuts/available-shortcuts-extension.js +3 -4
- package/lib/base/shortcuts/available-shortcuts-extension.js.map +1 -1
- package/lib/base/view/mouse-tool.d.ts +1 -1
- package/lib/base/view/mouse-tool.d.ts.map +1 -1
- package/lib/base/view/mouse-tool.js +3 -19
- package/lib/base/view/mouse-tool.js.map +1 -1
- package/lib/features/change-bounds/move-element-handler.d.ts +2 -3
- package/lib/features/change-bounds/move-element-handler.d.ts.map +1 -1
- package/lib/features/change-bounds/move-element-handler.js +2 -3
- package/lib/features/change-bounds/move-element-handler.js.map +1 -1
- package/lib/features/change-bounds/resize/resize-handler.d.ts +2 -3
- package/lib/features/change-bounds/resize/resize-handler.d.ts.map +1 -1
- package/lib/features/change-bounds/resize/resize-handler.js +2 -3
- package/lib/features/change-bounds/resize/resize-handler.js.map +1 -1
- package/lib/features/helper-lines/helper-line-feedback.d.ts +1 -1
- package/lib/features/helper-lines/helper-line-feedback.d.ts.map +1 -1
- package/lib/features/helper-lines/helper-line-feedback.js +2 -3
- package/lib/features/helper-lines/helper-line-feedback.js.map +1 -1
- package/lib/features/label-edit-ui/label-edit-ui.d.ts +4 -1
- package/lib/features/label-edit-ui/label-edit-ui.d.ts.map +1 -1
- package/lib/features/label-edit-ui/label-edit-ui.js +38 -1
- package/lib/features/label-edit-ui/label-edit-ui.js.map +1 -1
- package/lib/features/routing/edge-router.d.ts +2 -1
- package/lib/features/routing/edge-router.d.ts.map +1 -1
- package/lib/features/routing/edge-router.js +2 -1
- package/lib/features/routing/edge-router.js.map +1 -1
- package/lib/features/routing/routing-module.d.ts +1 -1
- package/lib/features/routing/routing-module.d.ts.map +1 -1
- package/lib/features/routing/routing-module.js +7 -1
- package/lib/features/routing/routing-module.js.map +1 -1
- package/lib/features/routing/sticky-manhattan-anchors.d.ts +29 -0
- package/lib/features/routing/sticky-manhattan-anchors.d.ts.map +1 -0
- package/lib/features/routing/sticky-manhattan-anchors.js +62 -0
- package/lib/features/routing/sticky-manhattan-anchors.js.map +1 -0
- package/lib/features/routing/sticky-manhattan-edge-router.d.ts +107 -0
- package/lib/features/routing/sticky-manhattan-edge-router.d.ts.map +1 -0
- package/lib/features/routing/sticky-manhattan-edge-router.js +626 -0
- package/lib/features/routing/sticky-manhattan-edge-router.js.map +1 -0
- package/lib/features/search-palette/search-palette.d.ts +2 -2
- package/lib/features/search-palette/search-palette.d.ts.map +1 -1
- package/lib/features/search-palette/search-palette.js +3 -4
- package/lib/features/search-palette/search-palette.js.map +1 -1
- package/lib/features/select/select-module.d.ts +1 -1
- package/lib/features/select/select-module.js +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.d.ts +2 -3
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js +2 -3
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js.map +1 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/views/gedge-view-with-gaps-on-intersections.d.ts +39 -0
- package/lib/views/gedge-view-with-gaps-on-intersections.d.ts.map +1 -0
- package/lib/views/gedge-view-with-gaps-on-intersections.js +85 -0
- package/lib/views/gedge-view-with-gaps-on-intersections.js.map +1 -0
- package/lib/views/rounded-corner-manhattan-edge-view.d.ts +58 -0
- package/lib/views/rounded-corner-manhattan-edge-view.d.ts.map +1 -0
- package/lib/views/rounded-corner-manhattan-edge-view.js +170 -0
- package/lib/views/rounded-corner-manhattan-edge-view.js.map +1 -0
- package/package.json +4 -6
- package/src/base/action-dispatcher.ts +6 -3
- package/src/base/default.module.ts +4 -0
- package/src/base/editor-context-service.ts +17 -5
- package/src/base/model/glsp-model-source.ts +35 -1
- package/src/base/selection-service.ts +11 -2
- package/src/base/shortcuts/available-shortcuts-extension.ts +3 -4
- package/src/base/view/mouse-tool.ts +4 -19
- package/src/features/change-bounds/move-element-handler.ts +3 -2
- package/src/features/change-bounds/resize/resize-handler.ts +4 -3
- package/src/features/helper-lines/helper-line-feedback.ts +6 -4
- package/src/features/label-edit-ui/label-edit-ui.ts +36 -3
- package/src/features/routing/edge-router.ts +2 -2
- package/src/features/routing/routing-module.ts +8 -1
- package/src/features/routing/sticky-manhattan-anchors.ts +53 -0
- package/src/features/routing/sticky-manhattan-edge-router.spec.ts +212 -0
- package/src/features/routing/sticky-manhattan-edge-router.ts +713 -0
- package/src/features/search-palette/search-palette.ts +3 -4
- package/src/features/select/select-module.ts +1 -1
- package/src/features/tools/change-bounds/change-bounds-tool-move-feedback.ts +13 -3
- package/src/index.ts +5 -1
- package/src/views/gedge-view-with-gaps-on-intersections.tsx +99 -0
- package/src/views/rounded-corner-manhattan-edge-view.ts +171 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.RoundedCornerManhattanEdgeView = void 0;
|
|
10
|
+
/********************************************************************************
|
|
11
|
+
* Copyright (c) 2022-2026 Imixs Software Solutions GmbH.
|
|
12
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
13
|
+
*
|
|
14
|
+
* This program and the accompanying materials are made available under the
|
|
15
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
16
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
17
|
+
*
|
|
18
|
+
* This Source Code may also be made available under the following Secondary
|
|
19
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
20
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
21
|
+
* with the GNU Classpath Exception which is available at
|
|
22
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
23
|
+
*
|
|
24
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
25
|
+
********************************************************************************/
|
|
26
|
+
const sprotty_1 = require("@eclipse-glsp/sprotty");
|
|
27
|
+
const inversify_1 = require("inversify");
|
|
28
|
+
const gedge_view_with_gaps_on_intersections_1 = require("./gedge-view-with-gaps-on-intersections");
|
|
29
|
+
/**
|
|
30
|
+
* Manhattan edge view with rounded bends rendered as quadratic Béziers.
|
|
31
|
+
* Non-orthogonal inputs render as sharp corners. Radius is clamped per corner;
|
|
32
|
+
* override {@link cornerRadius} or {@link computeMaxRadius} to tune.
|
|
33
|
+
*
|
|
34
|
+
* Inherits gap / line-jump rendering from {@link GEdgeViewWithGapsOnIntersections}.
|
|
35
|
+
* The rendered line splices intersection fragments between points; the mouse-
|
|
36
|
+
* handle overlay skips them so the hit area stays contiguous.
|
|
37
|
+
*
|
|
38
|
+
* Based on Ralph Soika's `BPMNEdgeView`; see
|
|
39
|
+
* https://github.com/eclipse-glsp/glsp/discussions/1642.
|
|
40
|
+
*/
|
|
41
|
+
let RoundedCornerManhattanEdgeView = class RoundedCornerManhattanEdgeView extends gedge_view_with_gaps_on_intersections_1.GEdgeViewWithGapsOnIntersections {
|
|
42
|
+
constructor() {
|
|
43
|
+
super(...arguments);
|
|
44
|
+
/** Target corner radius in pixels. The effective radius is clamped per corner. */
|
|
45
|
+
this.cornerRadius = 10;
|
|
46
|
+
/** Lower bound for the effective radius, even on very short adjacent segments. */
|
|
47
|
+
this.minCornerRadius = 2;
|
|
48
|
+
/** Upper fraction of the shorter adjacent segment to use for the radius. */
|
|
49
|
+
this.maxRadiusFactor = 0.45;
|
|
50
|
+
/** Segment length (px) below which {@link shortSegmentRadiusFactor} tightens the radius further. */
|
|
51
|
+
this.shortSegmentThreshold = 5;
|
|
52
|
+
/** Fraction of the shorter adjacent segment to use as the radius below {@link shortSegmentThreshold}. */
|
|
53
|
+
this.shortSegmentRadiusFactor = 0.3;
|
|
54
|
+
}
|
|
55
|
+
createPathForSegments(segments, edge, addIntersectionPoints, args) {
|
|
56
|
+
if (segments.length === 0) {
|
|
57
|
+
return '';
|
|
58
|
+
}
|
|
59
|
+
let path = `M ${segments[0].x},${segments[0].y}`;
|
|
60
|
+
for (let i = 1; i < segments.length; i++) {
|
|
61
|
+
const p = segments[i];
|
|
62
|
+
if (addIntersectionPoints && (0, sprotty_1.isIntersectingRoutedPoint)(p)) {
|
|
63
|
+
const effective = this.filterCornerZoneIntersections(p, segments, i);
|
|
64
|
+
if (effective.intersections.length > 0) {
|
|
65
|
+
path += this.intersectionPath(edge, segments, effective, args);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (i < segments.length - 1) {
|
|
69
|
+
const prev = segments[i - 1];
|
|
70
|
+
const next = segments[i + 1];
|
|
71
|
+
const radius = this.computeMaxRadius(p, prev, next);
|
|
72
|
+
path += this.renderRoundedCorner(p, prev, next, radius);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
path += ` L ${p.x},${p.y}`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return path;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Drops intersections inside either endpoint's rounded-corner zone (padded
|
|
82
|
+
* by the gap's skip-offset). The gap fragment can't be placed there without
|
|
83
|
+
* drawing backward into the curve on one side, and the crossing is hidden
|
|
84
|
+
* behind the curve anyway.
|
|
85
|
+
*/
|
|
86
|
+
filterCornerZoneIntersections(intersectingPoint, segments, pointIndex) {
|
|
87
|
+
const p1 = segments[pointIndex - 1];
|
|
88
|
+
const p2 = segments[pointIndex];
|
|
89
|
+
const p1Threshold = this.getCornerRadius(segments, pointIndex - 1) + this.skipOffsetBefore;
|
|
90
|
+
const p2Threshold = this.getCornerRadius(segments, pointIndex) + this.skipOffsetAfter;
|
|
91
|
+
const filtered = intersectingPoint.intersections.filter(intersection => sprotty_1.Point.maxDistance(intersection.intersectionPoint, p1) > p1Threshold &&
|
|
92
|
+
sprotty_1.Point.maxDistance(intersection.intersectionPoint, p2) > p2Threshold);
|
|
93
|
+
return { ...intersectingPoint, intersections: filtered };
|
|
94
|
+
}
|
|
95
|
+
/** Curve radius at `segments[cornerIndex]`, or 0 for source / target. */
|
|
96
|
+
getCornerRadius(segments, cornerIndex) {
|
|
97
|
+
if (cornerIndex <= 0 || cornerIndex >= segments.length - 1) {
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
const corner = segments[cornerIndex];
|
|
101
|
+
const prev = segments[cornerIndex - 1];
|
|
102
|
+
const next = segments[cornerIndex + 1];
|
|
103
|
+
return this.computeMaxRadius(corner, prev, next);
|
|
104
|
+
}
|
|
105
|
+
/** SVG fragment for one rounded corner; falls back to `L` if not a right angle. */
|
|
106
|
+
renderRoundedCorner(corner, prev, next, radius) {
|
|
107
|
+
// Round only right-angle bends; diagonal / collinear inputs render sharp.
|
|
108
|
+
const horizIn = sprotty_1.Point.isHorizontalAligned(prev, corner);
|
|
109
|
+
const vertIn = sprotty_1.Point.isVerticalAligned(prev, corner);
|
|
110
|
+
const horizOut = sprotty_1.Point.isHorizontalAligned(corner, next);
|
|
111
|
+
const vertOut = sprotty_1.Point.isVerticalAligned(corner, next);
|
|
112
|
+
const isRightAngle = (horizIn && vertOut && !vertIn) || (vertIn && horizOut && !horizIn);
|
|
113
|
+
if (!isRightAngle) {
|
|
114
|
+
return ` L ${corner.x},${corner.y}`;
|
|
115
|
+
}
|
|
116
|
+
if (prev.x < corner.x && corner.y < next.y) {
|
|
117
|
+
// right → down
|
|
118
|
+
return ` L ${corner.x - radius},${corner.y} Q ${corner.x},${corner.y} ${corner.x},${corner.y + radius}`;
|
|
119
|
+
}
|
|
120
|
+
if (prev.y < corner.y && corner.x < next.x) {
|
|
121
|
+
// down → right
|
|
122
|
+
return ` L ${corner.x},${corner.y - radius} Q ${corner.x},${corner.y} ${corner.x + radius},${corner.y}`;
|
|
123
|
+
}
|
|
124
|
+
if (prev.x < corner.x && corner.y > next.y) {
|
|
125
|
+
// right → up
|
|
126
|
+
return ` L ${corner.x - radius},${corner.y} Q ${corner.x},${corner.y} ${corner.x},${corner.y - radius}`;
|
|
127
|
+
}
|
|
128
|
+
if (prev.y > corner.y && corner.x < next.x) {
|
|
129
|
+
// up → right
|
|
130
|
+
return ` L ${corner.x},${corner.y + radius} Q ${corner.x},${corner.y} ${corner.x + radius},${corner.y}`;
|
|
131
|
+
}
|
|
132
|
+
if (prev.y < corner.y && corner.x > next.x) {
|
|
133
|
+
// down → left
|
|
134
|
+
return ` L ${corner.x},${corner.y - radius} Q ${corner.x},${corner.y} ${corner.x - radius},${corner.y}`;
|
|
135
|
+
}
|
|
136
|
+
if (prev.x > corner.x && corner.y < next.y) {
|
|
137
|
+
// left → down
|
|
138
|
+
return ` L ${corner.x + radius},${corner.y} Q ${corner.x},${corner.y} ${corner.x},${corner.y + radius}`;
|
|
139
|
+
}
|
|
140
|
+
if (prev.y > corner.y && corner.x > next.x) {
|
|
141
|
+
// up → left
|
|
142
|
+
return ` L ${corner.x},${corner.y + radius} Q ${corner.x},${corner.y} ${corner.x - radius},${corner.y}`;
|
|
143
|
+
}
|
|
144
|
+
if (prev.x > corner.x && corner.y > next.y) {
|
|
145
|
+
// left → up
|
|
146
|
+
return ` L ${corner.x + radius},${corner.y} Q ${corner.x},${corner.y} ${corner.x},${corner.y - radius}`;
|
|
147
|
+
}
|
|
148
|
+
return ` L ${corner.x},${corner.y}`;
|
|
149
|
+
}
|
|
150
|
+
/** Clamps {@link cornerRadius} to a fraction of the shorter adjacent segment. */
|
|
151
|
+
computeMaxRadius(corner, prev, next) {
|
|
152
|
+
const segBefore = sprotty_1.Point.maxDistance(corner, prev);
|
|
153
|
+
const segAfter = sprotty_1.Point.maxDistance(next, corner);
|
|
154
|
+
if (segBefore === 0 || segAfter === 0) {
|
|
155
|
+
return this.minCornerRadius;
|
|
156
|
+
}
|
|
157
|
+
const shortest = Math.min(segBefore, segAfter);
|
|
158
|
+
let radius = Math.min(this.cornerRadius, shortest * this.maxRadiusFactor);
|
|
159
|
+
if (shortest < this.shortSegmentThreshold) {
|
|
160
|
+
radius = Math.min(radius, shortest * this.shortSegmentRadiusFactor);
|
|
161
|
+
}
|
|
162
|
+
radius = Math.min(radius, shortest / 2);
|
|
163
|
+
return Math.max(this.minCornerRadius, radius);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
exports.RoundedCornerManhattanEdgeView = RoundedCornerManhattanEdgeView;
|
|
167
|
+
exports.RoundedCornerManhattanEdgeView = RoundedCornerManhattanEdgeView = __decorate([
|
|
168
|
+
(0, inversify_1.injectable)()
|
|
169
|
+
], RoundedCornerManhattanEdgeView);
|
|
170
|
+
//# sourceMappingURL=rounded-corner-manhattan-edge-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rounded-corner-manhattan-edge-view.js","sourceRoot":"","sources":["../../src/views/rounded-corner-manhattan-edge-view.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;;kFAekF;AAClF,mDAA6G;AAC7G,yCAAuC;AAEvC,mGAA2F;AAE3F;;;;;;;;;;;GAWG;AAEI,IAAM,8BAA8B,GAApC,MAAM,8BAA+B,SAAQ,wEAAgC;IAA7E;;QACH,kFAAkF;QAC/D,iBAAY,GAAW,EAAE,CAAC;QAE7C,kFAAkF;QAC/D,oBAAe,GAAW,CAAC,CAAC;QAE/C,4EAA4E;QACzD,oBAAe,GAAW,IAAI,CAAC;QAElD,oGAAoG;QACjF,0BAAqB,GAAW,CAAC,CAAC;QAErD,yGAAyG;QACtF,6BAAwB,GAAW,GAAG,CAAC;IA0H9D,CAAC;IAxHsB,qBAAqB,CAAC,QAAiB,EAAE,IAAW,EAAE,qBAA8B,EAAE,IAAgB;QACrH,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,EAAE,CAAC;QACd,CAAC;QACD,IAAI,IAAI,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YACtB,IAAI,qBAAqB,IAAI,IAAA,mCAAyB,EAAC,CAAC,CA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C,CAAC;QACxE,CAAC;QACD,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;CACJ,CAAA;AAxIY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,sBAAU,GAAE;GACA,8BAA8B,CAwI1C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eclipse-glsp/client",
|
|
3
|
-
"version": "2.7.0-next.
|
|
3
|
+
"version": "2.7.0-next.21+760b637",
|
|
4
4
|
"description": "A sprotty-based client for GLSP",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eclipse",
|
|
@@ -46,16 +46,14 @@
|
|
|
46
46
|
"watch": "tsc -w"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@eclipse-glsp/sprotty": "2.7.0-next.
|
|
49
|
+
"@eclipse-glsp/sprotty": "2.7.0-next.21+760b637",
|
|
50
50
|
"autocompleter": "^9.1.2",
|
|
51
51
|
"file-saver": "^2.0.5",
|
|
52
|
-
"lodash": "4.17.23",
|
|
53
52
|
"snabbdom": "~3.5.1",
|
|
54
53
|
"vscode-jsonrpc": "8.2.0"
|
|
55
54
|
},
|
|
56
55
|
"devDependencies": {
|
|
57
|
-
"@types/file-saver": "^2.0.5"
|
|
58
|
-
"@types/lodash": "4.14.191"
|
|
56
|
+
"@types/file-saver": "^2.0.5"
|
|
59
57
|
},
|
|
60
58
|
"peerDependencies": {
|
|
61
59
|
"inversify": "^6.1.3"
|
|
@@ -63,5 +61,5 @@
|
|
|
63
61
|
"publishConfig": {
|
|
64
62
|
"access": "public"
|
|
65
63
|
},
|
|
66
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "760b637de00febf2dd2cd0b4a97cc90b7cff1bca"
|
|
67
65
|
}
|
|
@@ -195,7 +195,7 @@ export class GLSPActionDispatcher extends ActionDispatcher implements IGModelRoo
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
override request<Res extends ResponseAction>(action: RequestAction<Res>): Promise<Res> {
|
|
198
|
-
if (!action.requestId
|
|
198
|
+
if (!action.requestId || action.requestId === '') {
|
|
199
199
|
// No request id has been specified. So we use a generated one.
|
|
200
200
|
action.requestId = RequestAction.generateRequestId();
|
|
201
201
|
}
|
|
@@ -214,13 +214,16 @@ export class GLSPActionDispatcher extends ActionDispatcher implements IGModelRoo
|
|
|
214
214
|
*/
|
|
215
215
|
requestUntil<Res extends ResponseAction>(
|
|
216
216
|
action: RequestAction<Res>,
|
|
217
|
-
timeoutMs = 2000,
|
|
217
|
+
timeoutMs: number = action.timeout ?? 2000,
|
|
218
218
|
rejectOnTimeout = false
|
|
219
219
|
): Promise<Res | undefined> {
|
|
220
|
-
if (!action.requestId
|
|
220
|
+
if (!action.requestId || action.requestId === '') {
|
|
221
221
|
// No request id has been specified. So we use a generated one.
|
|
222
222
|
action.requestId = RequestAction.generateRequestId();
|
|
223
223
|
}
|
|
224
|
+
// Stamp the effective timeout onto the action so the receiving side
|
|
225
|
+
// (handleServerRequest/handleClientRequest) can respect it.
|
|
226
|
+
action.timeout = timeoutMs;
|
|
224
227
|
|
|
225
228
|
const requestId = action.requestId;
|
|
226
229
|
const timeout = setTimeout(() => {
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
import {
|
|
17
17
|
ActionHandlerRegistry,
|
|
18
18
|
FeatureModule,
|
|
19
|
+
GetEditorContextAction,
|
|
20
|
+
GetSelectionAction,
|
|
19
21
|
KeyTool,
|
|
20
22
|
LocationPostprocessor,
|
|
21
23
|
MousePositionTracker,
|
|
@@ -83,6 +85,7 @@ export const defaultModule = new FeatureModule(
|
|
|
83
85
|
|
|
84
86
|
configureActionHandler(context, SetEditModeAction.KIND, EditorContextService);
|
|
85
87
|
configureActionHandler(context, SetDirtyStateAction.KIND, EditorContextService);
|
|
88
|
+
configureActionHandler(context, GetEditorContextAction.KIND, EditorContextService);
|
|
86
89
|
|
|
87
90
|
bind(FocusTracker).toSelf().inSingletonScope();
|
|
88
91
|
bind(TYPES.IDiagramStartup).toService(FocusTracker);
|
|
@@ -121,6 +124,7 @@ export const defaultModule = new FeatureModule(
|
|
|
121
124
|
bind(SelectionService).toSelf().inSingletonScope();
|
|
122
125
|
bind(TYPES.IGModelRootListener).toService(SelectionService);
|
|
123
126
|
bind(TYPES.IDiagramStartup).toService(SelectionService);
|
|
127
|
+
configureActionHandler(context, GetSelectionAction.KIND, SelectionService);
|
|
124
128
|
|
|
125
129
|
// Feedback Support ------------------------------------
|
|
126
130
|
// Generic re-usable feedback modifying css classes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2020-
|
|
2
|
+
* Copyright (c) 2020-2026 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
|
|
@@ -21,14 +21,14 @@ import {
|
|
|
21
21
|
DisposableCollection,
|
|
22
22
|
EditMode,
|
|
23
23
|
EditorContext,
|
|
24
|
+
EditorContextResult,
|
|
24
25
|
Emitter,
|
|
25
26
|
Event,
|
|
26
|
-
findParentByFeature,
|
|
27
27
|
GModelElement,
|
|
28
28
|
GModelRoot,
|
|
29
|
+
GetEditorContextAction,
|
|
29
30
|
IActionDispatcher,
|
|
30
31
|
IActionHandler,
|
|
31
|
-
isViewport,
|
|
32
32
|
LazyInjector,
|
|
33
33
|
MaybePromise,
|
|
34
34
|
MousePositionTracker,
|
|
@@ -37,7 +37,9 @@ import {
|
|
|
37
37
|
SetEditModeAction,
|
|
38
38
|
TYPES,
|
|
39
39
|
ValueChange,
|
|
40
|
-
Viewport
|
|
40
|
+
Viewport,
|
|
41
|
+
findParentByFeature,
|
|
42
|
+
isViewport
|
|
41
43
|
} from '@eclipse-glsp/sprotty';
|
|
42
44
|
import { inject, injectable, postConstruct, preDestroy } from 'inversify';
|
|
43
45
|
import { FocusChange, FocusTracker } from './focus/focus-tracker';
|
|
@@ -177,6 +179,8 @@ export class EditorContextService implements IActionHandler, Disposable, IDiagra
|
|
|
177
179
|
return {
|
|
178
180
|
selectedElementIds: Array.from(this.selectionService.getSelectedElementIDs()),
|
|
179
181
|
lastMousePosition: this.mousePositionTracker.lastPositionOnDiagram,
|
|
182
|
+
viewport: this.viewportData,
|
|
183
|
+
canvasBounds: this.canvasBounds,
|
|
180
184
|
args
|
|
181
185
|
};
|
|
182
186
|
}
|
|
@@ -185,18 +189,26 @@ export class EditorContextService implements IActionHandler, Disposable, IDiagra
|
|
|
185
189
|
return {
|
|
186
190
|
selectedElementIds,
|
|
187
191
|
lastMousePosition: this.mousePositionTracker.lastPositionOnDiagram,
|
|
192
|
+
viewport: this.viewportData,
|
|
193
|
+
canvasBounds: this.canvasBounds,
|
|
188
194
|
args
|
|
189
195
|
};
|
|
190
196
|
}
|
|
191
197
|
|
|
192
|
-
handle(action: Action): void {
|
|
198
|
+
handle(action: Action): Action | void {
|
|
193
199
|
if (SetEditModeAction.is(action)) {
|
|
194
200
|
this.handleSetEditModeAction(action);
|
|
195
201
|
} else if (SetDirtyStateAction.is(action)) {
|
|
196
202
|
this.handleSetDirtyStateAction(action);
|
|
203
|
+
} else if (GetEditorContextAction.is(action)) {
|
|
204
|
+
return this.handleGetEditorContext(action);
|
|
197
205
|
}
|
|
198
206
|
}
|
|
199
207
|
|
|
208
|
+
protected handleGetEditorContext(action: GetEditorContextAction): EditorContextResult {
|
|
209
|
+
return EditorContextResult.create(this.get(), { responseId: action.requestId });
|
|
210
|
+
}
|
|
211
|
+
|
|
200
212
|
protected handleSetEditModeAction(action: SetEditModeAction): void {
|
|
201
213
|
const oldValue = this._editMode;
|
|
202
214
|
this._editMode = action.editMode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2023-
|
|
2
|
+
* Copyright (c) 2023-2026 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
|
|
@@ -22,10 +22,14 @@ import {
|
|
|
22
22
|
DisposeClientSessionParameters,
|
|
23
23
|
GLSPClient,
|
|
24
24
|
GModelRootSchema,
|
|
25
|
+
IActionDispatcher,
|
|
25
26
|
ILogger,
|
|
26
27
|
InitializeClientSessionParameters,
|
|
27
28
|
InitializeResult,
|
|
28
29
|
ModelSource,
|
|
30
|
+
RejectAction,
|
|
31
|
+
RequestAction,
|
|
32
|
+
ResponseAction,
|
|
29
33
|
TYPES
|
|
30
34
|
} from '@eclipse-glsp/sprotty';
|
|
31
35
|
import { inject, injectable, preDestroy } from 'inversify';
|
|
@@ -94,6 +98,8 @@ export class GLSPModelSource extends ModelSource implements Disposable {
|
|
|
94
98
|
@inject(TYPES.IDiagramOptions)
|
|
95
99
|
protected options: IDiagramOptions;
|
|
96
100
|
|
|
101
|
+
declare readonly actionDispatcher: IActionDispatcher;
|
|
102
|
+
|
|
97
103
|
protected toDispose = new DisposableCollection();
|
|
98
104
|
clientId: string;
|
|
99
105
|
|
|
@@ -164,9 +170,37 @@ export class GLSPModelSource extends ModelSource implements Disposable {
|
|
|
164
170
|
const action = message.action;
|
|
165
171
|
ServerAction.mark(action);
|
|
166
172
|
this.logger.log(this, 'receiving', action);
|
|
173
|
+
if (RequestAction.is(action)) {
|
|
174
|
+
this.handleServerRequest(action);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
167
177
|
this.actionDispatcher.dispatch(action);
|
|
168
178
|
}
|
|
169
179
|
|
|
180
|
+
// Fire-and-forget: intentionally not awaited by messageReceived()
|
|
181
|
+
protected async handleServerRequest(action: RequestAction<ResponseAction>): Promise<void> {
|
|
182
|
+
try {
|
|
183
|
+
const response =
|
|
184
|
+
action.timeout !== undefined
|
|
185
|
+
? await this.actionDispatcher.requestUntil(action, action.timeout, true)
|
|
186
|
+
: await this.actionDispatcher.request(action);
|
|
187
|
+
if (response) {
|
|
188
|
+
this.sendResponseToServer(response);
|
|
189
|
+
}
|
|
190
|
+
} catch (error) {
|
|
191
|
+
this.logger.error(this, `Failed to handle server request '${action.kind}' (${action.requestId})`, error);
|
|
192
|
+
const reject = RejectAction.create(`Failed to handle request '${action.kind}' (${action.requestId})`, {
|
|
193
|
+
responseId: action.requestId,
|
|
194
|
+
detail: error?.toString?.()
|
|
195
|
+
});
|
|
196
|
+
this.sendResponseToServer(reject);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
protected sendResponseToServer(response: ResponseAction): void {
|
|
201
|
+
this.forwardToServer(response);
|
|
202
|
+
}
|
|
203
|
+
|
|
170
204
|
override initialize(registry: GLSPActionHandlerRegistry): void {
|
|
171
205
|
// Registering actions here is discouraged and it's recommended
|
|
172
206
|
// to implemented dedicated action handlers.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2026 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
|
|
@@ -23,12 +23,15 @@ import {
|
|
|
23
23
|
Emitter,
|
|
24
24
|
Event,
|
|
25
25
|
GChildElement,
|
|
26
|
+
GetSelectionAction,
|
|
26
27
|
GModelElement,
|
|
27
28
|
GModelRoot,
|
|
29
|
+
IActionHandler,
|
|
28
30
|
ILogger,
|
|
29
31
|
LazyInjector,
|
|
30
32
|
SelectAction,
|
|
31
33
|
SelectAllAction,
|
|
34
|
+
SelectionResult,
|
|
32
35
|
SprottySelectAllCommand,
|
|
33
36
|
SprottySelectCommand,
|
|
34
37
|
TYPES,
|
|
@@ -60,7 +63,7 @@ export interface SelectionChange {
|
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
@injectable()
|
|
63
|
-
export class SelectionService implements IGModelRootListener, Disposable, IDiagramStartup {
|
|
66
|
+
export class SelectionService implements IGModelRootListener, IActionHandler, Disposable, IDiagramStartup {
|
|
64
67
|
@inject(TYPES.IFeedbackActionDispatcher)
|
|
65
68
|
protected feedbackDispatcher: IFeedbackActionDispatcher;
|
|
66
69
|
|
|
@@ -84,6 +87,12 @@ export class SelectionService implements IGModelRootListener, Disposable, IDiagr
|
|
|
84
87
|
this.lazyInjector.getAll<ISelectionListener>(TYPES.ISelectionListener).forEach(listener => this.addListener(listener));
|
|
85
88
|
}
|
|
86
89
|
|
|
90
|
+
handle(action: Action): Action | void {
|
|
91
|
+
if (GetSelectionAction.is(action)) {
|
|
92
|
+
return SelectionResult.create(this.getSelectedElementIDs(), action.requestId);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
87
96
|
@preDestroy()
|
|
88
97
|
dispose(): void {
|
|
89
98
|
this.toDispose.dispose();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2023-
|
|
2
|
+
* Copyright (c) 2023-2026 Business Informatics Group (TU Wien) and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
|
|
17
|
-
import { GModelRoot, matchesKeystroke, TYPES } from '@eclipse-glsp/sprotty';
|
|
17
|
+
import { GModelRoot, groupBy, matchesKeystroke, TYPES } from '@eclipse-glsp/sprotty';
|
|
18
18
|
import { inject, injectable } from 'inversify';
|
|
19
|
-
import { groupBy } from 'lodash';
|
|
20
19
|
import { GLSPAbstractUIExtension } from '../../base/ui-extension/ui-extension';
|
|
21
20
|
import { messages } from '../messages';
|
|
22
21
|
import type { IShortcutManager, ShortcutRegistration } from './shortcuts-manager';
|
|
@@ -79,7 +78,7 @@ export class AvailableShortcutsUIExtension extends GLSPAbstractUIExtension {
|
|
|
79
78
|
headerRow.appendChild(keybindingCell);
|
|
80
79
|
tableHead.appendChild(headerRow);
|
|
81
80
|
|
|
82
|
-
for (const [group, shortcuts] of
|
|
81
|
+
for (const [group, shortcuts] of grouped.entries()) {
|
|
83
82
|
tableBody.appendChild(this.createGroupHeader(group));
|
|
84
83
|
shortcuts.forEach(s => {
|
|
85
84
|
tableBody.appendChild(this.createEntry(s));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2026 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
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
Disposable,
|
|
19
19
|
GModelElement,
|
|
20
20
|
GModelRoot,
|
|
21
|
+
groupBy,
|
|
21
22
|
LazyInjector,
|
|
22
23
|
MaybePromise,
|
|
23
24
|
MouseListener,
|
|
@@ -51,7 +52,7 @@ export class GLSPMouseTool extends MouseTool implements IDiagramStartup {
|
|
|
51
52
|
|
|
52
53
|
override register(mouseListener: MouseListener): void {
|
|
53
54
|
super.register(mouseListener);
|
|
54
|
-
this.rankedMouseListeners = groupBy(this.mouseListeners, listener => Ranked.getRank(listener));
|
|
55
|
+
this.rankedMouseListeners = groupBy(this.mouseListeners, listener => Ranked.getRank(listener), true);
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
registerListener(mouseListener: MouseListener): Disposable {
|
|
@@ -61,7 +62,7 @@ export class GLSPMouseTool extends MouseTool implements IDiagramStartup {
|
|
|
61
62
|
|
|
62
63
|
override deregister(mouseListener: MouseListener): void {
|
|
63
64
|
super.deregister(mouseListener);
|
|
64
|
-
this.rankedMouseListeners = groupBy(this.mouseListeners, listener => Ranked.getRank(listener));
|
|
65
|
+
this.rankedMouseListeners = groupBy(this.mouseListeners, listener => Ranked.getRank(listener), true);
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
protected override handleEvent<K extends MouseListenerMethods>(methodName: K, model: GModelRoot, event: MouseEvent): void {
|
|
@@ -104,19 +105,3 @@ export class GLSPMouseTool extends MouseTool implements IDiagramStartup {
|
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
|
|
108
|
-
function groupBy<K, T>(array: Array<T>, keyFunction: (x: T) => K): Map<K, T[]> {
|
|
109
|
-
const unsortedMap = array.reduce((result: Map<K, T[]>, item: T) => {
|
|
110
|
-
const key = keyFunction(item);
|
|
111
|
-
if (!result.has(key)) {
|
|
112
|
-
result.set(key, [item]);
|
|
113
|
-
} else {
|
|
114
|
-
const entries = result.get(key);
|
|
115
|
-
if (entries) {
|
|
116
|
-
entries.push(item);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return result;
|
|
120
|
-
}, new Map<K, T[]>());
|
|
121
|
-
return new Map<K, T[]>([...unsortedMap.entries()].sort());
|
|
122
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2023-
|
|
2
|
+
* Copyright (c) 2023-2026 Business Informatics Group (TU Wien) 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
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import {
|
|
18
18
|
Action,
|
|
19
19
|
ChangeBoundsOperation,
|
|
20
|
+
DebouncedFunc,
|
|
20
21
|
ElementAndBounds,
|
|
21
22
|
ElementMove,
|
|
22
23
|
IActionDispatcher,
|
|
@@ -27,10 +28,10 @@ import {
|
|
|
27
28
|
MoveViewportAction,
|
|
28
29
|
Point,
|
|
29
30
|
TYPES,
|
|
31
|
+
debounce,
|
|
30
32
|
isBoundsAware
|
|
31
33
|
} from '@eclipse-glsp/sprotty';
|
|
32
34
|
import { inject, injectable, optional, postConstruct } from 'inversify';
|
|
33
|
-
import { DebouncedFunc, debounce } from 'lodash';
|
|
34
35
|
import { EditorContextService } from '../../base/editor-context-service';
|
|
35
36
|
import { IFeedbackActionDispatcher } from '../../base/feedback/feedback-action-dispatcher';
|
|
36
37
|
import { FeedbackEmitter } from '../../base/feedback/feedback-emitter';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2023-
|
|
2
|
+
* Copyright (c) 2023-2026 Business Informatics Group (TU Wien) 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
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import {
|
|
18
18
|
Action,
|
|
19
19
|
ChangeBoundsOperation,
|
|
20
|
+
DebouncedFunc,
|
|
20
21
|
Dimension,
|
|
21
22
|
ElementAndBounds,
|
|
22
23
|
GModelElement,
|
|
@@ -27,10 +28,10 @@ import {
|
|
|
27
28
|
ISnapper,
|
|
28
29
|
Point,
|
|
29
30
|
SetBoundsAction,
|
|
30
|
-
TYPES
|
|
31
|
+
TYPES,
|
|
32
|
+
debounce
|
|
31
33
|
} from '@eclipse-glsp/sprotty';
|
|
32
34
|
import { inject, injectable, optional, postConstruct } from 'inversify';
|
|
33
|
-
import { DebouncedFunc, debounce } from 'lodash';
|
|
34
35
|
import { EditorContextService } from '../../../base/editor-context-service';
|
|
35
36
|
import { IFeedbackActionDispatcher } from '../../../base/feedback/feedback-action-dispatcher';
|
|
36
37
|
import { FeedbackEmitter } from '../../../base/feedback/feedback-emitter';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2023-
|
|
2
|
+
* Copyright (c) 2023-2026 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
|
|
@@ -30,10 +30,10 @@ import {
|
|
|
30
30
|
equalUpTo,
|
|
31
31
|
isBoundsAware,
|
|
32
32
|
isDecoration,
|
|
33
|
-
isViewport
|
|
33
|
+
isViewport,
|
|
34
|
+
partition
|
|
34
35
|
} from '@eclipse-glsp/sprotty';
|
|
35
36
|
import { inject, injectable } from 'inversify';
|
|
36
|
-
import { partition } from 'lodash';
|
|
37
37
|
import '../../../css/helper-lines.css';
|
|
38
38
|
import { EditorContextService } from '../../base/editor-context-service';
|
|
39
39
|
import { FeedbackCommand } from '../../base/feedback/feedback-command';
|
|
@@ -125,7 +125,9 @@ export class DrawHelperLinesFeedbackCommand extends FeedbackCommand {
|
|
|
125
125
|
removeSelectionBounds(context.root);
|
|
126
126
|
const alignableElements = getMatchingElements(context.root.index, this.isAlignableElementPredicate);
|
|
127
127
|
this.log('All alignable elements: ', alignableElements);
|
|
128
|
-
const
|
|
128
|
+
const { match: referenceElements, rest: elements } = partition(alignableElements, (element): element is BoundsAwareModelElement =>
|
|
129
|
+
this.elementIds.includes(element.id)
|
|
130
|
+
);
|
|
129
131
|
this.log('Split alignable elements into reference elements and other elements: ', referenceElements, elements);
|
|
130
132
|
if (referenceElements.length === 0) {
|
|
131
133
|
this.log('--> No helper lines as we do not have any reference elements.');
|