@eclipse-glsp/client 2.2.0-next.331 → 2.2.0-next.333
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/css/debug.css +25 -0
- package/css/grid.css +20 -0
- package/css/keyboard-tool-palette.css +0 -6
- package/css/tool-palette.css +30 -26
- package/lib/base/model/diagram-loader.d.ts.map +1 -1
- package/lib/base/model/diagram-loader.js +6 -1
- package/lib/base/model/diagram-loader.js.map +1 -1
- package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.d.ts.map +1 -1
- package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.js +21 -7
- package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.js.map +1 -1
- package/lib/features/accessibility/resize-key-tool/resize-key-handler.d.ts +2 -4
- package/lib/features/accessibility/resize-key-tool/resize-key-handler.d.ts.map +1 -1
- package/lib/features/accessibility/resize-key-tool/resize-key-handler.js +11 -7
- package/lib/features/accessibility/resize-key-tool/resize-key-handler.js.map +1 -1
- package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts +5 -6
- package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts.map +1 -1
- package/lib/features/accessibility/view-key-tools/movement-key-tool.js +12 -8
- package/lib/features/accessibility/view-key-tools/movement-key-tool.js.map +1 -1
- package/lib/features/change-bounds/snap.d.ts +1 -22
- package/lib/features/change-bounds/snap.d.ts.map +1 -1
- package/lib/features/change-bounds/snap.js +1 -37
- package/lib/features/change-bounds/snap.js.map +1 -1
- package/lib/features/debug/debug-bounds-decorator.d.ts +35 -0
- package/lib/features/debug/debug-bounds-decorator.d.ts.map +1 -0
- package/lib/features/debug/debug-bounds-decorator.js +149 -0
- package/lib/features/debug/debug-bounds-decorator.js.map +1 -0
- package/lib/features/debug/debug-manager.d.ts +29 -0
- package/lib/features/debug/debug-manager.d.ts.map +1 -0
- package/lib/features/debug/debug-manager.js +72 -0
- package/lib/features/debug/debug-manager.js.map +1 -0
- package/lib/features/debug/debug-model.d.ts +37 -0
- package/lib/features/debug/debug-model.d.ts.map +1 -0
- package/lib/features/debug/debug-model.js +73 -0
- package/lib/features/debug/debug-model.js.map +1 -0
- package/lib/features/debug/debug-module.d.ts +19 -0
- package/lib/features/debug/debug-module.d.ts.map +1 -0
- package/lib/features/debug/debug-module.js +31 -0
- package/lib/features/debug/debug-module.js.map +1 -0
- package/lib/features/debug/index.d.ts +20 -0
- package/lib/features/debug/index.d.ts.map +1 -0
- package/lib/features/debug/index.js +36 -0
- package/lib/features/debug/index.js.map +1 -0
- package/lib/features/grid/grid-manager.d.ts +32 -0
- package/lib/features/grid/grid-manager.d.ts.map +1 -0
- package/lib/features/grid/grid-manager.js +74 -0
- package/lib/features/grid/grid-manager.js.map +1 -0
- package/lib/features/grid/grid-model.d.ts +37 -0
- package/lib/features/grid/grid-model.d.ts.map +1 -0
- package/lib/features/grid/grid-model.js +73 -0
- package/lib/features/grid/grid-model.js.map +1 -0
- package/lib/features/grid/grid-module.d.ts +19 -0
- package/lib/features/grid/grid-module.d.ts.map +1 -0
- package/lib/features/grid/grid-module.js +32 -0
- package/lib/features/grid/grid-module.js.map +1 -0
- package/lib/features/grid/grid-snapper.d.ts +45 -0
- package/lib/features/grid/grid-snapper.d.ts.map +1 -0
- package/lib/features/grid/grid-snapper.js +83 -0
- package/lib/features/grid/grid-snapper.js.map +1 -0
- package/lib/features/grid/grid.d.ts +18 -0
- package/lib/features/grid/grid.d.ts.map +1 -0
- package/lib/features/grid/grid.js +3 -0
- package/lib/features/grid/grid.js.map +1 -0
- package/lib/features/grid/index.d.ts +21 -0
- package/lib/features/grid/index.d.ts.map +1 -0
- package/lib/features/grid/index.js +37 -0
- package/lib/features/grid/index.js.map +1 -0
- package/lib/features/helper-lines/helper-line-manager-default.d.ts +4 -1
- package/lib/features/helper-lines/helper-line-manager-default.d.ts.map +1 -1
- package/lib/features/helper-lines/helper-line-manager-default.js +11 -1
- package/lib/features/helper-lines/helper-line-manager-default.js.map +1 -1
- package/lib/features/index.d.ts +2 -0
- package/lib/features/index.d.ts.map +1 -1
- package/lib/features/index.js +2 -0
- package/lib/features/index.js.map +1 -1
- package/lib/features/tool-palette/tool-palette.d.ts +7 -0
- package/lib/features/tool-palette/tool-palette.d.ts.map +1 -1
- package/lib/features/tool-palette/tool-palette.js +80 -2
- package/lib/features/tool-palette/tool-palette.js.map +1 -1
- package/lib/features/viewport/index.d.ts +1 -0
- package/lib/features/viewport/index.d.ts.map +1 -1
- package/lib/features/viewport/index.js +1 -0
- package/lib/features/viewport/index.js.map +1 -1
- package/lib/features/viewport/origin-viewport.d.ts +36 -0
- package/lib/features/viewport/origin-viewport.d.ts.map +1 -0
- package/lib/features/viewport/origin-viewport.js +75 -0
- package/lib/features/viewport/origin-viewport.js.map +1 -0
- package/lib/features/viewport/viewport-handler.d.ts +6 -4
- package/lib/features/viewport/viewport-handler.d.ts.map +1 -1
- package/lib/features/viewport/viewport-handler.js +13 -8
- package/lib/features/viewport/viewport-handler.js.map +1 -1
- package/lib/features/viewport/viewport-modules.d.ts.map +1 -1
- package/lib/features/viewport/viewport-modules.js +4 -2
- package/lib/features/viewport/viewport-modules.js.map +1 -1
- package/lib/views/base-view-module.d.ts.map +1 -1
- package/lib/views/base-view-module.js +3 -2
- package/lib/views/base-view-module.js.map +1 -1
- package/lib/views/ggraph-view.d.ts +26 -0
- package/lib/views/ggraph-view.d.ts.map +1 -0
- package/lib/views/ggraph-view.js +71 -0
- package/lib/views/ggraph-view.js.map +1 -0
- package/lib/views/glsp-projection-view.d.ts +6 -1
- package/lib/views/glsp-projection-view.d.ts.map +1 -1
- package/lib/views/glsp-projection-view.js +30 -6
- package/lib/views/glsp-projection-view.js.map +1 -1
- package/lib/views/index.d.ts +1 -0
- package/lib/views/index.d.ts.map +1 -1
- package/lib/views/index.js +1 -0
- package/lib/views/index.js.map +1 -1
- package/package.json +3 -3
- package/src/base/model/diagram-loader.ts +5 -1
- package/src/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.ts +24 -7
- package/src/features/accessibility/resize-key-tool/resize-key-handler.ts +9 -9
- package/src/features/accessibility/view-key-tools/movement-key-tool.ts +13 -11
- package/src/features/change-bounds/{snap.spec.ts → point-position-updater.spec.ts} +1 -12
- package/src/features/change-bounds/snap.ts +1 -24
- package/src/features/debug/debug-bounds-decorator.tsx +171 -0
- package/src/features/debug/debug-manager.ts +56 -0
- package/src/features/debug/debug-model.ts +63 -0
- package/src/features/debug/debug-module.ts +32 -0
- package/src/features/debug/index.ts +19 -0
- package/src/features/grid/grid-manager.ts +60 -0
- package/src/features/grid/grid-model.ts +62 -0
- package/src/features/grid/grid-module.ts +34 -0
- package/src/features/grid/grid-snapper.spec.ts +30 -0
- package/src/features/grid/grid-snapper.ts +59 -0
- package/src/features/grid/grid.ts +18 -0
- package/src/features/grid/index.ts +20 -0
- package/src/features/helper-lines/helper-line-manager-default.ts +10 -2
- package/src/features/index.ts +2 -0
- package/src/features/tool-palette/tool-palette.ts +80 -3
- package/src/features/viewport/index.ts +1 -0
- package/src/features/viewport/origin-viewport.ts +68 -0
- package/src/features/viewport/viewport-handler.ts +13 -7
- package/src/features/viewport/viewport-modules.ts +4 -2
- package/src/views/base-view-module.ts +3 -3
- package/src/views/ggraph-view.tsx +56 -0
- package/src/views/glsp-projection-view.tsx +34 -7
- package/src/views/index.ts +1 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2024 Axon Ivy AG 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
|
+
/* eslint-disable max-len */
|
|
17
|
+
|
|
18
|
+
import { Bounds, GModelElement, IVNodePostprocessor, Point, TYPES, isBoundsAware, setClass, svg } from '@eclipse-glsp/sprotty';
|
|
19
|
+
import { inject, injectable, optional } from 'inversify';
|
|
20
|
+
import { VNode } from 'snabbdom';
|
|
21
|
+
import { GGraph } from '../../model';
|
|
22
|
+
import { BoundsAwareModelElement } from '../../utils';
|
|
23
|
+
import { DebugManager } from './debug-manager';
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
26
|
+
const JSX = { createElement: svg };
|
|
27
|
+
|
|
28
|
+
@injectable()
|
|
29
|
+
export class DebugBoundsDecorator implements IVNodePostprocessor {
|
|
30
|
+
@inject(TYPES.IDebugManager) @optional() protected debugManager?: DebugManager;
|
|
31
|
+
|
|
32
|
+
decorate(vnode: VNode, element: GModelElement): VNode {
|
|
33
|
+
if (!this.debugManager?.isDebugEnabled) {
|
|
34
|
+
return vnode;
|
|
35
|
+
}
|
|
36
|
+
if (isBoundsAware(element)) {
|
|
37
|
+
this.decorateBoundsAware(vnode, element);
|
|
38
|
+
}
|
|
39
|
+
if (element instanceof GGraph) {
|
|
40
|
+
this.decorateGraph(vnode, element);
|
|
41
|
+
}
|
|
42
|
+
return vnode;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
postUpdate(): void {}
|
|
46
|
+
|
|
47
|
+
protected get decorationSize(): number {
|
|
48
|
+
return 5;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected decorateGraph(vnode: VNode, graph: GGraph): void {
|
|
52
|
+
setClass(vnode, 'debug-bounds', true);
|
|
53
|
+
const svgChild = vnode.children?.find(child => typeof child !== 'string' && child.sel === 'svg') as VNode | undefined;
|
|
54
|
+
const group = svgChild?.children?.find(child => typeof child !== 'string' && child.sel === 'g') as VNode | undefined;
|
|
55
|
+
group?.children?.push(this.renderOrigin(graph));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
protected renderOrigin(graph: GGraph): VNode {
|
|
59
|
+
return (
|
|
60
|
+
<polyline
|
|
61
|
+
class-debug-bounds-decoration={true}
|
|
62
|
+
class-debug-bounds-origin={true}
|
|
63
|
+
points={`0,${this.decorationSize} 0,0 ${this.decorationSize},0`}
|
|
64
|
+
>
|
|
65
|
+
<title>Origin = x: 0, y: 0</title>
|
|
66
|
+
</polyline>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
protected decorateBoundsAware(vnode: VNode, element: BoundsAwareModelElement): void {
|
|
71
|
+
setClass(vnode, 'debug-bounds', true);
|
|
72
|
+
vnode.children?.push(this.renderTopLeftCorner(element));
|
|
73
|
+
vnode.children?.push(this.renderTopRightCorner(element));
|
|
74
|
+
vnode.children?.push(this.renderBottomLeftCorner(element));
|
|
75
|
+
vnode.children?.push(this.renderBottomRightCorner(element));
|
|
76
|
+
vnode.children?.push(this.renderCenter(element));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
protected renderTopLeftCorner(element: BoundsAwareModelElement): VNode {
|
|
80
|
+
const position = Bounds.topLeft(element.bounds);
|
|
81
|
+
const topLeft = Bounds.topLeft(element.bounds);
|
|
82
|
+
const corner = Point.subtract(topLeft, position);
|
|
83
|
+
return (
|
|
84
|
+
<polyline
|
|
85
|
+
class-debug-bounds-decoration={true}
|
|
86
|
+
class-debug-bounds-top-left={true}
|
|
87
|
+
points={`${corner.x},${corner.y + this.decorationSize} ${corner.x},${corner.y} ${corner.x + this.decorationSize},${corner.y}`}
|
|
88
|
+
>
|
|
89
|
+
<title>
|
|
90
|
+
Top Left = x: {topLeft.x}, y: {topLeft.y}
|
|
91
|
+
</title>
|
|
92
|
+
</polyline>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
protected renderTopRightCorner(element: BoundsAwareModelElement): VNode {
|
|
97
|
+
const position = Bounds.topLeft(element.bounds);
|
|
98
|
+
const topRight = Bounds.topRight(element.bounds);
|
|
99
|
+
const corner = Point.subtract(topRight, position);
|
|
100
|
+
return (
|
|
101
|
+
<polyline
|
|
102
|
+
class-debug-bounds-decoration={true}
|
|
103
|
+
class-debug-bounds-top-right={true}
|
|
104
|
+
points={`${corner.x - this.decorationSize},${corner.y} ${corner.x},${corner.y} ${corner.x},${corner.y + this.decorationSize}`}
|
|
105
|
+
>
|
|
106
|
+
<title>
|
|
107
|
+
Top Right = x: {topRight.x}, y: {topRight.y}
|
|
108
|
+
</title>
|
|
109
|
+
</polyline>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
protected renderBottomLeftCorner(element: BoundsAwareModelElement): VNode {
|
|
114
|
+
const position = Bounds.topLeft(element.bounds);
|
|
115
|
+
const bottomLeft = Bounds.bottomLeft(element.bounds);
|
|
116
|
+
const corner = Point.subtract(bottomLeft, position);
|
|
117
|
+
return (
|
|
118
|
+
<polyline
|
|
119
|
+
class-debug-bounds-decoration={true}
|
|
120
|
+
class-debug-bounds-bottom-left={true}
|
|
121
|
+
points={`${corner.x},${corner.y - this.decorationSize} ${corner.x},${corner.y} ${corner.x + this.decorationSize},${corner.y}`}
|
|
122
|
+
>
|
|
123
|
+
<title>
|
|
124
|
+
Bottom Left = x: {bottomLeft.x}, y: {bottomLeft.y}
|
|
125
|
+
</title>
|
|
126
|
+
</polyline>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
protected renderBottomRightCorner(element: BoundsAwareModelElement): VNode {
|
|
131
|
+
const position = Bounds.topLeft(element.bounds);
|
|
132
|
+
const bottomRight = Bounds.bottomRight(element.bounds);
|
|
133
|
+
const corner = Point.subtract(bottomRight, position);
|
|
134
|
+
return (
|
|
135
|
+
<polyline
|
|
136
|
+
class-debug-bounds-decoration={true}
|
|
137
|
+
class-debug-bounds-bottom-right={true}
|
|
138
|
+
points={`${corner.x - this.decorationSize},${corner.y} ${corner.x},${corner.y} ${corner.x},${corner.y - this.decorationSize}`}
|
|
139
|
+
>
|
|
140
|
+
<title>
|
|
141
|
+
Bottom Right = x: {bottomRight.x}, y: {bottomRight.y}
|
|
142
|
+
</title>
|
|
143
|
+
</polyline>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
protected renderCenter(element: BoundsAwareModelElement): VNode {
|
|
148
|
+
const bounds = element.bounds;
|
|
149
|
+
const position = Bounds.topLeft(bounds);
|
|
150
|
+
const center = Bounds.center(bounds);
|
|
151
|
+
const corner = Point.subtract(center, position);
|
|
152
|
+
return (
|
|
153
|
+
<g>
|
|
154
|
+
<title>
|
|
155
|
+
Center = x: {center.x}, y: {center.y}
|
|
156
|
+

Bounds = x: {bounds.x}, y: {bounds.y}, width: {bounds.width}, height: {bounds.height}
|
|
157
|
+
</title>
|
|
158
|
+
<polyline
|
|
159
|
+
class-debug-bounds-decoration={true}
|
|
160
|
+
class-debug-bounds-center={true}
|
|
161
|
+
points={`${corner.x - this.decorationSize / 2},${corner.y - this.decorationSize / 2} ${corner.x + this.decorationSize / 2},${corner.y + this.decorationSize / 2}`}
|
|
162
|
+
></polyline>
|
|
163
|
+
<polyline
|
|
164
|
+
class-debug-bounds-decoration={true}
|
|
165
|
+
class-debug-bounds-center={true}
|
|
166
|
+
points={`${corner.x + this.decorationSize / 2},${corner.y - this.decorationSize / 2} ${corner.x - this.decorationSize / 2},${corner.y + this.decorationSize / 2}`}
|
|
167
|
+
></polyline>
|
|
168
|
+
</g>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2024 Axon Ivy AG 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 { IActionHandler, TYPES } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import { inject, injectable, postConstruct } from 'inversify';
|
|
19
|
+
import { FeedbackEmitter, IFeedbackActionDispatcher } from '../../base';
|
|
20
|
+
import { EnableDebugModeAction } from './debug-model';
|
|
21
|
+
|
|
22
|
+
@injectable()
|
|
23
|
+
export class DebugManager implements IActionHandler {
|
|
24
|
+
protected _debugEnabled: boolean = false;
|
|
25
|
+
protected debugFeedback: FeedbackEmitter;
|
|
26
|
+
|
|
27
|
+
@inject(TYPES.IFeedbackActionDispatcher)
|
|
28
|
+
protected feedbackDispatcher: IFeedbackActionDispatcher;
|
|
29
|
+
|
|
30
|
+
get isDebugEnabled(): boolean {
|
|
31
|
+
return this._debugEnabled;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
handle(action: EnableDebugModeAction): void {
|
|
35
|
+
this._debugEnabled = action.enable;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@postConstruct()
|
|
39
|
+
protected init(): void {
|
|
40
|
+
this.debugFeedback = this.feedbackDispatcher.createEmitter();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
setDebugEnabled(visible: boolean): void {
|
|
44
|
+
if (!visible) {
|
|
45
|
+
this.debugFeedback.dispose();
|
|
46
|
+
} else {
|
|
47
|
+
this.debugFeedback
|
|
48
|
+
.add(EnableDebugModeAction.create({ enable: true }), EnableDebugModeAction.create({ enable: false }))
|
|
49
|
+
.submit();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
toggleDebugEnabled(): void {
|
|
54
|
+
this.setDebugEnabled(!this._debugEnabled);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2024 Axon Ivy AG 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 { Action, CommandExecutionContext, CommandReturn, GModelRoot, TYPES, hasBooleanProp } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import { inject, injectable } from 'inversify';
|
|
19
|
+
import { FeedbackCommand } from '../../base';
|
|
20
|
+
import { addCssClasses, removeCssClasses } from '../../utils';
|
|
21
|
+
|
|
22
|
+
export interface EnableDebugModeAction extends Action {
|
|
23
|
+
kind: typeof EnableDebugModeAction.KIND;
|
|
24
|
+
enable: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export namespace EnableDebugModeAction {
|
|
28
|
+
export const KIND = 'enableDebugMode';
|
|
29
|
+
export const CSS_ROOT_CLASS = 'debug-mode';
|
|
30
|
+
|
|
31
|
+
export function is(object: any): object is EnableDebugModeAction {
|
|
32
|
+
return Action.hasKind(object, KIND) && hasBooleanProp(object, 'enable');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function create(options: { enable: boolean }): EnableDebugModeAction {
|
|
36
|
+
return {
|
|
37
|
+
kind: EnableDebugModeAction.KIND,
|
|
38
|
+
...options
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@injectable()
|
|
44
|
+
export class EnableDebugModeCommand extends FeedbackCommand {
|
|
45
|
+
static readonly KIND = EnableDebugModeAction.KIND;
|
|
46
|
+
|
|
47
|
+
constructor(@inject(TYPES.Action) protected readonly action: EnableDebugModeAction) {
|
|
48
|
+
super();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
execute(context: CommandExecutionContext): CommandReturn {
|
|
52
|
+
return this.setDebugMode(context.root, this.action.enable);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
protected setDebugMode(root: GModelRoot, show: boolean): CommandReturn {
|
|
56
|
+
if (show) {
|
|
57
|
+
addCssClasses(root, [EnableDebugModeAction.CSS_ROOT_CLASS]);
|
|
58
|
+
} else {
|
|
59
|
+
removeCssClasses(root, [EnableDebugModeAction.CSS_ROOT_CLASS]);
|
|
60
|
+
}
|
|
61
|
+
return root;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2024 Axon Ivy AG 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 { FeatureModule, TYPES, bindAsService, configureActionHandler, configureCommand } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import '../../../css/debug.css';
|
|
19
|
+
import { DebugBoundsDecorator } from './debug-bounds-decorator';
|
|
20
|
+
import { DebugManager } from './debug-manager';
|
|
21
|
+
import { EnableDebugModeAction, EnableDebugModeCommand } from './debug-model';
|
|
22
|
+
|
|
23
|
+
export const debugModule = new FeatureModule((bind, unbind, isBound, rebind) => {
|
|
24
|
+
const context = { bind, unbind, isBound, rebind };
|
|
25
|
+
|
|
26
|
+
configureCommand(context, EnableDebugModeCommand);
|
|
27
|
+
|
|
28
|
+
bindAsService(bind, TYPES.IDebugManager, DebugManager);
|
|
29
|
+
configureActionHandler(context, EnableDebugModeAction.KIND, DebugManager);
|
|
30
|
+
|
|
31
|
+
bindAsService(context, TYPES.IVNodePostprocessor, DebugBoundsDecorator);
|
|
32
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2024 Axon Ivy AG 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
|
+
export * from './debug-bounds-decorator';
|
|
17
|
+
export * from './debug-manager';
|
|
18
|
+
export * from './debug-model';
|
|
19
|
+
export * from './debug-module';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2024 Axon Ivy AG 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 { IActionHandler, PropertiesOfType, TYPES } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import { inject, injectable, postConstruct } from 'inversify';
|
|
19
|
+
import { FeedbackEmitter, IFeedbackActionDispatcher } from '../../base';
|
|
20
|
+
import { Grid } from './grid';
|
|
21
|
+
import { ShowGridAction } from './grid-model';
|
|
22
|
+
|
|
23
|
+
export type GridStyle = Record<string, string> & Partial<PropertiesOfType<CSSStyleDeclaration, string>>;
|
|
24
|
+
|
|
25
|
+
@injectable()
|
|
26
|
+
export class GridManager implements IActionHandler {
|
|
27
|
+
protected _gridVisible: boolean = false;
|
|
28
|
+
protected gridFeedback: FeedbackEmitter;
|
|
29
|
+
|
|
30
|
+
@inject(TYPES.IFeedbackActionDispatcher)
|
|
31
|
+
protected feedbackDispatcher: IFeedbackActionDispatcher;
|
|
32
|
+
|
|
33
|
+
@inject(TYPES.Grid)
|
|
34
|
+
public readonly grid: Grid;
|
|
35
|
+
|
|
36
|
+
get isGridVisible(): boolean {
|
|
37
|
+
return this._gridVisible;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@postConstruct()
|
|
41
|
+
protected init(): void {
|
|
42
|
+
this.gridFeedback = this.feedbackDispatcher.createEmitter();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
handle(action: ShowGridAction): void {
|
|
46
|
+
this._gridVisible = action.show;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
setGridVisible(visible: boolean): void {
|
|
50
|
+
if (!visible) {
|
|
51
|
+
this.gridFeedback.dispose();
|
|
52
|
+
} else {
|
|
53
|
+
this.gridFeedback.add(ShowGridAction.create({ show: true }), ShowGridAction.create({ show: false })).submit();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
toggleGridVisible(): void {
|
|
58
|
+
this.setGridVisible(!this._gridVisible);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2024 Axon Ivy AG 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, CommandExecutionContext, CommandReturn, GModelRoot, TYPES, hasBooleanProp } from '@eclipse-glsp/sprotty';
|
|
17
|
+
import { inject, injectable } from 'inversify';
|
|
18
|
+
import { FeedbackCommand } from '../../base';
|
|
19
|
+
import { addCssClasses, removeCssClasses } from '../../utils';
|
|
20
|
+
|
|
21
|
+
export interface ShowGridAction extends Action {
|
|
22
|
+
kind: typeof ShowGridCommand.KIND;
|
|
23
|
+
show: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export namespace ShowGridAction {
|
|
27
|
+
export const KIND = 'showGrid';
|
|
28
|
+
export const CSS_ROOT_CLASS = 'grid-background';
|
|
29
|
+
|
|
30
|
+
export function is(object: any): object is ShowGridAction {
|
|
31
|
+
return Action.hasKind(object, KIND) && hasBooleanProp(object, 'show');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function create(options: { show: boolean }): ShowGridAction {
|
|
35
|
+
return {
|
|
36
|
+
kind: ShowGridCommand.KIND,
|
|
37
|
+
...options
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@injectable()
|
|
43
|
+
export class ShowGridCommand extends FeedbackCommand {
|
|
44
|
+
static readonly KIND = ShowGridAction.KIND;
|
|
45
|
+
|
|
46
|
+
constructor(@inject(TYPES.Action) protected readonly action: ShowGridAction) {
|
|
47
|
+
super();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
execute(context: CommandExecutionContext): CommandReturn {
|
|
51
|
+
return this.setGrid(context.root, this.action.show);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
protected setGrid(root: GModelRoot, show: boolean): CommandReturn {
|
|
55
|
+
if (show) {
|
|
56
|
+
addCssClasses(root, [ShowGridAction.CSS_ROOT_CLASS]);
|
|
57
|
+
} else {
|
|
58
|
+
removeCssClasses(root, [ShowGridAction.CSS_ROOT_CLASS]);
|
|
59
|
+
}
|
|
60
|
+
return root;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2023 Axon Ivy AG 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 { FeatureModule, TYPES, bindAsService, configureActionHandler, configureCommand } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import '../../../css/grid.css';
|
|
19
|
+
import { GridManager } from './grid-manager';
|
|
20
|
+
import { ShowGridAction, ShowGridCommand } from './grid-model';
|
|
21
|
+
import { GridSnapper } from './grid-snapper';
|
|
22
|
+
|
|
23
|
+
export const gridModule = new FeatureModule((bind, unbind, isBound, rebind) => {
|
|
24
|
+
const context = { bind, unbind, isBound, rebind };
|
|
25
|
+
|
|
26
|
+
bind(TYPES.Grid).toConstantValue({ x: 10, y: 10 });
|
|
27
|
+
|
|
28
|
+
configureCommand(context, ShowGridCommand);
|
|
29
|
+
|
|
30
|
+
bindAsService(bind, TYPES.IGridManager, GridManager);
|
|
31
|
+
configureActionHandler(context, ShowGridAction.KIND, GridManager);
|
|
32
|
+
|
|
33
|
+
bind(TYPES.ISnapper).to(GridSnapper);
|
|
34
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022-2023 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
|
|
17
|
+
import { GModelElement } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import { expect } from 'chai';
|
|
19
|
+
import { GridSnapper } from './grid-snapper';
|
|
20
|
+
|
|
21
|
+
describe('GridSnapper', () => {
|
|
22
|
+
it('snap', () => {
|
|
23
|
+
const element = new GModelElement();
|
|
24
|
+
const snapper = new GridSnapper();
|
|
25
|
+
expect(snapper.snap({ x: 0, y: 0 }, element)).to.be.deep.equals({ x: 0, y: 0 });
|
|
26
|
+
expect(snapper.snap({ x: 4, y: 5 }, element)).to.be.deep.equals({ x: 0, y: 10 });
|
|
27
|
+
expect(snapper.snap({ x: 8, y: 11 }, element)).to.be.deep.equals({ x: 10, y: 10 });
|
|
28
|
+
expect(snapper.snap({ x: -7, y: -4 }, element)).to.be.deep.equals({ x: -10, y: -0 });
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2024 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 { CenterGridSnapper, GModelElement, ISnapper, Point, TYPES } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import { inject, injectable, optional } from 'inversify';
|
|
19
|
+
import { Grid } from './grid';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A {@link ISnapper} implementation that snaps all elements onto a fixed gride size.
|
|
23
|
+
* The default grid size is 10x10 pixel.
|
|
24
|
+
* To configure a custom grid size bind the `TYPES.ISnapper` service identifier
|
|
25
|
+
* to constant value, e.g:
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* bind(TYPES.ISnapper).toConstantValue(new GridSnapper({ x: 25, y: 25 }));
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* or use the `Grid` to define the grid size more generically:
|
|
32
|
+
* ```ts
|
|
33
|
+
* bind(TYPES.Grid).toConstantValue({ x: 25, y: 25 });
|
|
34
|
+
* bind(TYPES.ISnapper).to(GridSnapper);
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
@injectable()
|
|
38
|
+
export class GridSnapper implements ISnapper {
|
|
39
|
+
constructor(@optional() @inject(TYPES.Grid) public readonly grid: Grid = { x: 10, y: 10 }) {}
|
|
40
|
+
|
|
41
|
+
snap(position: Point, element: GModelElement): Point {
|
|
42
|
+
return Point.snapToGrid(position, this.grid);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@injectable()
|
|
47
|
+
export class GLSPCenterGridSnapper extends CenterGridSnapper {
|
|
48
|
+
constructor(@optional() @inject(TYPES.Grid) public readonly grid: Grid = { x: 10, y: 10 }) {
|
|
49
|
+
super();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
override get gridX(): number {
|
|
53
|
+
return this.grid.x;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
override get gridY(): number {
|
|
57
|
+
return this.grid.y;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2024 Axon Ivy AG 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 { Point } from '@eclipse-glsp/sprotty';
|
|
17
|
+
|
|
18
|
+
export type Grid = Point;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2024 Axon Ivy AG 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
|
+
export * from './grid';
|
|
17
|
+
export * from './grid-manager';
|
|
18
|
+
export * from './grid-model';
|
|
19
|
+
export * from './grid-module';
|
|
20
|
+
export * from './grid-snapper';
|