@eclipse-glsp/client 2.2.0-next.331 → 2.2.0-next.332

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/css/debug.css +25 -0
  2. package/css/grid.css +20 -0
  3. package/css/keyboard-tool-palette.css +0 -6
  4. package/css/tool-palette.css +30 -26
  5. package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.d.ts.map +1 -1
  6. package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.js +21 -7
  7. package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.js.map +1 -1
  8. package/lib/features/accessibility/resize-key-tool/resize-key-handler.d.ts +2 -4
  9. package/lib/features/accessibility/resize-key-tool/resize-key-handler.d.ts.map +1 -1
  10. package/lib/features/accessibility/resize-key-tool/resize-key-handler.js +11 -7
  11. package/lib/features/accessibility/resize-key-tool/resize-key-handler.js.map +1 -1
  12. package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts +5 -6
  13. package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts.map +1 -1
  14. package/lib/features/accessibility/view-key-tools/movement-key-tool.js +12 -8
  15. package/lib/features/accessibility/view-key-tools/movement-key-tool.js.map +1 -1
  16. package/lib/features/change-bounds/snap.d.ts +1 -22
  17. package/lib/features/change-bounds/snap.d.ts.map +1 -1
  18. package/lib/features/change-bounds/snap.js +1 -37
  19. package/lib/features/change-bounds/snap.js.map +1 -1
  20. package/lib/features/debug/debug-bounds-decorator.d.ts +35 -0
  21. package/lib/features/debug/debug-bounds-decorator.d.ts.map +1 -0
  22. package/lib/features/debug/debug-bounds-decorator.js +149 -0
  23. package/lib/features/debug/debug-bounds-decorator.js.map +1 -0
  24. package/lib/features/debug/debug-manager.d.ts +29 -0
  25. package/lib/features/debug/debug-manager.d.ts.map +1 -0
  26. package/lib/features/debug/debug-manager.js +72 -0
  27. package/lib/features/debug/debug-manager.js.map +1 -0
  28. package/lib/features/debug/debug-model.d.ts +37 -0
  29. package/lib/features/debug/debug-model.d.ts.map +1 -0
  30. package/lib/features/debug/debug-model.js +73 -0
  31. package/lib/features/debug/debug-model.js.map +1 -0
  32. package/lib/features/debug/debug-module.d.ts +19 -0
  33. package/lib/features/debug/debug-module.d.ts.map +1 -0
  34. package/lib/features/debug/debug-module.js +31 -0
  35. package/lib/features/debug/debug-module.js.map +1 -0
  36. package/lib/features/debug/index.d.ts +20 -0
  37. package/lib/features/debug/index.d.ts.map +1 -0
  38. package/lib/features/debug/index.js +36 -0
  39. package/lib/features/debug/index.js.map +1 -0
  40. package/lib/features/grid/grid-manager.d.ts +32 -0
  41. package/lib/features/grid/grid-manager.d.ts.map +1 -0
  42. package/lib/features/grid/grid-manager.js +74 -0
  43. package/lib/features/grid/grid-manager.js.map +1 -0
  44. package/lib/features/grid/grid-model.d.ts +37 -0
  45. package/lib/features/grid/grid-model.d.ts.map +1 -0
  46. package/lib/features/grid/grid-model.js +73 -0
  47. package/lib/features/grid/grid-model.js.map +1 -0
  48. package/lib/features/grid/grid-module.d.ts +19 -0
  49. package/lib/features/grid/grid-module.d.ts.map +1 -0
  50. package/lib/features/grid/grid-module.js +32 -0
  51. package/lib/features/grid/grid-module.js.map +1 -0
  52. package/lib/features/grid/grid-snapper.d.ts +45 -0
  53. package/lib/features/grid/grid-snapper.d.ts.map +1 -0
  54. package/lib/features/grid/grid-snapper.js +83 -0
  55. package/lib/features/grid/grid-snapper.js.map +1 -0
  56. package/lib/features/grid/grid.d.ts +18 -0
  57. package/lib/features/grid/grid.d.ts.map +1 -0
  58. package/lib/features/grid/grid.js +3 -0
  59. package/lib/features/grid/grid.js.map +1 -0
  60. package/lib/features/grid/index.d.ts +21 -0
  61. package/lib/features/grid/index.d.ts.map +1 -0
  62. package/lib/features/grid/index.js +37 -0
  63. package/lib/features/grid/index.js.map +1 -0
  64. package/lib/features/helper-lines/helper-line-manager-default.d.ts +4 -1
  65. package/lib/features/helper-lines/helper-line-manager-default.d.ts.map +1 -1
  66. package/lib/features/helper-lines/helper-line-manager-default.js +11 -1
  67. package/lib/features/helper-lines/helper-line-manager-default.js.map +1 -1
  68. package/lib/features/index.d.ts +2 -0
  69. package/lib/features/index.d.ts.map +1 -1
  70. package/lib/features/index.js +2 -0
  71. package/lib/features/index.js.map +1 -1
  72. package/lib/features/tool-palette/tool-palette.d.ts +7 -0
  73. package/lib/features/tool-palette/tool-palette.d.ts.map +1 -1
  74. package/lib/features/tool-palette/tool-palette.js +80 -2
  75. package/lib/features/tool-palette/tool-palette.js.map +1 -1
  76. package/lib/features/viewport/index.d.ts +1 -0
  77. package/lib/features/viewport/index.d.ts.map +1 -1
  78. package/lib/features/viewport/index.js +1 -0
  79. package/lib/features/viewport/index.js.map +1 -1
  80. package/lib/features/viewport/origin-viewport.d.ts +36 -0
  81. package/lib/features/viewport/origin-viewport.d.ts.map +1 -0
  82. package/lib/features/viewport/origin-viewport.js +75 -0
  83. package/lib/features/viewport/origin-viewport.js.map +1 -0
  84. package/lib/features/viewport/viewport-modules.d.ts.map +1 -1
  85. package/lib/features/viewport/viewport-modules.js +4 -2
  86. package/lib/features/viewport/viewport-modules.js.map +1 -1
  87. package/lib/views/base-view-module.d.ts.map +1 -1
  88. package/lib/views/base-view-module.js +3 -2
  89. package/lib/views/base-view-module.js.map +1 -1
  90. package/lib/views/ggraph-view.d.ts +26 -0
  91. package/lib/views/ggraph-view.d.ts.map +1 -0
  92. package/lib/views/ggraph-view.js +71 -0
  93. package/lib/views/ggraph-view.js.map +1 -0
  94. package/lib/views/glsp-projection-view.d.ts +6 -1
  95. package/lib/views/glsp-projection-view.d.ts.map +1 -1
  96. package/lib/views/glsp-projection-view.js +30 -6
  97. package/lib/views/glsp-projection-view.js.map +1 -1
  98. package/lib/views/index.d.ts +1 -0
  99. package/lib/views/index.d.ts.map +1 -1
  100. package/lib/views/index.js +1 -0
  101. package/lib/views/index.js.map +1 -1
  102. package/package.json +3 -3
  103. package/src/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.ts +24 -7
  104. package/src/features/accessibility/resize-key-tool/resize-key-handler.ts +9 -9
  105. package/src/features/accessibility/view-key-tools/movement-key-tool.ts +13 -11
  106. package/src/features/change-bounds/{snap.spec.ts → point-position-updater.spec.ts} +1 -12
  107. package/src/features/change-bounds/snap.ts +1 -24
  108. package/src/features/debug/debug-bounds-decorator.tsx +171 -0
  109. package/src/features/debug/debug-manager.ts +56 -0
  110. package/src/features/debug/debug-model.ts +63 -0
  111. package/src/features/debug/debug-module.ts +32 -0
  112. package/src/features/debug/index.ts +19 -0
  113. package/src/features/grid/grid-manager.ts +60 -0
  114. package/src/features/grid/grid-model.ts +62 -0
  115. package/src/features/grid/grid-module.ts +34 -0
  116. package/src/features/grid/grid-snapper.spec.ts +30 -0
  117. package/src/features/grid/grid-snapper.ts +59 -0
  118. package/src/features/grid/grid.ts +18 -0
  119. package/src/features/grid/index.ts +20 -0
  120. package/src/features/helper-lines/helper-line-manager-default.ts +10 -2
  121. package/src/features/index.ts +2 -0
  122. package/src/features/tool-palette/tool-palette.ts +80 -3
  123. package/src/features/viewport/index.ts +1 -0
  124. package/src/features/viewport/origin-viewport.ts +68 -0
  125. package/src/features/viewport/viewport-modules.ts +4 -2
  126. package/src/views/base-view-module.ts +3 -3
  127. package/src/views/ggraph-view.tsx +56 -0
  128. package/src/views/glsp-projection-view.tsx +34 -7
  129. package/src/views/index.ts +1 -0
