@eclipse-glsp/client 1.1.0-next.93fd4ec.241 → 1.1.0-next.97e90c6.246

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 (78) hide show
  1. package/css/autocomplete-palette.css +22 -0
  2. package/css/glsp-sprotty.css +16 -1
  3. package/lib/base/auto-complete/auto-complete-widget.d.ts +8 -2
  4. package/lib/base/auto-complete/auto-complete-widget.d.ts.map +1 -1
  5. package/lib/base/auto-complete/auto-complete-widget.js +25 -6
  6. package/lib/base/auto-complete/auto-complete-widget.js.map +1 -1
  7. package/lib/features/accessibility/di.config.d.ts +21 -0
  8. package/lib/features/accessibility/di.config.d.ts.map +1 -0
  9. package/lib/features/accessibility/di.config.js +32 -0
  10. package/lib/features/accessibility/di.config.js.map +1 -0
  11. package/lib/features/accessibility/move-zoom/di.config.d.ts +23 -0
  12. package/lib/features/accessibility/move-zoom/di.config.d.ts.map +1 -0
  13. package/lib/features/accessibility/move-zoom/di.config.js +41 -0
  14. package/lib/features/accessibility/move-zoom/di.config.js.map +1 -0
  15. package/lib/features/accessibility/move-zoom/move-handler.d.ts +81 -0
  16. package/lib/features/accessibility/move-zoom/move-handler.d.ts.map +1 -0
  17. package/lib/features/accessibility/move-zoom/move-handler.js +173 -0
  18. package/lib/features/accessibility/move-zoom/move-handler.js.map +1 -0
  19. package/lib/features/accessibility/move-zoom/zoom-handler.d.ts +74 -0
  20. package/lib/features/accessibility/move-zoom/zoom-handler.d.ts.map +1 -0
  21. package/lib/features/accessibility/move-zoom/zoom-handler.js +159 -0
  22. package/lib/features/accessibility/move-zoom/zoom-handler.js.map +1 -0
  23. package/lib/features/accessibility/search/di.config.d.ts +20 -0
  24. package/lib/features/accessibility/search/di.config.d.ts.map +1 -0
  25. package/lib/features/accessibility/search/di.config.js +33 -0
  26. package/lib/features/accessibility/search/di.config.js.map +1 -0
  27. package/lib/features/accessibility/search/search-palette.d.ts +47 -0
  28. package/lib/features/accessibility/search/search-palette.d.ts.map +1 -0
  29. package/lib/features/accessibility/search/search-palette.js +155 -0
  30. package/lib/features/accessibility/search/search-palette.js.map +1 -0
  31. package/lib/features/accessibility/search/search-tool.d.ts +30 -0
  32. package/lib/features/accessibility/search/search-tool.d.ts.map +1 -0
  33. package/lib/features/accessibility/search/search-tool.js +73 -0
  34. package/lib/features/accessibility/search/search-tool.js.map +1 -0
  35. package/lib/features/accessibility/view-key-tools/deselect-key-tool.d.ts +35 -0
  36. package/lib/features/accessibility/view-key-tools/deselect-key-tool.d.ts.map +1 -0
  37. package/lib/features/accessibility/view-key-tools/deselect-key-tool.js +87 -0
  38. package/lib/features/accessibility/view-key-tools/deselect-key-tool.js.map +1 -0
  39. package/lib/features/accessibility/view-key-tools/di.config.d.ts +20 -0
  40. package/lib/features/accessibility/view-key-tools/di.config.d.ts.map +1 -0
  41. package/lib/features/accessibility/view-key-tools/di.config.js +35 -0
  42. package/lib/features/accessibility/view-key-tools/di.config.js.map +1 -0
  43. package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts +49 -0
  44. package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts.map +1 -0
  45. package/lib/features/accessibility/view-key-tools/movement-key-tool.js +131 -0
  46. package/lib/features/accessibility/view-key-tools/movement-key-tool.js.map +1 -0
  47. package/lib/features/accessibility/view-key-tools/zoom-key-tool.d.ts +43 -0
  48. package/lib/features/accessibility/view-key-tools/zoom-key-tool.d.ts.map +1 -0
  49. package/lib/features/accessibility/view-key-tools/zoom-key-tool.js +109 -0
  50. package/lib/features/accessibility/view-key-tools/zoom-key-tool.js.map +1 -0
  51. package/lib/features/autocomplete-palette/autocomplete-suggestion-providers.d.ts +35 -0
  52. package/lib/features/autocomplete-palette/autocomplete-suggestion-providers.d.ts.map +1 -0
  53. package/lib/features/autocomplete-palette/autocomplete-suggestion-providers.js +18 -0
  54. package/lib/features/autocomplete-palette/autocomplete-suggestion-providers.js.map +1 -0
  55. package/lib/features/autocomplete-palette/base-autocomplete-palette.d.ts +41 -0
  56. package/lib/features/autocomplete-palette/base-autocomplete-palette.d.ts.map +1 -0
  57. package/lib/features/autocomplete-palette/base-autocomplete-palette.js +82 -0
  58. package/lib/features/autocomplete-palette/base-autocomplete-palette.js.map +1 -0
  59. package/lib/index.d.ts +10 -3
  60. package/lib/index.d.ts.map +1 -1
  61. package/lib/index.js +59 -48
  62. package/lib/index.js.map +1 -1
  63. package/package.json +5 -3
  64. package/src/base/auto-complete/auto-complete-widget.ts +31 -7
  65. package/src/features/accessibility/di.config.ts +30 -0
  66. package/src/features/accessibility/move-zoom/di.config.ts +43 -0
  67. package/src/features/accessibility/move-zoom/move-handler.ts +198 -0
  68. package/src/features/accessibility/move-zoom/zoom-handler.ts +178 -0
  69. package/src/features/accessibility/search/di.config.ts +31 -0
  70. package/src/features/accessibility/search/search-palette.ts +181 -0
  71. package/src/features/accessibility/search/search-tool.ts +60 -0
  72. package/src/features/accessibility/view-key-tools/deselect-key-tool.ts +80 -0
  73. package/src/features/accessibility/view-key-tools/di.config.ts +33 -0
  74. package/src/features/accessibility/view-key-tools/movement-key-tool.ts +115 -0
  75. package/src/features/accessibility/view-key-tools/zoom-key-tool.ts +94 -0
  76. package/src/features/autocomplete-palette/autocomplete-suggestion-providers.ts +37 -0
  77. package/src/features/autocomplete-palette/base-autocomplete-palette.ts +88 -0
  78. package/src/index.ts +14 -3
