@eclipse-glsp/client 2.1.0 → 2.2.0-next.325
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/ghost-element.css +3 -1
- package/css/glsp-sprotty.css +4 -5
- package/lib/base/action-dispatcher.d.ts +3 -2
- package/lib/base/action-dispatcher.d.ts.map +1 -1
- package/lib/base/action-dispatcher.js +17 -2
- package/lib/base/action-dispatcher.js.map +1 -1
- package/lib/base/action-dispatcher.spec.js +2 -2
- package/lib/base/action-dispatcher.spec.js.map +1 -1
- package/lib/base/action-handler-registry.d.ts +6 -2
- package/lib/base/action-handler-registry.d.ts.map +1 -1
- package/lib/base/action-handler-registry.js +31 -3
- package/lib/base/action-handler-registry.js.map +1 -1
- package/lib/base/command-stack.d.ts +8 -16
- package/lib/base/command-stack.d.ts.map +1 -1
- package/lib/base/command-stack.js +15 -14
- package/lib/base/command-stack.js.map +1 -1
- package/lib/base/default.module.d.ts +1 -1
- package/lib/base/default.module.d.ts.map +1 -1
- package/lib/base/default.module.js +16 -3
- package/lib/base/default.module.js.map +1 -1
- package/lib/base/editor-context-service.d.ts +44 -3
- package/lib/base/editor-context-service.d.ts.map +1 -1
- package/lib/base/editor-context-service.js +36 -13
- package/lib/base/editor-context-service.js.map +1 -1
- package/lib/base/feedback/feedback-action-dispatcher.d.ts +28 -1
- package/lib/base/feedback/feedback-action-dispatcher.d.ts.map +1 -1
- package/lib/base/feedback/feedback-action-dispatcher.js +27 -2
- package/lib/base/feedback/feedback-action-dispatcher.js.map +1 -1
- package/lib/base/feedback/feedback-command.d.ts +9 -4
- package/lib/base/feedback/feedback-command.d.ts.map +1 -1
- package/lib/base/feedback/feedback-command.js +14 -3
- package/lib/base/feedback/feedback-command.js.map +1 -1
- package/lib/base/feedback/index.d.ts +2 -1
- package/lib/base/feedback/index.d.ts.map +1 -1
- package/lib/base/feedback/index.js +2 -1
- package/lib/base/feedback/index.js.map +1 -1
- package/lib/base/feedback/set-model-command.d.ts +25 -0
- package/lib/base/feedback/set-model-command.d.ts.map +1 -0
- package/lib/base/feedback/set-model-command.js +65 -0
- package/lib/base/feedback/set-model-command.js.map +1 -0
- package/lib/base/feedback/update-model-command.d.ts +17 -6
- package/lib/base/feedback/update-model-command.d.ts.map +1 -1
- package/lib/base/feedback/update-model-command.js +9 -29
- package/lib/base/feedback/update-model-command.js.map +1 -1
- package/lib/base/index.d.ts +2 -1
- package/lib/base/index.d.ts.map +1 -1
- package/lib/base/index.js +2 -1
- package/lib/base/index.js.map +1 -1
- package/lib/base/model/diagram-loader.d.ts +12 -7
- package/lib/base/model/diagram-loader.d.ts.map +1 -1
- package/lib/base/model/diagram-loader.js +10 -17
- package/lib/base/model/diagram-loader.js.map +1 -1
- package/lib/base/model/glsp-model-source.d.ts +1 -1
- package/lib/base/model/glsp-model-source.js +1 -1
- package/lib/base/ranked.d.ts +11 -1
- package/lib/base/ranked.d.ts.map +1 -1
- package/lib/base/ranked.js +7 -1
- package/lib/base/ranked.js.map +1 -1
- package/lib/base/selection-service.d.ts +9 -8
- package/lib/base/selection-service.d.ts.map +1 -1
- package/lib/base/selection-service.js +11 -14
- package/lib/base/selection-service.js.map +1 -1
- package/lib/base/selection-service.spec.js +5 -1
- package/lib/base/selection-service.spec.js.map +1 -1
- package/lib/base/tool-manager/tool-manager.d.ts +10 -8
- package/lib/base/tool-manager/tool-manager.d.ts.map +1 -1
- package/lib/base/tool-manager/tool-manager.js +25 -22
- package/lib/base/tool-manager/tool-manager.js.map +1 -1
- package/lib/base/ui-extension-registry.d.ts +23 -0
- package/lib/base/ui-extension-registry.d.ts.map +1 -0
- package/lib/base/ui-extension-registry.js +51 -0
- package/lib/base/ui-extension-registry.js.map +1 -0
- package/lib/base/view/key-tool.d.ts +21 -2
- package/lib/base/view/key-tool.d.ts.map +1 -1
- package/lib/base/view/key-tool.js +21 -3
- package/lib/base/view/key-tool.js.map +1 -1
- package/lib/base/view/mouse-tool.d.ts +20 -3
- package/lib/base/view/mouse-tool.d.ts.map +1 -1
- package/lib/base/view/mouse-tool.js +9 -5
- package/lib/base/view/mouse-tool.js.map +1 -1
- package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts +6 -4
- package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts.map +1 -1
- package/lib/features/bounds/glsp-hidden-bounds-updater.js +20 -3
- package/lib/features/bounds/glsp-hidden-bounds-updater.js.map +1 -1
- package/lib/features/bounds/local-bounds.d.ts +8 -4
- package/lib/features/bounds/local-bounds.d.ts.map +1 -1
- package/lib/features/bounds/local-bounds.js +9 -5
- package/lib/features/bounds/local-bounds.js.map +1 -1
- package/lib/features/bounds/set-bounds-feedback-command.d.ts +2 -2
- package/lib/features/bounds/set-bounds-feedback-command.d.ts.map +1 -1
- package/lib/features/bounds/set-bounds-feedback-command.js +5 -3
- package/lib/features/bounds/set-bounds-feedback-command.js.map +1 -1
- package/lib/features/change-bounds/position-snapper.d.ts +1 -1
- package/lib/features/change-bounds/position-snapper.js +1 -1
- package/lib/features/element-template/add-template-element.d.ts +1 -1
- package/lib/features/element-template/add-template-element.d.ts.map +1 -1
- package/lib/features/element-template/add-template-element.js +6 -5
- package/lib/features/element-template/add-template-element.js.map +1 -1
- package/lib/features/helper-lines/helper-line-feedback.d.ts +1 -1
- package/lib/features/helper-lines/helper-line-feedback.d.ts.map +1 -1
- package/lib/features/helper-lines/helper-line-feedback.js +9 -3
- package/lib/features/helper-lines/helper-line-feedback.js.map +1 -1
- package/lib/features/helper-lines/helper-line-manager-default.d.ts +1 -1
- package/lib/features/helper-lines/helper-line-manager-default.js +1 -1
- package/lib/features/helper-lines/helper-line-manager.d.ts +1 -1
- package/lib/features/hints/type-hint-provider.d.ts +17 -2
- package/lib/features/hints/type-hint-provider.d.ts.map +1 -1
- package/lib/features/hints/type-hint-provider.js +13 -13
- package/lib/features/hints/type-hint-provider.js.map +1 -1
- package/lib/features/navigation/navigation-action-handler.d.ts +15 -0
- package/lib/features/navigation/navigation-action-handler.d.ts.map +1 -1
- package/lib/features/navigation/navigation-action-handler.js +2 -2
- package/lib/features/navigation/navigation-action-handler.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-feedback.d.ts +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js +1 -1
- package/lib/features/tools/marquee-selection/marquee-behavior.spec.d.ts +1 -1
- package/lib/features/tools/marquee-selection/marquee-behavior.spec.js +1 -1
- package/lib/features/validation/validate.d.ts +20 -2
- package/lib/features/validation/validate.d.ts.map +1 -1
- package/lib/features/validation/validate.js +14 -11
- package/lib/features/validation/validate.js.map +1 -1
- package/lib/utils/gmodel-util.d.ts +2 -1
- package/lib/utils/gmodel-util.d.ts.map +1 -1
- package/lib/utils/gmodel-util.js +15 -5
- package/lib/utils/gmodel-util.js.map +1 -1
- package/lib/utils/html-utils.js +1 -1
- package/package.json +7 -6
- package/src/base/action-dispatcher.spec.ts +5 -4
- package/src/base/action-dispatcher.ts +20 -4
- package/src/base/action-handler-registry.ts +24 -3
- package/src/base/command-stack.ts +17 -29
- package/src/base/default.module.ts +22 -4
- package/src/base/editor-context-service.ts +61 -16
- package/src/base/feedback/feedback-action-dispatcher.ts +50 -2
- package/src/base/feedback/feedback-command.ts +16 -5
- package/src/base/feedback/index.ts +3 -1
- package/src/base/feedback/set-model-command.ts +45 -0
- package/src/base/feedback/update-model-command.ts +9 -46
- package/src/base/index.ts +2 -1
- package/src/base/model/diagram-loader.ts +21 -14
- package/src/base/model/glsp-model-source.ts +1 -1
- package/src/base/ranked.ts +15 -1
- package/src/base/selection-service.spec.ts +8 -2
- package/src/base/selection-service.ts +22 -21
- package/src/base/tool-manager/tool-manager.ts +27 -23
- package/src/base/ui-extension-registry.ts +33 -0
- package/src/base/view/key-tool.ts +16 -4
- package/src/base/view/mouse-tool.ts +23 -6
- package/src/features/bounds/glsp-hidden-bounds-updater.ts +27 -5
- package/src/features/bounds/local-bounds.ts +24 -7
- package/src/features/bounds/set-bounds-feedback-command.ts +5 -3
- package/src/features/change-bounds/position-snapper.ts +1 -1
- package/src/features/element-template/add-template-element.ts +6 -5
- package/src/features/helper-lines/helper-line-feedback.ts +9 -3
- package/src/features/helper-lines/helper-line-manager-default.ts +1 -1
- package/src/features/helper-lines/helper-line-manager.ts +1 -1
- package/src/features/hints/type-hint-provider.ts +6 -6
- package/src/features/navigation/navigation-action-handler.ts +2 -2
- package/src/features/tools/change-bounds/change-bounds-tool-feedback.ts +1 -1
- package/src/features/tools/marquee-selection/marquee-behavior.spec.ts +1 -1
- package/src/features/validation/validate.ts +19 -12
- package/src/utils/gmodel-util.ts +16 -5
- package/src/utils/html-utils.ts +1 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
GModelElement,
|
|
26
26
|
GModelRoot,
|
|
27
27
|
ILogger,
|
|
28
|
+
LazyInjector,
|
|
28
29
|
SelectAction,
|
|
29
30
|
SelectAllAction,
|
|
30
31
|
Selectable,
|
|
@@ -35,10 +36,11 @@ import {
|
|
|
35
36
|
isSelectable,
|
|
36
37
|
pluck
|
|
37
38
|
} from '@eclipse-glsp/sprotty';
|
|
38
|
-
import { inject, injectable,
|
|
39
|
+
import { inject, injectable, postConstruct, preDestroy } from 'inversify';
|
|
39
40
|
import { getElements, getMatchingElements } from '../utils/gmodel-util';
|
|
40
|
-
import {
|
|
41
|
+
import { IGModelRootListener } from './editor-context-service';
|
|
41
42
|
import { IFeedbackActionDispatcher } from './feedback/feedback-action-dispatcher';
|
|
43
|
+
import { IDiagramStartup } from './model';
|
|
42
44
|
|
|
43
45
|
export interface ISelectionListener {
|
|
44
46
|
selectionChanged(root: Readonly<GModelRoot>, selectedElements: string[], deselectedElements?: string[]): void;
|
|
@@ -51,35 +53,34 @@ export interface SelectionChange {
|
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
@injectable()
|
|
54
|
-
export class SelectionService implements IGModelRootListener, Disposable {
|
|
55
|
-
protected root: Readonly<GModelRoot>;
|
|
56
|
-
protected selectedElementIDs: Set<string> = new Set();
|
|
57
|
-
|
|
56
|
+
export class SelectionService implements IGModelRootListener, Disposable, IDiagramStartup {
|
|
58
57
|
@inject(TYPES.IFeedbackActionDispatcher)
|
|
59
58
|
protected feedbackDispatcher: IFeedbackActionDispatcher;
|
|
60
59
|
|
|
60
|
+
@inject(LazyInjector)
|
|
61
|
+
protected lazyInjector: LazyInjector;
|
|
62
|
+
|
|
61
63
|
@inject(TYPES.ILogger)
|
|
62
64
|
protected logger: ILogger;
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
protected
|
|
66
|
-
|
|
67
|
-
@multiInject(TYPES.ISelectionListener)
|
|
68
|
-
@optional()
|
|
69
|
-
protected selectionListeners: ISelectionListener[] = [];
|
|
66
|
+
protected root: Readonly<GModelRoot>;
|
|
67
|
+
protected selectedElementIDs: Set<string> = new Set();
|
|
70
68
|
|
|
71
69
|
protected toDispose = new DisposableCollection();
|
|
72
70
|
|
|
73
71
|
@postConstruct()
|
|
74
72
|
protected initialize(): void {
|
|
75
|
-
this.toDispose.push(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
this.toDispose.push(this.onSelectionChangedEmitter);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
preLoadDiagram(): void {
|
|
77
|
+
this.lazyInjector
|
|
78
|
+
.getAll<ISelectionListener>('selectionListener')
|
|
79
|
+
.forEach(listener =>
|
|
80
|
+
this.onSelectionChanged(change =>
|
|
81
|
+
listener.selectionChanged(change.root, change.selectedElements, change.deselectedElements)
|
|
82
|
+
)
|
|
83
|
+
);
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
@preDestroy()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -14,19 +14,23 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
|
|
17
|
-
import { inject, injectable, multiInject, optional } from 'inversify';
|
|
18
17
|
import {
|
|
19
18
|
Action,
|
|
20
19
|
EditMode,
|
|
20
|
+
GModelElement,
|
|
21
21
|
IActionHandler,
|
|
22
22
|
ICommand,
|
|
23
23
|
KeyListener,
|
|
24
|
-
|
|
24
|
+
LazyInjector,
|
|
25
|
+
MaybePromise,
|
|
25
26
|
TYPES,
|
|
26
27
|
distinctAdd,
|
|
27
28
|
matchesKeystroke
|
|
28
29
|
} from '@eclipse-glsp/sprotty';
|
|
29
|
-
import {
|
|
30
|
+
import { inject, injectable } from 'inversify';
|
|
31
|
+
import { EditorContextService, IEditModeListener } from '../editor-context-service';
|
|
32
|
+
import { IDiagramStartup } from '../model';
|
|
33
|
+
import { Ranked } from '../ranked';
|
|
30
34
|
import { EnableDefaultToolsAction, EnableToolsAction, Tool } from './tool';
|
|
31
35
|
/**
|
|
32
36
|
* A tool manager coordinates the state of tools in the context of an editor.
|
|
@@ -75,27 +79,23 @@ export interface IToolManager {
|
|
|
75
79
|
* registration of tools via Dependency Injection.
|
|
76
80
|
*/
|
|
77
81
|
@injectable()
|
|
78
|
-
export class ToolManager implements IToolManager {
|
|
79
|
-
|
|
82
|
+
export class ToolManager implements IToolManager, IDiagramStartup, IEditModeListener {
|
|
83
|
+
@inject(EditorContextService)
|
|
84
|
+
protected editorContext: EditorContextService;
|
|
85
|
+
|
|
86
|
+
@inject(LazyInjector)
|
|
87
|
+
protected readonly lazyInjector: LazyInjector;
|
|
80
88
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
@inject(TYPES.IEditorContextServiceProvider) protected contextServiceProvider: EditorContextServiceProvider
|
|
91
|
-
) {
|
|
92
|
-
this.registerTools(...this.tools);
|
|
93
|
-
this.registerDefaultTools(...this.defaultTools);
|
|
89
|
+
readonly actives: Tool[] = [];
|
|
90
|
+
readonly tools: Tool[] = [];
|
|
91
|
+
readonly defaultTools: Tool[] = [];
|
|
92
|
+
|
|
93
|
+
preLoadDiagram(): MaybePromise<void> {
|
|
94
|
+
const tools: Tool[] = this.lazyInjector.getAll(TYPES.ITool);
|
|
95
|
+
const defaultTools: Tool[] = this.lazyInjector.getAll(TYPES.IDefaultTool);
|
|
96
|
+
this.registerTools(...tools);
|
|
97
|
+
this.registerDefaultTools(...defaultTools);
|
|
94
98
|
this.enableDefaultTools();
|
|
95
|
-
this.contextServiceProvider().then(editorContext => {
|
|
96
|
-
editorContext.onEditModeChanged(change => this.editModeChanged(change.newValue, change.oldValue));
|
|
97
|
-
this.editorContext = editorContext;
|
|
98
|
-
});
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
get managedTools(): Tool[] {
|
|
@@ -106,6 +106,10 @@ export class ToolManager implements IToolManager {
|
|
|
106
106
|
return this.actives;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
get rank(): number {
|
|
110
|
+
return Ranked.DEFAULT_RANK - 100;
|
|
111
|
+
}
|
|
112
|
+
|
|
109
113
|
registerDefaultTools(...tools: Tool[]): void {
|
|
110
114
|
distinctAdd(this.defaultTools, ...tools);
|
|
111
115
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 { IUIExtension, LazyInjector, MaybePromise, TYPES, UIExtensionRegistry } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import { inject, injectable, optional } from 'inversify';
|
|
19
|
+
import { IDiagramStartup } from './model';
|
|
20
|
+
|
|
21
|
+
@injectable()
|
|
22
|
+
export class GLSPUIExtensionRegistry extends UIExtensionRegistry implements IDiagramStartup {
|
|
23
|
+
@inject(LazyInjector)
|
|
24
|
+
protected lazyInjector: LazyInjector;
|
|
25
|
+
|
|
26
|
+
constructor(@optional() extensions: IUIExtension[] = []) {
|
|
27
|
+
super(extensions);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
preLoadDiagram(): MaybePromise<void> {
|
|
31
|
+
this.lazyInjector.getAll<IUIExtension>(TYPES.IUIExtension).forEach(extension => this.register(extension.id(), extension));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2023 EclipseSource and others.
|
|
2
|
+
* Copyright (c) 2023-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -13,13 +13,25 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { Disposable, KeyListener, KeyTool, LazyInjector, MaybePromise, TYPES } from '@eclipse-glsp/sprotty';
|
|
17
|
+
import { inject, injectable, optional } from 'inversify';
|
|
18
|
+
import { IDiagramStartup } from '../model';
|
|
18
19
|
|
|
19
20
|
@injectable()
|
|
20
|
-
export class GLSPKeyTool extends KeyTool {
|
|
21
|
+
export class GLSPKeyTool extends KeyTool implements IDiagramStartup {
|
|
22
|
+
@inject(LazyInjector)
|
|
23
|
+
protected lazyInjector: LazyInjector;
|
|
24
|
+
|
|
25
|
+
constructor(@optional() keyListeners: KeyListener[] = []) {
|
|
26
|
+
super(keyListeners);
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
registerListener(keyListener: KeyListener): Disposable {
|
|
22
30
|
super.register(keyListener);
|
|
23
31
|
return Disposable.create(() => this.deregister(keyListener));
|
|
24
32
|
}
|
|
33
|
+
|
|
34
|
+
preLoadDiagram(): MaybePromise<void> {
|
|
35
|
+
this.lazyInjector.getAll<KeyListener>(TYPES.KeyListener).forEach(listener => this.register(listener));
|
|
36
|
+
}
|
|
25
37
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -13,8 +13,19 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import {
|
|
17
|
-
|
|
16
|
+
import {
|
|
17
|
+
Action,
|
|
18
|
+
Disposable,
|
|
19
|
+
GModelElement,
|
|
20
|
+
GModelRoot,
|
|
21
|
+
LazyInjector,
|
|
22
|
+
MaybePromise,
|
|
23
|
+
MouseListener,
|
|
24
|
+
MouseTool,
|
|
25
|
+
TYPES
|
|
26
|
+
} from '@eclipse-glsp/sprotty';
|
|
27
|
+
import { inject, injectable, optional } from 'inversify';
|
|
28
|
+
import { IDiagramStartup } from '../model';
|
|
18
29
|
import { Ranked } from '../ranked';
|
|
19
30
|
|
|
20
31
|
/**
|
|
@@ -24,12 +35,18 @@ import { Ranked } from '../ranked';
|
|
|
24
35
|
type MouseListenerMethods = keyof Omit<MouseListener, 'decorate'>;
|
|
25
36
|
|
|
26
37
|
@injectable()
|
|
27
|
-
export class GLSPMouseTool extends MouseTool {
|
|
38
|
+
export class GLSPMouseTool extends MouseTool implements IDiagramStartup {
|
|
39
|
+
@inject(LazyInjector)
|
|
40
|
+
protected lazyInjector: LazyInjector;
|
|
41
|
+
|
|
28
42
|
protected rankedMouseListeners: Map<number, MouseListener[]>;
|
|
29
43
|
|
|
30
|
-
constructor(@
|
|
44
|
+
constructor(@optional() mouseListeners: MouseListener[] = []) {
|
|
31
45
|
super(mouseListeners);
|
|
32
|
-
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
preLoadDiagram(): MaybePromise<void> {
|
|
49
|
+
this.lazyInjector.getAll<MouseListener>(TYPES.MouseListener).forEach(listener => this.register(listener));
|
|
33
50
|
}
|
|
34
51
|
|
|
35
52
|
override register(mouseListener: MouseListener): void {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022-
|
|
2
|
+
* Copyright (c) 2022-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -16,20 +16,21 @@
|
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
18
|
Action,
|
|
19
|
+
BoundsData,
|
|
19
20
|
ComputedBoundsAction,
|
|
20
21
|
Deferred,
|
|
21
22
|
EdgeRouterRegistry,
|
|
22
23
|
ElementAndRoutingPoints,
|
|
23
24
|
GModelElement,
|
|
24
|
-
GRoutableElement,
|
|
25
25
|
HiddenBoundsUpdater,
|
|
26
26
|
IActionDispatcher,
|
|
27
|
+
ModelIndexImpl,
|
|
27
28
|
RequestAction,
|
|
28
29
|
ResponseAction
|
|
29
30
|
} from '@eclipse-glsp/sprotty';
|
|
30
31
|
import { inject, injectable, optional } from 'inversify';
|
|
31
32
|
import { VNode } from 'snabbdom';
|
|
32
|
-
import { calcElementAndRoute, isRoutable } from '../../utils/gmodel-util';
|
|
33
|
+
import { BoundsAwareModelElement, calcElementAndRoute, getDescendantIds, isRoutable } from '../../utils/gmodel-util';
|
|
33
34
|
import { LocalComputedBoundsAction, LocalRequestBoundsAction } from './local-bounds';
|
|
34
35
|
|
|
35
36
|
/**
|
|
@@ -42,8 +43,10 @@ export class GLSPHiddenBoundsUpdater extends HiddenBoundsUpdater {
|
|
|
42
43
|
@inject(EdgeRouterRegistry) @optional() protected readonly edgeRouterRegistry?: EdgeRouterRegistry;
|
|
43
44
|
|
|
44
45
|
protected element2route: ElementAndRoutingPoints[] = [];
|
|
45
|
-
|
|
46
|
-
protected
|
|
46
|
+
|
|
47
|
+
protected getElement2BoundsData(): Map<BoundsAwareModelElement, BoundsData> {
|
|
48
|
+
return this['element2boundsData'];
|
|
49
|
+
}
|
|
47
50
|
|
|
48
51
|
override decorate(vnode: VNode, element: GModelElement): VNode {
|
|
49
52
|
super.decorate(vnode, element);
|
|
@@ -54,6 +57,9 @@ export class GLSPHiddenBoundsUpdater extends HiddenBoundsUpdater {
|
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
override postUpdate(cause?: Action): void {
|
|
60
|
+
if (LocalRequestBoundsAction.is(cause) && cause.elementIDs) {
|
|
61
|
+
this.focusOnElements(cause.elementIDs);
|
|
62
|
+
}
|
|
57
63
|
const actions = this.captureActions(() => super.postUpdate(cause));
|
|
58
64
|
actions
|
|
59
65
|
.filter(action => ComputedBoundsAction.is(action))
|
|
@@ -61,6 +67,22 @@ export class GLSPHiddenBoundsUpdater extends HiddenBoundsUpdater {
|
|
|
61
67
|
this.element2route = [];
|
|
62
68
|
}
|
|
63
69
|
|
|
70
|
+
protected focusOnElements(elementIDs: string[]): void {
|
|
71
|
+
const data = this.getElement2BoundsData();
|
|
72
|
+
if (data.size > 0) {
|
|
73
|
+
// expand given IDs to their descendent element IDs as we need their bounding boxes as well
|
|
74
|
+
const index = [...data.keys()][0].index;
|
|
75
|
+
const relevantIds = new Set(elementIDs.flatMap(elementId => this.expandElementId(elementId, index, elementIDs)));
|
|
76
|
+
|
|
77
|
+
// ensure we only keep the bounds of the elements we are interested in
|
|
78
|
+
data.forEach((_bounds, element) => !relevantIds.has(element.id) && data.delete(element));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
protected expandElementId(id: string, index: ModelIndexImpl, elementIDs: string[]): string[] {
|
|
83
|
+
return getDescendantIds(index.getById(id));
|
|
84
|
+
}
|
|
85
|
+
|
|
64
86
|
protected captureActions(call: () => void): Action[] {
|
|
65
87
|
const capturingActionDispatcher = new CapturingActionDispatcher();
|
|
66
88
|
const actualActionDispatcher = this.actionDispatcher;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2023 EclipseSource and others.
|
|
2
|
+
* Copyright (c) 2023-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -26,21 +26,38 @@ import {
|
|
|
26
26
|
GModelRootSchema,
|
|
27
27
|
RequestBoundsAction,
|
|
28
28
|
TYPES,
|
|
29
|
-
ViewerOptions
|
|
29
|
+
ViewerOptions,
|
|
30
|
+
hasArrayProp
|
|
30
31
|
} from '@eclipse-glsp/sprotty';
|
|
31
32
|
import { inject, injectable } from 'inversify';
|
|
32
33
|
import { ServerAction } from '../../base/model/glsp-model-source';
|
|
33
34
|
|
|
35
|
+
export interface LocalRequestBoundsAction extends RequestBoundsAction {
|
|
36
|
+
elementIDs?: string[];
|
|
37
|
+
}
|
|
38
|
+
|
|
34
39
|
export namespace LocalRequestBoundsAction {
|
|
35
|
-
export function is(object: unknown): object is
|
|
36
|
-
return RequestBoundsAction.is(object) && !ServerAction.is(object);
|
|
40
|
+
export function is(object: unknown): object is LocalRequestBoundsAction {
|
|
41
|
+
return RequestBoundsAction.is(object) && !ServerAction.is(object) && hasArrayProp(object, 'elementIDs', true);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function create(newRoot: GModelRootSchema, elementIDs?: string[]): LocalRequestBoundsAction {
|
|
45
|
+
return {
|
|
46
|
+
...RequestBoundsAction.create(newRoot),
|
|
47
|
+
elementIDs
|
|
48
|
+
};
|
|
37
49
|
}
|
|
38
50
|
|
|
39
|
-
export function fromCommand(
|
|
51
|
+
export function fromCommand(
|
|
52
|
+
{ root }: CommandExecutionContext,
|
|
53
|
+
actionDispatcher: ActionDispatcher,
|
|
54
|
+
cause?: Action,
|
|
55
|
+
elementIDs?: string[]
|
|
56
|
+
): CommandResult {
|
|
40
57
|
// do not modify the main model (modelChanged = false) but request local bounds calculation on hidden model
|
|
41
|
-
actionDispatcher.dispatch(
|
|
58
|
+
actionDispatcher.dispatch(LocalRequestBoundsAction.create(root as unknown as GModelRootSchema, elementIDs));
|
|
42
59
|
return {
|
|
43
|
-
model:
|
|
60
|
+
model: root,
|
|
44
61
|
modelChanged: false,
|
|
45
62
|
cause
|
|
46
63
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2023 EclipseSource and others.
|
|
2
|
+
* Copyright (c) 2023-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
isLayoutContainer
|
|
25
25
|
} from '@eclipse-glsp/sprotty';
|
|
26
26
|
import { inject, injectable } from 'inversify';
|
|
27
|
+
import { Ranked } from '../../base';
|
|
27
28
|
import { GLSPActionDispatcher } from '../../base/action-dispatcher';
|
|
28
29
|
import { FeedbackCommand } from '../../base/feedback/feedback-command';
|
|
29
30
|
import { LocalRequestBoundsAction } from './local-bounds';
|
|
@@ -48,7 +49,7 @@ export namespace SetBoundsFeedbackAction {
|
|
|
48
49
|
export class SetBoundsFeedbackCommand extends SetBoundsCommand implements FeedbackCommand {
|
|
49
50
|
static override readonly KIND: string = SetBoundsFeedbackAction.KIND;
|
|
50
51
|
|
|
51
|
-
readonly
|
|
52
|
+
readonly rank: number = Ranked.DEFAULT_RANK;
|
|
52
53
|
|
|
53
54
|
@inject(TYPES.IActionDispatcher) protected actionDispatcher: GLSPActionDispatcher;
|
|
54
55
|
|
|
@@ -65,6 +66,7 @@ export class SetBoundsFeedbackCommand extends SetBoundsCommand implements Feedba
|
|
|
65
66
|
element.layoutOptions = options;
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
|
-
|
|
69
|
+
const elementIDs = this.action.bounds.map(bounds => bounds.elementId);
|
|
70
|
+
return LocalRequestBoundsAction.fromCommand(context, this.actionDispatcher, this.action, elementIDs);
|
|
69
71
|
}
|
|
70
72
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2023 EclipseSource and others.
|
|
2
|
+
* Copyright (c) 2023-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2023 EclipseSource and others.
|
|
2
|
+
* Copyright (c) 2023-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -64,13 +64,14 @@ export class AddTemplateElementsFeedbackCommand extends FeedbackCommand {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
override execute(context: CommandExecutionContext): CommandResult {
|
|
67
|
-
this.action.templates
|
|
67
|
+
const templateElements = this.action.templates
|
|
68
68
|
.map(template => templateToSchema(template, context))
|
|
69
69
|
.filter(isNotUndefined)
|
|
70
70
|
.map(schema => context.modelFactory.createElement(schema))
|
|
71
|
-
.map(element => this.applyRootCssClasses(element, this.action.addClasses, this.action.removeClasses))
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
.map(element => this.applyRootCssClasses(element, this.action.addClasses, this.action.removeClasses));
|
|
72
|
+
templateElements.forEach(templateElement => context.root.add(templateElement));
|
|
73
|
+
const templateElementIDs = templateElements.map(element => element.id);
|
|
74
|
+
return LocalRequestBoundsAction.fromCommand(context, this.actionDispatcher, this.action, templateElementIDs);
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
protected applyRootCssClasses(element: GChildElement, addClasses?: string[], removeClasses?: string[]): GChildElement {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2023 EclipseSource and others.
|
|
2
|
+
* Copyright (c) 2023-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -64,6 +64,7 @@ import {
|
|
|
64
64
|
isVisibleOnCanvas
|
|
65
65
|
} from '../../utils/gmodel-util';
|
|
66
66
|
import { getViewportBounds, toAbsoluteBounds } from '../../utils/viewpoint-util';
|
|
67
|
+
import { feedbackEdgeEndId, feedbackEdgeId } from '../tools';
|
|
67
68
|
import { HelperLine, HelperLineType, SelectionBounds, isHelperLine, isSelectionBounds } from './model';
|
|
68
69
|
|
|
69
70
|
export type ViewportLineType = typeof HelperLineType.Center | typeof HelperLineType.Middle | string;
|
|
@@ -90,7 +91,12 @@ export const DEFAULT_ELEMENT_LINES = ALL_ELEMENT_LINE_TYPES;
|
|
|
90
91
|
export const DEFAULT_VIEWPORT_LINES = ALL_VIEWPORT_LINE_TYPES;
|
|
91
92
|
export const DEFAULT_EPSILON = 1;
|
|
92
93
|
export const DEFAULT_ALIGNABLE_ELEMENT_FILTER = (element: BoundsAwareModelElement): boolean =>
|
|
93
|
-
isVisibleOnCanvas(element) &&
|
|
94
|
+
isVisibleOnCanvas(element) &&
|
|
95
|
+
!isRoutable(element) &&
|
|
96
|
+
!(element instanceof GLabel) &&
|
|
97
|
+
!(element.id === feedbackEdgeId(element.root)) &&
|
|
98
|
+
!(element.id === feedbackEdgeEndId(element.root)) &&
|
|
99
|
+
!isDecoration(element);
|
|
94
100
|
export const DEFAULT_DEBUG = false;
|
|
95
101
|
|
|
96
102
|
export namespace DrawHelperLinesFeedbackAction {
|
|
@@ -294,7 +300,7 @@ export class DrawHelperLinesFeedbackCommand extends FeedbackCommand {
|
|
|
294
300
|
}
|
|
295
301
|
|
|
296
302
|
protected isMatch(leftCoordinate: number, rightCoordinate: number, epsilon: number): boolean {
|
|
297
|
-
return Math.abs(leftCoordinate - rightCoordinate)
|
|
303
|
+
return Math.abs(leftCoordinate - rightCoordinate) <= epsilon;
|
|
298
304
|
}
|
|
299
305
|
|
|
300
306
|
protected log(message: string, ...params: any[]): void {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2023 EclipseSource and others.
|
|
2
|
+
* Copyright (c) 2023-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2023 EclipseSource and others.
|
|
2
|
+
* Copyright (c) 2023-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -13,19 +13,18 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { inject, injectable } from 'inversify';
|
|
17
16
|
import {
|
|
18
17
|
Action,
|
|
19
18
|
CommandExecutionContext,
|
|
20
19
|
Connectable,
|
|
21
20
|
EdgeTypeHint,
|
|
22
|
-
IActionHandler,
|
|
23
|
-
RequestTypeHintsAction,
|
|
24
21
|
GModelElement,
|
|
25
22
|
GModelElementSchema,
|
|
26
23
|
GModelRoot,
|
|
27
24
|
GRoutableElement,
|
|
28
25
|
GShapeElement,
|
|
26
|
+
IActionHandler,
|
|
27
|
+
RequestTypeHintsAction,
|
|
29
28
|
SetTypeHintsAction,
|
|
30
29
|
ShapeTypeHint,
|
|
31
30
|
TYPES,
|
|
@@ -36,16 +35,17 @@ import {
|
|
|
36
35
|
isConnectable,
|
|
37
36
|
moveFeature
|
|
38
37
|
} from '@eclipse-glsp/sprotty';
|
|
38
|
+
import { inject, injectable } from 'inversify';
|
|
39
39
|
|
|
40
40
|
import { GLSPActionDispatcher } from '../../base/action-dispatcher';
|
|
41
41
|
import { IFeedbackActionDispatcher } from '../../base/feedback/feedback-action-dispatcher';
|
|
42
42
|
import { FeedbackCommand } from '../../base/feedback/feedback-command';
|
|
43
43
|
import { IDiagramStartup } from '../../base/model/diagram-loader';
|
|
44
|
+
import { GEdge } from '../../model';
|
|
44
45
|
import { getElementTypeId } from '../../utils/gmodel-util';
|
|
45
46
|
import { resizeFeature } from '../change-bounds/model';
|
|
46
47
|
import { reconnectFeature } from '../reconnect/model';
|
|
47
48
|
import { containerFeature, isContainable, reparentFeature } from './model';
|
|
48
|
-
import { GEdge } from '../../model';
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Is dispatched by the {@link TypeHintProvider} to apply the type hints received from the server
|
|
@@ -78,7 +78,7 @@ type CanConnectFn = Connectable['canConnect'];
|
|
|
78
78
|
@injectable()
|
|
79
79
|
export class ApplyTypeHintsCommand extends FeedbackCommand {
|
|
80
80
|
public static KIND = ApplyTypeHintsAction.KIND;
|
|
81
|
-
public override readonly
|
|
81
|
+
public override readonly rank: number = -10;
|
|
82
82
|
|
|
83
83
|
@inject(TYPES.ITypeHintProvider)
|
|
84
84
|
protected typeHintProvider: ITypeHintProvider;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2020-
|
|
2
|
+
* Copyright (c) 2020-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { inject, injectable } from 'inversify';
|
|
17
16
|
import {
|
|
18
17
|
Action,
|
|
19
18
|
ActionHandlerRegistry,
|
|
@@ -38,6 +37,7 @@ import {
|
|
|
38
37
|
hasObjectProp,
|
|
39
38
|
hasStringProp
|
|
40
39
|
} from '@eclipse-glsp/sprotty';
|
|
40
|
+
import { inject, injectable } from 'inversify';
|
|
41
41
|
import { EditorContextServiceProvider } from '../../base/editor-context-service';
|
|
42
42
|
import { NavigationTargetResolver } from './navigation-target-resolver';
|
|
43
43
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2024 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2021 EclipseSource and others.
|
|
2
|
+
* Copyright (c) 2021-2023 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|