@@ -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';
@@ -19,6 +19,7 @@ import { FeedbackEmitter } from '../../base';
19
19
  import { IFeedbackActionDispatcher } from '../../base/feedback/feedback-action-dispatcher';
20
20
  import { ISelectionListener, SelectionService } from '../../base/selection-service';
21
21
  import { SetBoundsFeedbackAction } from '../bounds/set-bounds-feedback-command';
22
+ import { Grid } from '../grid';
22
23
  import { MoveFinishedEventAction, MoveInitializedEventAction } from '../tools/change-bounds/change-bounds-tool-feedback';
23
24
  import {
24
25
  AlignmentElementFilter,
@@ -47,7 +48,7 @@ export interface IHelperLineOptions {
47
48
  viewportLines?: ViewportLineType[];
48
49
  /**
49
50
  * The minimum difference between two coordinates
50
- * Defaults to 1.
51
+ * Defaults to 1 or zero (perfect match) if the optional grid module is loaded.
51
52
  */
52
53
  alignmentEpsilon?: number;
53
54
  /**
@@ -58,6 +59,7 @@ export interface IHelperLineOptions {
58
59
  /**
59
60
  * The minimum move delta that is necessary for an element to break through a helper line.
60
61
  * Defaults to { x: 1, y: 1 } whereas the x represents the horizontal distance and y represents the vertical distance.
62
+ * If the optional grid module is loaded, defaults to twice the grid size, i.e., two grid moves to break through a helper line.
61
63
  */
62
64
  minimumMoveDelta?: Point;
63
65
 
@@ -84,6 +86,7 @@ export class HelperLineManager implements IActionHandler, ISelectionListener, IH
84
86
  @inject(TYPES.IFeedbackActionDispatcher) protected feedbackDispatcher: IFeedbackActionDispatcher;
85
87
  @inject(SelectionService) protected selectionService: SelectionService;
86
88
  @optional() @inject(TYPES.IHelperLineOptions) protected userOptions?: IHelperLineOptions;
89
+ @optional() @inject(TYPES.Grid) protected grid?: Grid;
87
90
 
88
91
  protected options: Required<IHelperLineOptions>;
89
92
  protected feedback: FeedbackEmitter;
@@ -91,7 +94,12 @@ export class HelperLineManager implements IActionHandler, ISelectionListener, IH
91
94
  @postConstruct()
92
95
  protected init(): void {
93
96
  this.feedback = this.feedbackDispatcher.createEmitter();
94
- this.options = { ...DEFAULT_HELPER_LINE_OPTIONS, ...this.userOptions };
97
+ const dynamicOptions: IHelperLineOptions = {};
98
+ if (this.grid) {
99
+ dynamicOptions.alignmentEpsilon = 0;
100
+ dynamicOptions.minimumMoveDelta = Point.multiplyScalar(this.grid, 2);
101
+ }
102
+ this.options = { ...DEFAULT_HELPER_LINE_OPTIONS, ...dynamicOptions, ...this.userOptions };
95
103
  this.selectionService.onSelectionChanged(change =>
96
104
  this.selectionChanged(change.root, change.selectedElements, change.deselectedElements)
97
105
  );
@@ -19,9 +19,11 @@ export * from './change-bounds';
19
19
  export * from './command-palette';
20
20
  export * from './context-menu';
21
21
  export * from './copy-paste';
22
+ export * from './debug';
22
23
  export * from './decoration';
23
24
  export * from './element-template';
24
25
  export * from './export';
26
+ export * from './grid';
25
27
  export * from './helper-lines';
26
28
  export * from './hints';
27
29
  export * from './hover';
@@ -26,23 +26,27 @@ import {
26
26
  SetContextActions,
27
27
  SetModelAction,
28
28
  SetUIExtensionVisibilityAction,
29
+ TYPES,
29
30
  TriggerNodeCreationAction,
30
31
  UpdateModelAction,
31
32
  codiconCSSClasses,
32
33
  matchesKeystroke
33
34
  } from '@eclipse-glsp/sprotty';
34
- import { inject, injectable, postConstruct } from 'inversify';
35
+ import { inject, injectable, optional, postConstruct } from 'inversify';
35
36
  import { GLSPActionDispatcher } from '../../base/action-dispatcher';
36
37
  import { EditorContextService, IEditModeListener } from '../../base/editor-context-service';
37
38
  import { FocusTracker } from '../../base/focus/focus-tracker';
38
39
  import { IDiagramStartup } from '../../base/model/diagram-loader';
39
40
  import { EnableDefaultToolsAction, EnableToolsAction } from '../../base/tool-manager/tool';
41
+ import { DebugManager } from '../debug';
42
+ import { GridManager } from '../grid';
40
43
  import { MouseDeleteTool } from '../tools/deletion/delete-tool';
41
44
  import { MarqueeMouseTool } from '../tools/marquee-selection/marquee-mouse-tool';
45
+ import { OriginViewportAction } from '../viewport';
42
46
 
43
47
  const CLICKED_CSS_CLASS = 'clicked';
44
48
  const SEARCH_ICON_ID = 'search';
45
- const PALETTE_ICON_ID = 'symbol-color';
49
+ const PALETTE_ICON_ID = 'tools';
46
50
  const CHEVRON_DOWN_ICON_ID = 'chevron-right';
47
51
  const PALETTE_HEIGHT = '500px';
48
52
 
@@ -74,6 +78,14 @@ export class ToolPalette extends AbstractUIExtension implements IActionHandler,
74
78
  @inject(FocusTracker)
75
79
  protected focusTracker: FocusTracker;
76
80
 
81
+ @inject(TYPES.IGridManager)
82
+ @optional()
83
+ protected gridManager?: GridManager;
84
+
85
+ @inject(TYPES.IDebugManager)
86
+ @optional()
87
+ protected debugManager?: DebugManager;
88
+
77
89
  protected paletteItems: PaletteItem[];
78
90
  protected paletteItemsCopy: PaletteItem[] = [];
79
91
  protected dynamic = false;
@@ -202,6 +214,19 @@ export class ToolPalette extends AbstractUIExtension implements IActionHandler,
202
214
  const validateActionButton = this.createValidateButton();
203
215
  headerTools.appendChild(validateActionButton);
204
216
 
217
+ const resetViewportButton = this.createResetViewportButton();
218
+ headerTools.appendChild(resetViewportButton);
219
+
220
+ if (this.gridManager) {
221
+ const toggleGridButton = this.createToggleGridButton();
222
+ headerTools.appendChild(toggleGridButton);
223
+ }
224
+
225
+ if (this.debugManager) {
226
+ const toggleDebugButton = this.createToggleDebugButton();
227
+ headerTools.appendChild(toggleDebugButton);
228
+ }
229
+
205
230
  // Create button for Search
206
231
  const searchIcon = this.createSearchButton();
207
232
  headerTools.appendChild(searchIcon);
@@ -250,6 +275,58 @@ export class ToolPalette extends AbstractUIExtension implements IActionHandler,
250
275
  return validateActionButton;
251
276
  }
252
277
 
278
+ protected createResetViewportButton(): HTMLElement {
279
+ const resetViewportButton = createIcon('screen-normal');
280
+ resetViewportButton.title = 'Reset Viewport';
281
+ resetViewportButton.onclick = _event => {
282
+ this.actionDispatcher.dispatch(OriginViewportAction.create());
283
+ resetViewportButton.focus();
284
+ };
285
+ resetViewportButton.ariaLabel = resetViewportButton.title;
286
+ resetViewportButton.tabIndex = 1;
287
+ return resetViewportButton;
288
+ }
289
+
290
+ protected createToggleGridButton(): HTMLElement {
291
+ const toggleGridButton = createIcon('symbol-numeric');
292
+ toggleGridButton.title = 'Toggle Grid';
293
+ toggleGridButton.onclick = () => {
294
+ if (this.gridManager?.isGridVisible) {
295
+ toggleGridButton.classList.remove(CLICKED_CSS_CLASS);
296
+ this.gridManager?.setGridVisible(false);
297
+ } else {
298
+ toggleGridButton.classList.add(CLICKED_CSS_CLASS);
299
+ this.gridManager?.setGridVisible(true);
300
+ }
301
+ };
302
+ if (this.gridManager?.isGridVisible) {
303
+ toggleGridButton.classList.add(CLICKED_CSS_CLASS);
304
+ }
305
+ toggleGridButton.ariaLabel = toggleGridButton.title;
306
+ toggleGridButton.tabIndex = 1;
307
+ return toggleGridButton;
308
+ }
309
+
310
+ protected createToggleDebugButton(): HTMLElement {
311
+ const toggleDebugButton = createIcon('debug');
312
+ toggleDebugButton.title = 'Debug Mode';
313
+ toggleDebugButton.onclick = () => {
314
+ if (this.debugManager?.isDebugEnabled) {
315
+ toggleDebugButton.classList.remove(CLICKED_CSS_CLASS);
316
+ this.debugManager?.setDebugEnabled(false);
317
+ } else {
318
+ toggleDebugButton.classList.add(CLICKED_CSS_CLASS);
319
+ this.debugManager?.setDebugEnabled(true);
320
+ }
321
+ };
322
+ if (this.debugManager?.isDebugEnabled) {
323
+ toggleDebugButton.classList.add(CLICKED_CSS_CLASS);
324
+ }
325
+ toggleDebugButton.ariaLabel = toggleDebugButton.title;
326
+ toggleDebugButton.tabIndex = 1;
327
+ return toggleDebugButton;
328
+ }
329
+
253
330
  protected createSearchButton(): HTMLElement {
254
331
  const searchIcon = createIcon(SEARCH_ICON_ID);
255
332
  searchIcon.onclick = _ev => {
@@ -275,7 +352,7 @@ export class ToolPalette extends AbstractUIExtension implements IActionHandler,
275
352
  searchField.classList.add('search-input');
276
353
  searchField.id = this.containerElement.id + '_search_field';
277
354
  searchField.type = 'text';
278
- searchField.placeholder = ' Search...';
355
+ searchField.placeholder = 'Search...';
279
356
  searchField.style.display = 'none';
280
357
  searchField.onkeyup = () => this.requestFilterUpdate(this.searchField.value);
281
358
  searchField.onkeydown = ev => this.clearOnEscape(ev);
@@ -14,6 +14,7 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
  export * from './glsp-scroll-mouse-listener';
17
+ export * from './origin-viewport';
17
18
  export * from './reposition';
18
19
  export * from './viewport-handler';
19
20
  export * from './viewport-modules';