@@ -0,0 +1,60 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2023 Business Informatics Group (TU Wien) 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 } from '@eclipse-glsp/protocol';
18
+ import { inject, injectable } from 'inversify';
19
+ import { KeyListener, KeyTool, SetUIExtensionVisibilityAction, SModelElement, Tool } from 'sprotty';
20
+ import { matchesKeystroke } from 'sprotty/lib/utils/keyboard';
21
+ import { SearchAutocompletePalette } from './search-palette';
22
+
23
+ @injectable()
24
+ export class SearchAutocompletePaletteTool implements Tool {
25
+ static readonly ID = 'glsp.search-autocomplete-palette-tool';
26
+
27
+ protected readonly keyListener = new SearchAutocompletePaletteKeyListener();
28
+
29
+ @inject(KeyTool) protected keyTool: KeyTool;
30
+
31
+ get id(): string {
32
+ return SearchAutocompletePaletteTool.ID;
33
+ }
34
+
35
+ enable(): void {
36
+ this.keyTool.register(this.keyListener);
37
+ }
38
+
39
+ disable(): void {
40
+ this.keyTool.deregister(this.keyListener);
41
+ }
42
+ }
43
+
44
+ export class SearchAutocompletePaletteKeyListener extends KeyListener {
45
+ override keyDown(element: SModelElement, event: KeyboardEvent): Action[] {
46
+ if (this.matchesSearchActivateKeystroke(event)) {
47
+ return [
48
+ SetUIExtensionVisibilityAction.create({
49
+ extensionId: SearchAutocompletePalette.ID,
50
+ visible: true
51
+ })
52
+ ];
53
+ }
54
+ return [];
55
+ }
56
+
57
+ protected matchesSearchActivateKeystroke(event: KeyboardEvent): boolean {
58
+ return matchesKeystroke(event, 'KeyF', 'ctrl');
59
+ }
60
+ }
@@ -0,0 +1,80 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2023 Business Informatics Group (TU Wien) 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, SelectAction } from '@eclipse-glsp/protocol';
18
+ import { inject, injectable } from 'inversify';
19
+ import { isSelectable, KeyListener, KeyTool, SModelElement, SRoutableElement, SwitchEditModeAction } from 'sprotty';
20
+ import { toArray } from 'sprotty/lib/utils/iterable';
21
+ import { matchesKeystroke } from 'sprotty/lib/utils/keyboard';
22
+ import { GLSPTool } from '../../../base/tool-manager/glsp-tool-manager';
23
+ import { SResizeHandle } from '../../change-bounds/model';
24
+
25
+ /**
26
+ * Deselects the element if there is no interaction possible with element.
27
+ */
28
+ @injectable()
29
+ export class DeselectKeyTool implements GLSPTool {
30
+ static ID = 'glsp.deselect-key-tool';
31
+
32
+ isEditTool = true;
33
+
34
+ protected readonly deselectKeyListener = new DeselectKeyListener();
35
+
36
+ @inject(KeyTool) protected readonly keytool: KeyTool;
37
+
38
+ get id(): string {
39
+ return DeselectKeyTool.ID;
40
+ }
41
+
42
+ enable(): void {
43
+ this.keytool.register(this.deselectKeyListener);
44
+ }
45
+
46
+ disable(): void {
47
+ this.keytool.deregister(this.deselectKeyListener);
48
+ }
49
+ }
50
+
51
+ export class DeselectKeyListener extends KeyListener {
52
+ override keyDown(target: SModelElement, event: KeyboardEvent): Action[] {
53
+ if (this.matchesDeselectKeystroke(event)) {
54
+ const isResizeHandleActive = toArray(target.root.index.all().filter(el => el instanceof SResizeHandle)).length > 0;
55
+
56
+ if (isResizeHandleActive) {
57
+ return [];
58
+ }
59
+
60
+ const deselect = toArray(target.root.index.all().filter(element => isSelectable(element) && element.selected));
61
+ const actions: Action[] = [];
62
+
63
+ if (deselect.length > 0) {
64
+ actions.push(SelectAction.create({ deselectedElementsIDs: deselect.map(e => e.id) }));
65
+ }
66
+
67
+ const routableDeselect = deselect.filter(e => e instanceof SRoutableElement).map(e => e.id);
68
+ if (routableDeselect.length > 0) {
69
+ actions.push(SwitchEditModeAction.create({ elementsToDeactivate: routableDeselect }));
70
+ }
71
+
72
+ return actions;
73
+ }
74
+ return [];
75
+ }
76
+
77
+ protected matchesDeselectKeystroke(event: KeyboardEvent): boolean {
78
+ return matchesKeystroke(event, 'Escape');
79
+ }
80
+ }
@@ -0,0 +1,33 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2019-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 { bindAsService, BindingContext } from '@eclipse-glsp/protocol';
18
+ import { ContainerModule } from 'inversify';
19
+ import { TYPES } from '../../../base/types';
20
+ import { DeselectKeyTool } from '../view-key-tools/deselect-key-tool';
21
+ import { MovementKeyTool } from './movement-key-tool';
22
+ import { ZoomKeyTool } from './zoom-key-tool';
23
+
24
+ export const glspViewKeyToolsModule = new ContainerModule((bind, _unbind, isBound, rebind) => {
25
+ const context = { bind, isBound, rebind };
26
+ configureViewKeyTools(context);
27
+ });
28
+
29
+ export function configureViewKeyTools(context: Pick<BindingContext, 'bind'>): void {
30
+ bindAsService(context, TYPES.IDefaultTool, MovementKeyTool);
31
+ bindAsService(context, TYPES.IDefaultTool, ZoomKeyTool);
32
+ bindAsService(context, TYPES.IDefaultTool, DeselectKeyTool);
33
+ }
@@ -0,0 +1,115 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2023 Business Informatics Group (TU Wien) 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 } from '@eclipse-glsp/protocol';
18
+ import { inject, injectable, optional } from 'inversify';
19
+ import { ISnapper, KeyListener, KeyTool, SModelElement } from 'sprotty';
20
+ import { matchesKeystroke } from 'sprotty/lib/utils/keyboard';
21
+ import { GLSPTool } from '../../../base/tool-manager/glsp-tool-manager';
22
+ import { TYPES } from '../../../base/types';
23
+ import { GridSnapper } from '../../change-bounds/snap';
24
+
25
+ import { SelectionService } from '../../select/selection-service';
26
+ import { MoveElementAction, MoveViewportAction } from '../move-zoom/move-handler';
27
+
28
+ /**
29
+ * Moves viewport and elements when its focused and arrow keys are hit.
30
+ */
31
+ @injectable()
32
+ export class MovementKeyTool implements GLSPTool {
33
+ static ID = 'glsp.movement-key-tool';
34
+
35
+ isEditTool = true;
36
+
37
+ protected readonly movementKeyListener = new MoveKeyListener(this);
38
+
39
+ @inject(KeyTool) protected readonly keytool: KeyTool;
40
+ @inject(TYPES.SelectionService) selectionService: SelectionService;
41
+ @inject(TYPES.ISnapper) @optional() readonly snapper?: ISnapper;
42
+
43
+ get id(): string {
44
+ return MovementKeyTool.ID;
45
+ }
46
+
47
+ enable(): void {
48
+ this.keytool.register(this.movementKeyListener);
49
+ }
50
+
51
+ disable(): void {
52
+ this.keytool.deregister(this.movementKeyListener);
53
+ }
54
+ }
55
+
56
+ export class MoveKeyListener extends KeyListener {
57
+ // Default x distance used if GridSnapper is not provided
58
+ static readonly defaultMoveX = 20;
59
+
60
+ // Default y distance used if GridSnapper is not provided
61
+ static readonly defaultMoveY = 20;
62
+
63
+ protected grid = { x: MoveKeyListener.defaultMoveX, y: MoveKeyListener.defaultMoveY };
64
+
65
+ constructor(protected readonly tool: MovementKeyTool) {
66
+ super();
67
+
68
+ if (this.tool.snapper instanceof GridSnapper) {
69
+ this.grid = this.tool.snapper.grid;
70
+ }
71
+ }
72
+
73
+ override keyDown(element: SModelElement, event: KeyboardEvent): Action[] {
74
+ const selectedElementIds = this.tool.selectionService.getSelectedElementIDs();
75
+
76
+ if (selectedElementIds.length > 0) {
77
+ if (this.matchesMoveUpKeystroke(event)) {
78
+ return [MoveElementAction.create(selectedElementIds, 0, -this.grid.x)];
79
+ } else if (this.matchesMoveDownKeystroke(event)) {
80
+ return [MoveElementAction.create(selectedElementIds, 0, this.grid.x)];
81
+ } else if (this.matchesMoveRightKeystroke(event)) {
82
+ return [MoveElementAction.create(selectedElementIds, this.grid.x, 0)];
83
+ } else if (this.matchesMoveLeftKeystroke(event)) {
84
+ return [MoveElementAction.create(selectedElementIds, -this.grid.x, 0)];
85
+ }
86
+ } else {
87
+ if (this.matchesMoveUpKeystroke(event)) {
88
+ return [MoveViewportAction.create(0, -this.grid.x)];
89
+ } else if (this.matchesMoveDownKeystroke(event)) {
90
+ return [MoveViewportAction.create(0, this.grid.x)];
91
+ } else if (this.matchesMoveRightKeystroke(event)) {
92
+ return [MoveViewportAction.create(this.grid.x, 0)];
93
+ } else if (this.matchesMoveLeftKeystroke(event)) {
94
+ return [MoveViewportAction.create(-this.grid.x, 0)];
95
+ }
96
+ }
97
+ return [];
98
+ }
99
+
100
+ protected matchesMoveUpKeystroke(event: KeyboardEvent): boolean {
101
+ return matchesKeystroke(event, 'ArrowUp');
102
+ }
103
+
104
+ protected matchesMoveDownKeystroke(event: KeyboardEvent): boolean {
105
+ return matchesKeystroke(event, 'ArrowDown');
106
+ }
107
+
108
+ protected matchesMoveRightKeystroke(event: KeyboardEvent): boolean {
109
+ return matchesKeystroke(event, 'ArrowRight');
110
+ }
111
+
112
+ protected matchesMoveLeftKeystroke(event: KeyboardEvent): boolean {
113
+ return matchesKeystroke(event, 'ArrowLeft');
114
+ }
115
+ }
@@ -0,0 +1,94 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2023 Business Informatics Group (TU Wien) 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, CenterAction } from '@eclipse-glsp/protocol';
18
+ import { inject, injectable } from 'inversify';
19
+ import { KeyListener, KeyTool, SModelElement } from 'sprotty';
20
+ import { matchesKeystroke } from 'sprotty/lib/utils/keyboard';
21
+ import { GLSPTool } from '../../../base/tool-manager/glsp-tool-manager';
22
+ import { TYPES } from '../../../base/types';
23
+ import { SelectionService } from '../../select/selection-service';
24
+ import { ZoomElementAction, ZoomViewportAction } from '../move-zoom/zoom-handler';
25
+
26
+ /**
27
+ * Zoom viewport and elements when its focused and arrow keys are hit.
28
+ */
29
+ @injectable()
30
+ export class ZoomKeyTool implements GLSPTool {
31
+ static ID = 'glsp.zoom-key-tool';
32
+
33
+ isEditTool = false;
34
+
35
+ protected readonly zoomKeyListener = new ZoomKeyListener(this);
36
+
37
+ @inject(KeyTool) protected readonly keytool: KeyTool;
38
+ @inject(TYPES.SelectionService) selectionService: SelectionService;
39
+
40
+ get id(): string {
41
+ return ZoomKeyTool.ID;
42
+ }
43
+
44
+ enable(): void {
45
+ this.keytool.register(this.zoomKeyListener);
46
+ }
47
+
48
+ disable(): void {
49
+ this.keytool.deregister(this.zoomKeyListener);
50
+ }
51
+ }
52
+
53
+ export class ZoomKeyListener extends KeyListener {
54
+ static readonly defaultZoomInFactor = 1.1;
55
+ static readonly defaultZoomOutFactor = 0.9;
56
+
57
+ constructor(protected tool: ZoomKeyTool) {
58
+ super();
59
+ }
60
+
61
+ override keyDown(element: SModelElement, event: KeyboardEvent): Action[] {
62
+ const selectedElementIds = this.tool.selectionService.getSelectedElementIDs();
63
+
64
+ if (this.matchesZoomOutKeystroke(event)) {
65
+ if (selectedElementIds.length > 0) {
66
+ return [ZoomElementAction.create(selectedElementIds, ZoomKeyListener.defaultZoomOutFactor)];
67
+ } else {
68
+ return [ZoomViewportAction.create(ZoomKeyListener.defaultZoomOutFactor)];
69
+ }
70
+ } else if (this.matchesZoomInKeystroke(event)) {
71
+ if (selectedElementIds.length > 0) {
72
+ return [ZoomElementAction.create(selectedElementIds, ZoomKeyListener.defaultZoomInFactor)];
73
+ } else {
74
+ return [ZoomViewportAction.create(ZoomKeyListener.defaultZoomInFactor)];
75
+ }
76
+ } else if (this.matchesMinZoomLevelKeystroke(event)) {
77
+ return [CenterAction.create(selectedElementIds)];
78
+ }
79
+ return [];
80
+ }
81
+
82
+ protected matchesZoomInKeystroke(event: KeyboardEvent): boolean {
83
+ /** here event.key is used for '+', as keycode 187 is already declared for 'Equals' in {@link matchesKeystroke}.*/
84
+ return event.key === '+' || matchesKeystroke(event, 'NumpadAdd');
85
+ }
86
+
87
+ protected matchesMinZoomLevelKeystroke(event: KeyboardEvent): boolean {
88
+ return matchesKeystroke(event, 'Digit0', 'ctrl') || matchesKeystroke(event, 'Numpad0', 'ctrl');
89
+ }
90
+
91
+ protected matchesZoomOutKeystroke(event: KeyboardEvent): boolean {
92
+ return matchesKeystroke(event, 'Minus') || matchesKeystroke(event, 'NumpadSubtract');
93
+ }
94
+ }
@@ -0,0 +1,37 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2023 Business Informatics Group (TU Wien) 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 { LabeledAction, SModelElement, SModelRoot } from 'sprotty';
18
+
19
+ /**
20
+ * Interface for a provider that provides suggestions that can be used to fill the autocomplete
21
+ */
22
+ export interface IAutocompleteSuggestionProvider {
23
+ /**
24
+ * Returns the suggestions based on the provided parameters.
25
+ * @param root: The root model
26
+ * @param text: The text input provided by the user.
27
+ */
28
+ retrieveSuggestions(root: Readonly<SModelRoot>, text: string): Promise<AutocompleteSuggestion[]>;
29
+ }
30
+
31
+ /**
32
+ * Interface for autocomplete suggestions.
33
+ */
34
+ export interface AutocompleteSuggestion {
35
+ element: SModelElement;
36
+ action: LabeledAction;
37
+ }
@@ -0,0 +1,88 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2023 Business Informatics Group (TU Wien) 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 } from '@eclipse-glsp/protocol';
18
+ import { inject } from 'inversify';
19
+ import { AbstractUIExtension, LabeledAction, SModelRoot, TYPES } from 'sprotty';
20
+ import '../../../css/autocomplete-palette.css';
21
+ import { GLSPActionDispatcher } from '../../base/action-dispatcher';
22
+ import { AutoCompleteWidget, CloseReason, toActionArray } from '../../base/auto-complete/auto-complete-widget';
23
+
24
+ export abstract class BaseAutocompletePalette extends AbstractUIExtension {
25
+ protected readonly autoSuggestionSettings = {
26
+ noSuggestionsMessage: 'No suggestions available',
27
+ suggestionsClass: 'command-palette-suggestions',
28
+ debounceWaitMs: 50,
29
+ showOnFocus: true
30
+ };
31
+
32
+ protected root?: Readonly<SModelRoot>;
33
+ protected autocompleteWidget: AutoCompleteWidget;
34
+
35
+ @inject(TYPES.IActionDispatcher)
36
+ protected actionDispatcher: GLSPActionDispatcher;
37
+
38
+ containerClass(): string {
39
+ return 'autocomplete-palette';
40
+ }
41
+
42
+ override show(root: Readonly<SModelRoot>, ...contextElementIds: string[]): void {
43
+ super.show(root, ...contextElementIds);
44
+ this.root = root;
45
+ this.autocompleteWidget.open(root);
46
+ }
47
+
48
+ override hide(): void {
49
+ this.autocompleteWidget.dispose();
50
+ this.root = undefined;
51
+ super.hide();
52
+ }
53
+
54
+ protected initializeContents(containerElement: HTMLElement): void {
55
+ containerElement.classList.add('command-palette');
56
+
57
+ this.autocompleteWidget = new AutoCompleteWidget(
58
+ this.autoSuggestionSettings,
59
+ { provideSuggestions: input => this.retrieveSuggestions(this.root!, input) },
60
+ { executeFromSuggestion: input => this.executeSuggestion(input) },
61
+ reason => this.autocompleteHide(reason),
62
+ this.logger,
63
+ {
64
+ visibleSuggestionsChanged: suggestions => this.visibleSuggestionsChanged(this.root!, suggestions),
65
+ selectedSuggestionChanged: suggestion => this.selectedSuggestionChanged(this.root!, suggestion)
66
+ }
67
+ );
68
+ this.autocompleteWidget.initialize(containerElement);
69
+ }
70
+
71
+ protected abstract retrieveSuggestions(root: Readonly<SModelRoot>, input: string): Promise<LabeledAction[]>;
72
+
73
+ protected async visibleSuggestionsChanged(root: Readonly<SModelRoot>, labeledActions: LabeledAction[]): Promise<void> {
74
+ return;
75
+ }
76
+
77
+ protected async selectedSuggestionChanged(root: Readonly<SModelRoot>, labeledAction?: LabeledAction): Promise<void> {
78
+ return;
79
+ }
80
+
81
+ protected autocompleteHide(reason: CloseReason): void {
82
+ this.hide();
83
+ }
84
+
85
+ protected executeSuggestion(input: LabeledAction | Action[] | Action): void {
86
+ this.actionDispatcher.dispatchAll(toActionArray(input));
87
+ }
88
+ }
package/src/index.ts CHANGED
@@ -14,11 +14,14 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
  import defaultGLSPModule from './base/di.config';
