@eclipse-glsp/client 2.1.1 → 2.2.0-next.326
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/default-modules.d.ts.map +1 -1
- package/lib/default-modules.js +2 -1
- package/lib/default-modules.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/command-palette/command-palette-module.d.ts.map +1 -1
- package/lib/features/command-palette/command-palette-module.js +2 -1
- package/lib/features/command-palette/command-palette-module.js.map +1 -1
- package/lib/features/command-palette/command-palette.d.ts +21 -0
- package/lib/features/command-palette/command-palette.d.ts.map +1 -0
- package/lib/features/command-palette/command-palette.js +46 -0
- package/lib/features/command-palette/command-palette.js.map +1 -0
- package/lib/features/command-palette/index.d.ts +1 -0
- package/lib/features/command-palette/index.d.ts.map +1 -1
- package/lib/features/command-palette/index.js +1 -0
- package/lib/features/command-palette/index.js.map +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/label-edit-ui/label-edit-ui-module.d.ts +18 -0
- package/lib/features/label-edit-ui/label-edit-ui-module.d.ts.map +1 -0
- package/lib/features/label-edit-ui/label-edit-ui-module.js +27 -0
- package/lib/features/label-edit-ui/label-edit-ui-module.js.map +1 -0
- package/lib/features/label-edit-ui/label-edit-ui.d.ts +21 -0
- package/lib/features/label-edit-ui/label-edit-ui.d.ts.map +1 -0
- package/lib/features/label-edit-ui/label-edit-ui.js +46 -0
- package/lib/features/label-edit-ui/label-edit-ui.js.map +1 -0
- 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/default-modules.ts +1 -1
- 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/command-palette/command-palette-module.ts +3 -2
- package/src/features/command-palette/command-palette.ts +34 -0
- package/src/features/command-palette/index.ts +1 -0
- 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/label-edit-ui/label-edit-ui-module.ts +24 -0
- package/src/features/label-edit-ui/label-edit-ui.ts +33 -0
- 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) 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
|
|
@@ -14,11 +14,19 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
17
|
+
import { ActionHandlerRegistration, ActionHandlerRegistry, IActionHandlerInitializer, LazyInjector, TYPES } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import { inject, injectable, optional } from 'inversify';
|
|
19
19
|
|
|
20
20
|
@injectable()
|
|
21
21
|
export class GLSPActionHandlerRegistry extends ActionHandlerRegistry {
|
|
22
|
+
@inject(LazyInjector)
|
|
23
|
+
protected lazyInjector: LazyInjector;
|
|
24
|
+
|
|
25
|
+
protected initialized = false;
|
|
26
|
+
|
|
27
|
+
constructor(@optional() registrations: ActionHandlerRegistration[] = [], @optional() initializers: IActionHandlerInitializer[] = []) {
|
|
28
|
+
super(registrations, initializers);
|
|
29
|
+
}
|
|
22
30
|
/**
|
|
23
31
|
* Retrieve a set of all action kinds for which (at least) one
|
|
24
32
|
* handler is registered
|
|
@@ -27,4 +35,17 @@ export class GLSPActionHandlerRegistry extends ActionHandlerRegistry {
|
|
|
27
35
|
getHandledActionKinds(): string[] {
|
|
28
36
|
return Array.from(this.elements.keys());
|
|
29
37
|
}
|
|
38
|
+
|
|
39
|
+
initialize(): void {
|
|
40
|
+
if (this.initialized) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
this.lazyInjector
|
|
45
|
+
.getAll<ActionHandlerRegistration>(TYPES.ActionHandlerRegistration)
|
|
46
|
+
.forEach(registration => this.register(registration.actionKind, registration.factory()));
|
|
47
|
+
this.lazyInjector
|
|
48
|
+
.getAll<IActionHandlerInitializer>(TYPES.IActionHandlerInitializer)
|
|
49
|
+
.forEach(initializer => this.initializeActionHandler(initializer));
|
|
50
|
+
}
|
|
30
51
|
}
|
|
@@ -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
|
|
@@ -17,50 +17,38 @@ import {
|
|
|
17
17
|
CommandStack,
|
|
18
18
|
Disposable,
|
|
19
19
|
DisposableCollection,
|
|
20
|
-
Emitter,
|
|
21
20
|
Event,
|
|
22
21
|
GModelRoot,
|
|
23
22
|
ICommand,
|
|
23
|
+
LazyInjector,
|
|
24
24
|
SetModelCommand,
|
|
25
|
-
TYPES,
|
|
26
25
|
UpdateModelCommand
|
|
27
26
|
} from '@eclipse-glsp/sprotty';
|
|
28
|
-
import {
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* A hook to listen for model root changes. Will be called after a server update
|
|
32
|
-
* has been processed
|
|
33
|
-
*/
|
|
34
|
-
export interface IGModelRootListener {
|
|
35
|
-
modelRootChanged(root: Readonly<GModelRoot>): void;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @deprecated Use {@link IGModelRootListener} instead
|
|
40
|
-
*/
|
|
41
|
-
export type ISModelRootListener = IGModelRootListener;
|
|
27
|
+
import { inject, injectable, preDestroy } from 'inversify';
|
|
28
|
+
import { EditorContextService } from './editor-context-service';
|
|
42
29
|
|
|
43
30
|
@injectable()
|
|
44
31
|
export class GLSPCommandStack extends CommandStack implements Disposable {
|
|
45
|
-
@
|
|
46
|
-
|
|
47
|
-
protected modelRootListeners: IGModelRootListener[] = [];
|
|
32
|
+
@inject(LazyInjector)
|
|
33
|
+
protected lazyInjector: LazyInjector;
|
|
48
34
|
protected toDispose = new DisposableCollection();
|
|
49
35
|
|
|
50
|
-
protected override initialize(): void {
|
|
51
|
-
super.initialize();
|
|
52
|
-
this.toDispose.push(this.onModelRootChangedEmitter);
|
|
53
|
-
this.modelRootListeners.forEach(listener => this.onModelRootChanged(root => listener.modelRootChanged(root)));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
36
|
@preDestroy()
|
|
57
37
|
dispose(): void {
|
|
58
38
|
this.toDispose.dispose();
|
|
59
39
|
}
|
|
60
40
|
|
|
61
|
-
|
|
41
|
+
// Use lazyInjector to resolve circular dependency
|
|
42
|
+
// GLSPActionDispatcher --> GLSPCommandStack --> EditorContextService --> GLSPActionDispatcher
|
|
43
|
+
get editorContext(): EditorContextService {
|
|
44
|
+
return this.lazyInjector.get(EditorContextService);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Use the `EditorContext.onModelRootChanged` event instead
|
|
49
|
+
*/
|
|
62
50
|
get onModelRootChanged(): Event<Readonly<GModelRoot>> {
|
|
63
|
-
return this.
|
|
51
|
+
return this.editorContext.onModelRootChanged;
|
|
64
52
|
}
|
|
65
53
|
|
|
66
54
|
override undo(): Promise<GModelRoot> {
|
|
@@ -88,6 +76,6 @@ export class GLSPCommandStack extends CommandStack implements Disposable {
|
|
|
88
76
|
}
|
|
89
77
|
|
|
90
78
|
protected notifyListeners(root: Readonly<GModelRoot>): void {
|
|
91
|
-
this.
|
|
79
|
+
this.editorContext.notifyModelRootChanged(root, this);
|
|
92
80
|
}
|
|
93
81
|
}
|
|
@@ -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
|
|
@@ -22,8 +22,10 @@ import {
|
|
|
22
22
|
MoveCommand,
|
|
23
23
|
SetDirtyStateAction,
|
|
24
24
|
SetEditModeAction,
|
|
25
|
+
SetModelCommand,
|
|
25
26
|
TYPES,
|
|
26
27
|
bindAsService,
|
|
28
|
+
bindLazyInjector,
|
|
27
29
|
bindOrRebind,
|
|
28
30
|
configureActionHandler,
|
|
29
31
|
configureCommand,
|
|
@@ -35,6 +37,7 @@ import { GLSPActionDispatcher } from './action-dispatcher';
|
|
|
35
37
|
import { GLSPActionHandlerRegistry } from './action-handler-registry';
|
|
36
38
|
import { GLSPCommandStack } from './command-stack';
|
|
37
39
|
import { EditorContextService } from './editor-context-service';
|
|
40
|
+
import { FeedbackAwareSetModelCommand } from './feedback';
|
|
38
41
|
import { ModifyCssFeedbackCommand } from './feedback/css-feedback';
|
|
39
42
|
import { FeedbackActionDispatcher } from './feedback/feedback-action-dispatcher';
|
|
40
43
|
import { FeedbackAwareUpdateModelCommand } from './feedback/update-model-command';
|
|
@@ -48,6 +51,7 @@ import { SelectionClearingMouseListener } from './selection-clearing-mouse-liste
|
|
|
48
51
|
import { SelectionService } from './selection-service';
|
|
49
52
|
import { EnableDefaultToolsAction, EnableToolsAction } from './tool-manager/tool';
|
|
50
53
|
import { DefaultToolsEnablingKeyListener, ToolManager, ToolManagerActionHandler } from './tool-manager/tool-manager';
|
|
54
|
+
import { GLSPUIExtensionRegistry } from './ui-extension-registry';
|
|
51
55
|
import { GLSPKeyTool } from './view/key-tool';
|
|
52
56
|
import { GLSPMouseTool } from './view/mouse-tool';
|
|
53
57
|
import { GViewRegistry } from './view/view-registry';
|
|
@@ -61,7 +65,10 @@ export const defaultModule = new FeatureModule((bind, unbind, isBound, rebind, .
|
|
|
61
65
|
sprottyDefaultModule.registry(bind, unbind, isBound, rebind, ...rest);
|
|
62
66
|
const context = { bind, unbind, isBound, rebind };
|
|
63
67
|
|
|
68
|
+
bindLazyInjector(context);
|
|
69
|
+
|
|
64
70
|
bind(EditorContextService).toSelf().inSingletonScope();
|
|
71
|
+
bind(TYPES.IDiagramStartup).toService(EditorContextService);
|
|
65
72
|
bind(TYPES.IEditorContextServiceProvider).toProvider<EditorContextService>(ctx => async () => ctx.container.get(EditorContextService));
|
|
66
73
|
|
|
67
74
|
configureActionHandler(context, SetEditModeAction.KIND, EditorContextService);
|
|
@@ -73,19 +80,22 @@ export const defaultModule = new FeatureModule((bind, unbind, isBound, rebind, .
|
|
|
73
80
|
// Model update initialization ------------------------------------
|
|
74
81
|
bind(TYPES.IFeedbackActionDispatcher).to(FeedbackActionDispatcher).inSingletonScope();
|
|
75
82
|
configureCommand(context, FeedbackAwareUpdateModelCommand);
|
|
83
|
+
rebind(SetModelCommand).to(FeedbackAwareSetModelCommand);
|
|
76
84
|
|
|
77
85
|
bind(GLSPMouseTool).toSelf().inSingletonScope();
|
|
78
86
|
bindOrRebind(context, MouseTool).toService(GLSPMouseTool);
|
|
87
|
+
bind(TYPES.IDiagramStartup).toService(GLSPMouseTool);
|
|
88
|
+
|
|
79
89
|
bind(GLSPKeyTool).toSelf().inSingletonScope();
|
|
80
90
|
bindOrRebind(context, KeyTool).toService(GLSPKeyTool);
|
|
91
|
+
bind(TYPES.IDiagramStartup).toService(GLSPKeyTool);
|
|
81
92
|
|
|
82
93
|
bindAsService(context, TYPES.MouseListener, SelectionClearingMouseListener);
|
|
83
|
-
|
|
84
94
|
bindOrRebind(context, TYPES.ICommandStack).to(GLSPCommandStack).inSingletonScope();
|
|
85
95
|
bind(GLSPActionDispatcher).toSelf().inSingletonScope();
|
|
86
96
|
bindOrRebind(context, TYPES.IActionDispatcher).toService(GLSPActionDispatcher);
|
|
87
|
-
|
|
88
|
-
bindOrRebind(context, ActionHandlerRegistry).
|
|
97
|
+
|
|
98
|
+
bindOrRebind(context, ActionHandlerRegistry).to(GLSPActionHandlerRegistry).inSingletonScope();
|
|
89
99
|
|
|
90
100
|
bindAsService(context, TYPES.ModelSource, GLSPModelSource);
|
|
91
101
|
bind(DiagramLoader).toSelf().inSingletonScope();
|
|
@@ -96,6 +106,8 @@ export const defaultModule = new FeatureModule((bind, unbind, isBound, rebind, .
|
|
|
96
106
|
bindOrRebind(context, TYPES.ViewRegistry).to(GViewRegistry).inSingletonScope();
|
|
97
107
|
|
|
98
108
|
bind(SelectionService).toSelf().inSingletonScope();
|
|
109
|
+
bind(TYPES.IGModelRootListener).toService(SelectionService);
|
|
110
|
+
bind(TYPES.IDiagramStartup).toService(SelectionService);
|
|
99
111
|
|
|
100
112
|
// Feedback Support ------------------------------------
|
|
101
113
|
// Generic re-usable feedback modifying css classes
|
|
@@ -108,9 +120,15 @@ export const defaultModule = new FeatureModule((bind, unbind, isBound, rebind, .
|
|
|
108
120
|
|
|
109
121
|
// Tool manager initialization ------------------------------------
|
|
110
122
|
bind(TYPES.IToolManager).to(ToolManager).inSingletonScope();
|
|
123
|
+
bind(TYPES.IDiagramStartup).toService(TYPES.IToolManager);
|
|
124
|
+
bind(TYPES.IEditModeListener).toService(TYPES.IToolManager);
|
|
111
125
|
bind(DefaultToolsEnablingKeyListener).toSelf().inSingletonScope();
|
|
112
126
|
bind(TYPES.KeyListener).toService(DefaultToolsEnablingKeyListener);
|
|
113
127
|
bind(ToolManagerActionHandler).toSelf().inSingletonScope();
|
|
114
128
|
configureActionHandler(context, EnableDefaultToolsAction.KIND, ToolManagerActionHandler);
|
|
115
129
|
configureActionHandler(context, EnableToolsAction.KIND, ToolManagerActionHandler);
|
|
130
|
+
|
|
131
|
+
bind(GLSPUIExtensionRegistry).toSelf().inSingletonScope();
|
|
132
|
+
bindOrRebind(context, TYPES.UIExtensionRegistry).toService(GLSPUIExtensionRegistry);
|
|
133
|
+
bind(TYPES.IDiagramStartup).toService(GLSPUIExtensionRegistry);
|
|
116
134
|
});
|
|
@@ -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,30 +13,50 @@
|
|
|
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, multiInject, optional, postConstruct, preDestroy } from 'inversify';
|
|
17
16
|
import {
|
|
18
17
|
Action,
|
|
18
|
+
AnyObject,
|
|
19
19
|
Args,
|
|
20
|
+
CommandStack,
|
|
20
21
|
Disposable,
|
|
21
22
|
DisposableCollection,
|
|
22
23
|
EditMode,
|
|
23
24
|
EditorContext,
|
|
24
25
|
Emitter,
|
|
25
26
|
Event,
|
|
27
|
+
GModelElement,
|
|
28
|
+
GModelRoot,
|
|
26
29
|
IActionHandler,
|
|
30
|
+
LazyInjector,
|
|
27
31
|
MaybePromise,
|
|
28
32
|
MousePositionTracker,
|
|
29
|
-
GModelElement,
|
|
30
|
-
GModelRoot,
|
|
31
33
|
SetDirtyStateAction,
|
|
32
34
|
SetEditModeAction,
|
|
33
35
|
TYPES,
|
|
34
36
|
ValueChange
|
|
35
37
|
} from '@eclipse-glsp/sprotty';
|
|
38
|
+
import { inject, injectable, postConstruct, preDestroy } from 'inversify';
|
|
36
39
|
import { GLSPActionDispatcher } from './action-dispatcher';
|
|
37
40
|
import { IDiagramOptions, IDiagramStartup } from './model/diagram-loader';
|
|
38
41
|
import { SelectionService } from './selection-service';
|
|
39
42
|
|
|
43
|
+
/**
|
|
44
|
+
* A hook to listen for model root changes. Will be called after a server update
|
|
45
|
+
* has been processed
|
|
46
|
+
*/
|
|
47
|
+
export interface IGModelRootListener {
|
|
48
|
+
modelRootChanged(root: Readonly<GModelRoot>): void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated Use {@link IGModelRootListener} instead
|
|
53
|
+
*/
|
|
54
|
+
export type ISModelRootListener = IGModelRootListener;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A hook to listen for edit mode changes. Will be after the {@link EditorContextService}
|
|
58
|
+
* has handled the {@link SetEditModeAction}.
|
|
59
|
+
*/
|
|
40
60
|
export interface IEditModeListener {
|
|
41
61
|
editModeChanged(newValue: string, oldValue: string): void;
|
|
42
62
|
}
|
|
@@ -62,13 +82,12 @@ export class EditorContextService implements IActionHandler, Disposable, IDiagra
|
|
|
62
82
|
@inject(MousePositionTracker)
|
|
63
83
|
protected mousePositionTracker: MousePositionTracker;
|
|
64
84
|
|
|
85
|
+
@inject(LazyInjector)
|
|
86
|
+
protected lazyInjector: LazyInjector;
|
|
87
|
+
|
|
65
88
|
@inject(TYPES.IDiagramOptions)
|
|
66
89
|
protected diagramOptions: IDiagramOptions;
|
|
67
90
|
|
|
68
|
-
@multiInject(TYPES.IEditModeListener)
|
|
69
|
-
@optional()
|
|
70
|
-
protected editModeListeners: IEditModeListener[] = [];
|
|
71
|
-
|
|
72
91
|
@inject(GLSPActionDispatcher)
|
|
73
92
|
protected actionDispatcher: GLSPActionDispatcher;
|
|
74
93
|
|
|
@@ -84,15 +103,27 @@ export class EditorContextService implements IActionHandler, Disposable, IDiagra
|
|
|
84
103
|
return this.onDirtyStateChangedEmitter.event;
|
|
85
104
|
}
|
|
86
105
|
|
|
106
|
+
protected _modelRoot?: Readonly<GModelRoot>;
|
|
107
|
+
protected onModelRootChangedEmitter = new Emitter<Readonly<GModelRoot>>();
|
|
108
|
+
get onModelRootChanged(): Event<Readonly<GModelRoot>> {
|
|
109
|
+
return this.onModelRootChangedEmitter.event;
|
|
110
|
+
}
|
|
111
|
+
|
|
87
112
|
protected toDispose = new DisposableCollection();
|
|
88
113
|
|
|
89
114
|
@postConstruct()
|
|
90
115
|
protected initialize(): void {
|
|
91
116
|
this._editMode = this.diagramOptions.editMode ?? EditMode.EDITABLE;
|
|
92
117
|
this.toDispose.push(this.onEditModeChangedEmitter, this.onDirtyStateChangedEmitter);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
preLoadDiagram(): MaybePromise<void> {
|
|
121
|
+
this.lazyInjector.getAll<IGModelRootListener>(TYPES.IGModelRootListener).forEach(listener => {
|
|
122
|
+
this.onModelRootChanged(event => listener.modelRootChanged(event));
|
|
123
|
+
});
|
|
124
|
+
this.lazyInjector.getAll<IEditModeListener>(TYPES.IEditModeListener).forEach(listener => {
|
|
125
|
+
this.onEditModeChanged(event => listener.editModeChanged(event.newValue, event.oldValue));
|
|
126
|
+
});
|
|
96
127
|
}
|
|
97
128
|
|
|
98
129
|
@preDestroy()
|
|
@@ -116,6 +147,21 @@ export class EditorContextService implements IActionHandler, Disposable, IDiagra
|
|
|
116
147
|
};
|
|
117
148
|
}
|
|
118
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Notifies the service about a model root change. This method should not be called
|
|
152
|
+
* directly. It is called by the `CommandStack` after a model update has been processed.
|
|
153
|
+
* @throws an error if the notifier is not a `CommandStack`
|
|
154
|
+
* @param root the new model root
|
|
155
|
+
* @param notifier the object that triggered the model root change
|
|
156
|
+
*/
|
|
157
|
+
notifyModelRootChanged(root: Readonly<GModelRoot>, notifier: AnyObject): void {
|
|
158
|
+
if (!(notifier instanceof CommandStack)) {
|
|
159
|
+
throw new Error('Invalid model root change notification. Notifier is not an instance of `CommandStack`.');
|
|
160
|
+
}
|
|
161
|
+
this._modelRoot = root;
|
|
162
|
+
this.onModelRootChangedEmitter.fire(root);
|
|
163
|
+
}
|
|
164
|
+
|
|
119
165
|
handle(action: Action): void {
|
|
120
166
|
if (SetEditModeAction.is(action)) {
|
|
121
167
|
this.handleSetEditModeAction(action);
|
|
@@ -154,7 +200,10 @@ export class EditorContextService implements IActionHandler, Disposable, IDiagra
|
|
|
154
200
|
}
|
|
155
201
|
|
|
156
202
|
get modelRoot(): Readonly<GModelRoot> {
|
|
157
|
-
|
|
203
|
+
if (!this._modelRoot) {
|
|
204
|
+
throw new Error('Model root not available yet');
|
|
205
|
+
}
|
|
206
|
+
return this._modelRoot;
|
|
158
207
|
}
|
|
159
208
|
|
|
160
209
|
get selectedElements(): Readonly<GModelElement>[] {
|
|
@@ -168,10 +217,6 @@ export class EditorContextService implements IActionHandler, Disposable, IDiagra
|
|
|
168
217
|
get isDirty(): boolean {
|
|
169
218
|
return this._isDirty;
|
|
170
219
|
}
|
|
171
|
-
|
|
172
|
-
postRequestModel(): MaybePromise<void> {
|
|
173
|
-
this.actionDispatcher.dispatch(SetEditModeAction.create(this.editMode));
|
|
174
|
-
}
|
|
175
220
|
}
|
|
176
221
|
|
|
177
222
|
export type EditorContextServiceProvider = () => Promise<EditorContextService>;
|
|
@@ -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,21 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
+
import {
|
|
17
|
+
Action,
|
|
18
|
+
ActionHandlerRegistry,
|
|
19
|
+
Command,
|
|
20
|
+
CommandActionHandler,
|
|
21
|
+
CommandExecutionContext,
|
|
22
|
+
Disposable,
|
|
23
|
+
IActionDispatcher,
|
|
24
|
+
ICommand,
|
|
25
|
+
ILogger,
|
|
26
|
+
TYPES,
|
|
27
|
+
toTypeGuard
|
|
28
|
+
} from '@eclipse-glsp/sprotty';
|
|
16
29
|
import { inject, injectable } from 'inversify';
|
|
17
|
-
import {
|
|
30
|
+
import { getFeedbackRank } from './feedback-command';
|
|
18
31
|
|
|
19
32
|
export interface IFeedbackEmitter {}
|
|
20
33
|
|
|
@@ -57,6 +70,16 @@ export interface IFeedbackActionDispatcher {
|
|
|
57
70
|
* Retrieve all `actions` sent out by currently registered `feedbackEmitter`.
|
|
58
71
|
*/
|
|
59
72
|
getRegisteredFeedback(): Action[];
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Retrieves all commands based on the registered feedback actions, ordered by their rank (lowest rank first).
|
|
76
|
+
*/
|
|
77
|
+
getFeedbackCommands(): Command[];
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Applies all current feedback commands to the given command execution context.
|
|
81
|
+
*/
|
|
82
|
+
applyFeedbackCommands(context: CommandExecutionContext): Promise<void>;
|
|
60
83
|
}
|
|
61
84
|
|
|
62
85
|
@injectable()
|
|
@@ -66,6 +89,8 @@ export class FeedbackActionDispatcher implements IFeedbackActionDispatcher {
|
|
|
66
89
|
@inject(TYPES.IActionDispatcherProvider) protected actionDispatcher: () => Promise<IActionDispatcher>;
|
|
67
90
|
@inject(TYPES.ILogger) protected logger: ILogger;
|
|
68
91
|
|
|
92
|
+
@inject(ActionHandlerRegistry) protected actionHandlerRegistry: ActionHandlerRegistry;
|
|
93
|
+
|
|
69
94
|
registerFeedback(feedbackEmitter: IFeedbackEmitter, feedbackActions: Action[], cleanupActions?: Action[] | undefined): Disposable {
|
|
70
95
|
if (feedbackActions.length > 0) {
|
|
71
96
|
this.registeredFeedback.set(feedbackEmitter, feedbackActions);
|
|
@@ -97,6 +122,29 @@ export class FeedbackActionDispatcher implements IFeedbackActionDispatcher {
|
|
|
97
122
|
return result;
|
|
98
123
|
}
|
|
99
124
|
|
|
125
|
+
getFeedbackCommands(): Command[] {
|
|
126
|
+
return this.getRegisteredFeedback()
|
|
127
|
+
.flatMap(action => this.actionToCommands(action))
|
|
128
|
+
.sort((left, right) => getFeedbackRank(left) - getFeedbackRank(right));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async applyFeedbackCommands(context: CommandExecutionContext): Promise<void> {
|
|
132
|
+
const feedbackCommands = this.getFeedbackCommands() ?? [];
|
|
133
|
+
if (feedbackCommands?.length > 0) {
|
|
134
|
+
const results = feedbackCommands.map(command => command.execute(context));
|
|
135
|
+
await Promise.all(results);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
protected actionToCommands(action: Action): ICommand[] {
|
|
140
|
+
return (
|
|
141
|
+
this.actionHandlerRegistry
|
|
142
|
+
.get(action.kind)
|
|
143
|
+
.filter(toTypeGuard(CommandActionHandler))
|
|
144
|
+
.map(handler => handler.handle(action)) ?? []
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
100
148
|
protected async dispatchFeedback(actions: Action[], feedbackEmitter: IFeedbackEmitter): Promise<void> {
|
|
101
149
|
try {
|
|
102
150
|
const actionDispatcher = await this.actionDispatcher();
|
|
@@ -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,11 +13,16 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
|
|
16
|
+
/* eslint-disable deprecation/deprecation */
|
|
17
|
+
import { Command, CommandExecutionContext, CommandReturn, ICommand } from '@eclipse-glsp/sprotty';
|
|
18
|
+
import { Ranked } from '../ranked';
|
|
17
19
|
|
|
18
|
-
export abstract class FeedbackCommand extends Command {
|
|
19
|
-
|
|
20
|
-
readonly priority
|
|
20
|
+
export abstract class FeedbackCommand extends Command implements Ranked {
|
|
21
|
+
/** @deprecated Use rank instead. Please note that a lower rank implies higher priority, so the order is reversed. */
|
|
22
|
+
readonly priority?: number = 0;
|
|
23
|
+
|
|
24
|
+
// backwards compatibility: convert any existing priority to an equivalent rank
|
|
25
|
+
readonly rank: number = this.priority ? -this.priority : Ranked.DEFAULT_RANK;
|
|
21
26
|
|
|
22
27
|
undo(context: CommandExecutionContext): CommandReturn {
|
|
23
28
|
return context.root;
|
|
@@ -27,3 +32,9 @@ export abstract class FeedbackCommand extends Command {
|
|
|
27
32
|
return context.root;
|
|
28
33
|
}
|
|
29
34
|
}
|
|
35
|
+
|
|
36
|
+
/** Used for backwards compatibility, otherwise use Ranked.getRank or Ranked sort functions. */
|
|
37
|
+
export function getFeedbackRank(command: ICommand): number {
|
|
38
|
+
const feedbackCommand = command as Partial<FeedbackCommand>;
|
|
39
|
+
return feedbackCommand?.priority ? -feedbackCommand.priority : feedbackCommand.rank ?? Ranked.DEFAULT_RANK;
|
|
40
|
+
}
|
|
@@ -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
|
|
@@ -16,4 +16,6 @@
|
|
|
16
16
|
export * from './css-feedback';
|
|
17
17
|
export * from './feedback-action-dispatcher';
|
|
18
18
|
export * from './feedback-command';
|
|
19
|
+
export * from './set-model-command';
|
|
19
20
|
export * from './update-model-command';
|
|
21
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
import { CommandExecutionContext, GModelRoot, ILogger, SetModelAction, SetModelCommand, TYPES } from '@eclipse-glsp/sprotty';
|
|
17
|
+
import { inject, injectable, optional } from 'inversify';
|
|
18
|
+
import { IFeedbackActionDispatcher } from './feedback-action-dispatcher';
|
|
19
|
+
|
|
20
|
+
@injectable()
|
|
21
|
+
export class FeedbackAwareSetModelCommand extends SetModelCommand {
|
|
22
|
+
@inject(TYPES.ILogger)
|
|
23
|
+
protected logger: ILogger;
|
|
24
|
+
|
|
25
|
+
@inject(TYPES.IFeedbackActionDispatcher)
|
|
26
|
+
@optional()
|
|
27
|
+
protected feedbackActionDispatcher?: IFeedbackActionDispatcher;
|
|
28
|
+
|
|
29
|
+
constructor(@inject(TYPES.Action) action: SetModelAction) {
|
|
30
|
+
super(action);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
override execute(context: CommandExecutionContext): GModelRoot {
|
|
34
|
+
const root = super.execute(context);
|
|
35
|
+
this.applyFeedback(root, context);
|
|
36
|
+
return root;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
protected applyFeedback(newRoot: GModelRoot, context: CommandExecutionContext): void {
|
|
40
|
+
// Create a temporary context which defines the `newRoot` as `root`
|
|
41
|
+
// This way we do not corrupt the redo/undo behavior of the super class
|
|
42
|
+
const tempContext: CommandExecutionContext = { ...context, root: newRoot };
|
|
43
|
+
this.feedbackActionDispatcher?.applyFeedbackCommands(tempContext);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -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,25 +13,20 @@
|
|
|
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, optional } from 'inversify';
|
|
17
16
|
import {
|
|
18
|
-
ActionHandlerRegistry,
|
|
19
17
|
Animation,
|
|
20
|
-
Command,
|
|
21
|
-
CommandActionHandler,
|
|
22
18
|
CommandExecutionContext,
|
|
23
19
|
CommandReturn,
|
|
20
|
+
GModelRoot,
|
|
24
21
|
ILogger,
|
|
25
22
|
MorphEdgesAnimation,
|
|
26
|
-
GModelRoot,
|
|
27
23
|
TYPES,
|
|
28
24
|
UpdateAnimationData,
|
|
29
25
|
UpdateModelAction,
|
|
30
|
-
UpdateModelCommand
|
|
31
|
-
toTypeGuard
|
|
26
|
+
UpdateModelCommand
|
|
32
27
|
} from '@eclipse-glsp/sprotty';
|
|
28
|
+
import { inject, injectable, optional } from 'inversify';
|
|
33
29
|
import { IFeedbackActionDispatcher } from './feedback-action-dispatcher';
|
|
34
|
-
import { FeedbackCommand } from './feedback-command';
|
|
35
30
|
|
|
36
31
|
/**
|
|
37
32
|
* A special {@link UpdateModelCommand} that retrieves all registered {@link Action}s from the {@link IFeedbackActionDispatcher}
|
|
@@ -47,50 +42,18 @@ export class FeedbackAwareUpdateModelCommand extends UpdateModelCommand {
|
|
|
47
42
|
@optional()
|
|
48
43
|
protected feedbackActionDispatcher: IFeedbackActionDispatcher;
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
constructor(
|
|
53
|
-
@inject(TYPES.Action) action: UpdateModelAction,
|
|
54
|
-
@inject(TYPES.ActionHandlerRegistryProvider)
|
|
55
|
-
actionHandlerRegistryProvider: () => Promise<ActionHandlerRegistry>
|
|
56
|
-
) {
|
|
45
|
+
constructor(@inject(TYPES.Action) action: UpdateModelAction) {
|
|
57
46
|
super({ animate: true, ...action });
|
|
58
|
-
actionHandlerRegistryProvider().then(registry => (this.actionHandlerRegistry = registry));
|
|
59
47
|
}
|
|
60
48
|
|
|
61
49
|
protected override performUpdate(oldRoot: GModelRoot, newRoot: GModelRoot, context: CommandExecutionContext): CommandReturn {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
...context,
|
|
67
|
-
root: newRoot
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const feedbackCommands = this.getFeedbackCommands(this.actionHandlerRegistry);
|
|
71
|
-
feedbackCommands.forEach(command => command.execute(tempContext));
|
|
72
|
-
}
|
|
73
|
-
|
|
50
|
+
// Create a temporary context which defines the `newRoot` as `root`
|
|
51
|
+
// This way we do not corrupt the redo/undo behavior of the super class
|
|
52
|
+
const tempContext: CommandExecutionContext = { ...context, root: newRoot };
|
|
53
|
+
this.feedbackActionDispatcher?.applyFeedbackCommands(tempContext);
|
|
74
54
|
return super.performUpdate(oldRoot, newRoot, context);
|
|
75
55
|
}
|
|
76
56
|
|
|
77
|
-
protected getFeedbackCommands(registry: ActionHandlerRegistry): Command[] {
|
|
78
|
-
const result: Command[] = [];
|
|
79
|
-
this.feedbackActionDispatcher.getRegisteredFeedback().forEach(action => {
|
|
80
|
-
const commands = registry
|
|
81
|
-
.get(action.kind)
|
|
82
|
-
.filter<CommandActionHandler>(toTypeGuard(CommandActionHandler))
|
|
83
|
-
.map(handler => handler.handle(action));
|
|
84
|
-
result.push(...commands);
|
|
85
|
-
});
|
|
86
|
-
// sort commands descanting by priority
|
|
87
|
-
return result.sort((a, b) => this.getPriority(b) - this.getPriority(a));
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
protected getPriority(command: Partial<FeedbackCommand>): number {
|
|
91
|
-
return command.priority ?? 0;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
57
|
// Override the `createAnimations` implementation and remove the animation for edge morphing. Otherwise routing & reconnect
|
|
95
58
|
// handles flicker after each server update.
|
|
96
59
|
protected override createAnimations(data: UpdateAnimationData, root: GModelRoot, context: CommandExecutionContext): Animation[] {
|
package/src/base/index.ts
CHANGED
|
@@ -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
|
|
@@ -28,4 +28,5 @@ export * from './ranked';
|
|
|
28
28
|
export * from './selection-clearing-mouse-listener';
|
|
29
29
|
export * from './selection-service';
|
|
30
30
|
export * from './tool-manager';
|
|
31
|
+
export * from './ui-extension-registry';
|
|
31
32
|
export * from './view';
|