17
+ import { glspAccessibilityModule } from './features/accessibility/di.config';
18
+ import { glspMoveZoomModule } from './features/accessibility/move-zoom/di.config';
19
+ import { glspSearchPaletteModule } from './features/accessibility/search/di.config';
20
+ import { glspViewKeyToolsModule } from './features/accessibility/view-key-tools/di.config';
17
21
  import glspCommandPaletteModule from './features/command-palette/di.config';
18
22
  import glspContextMenuModule from './features/context-menu/di.config';
19
23
  import { copyPasteContextMenuModule, glspServerCopyPasteModule } from './features/copy-paste/di.config';
20
24
  import glspDecorationModule from './features/decoration/di.config';
21
- import svgMetadataModule from './features/svg-metadata/di.config';
22
25
  import glspEditLabelModule from './features/edit-label/di.config';
23
26
  import modelHintsModule from './features/hints/di.config';
24
27
  import glspHoverModule from './features/hover/di.config';
@@ -28,6 +31,7 @@ import navigationModule from './features/navigation/di.config';
28
31
  import saveModule from './features/save/di.config';
29
32
  import glspSelectModule from './features/select/di.config';
30
33
  import sourceModelWatcherModule from './features/source-model-watcher/di.config';
34
+ import svgMetadataModule from './features/svg-metadata/di.config';
31
35
  import toolFeedbackModule from './features/tool-feedback/di.config';
32
36
  import paletteModule from './features/tool-palette/di.config';
33
37
  import { enableDefaultToolsOnFocusLossModule, toolsModule } from './features/tools/di.config';
@@ -56,6 +60,9 @@ export * from './base/tool-manager/glsp-tool-manager';
56
60
  export * from './base/tool-manager/tool-actions';
57
61
  export * from './base/types';
58
62
  export * from './base/view/view-registry';
63
+ export * from './features/accessibility/view-key-tools/deselect-key-tool';
64
+ export * from './features/accessibility/view-key-tools/movement-key-tool';
65
+ export * from './features/accessibility/view-key-tools/zoom-key-tool';
59
66
  //
60
67
  // ------------------ Features ------------------
61
68
  export * from './features/bounds/freeform-layout';
@@ -74,7 +81,6 @@ export * from './features/context-menu/server-context-menu-provider';
74
81
  export * from './features/copy-paste/copy-paste-context-menu';
75
82
  export * from './features/copy-paste/copy-paste-handler';
76
83
  export * from './features/decoration/decoration-placer';
77
- export * from './features/svg-metadata/metadata-placer';
78
84
  export * from './features/edit-label/edit-label-tool';
79
85
  export * from './features/edit-label/edit-label-validator';
80
86
  export * from './features/export/glsp-svg-exporter';
@@ -93,6 +99,7 @@ export * from './features/select/select-feedback-action';
93
99
  export * from './features/select/select-mouse-listener';
94
100
  export * from './features/select/selection-service';
95
101
  export * from './features/source-model-watcher/source-model-changed-action-handler';
102
+ export * from './features/svg-metadata/metadata-placer';
96
103
  export * from './features/tool-feedback/change-bounds-tool-feedback';
97
104
  export * from './features/tool-feedback/creation-tool-feedback';
98
105
  export * from './features/tool-feedback/css-feedback';
@@ -154,5 +161,9 @@ export {
154
161
  sourceModelWatcherModule,
155
162
  markerNavigatorContextMenuModule,
156
163
  glspViewportModule,
157
- svgMetadataModule
164
+ svgMetadataModule,
165
+ glspViewKeyToolsModule,
166
+ glspMoveZoomModule,
167
+ glspAccessibilityModule,
168
+ glspSearchPaletteModule
158
169
  };