@eclipse-glsp/client 2.5.0-next.427 → 2.5.0-next.428
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/lib/base/command-stack.d.ts +6 -4
- package/lib/base/command-stack.d.ts.map +1 -1
- package/lib/base/command-stack.js +16 -7
- package/lib/base/command-stack.js.map +1 -1
- package/lib/base/default.module.d.ts.map +1 -1
- package/lib/base/default.module.js +2 -0
- package/lib/base/default.module.js.map +1 -1
- package/lib/base/editor-context-service.d.ts +9 -12
- package/lib/base/editor-context-service.d.ts.map +1 -1
- package/lib/base/editor-context-service.js +22 -26
- package/lib/base/editor-context-service.js.map +1 -1
- package/lib/base/focus/focus-tracker.d.ts +3 -2
- package/lib/base/focus/focus-tracker.d.ts.map +1 -1
- package/lib/base/focus/focus-tracker.js +9 -0
- package/lib/base/focus/focus-tracker.js.map +1 -1
- package/lib/base/model/model-change-service.d.ts +65 -0
- package/lib/base/model/model-change-service.d.ts.map +1 -0
- package/lib/base/model/model-change-service.js +113 -0
- package/lib/base/model/model-change-service.js.map +1 -0
- package/package.json +3 -3
- package/src/base/command-stack.ts +19 -13
- package/src/base/default.module.ts +2 -0
- package/src/base/editor-context-service.ts +22 -29
- package/src/base/focus/focus-tracker.ts +8 -3
- package/src/base/model/model-change-service.ts +151 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2025 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,14 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { CommandExecutionContext, CommandStack, Disposable, DisposableCollection, Event, GModelRoot, ICommand, LazyInjector } from '@eclipse-glsp/sprotty';
|
|
16
|
+
import { CommandExecutionContext, CommandExecutionData, CommandStack, Disposable, DisposableCollection, Emitter, Event, GModelRoot, ICommand, ICommandStack, LazyInjector } from '@eclipse-glsp/sprotty';
|
|
17
17
|
import { EditorContextService } from './editor-context-service';
|
|
18
|
-
export declare class GLSPCommandStack extends CommandStack implements Disposable {
|
|
18
|
+
export declare class GLSPCommandStack extends CommandStack implements ICommandStack, Disposable {
|
|
19
19
|
protected lazyInjector: LazyInjector;
|
|
20
20
|
protected toDispose: DisposableCollection;
|
|
21
|
+
protected onCommandExecutedEmitter: Emitter<CommandExecutionData>;
|
|
22
|
+
get onCommandExecuted(): Event<CommandExecutionData>;
|
|
23
|
+
protected initialize(): void;
|
|
21
24
|
dispose(): void;
|
|
22
25
|
get editorContext(): EditorContextService;
|
|
23
26
|
/**
|
|
@@ -47,6 +50,5 @@ export declare class GLSPCommandStack extends CommandStack implements Disposable
|
|
|
47
50
|
*/
|
|
48
51
|
protected mergeOrPush(command: ICommand, context: CommandExecutionContext): void;
|
|
49
52
|
execute(command: ICommand): Promise<GModelRoot>;
|
|
50
|
-
protected notifyListeners(root: Readonly<GModelRoot>): void;
|
|
51
53
|
}
|
|
52
54
|
//# sourceMappingURL=command-stack.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-stack.d.ts","sourceRoot":"","sources":["../../src/base/command-stack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EACH,uBAAuB,EACvB,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,KAAK,EACL,UAAU,EACV,QAAQ,EACR,YAAY,
|
|
1
|
+
{"version":3,"file":"command-stack.d.ts","sourceRoot":"","sources":["../../src/base/command-stack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EACH,uBAAuB,EACvB,oBAAoB,EACpB,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,OAAO,EACP,KAAK,EACL,UAAU,EACV,QAAQ,EACR,aAAa,EACb,YAAY,EACf,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,qBACa,gBAAiB,SAAQ,YAAa,YAAW,aAAa,EAAE,UAAU;IAEnF,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC;IACrC,SAAS,CAAC,SAAS,uBAA8B;IAEjD,SAAS,CAAC,wBAAwB,gCAAuC;IACzE,IAAI,iBAAiB,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAEnD;cAGkB,UAAU,IAAI,IAAI;IAMrC,OAAO,IAAI,IAAI;IAMf,IAAI,aAAa,IAAI,oBAAoB,CAExC;IAED;;OAEG;IACH,IAAI,kBAAkB,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAEpD;IAED;;;OAGG;IACM,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC;IAQpC;;;OAGG;IACM,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC;IAQpC;;;;OAIG;cACgB,eAAe,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI;IAI3D;;;;OAIG;cACgB,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI;IAG1E,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAKjE"}
|
|
@@ -11,7 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.GLSPCommandStack = void 0;
|
|
13
13
|
/********************************************************************************
|
|
14
|
-
* Copyright (c) 2019-
|
|
14
|
+
* Copyright (c) 2019-2025 EclipseSource and others.
|
|
15
15
|
*
|
|
16
16
|
* This program and the accompanying materials are made available under the
|
|
17
17
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -32,6 +32,14 @@ let GLSPCommandStack = class GLSPCommandStack extends sprotty_1.CommandStack {
|
|
|
32
32
|
constructor() {
|
|
33
33
|
super(...arguments);
|
|
34
34
|
this.toDispose = new sprotty_1.DisposableCollection();
|
|
35
|
+
this.onCommandExecutedEmitter = new sprotty_1.Emitter();
|
|
36
|
+
}
|
|
37
|
+
get onCommandExecuted() {
|
|
38
|
+
return this.onCommandExecutedEmitter.event;
|
|
39
|
+
}
|
|
40
|
+
initialize() {
|
|
41
|
+
super.initialize();
|
|
42
|
+
this.toDispose.push(this.onCommandExecutedEmitter);
|
|
35
43
|
}
|
|
36
44
|
dispose() {
|
|
37
45
|
this.toDispose.dispose();
|
|
@@ -81,20 +89,21 @@ let GLSPCommandStack = class GLSPCommandStack extends sprotty_1.CommandStack {
|
|
|
81
89
|
}
|
|
82
90
|
async execute(command) {
|
|
83
91
|
const result = await super.execute(command);
|
|
84
|
-
|
|
85
|
-
this.notifyListeners(result);
|
|
86
|
-
}
|
|
92
|
+
this.onCommandExecutedEmitter.fire({ command, newRoot: result });
|
|
87
93
|
return result;
|
|
88
94
|
}
|
|
89
|
-
notifyListeners(root) {
|
|
90
|
-
this.editorContext.notifyModelRootChanged(root, this);
|
|
91
|
-
}
|
|
92
95
|
};
|
|
93
96
|
exports.GLSPCommandStack = GLSPCommandStack;
|
|
94
97
|
__decorate([
|
|
95
98
|
(0, inversify_1.inject)(sprotty_1.LazyInjector),
|
|
96
99
|
__metadata("design:type", Object)
|
|
97
100
|
], GLSPCommandStack.prototype, "lazyInjector", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
(0, inversify_1.postConstruct)(),
|
|
103
|
+
__metadata("design:type", Function),
|
|
104
|
+
__metadata("design:paramtypes", []),
|
|
105
|
+
__metadata("design:returntype", void 0)
|
|
106
|
+
], GLSPCommandStack.prototype, "initialize", null);
|
|
98
107
|
__decorate([
|
|
99
108
|
(0, inversify_1.preDestroy)(),
|
|
100
109
|
__metadata("design:type", Function),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-stack.js","sourceRoot":"","sources":["../../src/base/command-stack.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,
|
|
1
|
+
{"version":3,"file":"command-stack.js","sourceRoot":"","sources":["../../src/base/command-stack.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,mDAY+B;AAC/B,yCAA0E;AAC1E,qEAAgE;AAGzD,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,sBAAY;IAA3C;;QAGO,cAAS,GAAG,IAAI,8BAAoB,EAAE,CAAC;QAEvC,6BAAwB,GAAG,IAAI,iBAAO,EAAwB,CAAC;IA2E7E,CAAC;IA1EG,IAAI,iBAAiB;QACjB,OAAO,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC;IAC/C,CAAC;IAGkB,UAAU;QACzB,KAAK,CAAC,UAAU,EAAE,CAAC;QACnB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACvD,CAAC;IAGD,OAAO;QACH,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAED,kDAAkD;IAClD,+FAA+F;IAC/F,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,6CAAoB,CAAC,CAAC;IACvD,CAAC;IAED;;OAEG;IACH,IAAI,kBAAkB;QAClB,OAAO,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC;IACjD,CAAC;IAED;;;OAGG;IACM,IAAI;QACT,IAAI,CAAC,MAAM,CAAC,IAAI,CACZ,IAAI,EACJ,2HAA2H,CAC9H,CAAC;QACF,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACM,IAAI;QACT,IAAI,CAAC,MAAM,CAAC,IAAI,CACZ,IAAI,EACJ,2HAA2H,CAC9H,CAAC;QACF,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACgB,eAAe,CAAC,OAAiB;QAChD,QAAQ;IACZ,CAAC;IAED;;;;OAIG;IACgB,WAAW,CAAC,OAAiB,EAAE,OAAgC;QAC9E,QAAQ;IACZ,CAAC;IACQ,KAAK,CAAC,OAAO,CAAC,OAAiB;QACpC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QACjE,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAA;AAhFY,4CAAgB;AAEf;IADT,IAAA,kBAAM,EAAC,sBAAY,CAAC;;sDACgB;AASlB;IADlB,IAAA,yBAAa,GAAE;;;;kDAIf;AAGD;IADC,IAAA,sBAAU,GAAE;;;;+CAGZ;2BAnBQ,gBAAgB;IAD5B,IAAA,sBAAU,GAAE;GACA,gBAAgB,CAgF5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.module.d.ts","sourceRoot":"","sources":["../../src/base/default.module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAEH,aAAa,EAgBhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,mCAAmC,CAAC;AAC3C,OAAO,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"default.module.d.ts","sourceRoot":"","sources":["../../src/base/default.module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAEH,aAAa,EAgBhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,mCAAmC,CAAC;AAC3C,OAAO,4BAA4B,CAAC;AA2BpC;;;GAGG;AACH,eAAO,MAAM,aAAa,eAwFzB,CAAC"}
|
|
@@ -31,6 +31,7 @@ const focus_state_change_action_1 = require("./focus/focus-state-change-action")
|
|
|
31
31
|
const focus_tracker_1 = require("./focus/focus-tracker");
|
|
32
32
|
const diagram_loader_1 = require("./model/diagram-loader");
|
|
33
33
|
const glsp_model_source_1 = require("./model/glsp-model-source");
|
|
34
|
+
const model_change_service_1 = require("./model/model-change-service");
|
|
34
35
|
const model_initialization_constraint_1 = require("./model/model-initialization-constraint");
|
|
35
36
|
const model_registry_1 = require("./model/model-registry");
|
|
36
37
|
const mouse_position_tracker_1 = require("./mouse-position-tracker");
|
|
@@ -56,6 +57,7 @@ exports.defaultModule = new sprotty_1.FeatureModule((bind, unbind, isBound, rebi
|
|
|
56
57
|
bind(sprotty_1.TYPES.IDiagramStartup).toService(editor_context_service_1.EditorContextService);
|
|
57
58
|
// eslint-disable-next-line deprecation/deprecation
|
|
58
59
|
bind(sprotty_1.TYPES.IEditorContextServiceProvider).toProvider(ctx => async () => ctx.container.get(editor_context_service_1.EditorContextService));
|
|
60
|
+
bind(sprotty_1.TYPES.IModelChangeService).to(model_change_service_1.ModelChangeService).inSingletonScope();
|
|
59
61
|
(0, sprotty_1.configureActionHandler)(context, sprotty_1.SetEditModeAction.KIND, editor_context_service_1.EditorContextService);
|
|
60
62
|
(0, sprotty_1.configureActionHandler)(context, sprotty_1.SetDirtyStateAction.KIND, editor_context_service_1.EditorContextService);
|
|
61
63
|
bind(focus_tracker_1.FocusTracker).toSelf().inSingletonScope();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.module.js","sourceRoot":"","sources":["../../src/base/default.module.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,mDAkB+B;AAC/B,6CAA2C;AAC3C,sCAAoC;AACpC,2DAA2D;AAC3D,uEAAsE;AACtE,mDAAmD;AACnD,qEAAgE;AAChE,0DAAmE;AACnE,sFAAiF;AACjF,oEAA4E;AAC5E,0EAAkF;AAClF,iFAA4E;AAC5E,yDAAqD;AACrD,2DAAuD;AACvD,iEAA4D;AAC5D,6FAA8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e,CAAC,CAAC,SAAS,CAAC,+CAAuB,CAAC,CAAC;IAE/D,IAAI,CAAC,eAAK,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;IAEhD,uEAAuE;IACvE,IAAA,uBAAa,EAAC,OAAO,EAAE,eAAK,CAAC,gBAAgB,EAAE,mCAAe,CAAC,CAAC;AACpE,CAAC,EACD;IACI,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC;CAC/B,CACJ,CAAC"}
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { Action,
|
|
16
|
+
import { Action, Args, Bounds, Disposable, DisposableCollection, EditorContext, Emitter, Event, GModelElement, GModelRoot, IActionDispatcher, IActionHandler, LazyInjector, MaybePromise, MousePositionTracker, SetDirtyStateAction, SetEditModeAction, ValueChange, Viewport } from '@eclipse-glsp/sprotty';
|
|
17
17
|
import { FocusChange, FocusTracker } from './focus/focus-tracker';
|
|
18
18
|
import { IDiagramOptions, IDiagramStartup } from './model/diagram-loader';
|
|
19
|
+
import { IModelChangeService, ViewportChange } from './model/model-change-service';
|
|
19
20
|
import { SelectionChange, SelectionService } from './selection-service';
|
|
20
21
|
/**
|
|
21
22
|
* A hook to listen for model root changes. Will be called after a server update
|
|
@@ -50,6 +51,7 @@ export type DirtyStateChange = Pick<SetDirtyStateAction, 'isDirty' | 'reason'>;
|
|
|
50
51
|
*/
|
|
51
52
|
export declare class EditorContextService implements IActionHandler, Disposable, IDiagramStartup {
|
|
52
53
|
protected selectionService: SelectionService;
|
|
54
|
+
protected modelChangeService: IModelChangeService;
|
|
53
55
|
protected mousePositionTracker: MousePositionTracker;
|
|
54
56
|
protected lazyInjector: LazyInjector;
|
|
55
57
|
protected diagramOptions: IDiagramOptions;
|
|
@@ -67,11 +69,9 @@ export declare class EditorContextService implements IActionHandler, Disposable,
|
|
|
67
69
|
* Event that is fired when the dirty state of the diagram changes i.e. after a {@link SetDirtyStateAction} has been handled.
|
|
68
70
|
*/
|
|
69
71
|
get onDirtyStateChanged(): Event<DirtyStateChange>;
|
|
70
|
-
protected _modelRoot?: Readonly<GModelRoot>;
|
|
71
72
|
/**
|
|
72
73
|
* Event that is fired when the model root of the diagram changes i.e. after the `CommandStack` has processed a model update.
|
|
73
74
|
*/
|
|
74
|
-
protected onModelRootChangedEmitter: Emitter<Readonly<GModelRoot>>;
|
|
75
75
|
get onModelRootChanged(): Event<Readonly<GModelRoot>>;
|
|
76
76
|
/**
|
|
77
77
|
* Event that is fired when the focus state of the diagram changes i.e. after a {@link FocusStateChangedAction} has been handled
|
|
@@ -83,20 +83,17 @@ export declare class EditorContextService implements IActionHandler, Disposable,
|
|
|
83
83
|
* by the {@link SelectionService}.
|
|
84
84
|
*/
|
|
85
85
|
get onSelectionChanged(): Event<SelectionChange>;
|
|
86
|
+
/**
|
|
87
|
+
* Event that is fired when the viewport of the diagram changes i.e. after the `CommandStack` has processed a viewport update.
|
|
88
|
+
* By default, this event is only fired if the viewport was changed via a `SetViewportCommand` or `BoundsAwareViewportCommand`
|
|
89
|
+
*/
|
|
90
|
+
get onViewportChanged(): Event<ViewportChange>;
|
|
86
91
|
protected toDispose: DisposableCollection;
|
|
87
92
|
protected initialize(): void;
|
|
88
|
-
preLoadDiagram(): MaybePromise<void>;
|
|
89
93
|
dispose(): void;
|
|
94
|
+
preLoadDiagram(): MaybePromise<void>;
|
|
90
95
|
get(args?: Args): EditorContext;
|
|
91
96
|
getWithSelection(selectedElementIds: string[], args?: Args): EditorContext;
|
|
92
|
-
/**
|
|
93
|
-
* Notifies the service about a model root change. This method should not be called
|
|
94
|
-
* directly. It is called by the `CommandStack` after a model update has been processed.
|
|
95
|
-
* @throws an error if the notifier is not a `CommandStack`
|
|
96
|
-
* @param root the new model root
|
|
97
|
-
* @param notifier the object that triggered the model root change
|
|
98
|
-
*/
|
|
99
|
-
notifyModelRootChanged(root: Readonly<GModelRoot>, notifier: AnyObject): void;
|
|
100
97
|
handle(action: Action): void;
|
|
101
98
|
protected handleSetEditModeAction(action: SetEditModeAction): void;
|
|
102
99
|
protected handleSetDirtyStateAction(action: SetDirtyStateAction): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-context-service.d.ts","sourceRoot":"","sources":["../../src/base/editor-context-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EACH,MAAM,EACN,
|
|
1
|
+
{"version":3,"file":"editor-context-service.d.ts","sourceRoot":"","sources":["../../src/base/editor-context-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EACH,MAAM,EACN,IAAI,EACJ,MAAM,EACN,UAAU,EACV,oBAAoB,EAEpB,aAAa,EACb,OAAO,EACP,KAAK,EAEL,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,cAAc,EAEd,YAAY,EACZ,YAAY,EACZ,oBAAoB,EAEpB,mBAAmB,EACnB,iBAAiB,EAEjB,WAAW,EACX,QAAQ,EACX,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAExE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAChC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;CACtD;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAC9B,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C,UAAU,IAAI,IAAI;IAM5B,OAAO,IAAI,IAAI;IAIf,cAAc,IAAI,YAAY,CAAC,IAAI,CAAC;IASpC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,aAAa;IAQ/B,gBAAgB,CAAC,kBAAkB,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,aAAa;IAQ1E,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQ5B,SAAS,CAAC,uBAAuB,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAMlE,SAAS,CAAC,yBAAyB,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI;IAOtE,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAElC;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,SAAS,IAAI,QAAQ,CAAC,UAAU,CAAC,CAKpC;IAED,IAAI,QAAQ,IAAI,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,GAAG,SAAS,CAE1D;IAED,IAAI,YAAY,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAOrC;IAED,IAAI,YAAY,IAAI,QAAQ,CAAC,MAAM,CAAC,CAGnC;IAED,IAAI,gBAAgB,IAAI,QAAQ,CAAC,aAAa,CAAC,EAAE,CAEhD;IAED,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;CACJ;AAED,MAAM,MAAM,4BAA4B,GAAG,MAAM,OAAO,CAAC,oBAAoB,CAAC,CAAC"}
|
|
@@ -45,10 +45,6 @@ let EditorContextService = class EditorContextService {
|
|
|
45
45
|
constructor() {
|
|
46
46
|
this.onEditModeChangedEmitter = new sprotty_1.Emitter();
|
|
47
47
|
this.onDirtyStateChangedEmitter = new sprotty_1.Emitter();
|
|
48
|
-
/**
|
|
49
|
-
* Event that is fired when the model root of the diagram changes i.e. after the `CommandStack` has processed a model update.
|
|
50
|
-
*/
|
|
51
|
-
this.onModelRootChangedEmitter = new sprotty_1.Emitter();
|
|
52
48
|
this.toDispose = new sprotty_1.DisposableCollection();
|
|
53
49
|
}
|
|
54
50
|
/**
|
|
@@ -63,8 +59,11 @@ let EditorContextService = class EditorContextService {
|
|
|
63
59
|
get onDirtyStateChanged() {
|
|
64
60
|
return this.onDirtyStateChangedEmitter.event;
|
|
65
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Event that is fired when the model root of the diagram changes i.e. after the `CommandStack` has processed a model update.
|
|
64
|
+
*/
|
|
66
65
|
get onModelRootChanged() {
|
|
67
|
-
return this.
|
|
66
|
+
return this.modelChangeService.onModelRootChanged;
|
|
68
67
|
}
|
|
69
68
|
/**
|
|
70
69
|
* Event that is fired when the focus state of the diagram changes i.e. after a {@link FocusStateChangedAction} has been handled
|
|
@@ -80,11 +79,21 @@ let EditorContextService = class EditorContextService {
|
|
|
80
79
|
get onSelectionChanged() {
|
|
81
80
|
return this.selectionService.onSelectionChanged;
|
|
82
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Event that is fired when the viewport of the diagram changes i.e. after the `CommandStack` has processed a viewport update.
|
|
84
|
+
* By default, this event is only fired if the viewport was changed via a `SetViewportCommand` or `BoundsAwareViewportCommand`
|
|
85
|
+
*/
|
|
86
|
+
get onViewportChanged() {
|
|
87
|
+
return this.modelChangeService.onViewportChanged;
|
|
88
|
+
}
|
|
83
89
|
initialize() {
|
|
84
90
|
var _a;
|
|
85
91
|
this._editMode = (_a = this.diagramOptions.editMode) !== null && _a !== void 0 ? _a : sprotty_1.EditMode.EDITABLE;
|
|
86
92
|
this.toDispose.push(this.onEditModeChangedEmitter, this.onDirtyStateChangedEmitter);
|
|
87
93
|
}
|
|
94
|
+
dispose() {
|
|
95
|
+
this.toDispose.dispose();
|
|
96
|
+
}
|
|
88
97
|
preLoadDiagram() {
|
|
89
98
|
this.lazyInjector.getAll(sprotty_1.TYPES.IGModelRootListener).forEach(listener => {
|
|
90
99
|
this.onModelRootChanged(event => listener.modelRootChanged(event));
|
|
@@ -93,9 +102,6 @@ let EditorContextService = class EditorContextService {
|
|
|
93
102
|
this.onEditModeChanged(event => listener.editModeChanged(event.newValue, event.oldValue));
|
|
94
103
|
});
|
|
95
104
|
}
|
|
96
|
-
dispose() {
|
|
97
|
-
this.toDispose.dispose();
|
|
98
|
-
}
|
|
99
105
|
get(args) {
|
|
100
106
|
return {
|
|
101
107
|
selectedElementIds: Array.from(this.selectionService.getSelectedElementIDs()),
|
|
@@ -110,20 +116,6 @@ let EditorContextService = class EditorContextService {
|
|
|
110
116
|
args
|
|
111
117
|
};
|
|
112
118
|
}
|
|
113
|
-
/**
|
|
114
|
-
* Notifies the service about a model root change. This method should not be called
|
|
115
|
-
* directly. It is called by the `CommandStack` after a model update has been processed.
|
|
116
|
-
* @throws an error if the notifier is not a `CommandStack`
|
|
117
|
-
* @param root the new model root
|
|
118
|
-
* @param notifier the object that triggered the model root change
|
|
119
|
-
*/
|
|
120
|
-
notifyModelRootChanged(root, notifier) {
|
|
121
|
-
if (!(notifier instanceof sprotty_1.CommandStack)) {
|
|
122
|
-
throw new Error('Invalid model root change notification. Notifier is not an instance of `CommandStack`.');
|
|
123
|
-
}
|
|
124
|
-
this._modelRoot = root;
|
|
125
|
-
this.onModelRootChangedEmitter.fire(root);
|
|
126
|
-
}
|
|
127
119
|
handle(action) {
|
|
128
120
|
if (sprotty_1.SetEditModeAction.is(action)) {
|
|
129
121
|
this.handleSetEditModeAction(action);
|
|
@@ -156,13 +148,13 @@ let EditorContextService = class EditorContextService {
|
|
|
156
148
|
return this.diagramOptions.clientId;
|
|
157
149
|
}
|
|
158
150
|
get modelRoot() {
|
|
159
|
-
if (!this.
|
|
151
|
+
if (!this.modelChangeService.currentRoot) {
|
|
160
152
|
throw new Error('Model root not available yet');
|
|
161
153
|
}
|
|
162
|
-
return this.
|
|
154
|
+
return this.modelChangeService.currentRoot;
|
|
163
155
|
}
|
|
164
156
|
get viewport() {
|
|
165
|
-
return this.
|
|
157
|
+
return this.modelRoot ? (0, sprotty_1.findParentByFeature)(this.modelRoot, sprotty_1.isViewport) : undefined;
|
|
166
158
|
}
|
|
167
159
|
get viewportData() {
|
|
168
160
|
var _a, _b;
|
|
@@ -176,7 +168,7 @@ let EditorContextService = class EditorContextService {
|
|
|
176
168
|
get canvasBounds() {
|
|
177
169
|
var _a, _b;
|
|
178
170
|
// default value aligned with the initialization of canvasBounds in GModelRoot
|
|
179
|
-
return (_b = (_a = this.
|
|
171
|
+
return (_b = (_a = this.modelRoot) === null || _a === void 0 ? void 0 : _a.canvasBounds) !== null && _b !== void 0 ? _b : sprotty_1.Bounds.EMPTY;
|
|
180
172
|
}
|
|
181
173
|
get selectedElements() {
|
|
182
174
|
return this.selectionService.getSelectedElements();
|
|
@@ -193,6 +185,10 @@ __decorate([
|
|
|
193
185
|
(0, inversify_1.inject)(selection_service_1.SelectionService),
|
|
194
186
|
__metadata("design:type", selection_service_1.SelectionService)
|
|
195
187
|
], EditorContextService.prototype, "selectionService", void 0);
|
|
188
|
+
__decorate([
|
|
189
|
+
(0, inversify_1.inject)(sprotty_1.TYPES.IModelChangeService),
|
|
190
|
+
__metadata("design:type", Object)
|
|
191
|
+
], EditorContextService.prototype, "modelChangeService", void 0);
|
|
196
192
|
__decorate([
|
|
197
193
|
(0, inversify_1.inject)(sprotty_1.MousePositionTracker),
|
|
198
194
|
__metadata("design:type", sprotty_1.MousePositionTracker)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-context-service.js","sourceRoot":"","sources":["../../src/base/editor-context-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,
|
|
1
|
+
{"version":3,"file":"editor-context-service.js","sourceRoot":"","sources":["../../src/base/editor-context-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AA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ception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { Action, Emitter, Event, IActionHandler, ICommand, ViewerOptions } from '@eclipse-glsp/sprotty';
|
|
16
|
+
import { Action, Disposable, Emitter, Event, IActionHandler, ICommand, ViewerOptions } from '@eclipse-glsp/sprotty';
|
|
17
17
|
export interface FocusChange {
|
|
18
18
|
hasFocus: boolean;
|
|
19
19
|
focusElement: HTMLOrSVGElement | null;
|
|
@@ -24,7 +24,7 @@ export interface FocusChange {
|
|
|
24
24
|
* Emits a {@link FocusChange} event when the focus state changes.
|
|
25
25
|
* Allows querying of the current focus state and the focused root diagram element and the currently focused element within the diagram.
|
|
26
26
|
*/
|
|
27
|
-
export declare class FocusTracker implements IActionHandler {
|
|
27
|
+
export declare class FocusTracker implements IActionHandler, Disposable {
|
|
28
28
|
protected inActiveCssClass: string;
|
|
29
29
|
protected _hasFocus: boolean;
|
|
30
30
|
protected _focusElement: HTMLOrSVGElement | null;
|
|
@@ -39,5 +39,6 @@ export declare class FocusTracker implements IActionHandler {
|
|
|
39
39
|
get focusElement(): HTMLOrSVGElement | null;
|
|
40
40
|
get diagramElement(): HTMLElement | null;
|
|
41
41
|
handle(action: Action): void | Action | ICommand;
|
|
42
|
+
dispose(): void;
|
|
42
43
|
}
|
|
43
44
|
//# sourceMappingURL=focus-tracker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focus-tracker.d.ts","sourceRoot":"","sources":["../../../src/base/focus/focus-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAS,aAAa,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"focus-tracker.d.ts","sourceRoot":"","sources":["../../../src/base/focus/focus-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAS,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAI3H,MAAM,WAAW,WAAW;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACtC,cAAc,EAAE,WAAW,GAAG,IAAI,CAAC;CACtC;AAED;;;;GAIG;AACH,qBACa,YAAa,YAAW,cAAc,EAAE,UAAU;IAC3D,SAAS,CAAC,gBAAgB,SAAc;IACxC,SAAS,CAAC,SAAS,UAAQ;IAC3B,SAAS,CAAC,aAAa,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACjD,SAAS,CAAC,eAAe,EAAE,WAAW,GAAG,IAAI,CAAC;IAEjB,SAAS,CAAC,OAAO,EAAE,aAAa,CAAC;IAE9D,SAAS,CAAC,qBAAqB,uBAA8B;IAC7D;;OAEG;IACH,IAAI,cAAc,IAAI,KAAK,CAAC,WAAW,CAAC,CAEvC;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,YAAY,IAAI,gBAAgB,GAAG,IAAI,CAE1C;IAED,IAAI,cAAc,IAAI,WAAW,GAAG,IAAI,CAEvC;IAED,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,QAAQ;IAsBhD,OAAO,IAAI,IAAI;CAGlB"}
|
|
@@ -74,12 +74,21 @@ let FocusTracker = class FocusTracker {
|
|
|
74
74
|
}
|
|
75
75
|
this.onFocusChangedEmitter.fire({ hasFocus: this.hasFocus, focusElement: this.focusElement, diagramElement: this.diagramElement });
|
|
76
76
|
}
|
|
77
|
+
dispose() {
|
|
78
|
+
this.onFocusChangedEmitter.dispose();
|
|
79
|
+
}
|
|
77
80
|
};
|
|
78
81
|
exports.FocusTracker = FocusTracker;
|
|
79
82
|
__decorate([
|
|
80
83
|
(0, inversify_1.inject)(sprotty_1.TYPES.ViewerOptions),
|
|
81
84
|
__metadata("design:type", Object)
|
|
82
85
|
], FocusTracker.prototype, "options", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
(0, inversify_1.preDestroy)(),
|
|
88
|
+
__metadata("design:type", Function),
|
|
89
|
+
__metadata("design:paramtypes", []),
|
|
90
|
+
__metadata("design:returntype", void 0)
|
|
91
|
+
], FocusTracker.prototype, "dispose", null);
|
|
83
92
|
exports.FocusTracker = FocusTracker = __decorate([
|
|
84
93
|
(0, inversify_1.injectable)()
|
|
85
94
|
], FocusTracker);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focus-tracker.js","sourceRoot":"","sources":["../../../src/base/focus/focus-tracker.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,
|
|
1
|
+
{"version":3,"file":"focus-tracker.js","sourceRoot":"","sources":["../../../src/base/focus/focus-tracker.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,mDAA2H;AAC3H,yCAA2D;AAC3D,2EAAsE;AAQtE;;;;GAIG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAY;IAAlB;QACO,qBAAgB,GAAG,UAAU,CAAC;QAC9B,cAAS,GAAG,IAAI,CAAC;QAMjB,0BAAqB,GAAG,IAAI,iBAAO,EAAe,CAAC;IA6CjE,CAAC;IA5CG;;OAEG;IACH,IAAI,cAAc;QACd,OAAO,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC;IAC5C,CAAC;IAED,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED,IAAI,cAAc;QACd,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,MAAc;QACjB,IAAI,CAAC,mDAAuB,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;YACtC,OAAO;QACX,CAAC;QAED,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC,aAAwC,CAAC;QACvE,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACrE,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YACxB,OAAO;QACX,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,IAAI,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC;gBACjE,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YACjE,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC9D,CAAC;QACD,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;IACvI,CAAC;IAGD,OAAO;QACH,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAC;IACzC,CAAC;CACJ,CAAA;AArDY,oCAAY;AAMkB;IAAtC,IAAA,kBAAM,EAAC,eAAK,CAAC,aAAa,CAAC;;6CAAkC;AA4C9D;IADC,IAAA,sBAAU,GAAE;;;;2CAGZ;uBApDQ,YAAY;IADxB,IAAA,sBAAU,GAAE;GACA,YAAY,CAqDxB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2025 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 { Disposable, DisposableCollection, Emitter, Event, GModelRoot, ICommand, ICommandStack, LazyInjector, Viewport } from '@eclipse-glsp/sprotty';
|
|
17
|
+
/**
|
|
18
|
+
* Service that tracks changes to the model root and the viewport.
|
|
19
|
+
* Allows to register listeners that are notified when the model root or the viewport changes.
|
|
20
|
+
* The current model root can be queried at any time.
|
|
21
|
+
*/
|
|
22
|
+
export interface IModelChangeService {
|
|
23
|
+
/** The current model root */
|
|
24
|
+
readonly currentRoot: Readonly<GModelRoot> | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Event that is fired when the model root of the diagram changes i.e. after the `CommandStack` has processed a model update.
|
|
27
|
+
*/
|
|
28
|
+
onModelRootChanged: Event<Readonly<GModelRoot>>;
|
|
29
|
+
/**
|
|
30
|
+
* Event that is fired when the viewport of the diagram changes i.e. after the `CommandStack` has processed a viewport update.
|
|
31
|
+
* By default, this event is only fired if the viewport was changed via a `SetViewportCommand` or `BoundsAwareViewportCommand`
|
|
32
|
+
*/
|
|
33
|
+
onViewportChanged: Event<ViewportChange>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Event data for the {@link IModelChangeService.onViewportChanged} event.
|
|
37
|
+
*/
|
|
38
|
+
export interface ViewportChange {
|
|
39
|
+
/** The new viewport */
|
|
40
|
+
newViewport: Readonly<Viewport>;
|
|
41
|
+
/** The old viewport */
|
|
42
|
+
oldViewport?: Readonly<Viewport>;
|
|
43
|
+
}
|
|
44
|
+
export declare class ModelChangeService implements IModelChangeService, Disposable {
|
|
45
|
+
protected lazyInjector: LazyInjector;
|
|
46
|
+
protected _currentRoot?: Readonly<GModelRoot>;
|
|
47
|
+
protected lastViewport?: Readonly<Viewport>;
|
|
48
|
+
protected toDispose: DisposableCollection;
|
|
49
|
+
get currentRoot(): Readonly<GModelRoot> | undefined;
|
|
50
|
+
protected get commandStack(): ICommandStack;
|
|
51
|
+
protected onModelRootChangedEmitter: Emitter<Readonly<GModelRoot>>;
|
|
52
|
+
get onModelRootChanged(): Event<Readonly<GModelRoot>>;
|
|
53
|
+
protected onViewportChangedEmitter: Emitter<ViewportChange>;
|
|
54
|
+
get onViewportChanged(): Event<ViewportChange>;
|
|
55
|
+
protected initialize(): void;
|
|
56
|
+
dispose(): void;
|
|
57
|
+
protected handleCommandExecution(command: ICommand, newRoot: GModelRoot): void;
|
|
58
|
+
protected isModelRootChangeCommand(command: ICommand): boolean;
|
|
59
|
+
protected isViewportChangeCommand(command: ICommand): boolean;
|
|
60
|
+
protected handleModelRootChangeCommand(command: ICommand, newRoot: GModelRoot): void;
|
|
61
|
+
protected handleViewportChangeCommand(command: ICommand, newRoot: GModelRoot): void;
|
|
62
|
+
protected hasViewportChanged(newViewport: Readonly<Viewport>): boolean;
|
|
63
|
+
protected toViewport(root: Readonly<GModelRoot>): Readonly<Viewport> | undefined;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=model-change-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-change-service.d.ts","sourceRoot":"","sources":["../../../src/base/model/model-change-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAEH,UAAU,EACV,oBAAoB,EACpB,OAAO,EACP,KAAK,EACL,UAAU,EACV,QAAQ,EACR,aA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GAAG,IAAI;IAS9E,SAAS,CAAC,wBAAwB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAI9D,SAAS,CAAC,uBAAuB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAI7D,SAAS,CAAC,4BAA4B,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI;IAMpF,SAAS,CAAC,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI;IAYnF,SAAS,CAAC,kBAAkB,CAAC,WAAW,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,OAAO;IAWtE,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,SAAS;CAGnF"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ModelChangeService = void 0;
|
|
13
|
+
/********************************************************************************
|
|
14
|
+
* Copyright (c) 2025 EclipseSource and others.
|
|
15
|
+
*
|
|
16
|
+
* This program and the accompanying materials are made available under the
|
|
17
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
18
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
19
|
+
*
|
|
20
|
+
* This Source Code may also be made available under the following Secondary
|
|
21
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
22
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
23
|
+
* with the GNU Classpath Exception which is available at
|
|
24
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
25
|
+
*
|
|
26
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
27
|
+
********************************************************************************/
|
|
28
|
+
const sprotty_1 = require("@eclipse-glsp/sprotty");
|
|
29
|
+
const inversify_1 = require("inversify");
|
|
30
|
+
class ModelChangeService {
|
|
31
|
+
constructor() {
|
|
32
|
+
this.toDispose = new sprotty_1.DisposableCollection();
|
|
33
|
+
this.onModelRootChangedEmitter = new sprotty_1.Emitter();
|
|
34
|
+
this.onViewportChangedEmitter = new sprotty_1.Emitter();
|
|
35
|
+
}
|
|
36
|
+
get currentRoot() {
|
|
37
|
+
return this._currentRoot;
|
|
38
|
+
}
|
|
39
|
+
get commandStack() {
|
|
40
|
+
return this.lazyInjector.get(sprotty_1.TYPES.ICommandStack);
|
|
41
|
+
}
|
|
42
|
+
get onModelRootChanged() {
|
|
43
|
+
return this.onModelRootChangedEmitter.event;
|
|
44
|
+
}
|
|
45
|
+
get onViewportChanged() {
|
|
46
|
+
return this.onViewportChangedEmitter.event;
|
|
47
|
+
}
|
|
48
|
+
initialize() {
|
|
49
|
+
this.toDispose.push(this.onModelRootChangedEmitter, this.onViewportChangedEmitter);
|
|
50
|
+
this.commandStack.onCommandExecuted(data => this.handleCommandExecution(data.command, data.newRoot));
|
|
51
|
+
}
|
|
52
|
+
dispose() {
|
|
53
|
+
this.toDispose.dispose();
|
|
54
|
+
}
|
|
55
|
+
handleCommandExecution(command, newRoot) {
|
|
56
|
+
if (this.isModelRootChangeCommand(command)) {
|
|
57
|
+
this.handleModelRootChangeCommand(command, newRoot);
|
|
58
|
+
}
|
|
59
|
+
if (this.isViewportChangeCommand(command)) {
|
|
60
|
+
this.handleViewportChangeCommand(command, newRoot);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
isModelRootChangeCommand(command) {
|
|
64
|
+
return command instanceof sprotty_1.SetModelCommand || command instanceof sprotty_1.UpdateModelCommand;
|
|
65
|
+
}
|
|
66
|
+
isViewportChangeCommand(command) {
|
|
67
|
+
return command instanceof sprotty_1.SetViewportCommand || command instanceof sprotty_1.BoundsAwareViewportCommand;
|
|
68
|
+
}
|
|
69
|
+
handleModelRootChangeCommand(command, newRoot) {
|
|
70
|
+
this._currentRoot = newRoot;
|
|
71
|
+
this.lastViewport = this.toViewport(newRoot);
|
|
72
|
+
this.onModelRootChangedEmitter.fire(newRoot);
|
|
73
|
+
}
|
|
74
|
+
handleViewportChangeCommand(command, newRoot) {
|
|
75
|
+
const viewport = this.toViewport(newRoot);
|
|
76
|
+
if (!viewport) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (this.hasViewportChanged(viewport)) {
|
|
80
|
+
this.onViewportChangedEmitter.fire({ newViewport: viewport, oldViewport: this.lastViewport });
|
|
81
|
+
this.lastViewport = viewport;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
hasViewportChanged(newViewport) {
|
|
85
|
+
if (!this.lastViewport) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
return !((0, sprotty_1.almostEquals)(newViewport.zoom, this.lastViewport.zoom) &&
|
|
89
|
+
(0, sprotty_1.almostEquals)(newViewport.scroll.x, this.lastViewport.scroll.x) &&
|
|
90
|
+
(0, sprotty_1.almostEquals)(newViewport.scroll.y, this.lastViewport.scroll.y));
|
|
91
|
+
}
|
|
92
|
+
toViewport(root) {
|
|
93
|
+
return (0, sprotty_1.isViewport)(root) ? { scroll: root.scroll, zoom: root.zoom } : undefined;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.ModelChangeService = ModelChangeService;
|
|
97
|
+
__decorate([
|
|
98
|
+
(0, inversify_1.inject)(sprotty_1.LazyInjector),
|
|
99
|
+
__metadata("design:type", Object)
|
|
100
|
+
], ModelChangeService.prototype, "lazyInjector", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
(0, inversify_1.postConstruct)(),
|
|
103
|
+
__metadata("design:type", Function),
|
|
104
|
+
__metadata("design:paramtypes", []),
|
|
105
|
+
__metadata("design:returntype", void 0)
|
|
106
|
+
], ModelChangeService.prototype, "initialize", null);
|
|
107
|
+
__decorate([
|
|
108
|
+
(0, inversify_1.preDestroy)(),
|
|
109
|
+
__metadata("design:type", Function),
|
|
110
|
+
__metadata("design:paramtypes", []),
|
|
111
|
+
__metadata("design:returntype", void 0)
|
|
112
|
+
], ModelChangeService.prototype, "dispose", null);
|
|
113
|
+
//# sourceMappingURL=model-change-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-change-service.js","sourceRoot":"","sources":["../../../src/base/model/model-change-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,mDAiB+B;AAC/B,yCAA8D;AAgC9D,MAAa,kBAAkB;IAA/B;QAKc,cAAS,GAAG,IAAI,8BAAoB,EAAE,CAAC;QAUvC,8BAAyB,GAAG,IAAI,iBAAO,EAAwB,CAAC;QAKhE,6BAAwB,GAAG,IAAI,iBAAO,EAAkB,CAAC;IAiEvE,CAAC;IA9EG,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED,IAAc,YAAY;QACtB,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAgB,eAAK,CAAC,aAAa,CAAC,CAAC;IACrE,CAAC;IAGD,IAAI,kBAAkB;QAClB,OAAO,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC;IAChD,CAAC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
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eclipse-glsp/client",
|
|
3
|
-
"version": "2.5.0-next.
|
|
3
|
+
"version": "2.5.0-next.428+ab936c7",
|
|
4
4
|
"description": "A sprotty-based client for GLSP",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eclipse",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"watch": "tsc -w"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@eclipse-glsp/sprotty": "2.5.0-next.
|
|
49
|
+
"@eclipse-glsp/sprotty": "2.5.0-next.428+ab936c7",
|
|
50
50
|
"autocompleter": "^9.1.2",
|
|
51
51
|
"file-saver": "^2.0.5",
|
|
52
52
|
"lodash": "4.17.21",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "ab936c708ffa231e8aa57386385018c470d54b4f"
|
|
67
67
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2025 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
|
|
@@ -15,25 +15,37 @@
|
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import {
|
|
17
17
|
CommandExecutionContext,
|
|
18
|
+
CommandExecutionData,
|
|
18
19
|
CommandStack,
|
|
19
20
|
Disposable,
|
|
20
21
|
DisposableCollection,
|
|
22
|
+
Emitter,
|
|
21
23
|
Event,
|
|
22
24
|
GModelRoot,
|
|
23
25
|
ICommand,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
UpdateModelCommand
|
|
26
|
+
ICommandStack,
|
|
27
|
+
LazyInjector
|
|
27
28
|
} from '@eclipse-glsp/sprotty';
|
|
28
|
-
import { inject, injectable, preDestroy } from 'inversify';
|
|
29
|
+
import { inject, injectable, postConstruct, preDestroy } from 'inversify';
|
|
29
30
|
import { EditorContextService } from './editor-context-service';
|
|
30
31
|
|
|
31
32
|
@injectable()
|
|
32
|
-
export class GLSPCommandStack extends CommandStack implements Disposable {
|
|
33
|
+
export class GLSPCommandStack extends CommandStack implements ICommandStack, Disposable {
|
|
33
34
|
@inject(LazyInjector)
|
|
34
35
|
protected lazyInjector: LazyInjector;
|
|
35
36
|
protected toDispose = new DisposableCollection();
|
|
36
37
|
|
|
38
|
+
protected onCommandExecutedEmitter = new Emitter<CommandExecutionData>();
|
|
39
|
+
get onCommandExecuted(): Event<CommandExecutionData> {
|
|
40
|
+
return this.onCommandExecutedEmitter.event;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@postConstruct()
|
|
44
|
+
protected override initialize(): void {
|
|
45
|
+
super.initialize();
|
|
46
|
+
this.toDispose.push(this.onCommandExecutedEmitter);
|
|
47
|
+
}
|
|
48
|
+
|
|
37
49
|
@preDestroy()
|
|
38
50
|
dispose(): void {
|
|
39
51
|
this.toDispose.dispose();
|
|
@@ -95,13 +107,7 @@ export class GLSPCommandStack extends CommandStack implements Disposable {
|
|
|
95
107
|
}
|
|
96
108
|
override async execute(command: ICommand): Promise<GModelRoot> {
|
|
97
109
|
const result = await super.execute(command);
|
|
98
|
-
|
|
99
|
-
this.notifyListeners(result);
|
|
100
|
-
}
|
|
110
|
+
this.onCommandExecutedEmitter.fire({ command, newRoot: result });
|
|
101
111
|
return result;
|
|
102
112
|
}
|
|
103
|
-
|
|
104
|
-
protected notifyListeners(root: Readonly<GModelRoot>): void {
|
|
105
|
-
this.editorContext.notifyModelRootChanged(root, this);
|
|
106
|
-
}
|
|
107
113
|
}
|
|
@@ -46,6 +46,7 @@ import { FocusStateChangedAction } from './focus/focus-state-change-action';
|
|
|
46
46
|
import { FocusTracker } from './focus/focus-tracker';
|
|
47
47
|
import { DiagramLoader } from './model/diagram-loader';
|
|
48
48
|
import { GLSPModelSource } from './model/glsp-model-source';
|
|
49
|
+
import { ModelChangeService } from './model/model-change-service';
|
|
49
50
|
import { DefaultModelInitializationConstraint, ModelInitializationConstraint } from './model/model-initialization-constraint';
|
|
50
51
|
import { GModelRegistry } from './model/model-registry';
|
|
51
52
|
import { GLSPMousePositionTracker } from './mouse-position-tracker';
|
|
@@ -77,6 +78,7 @@ export const defaultModule = new FeatureModule(
|
|
|
77
78
|
bind(TYPES.IEditorContextServiceProvider).toProvider<EditorContextService>(
|
|
78
79
|
ctx => async () => ctx.container.get(EditorContextService)
|
|
79
80
|
);
|
|
81
|
+
bind(TYPES.IModelChangeService).to(ModelChangeService).inSingletonScope();
|
|
80
82
|
|
|
81
83
|
configureActionHandler(context, SetEditModeAction.KIND, EditorContextService);
|
|
82
84
|
configureActionHandler(context, SetDirtyStateAction.KIND, EditorContextService);
|
|
@@ -15,10 +15,8 @@
|
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import {
|
|
17
17
|
Action,
|
|
18
|
-
AnyObject,
|
|
19
18
|
Args,
|
|
20
19
|
Bounds,
|
|
21
|
-
CommandStack,
|
|
22
20
|
Disposable,
|
|
23
21
|
DisposableCollection,
|
|
24
22
|
EditMode,
|
|
@@ -44,6 +42,7 @@ import {
|
|
|
44
42
|
import { inject, injectable, postConstruct, preDestroy } from 'inversify';
|
|
45
43
|
import { FocusChange, FocusTracker } from './focus/focus-tracker';
|
|
46
44
|
import { IDiagramOptions, IDiagramStartup } from './model/diagram-loader';
|
|
45
|
+
import { IModelChangeService, ViewportChange } from './model/model-change-service';
|
|
47
46
|
import { SelectionChange, SelectionService } from './selection-service';
|
|
48
47
|
|
|
49
48
|
/**
|
|
@@ -85,6 +84,9 @@ export class EditorContextService implements IActionHandler, Disposable, IDiagra
|
|
|
85
84
|
@inject(SelectionService)
|
|
86
85
|
protected selectionService: SelectionService;
|
|
87
86
|
|
|
87
|
+
@inject(TYPES.IModelChangeService)
|
|
88
|
+
protected modelChangeService: IModelChangeService;
|
|
89
|
+
|
|
88
90
|
@inject(MousePositionTracker)
|
|
89
91
|
protected mousePositionTracker: MousePositionTracker;
|
|
90
92
|
|
|
@@ -118,13 +120,11 @@ export class EditorContextService implements IActionHandler, Disposable, IDiagra
|
|
|
118
120
|
return this.onDirtyStateChangedEmitter.event;
|
|
119
121
|
}
|
|
120
122
|
|
|
121
|
-
protected _modelRoot?: Readonly<GModelRoot>;
|
|
122
123
|
/**
|
|
123
124
|
* Event that is fired when the model root of the diagram changes i.e. after the `CommandStack` has processed a model update.
|
|
124
125
|
*/
|
|
125
|
-
protected onModelRootChangedEmitter = new Emitter<Readonly<GModelRoot>>();
|
|
126
126
|
get onModelRootChanged(): Event<Readonly<GModelRoot>> {
|
|
127
|
-
return this.
|
|
127
|
+
return this.modelChangeService.onModelRootChanged;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
/**
|
|
@@ -143,6 +143,14 @@ export class EditorContextService implements IActionHandler, Disposable, IDiagra
|
|
|
143
143
|
return this.selectionService.onSelectionChanged;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Event that is fired when the viewport of the diagram changes i.e. after the `CommandStack` has processed a viewport update.
|
|
148
|
+
* By default, this event is only fired if the viewport was changed via a `SetViewportCommand` or `BoundsAwareViewportCommand`
|
|
149
|
+
*/
|
|
150
|
+
get onViewportChanged(): Event<ViewportChange> {
|
|
151
|
+
return this.modelChangeService.onViewportChanged;
|
|
152
|
+
}
|
|
153
|
+
|
|
146
154
|
protected toDispose = new DisposableCollection();
|
|
147
155
|
|
|
148
156
|
@postConstruct()
|
|
@@ -151,6 +159,11 @@ export class EditorContextService implements IActionHandler, Disposable, IDiagra
|
|
|
151
159
|
this.toDispose.push(this.onEditModeChangedEmitter, this.onDirtyStateChangedEmitter);
|
|
152
160
|
}
|
|
153
161
|
|
|
162
|
+
@preDestroy()
|
|
163
|
+
dispose(): void {
|
|
164
|
+
this.toDispose.dispose();
|
|
165
|
+
}
|
|
166
|
+
|
|
154
167
|
preLoadDiagram(): MaybePromise<void> {
|
|
155
168
|
this.lazyInjector.getAll<IGModelRootListener>(TYPES.IGModelRootListener).forEach(listener => {
|
|
156
169
|
this.onModelRootChanged(event => listener.modelRootChanged(event));
|
|
@@ -160,11 +173,6 @@ export class EditorContextService implements IActionHandler, Disposable, IDiagra
|
|
|
160
173
|
});
|
|
161
174
|
}
|
|
162
175
|
|
|
163
|
-
@preDestroy()
|
|
164
|
-
dispose(): void {
|
|
165
|
-
this.toDispose.dispose();
|
|
166
|
-
}
|
|
167
|
-
|
|
168
176
|
get(args?: Args): EditorContext {
|
|
169
177
|
return {
|
|
170
178
|
selectedElementIds: Array.from(this.selectionService.getSelectedElementIDs()),
|
|
@@ -181,21 +189,6 @@ export class EditorContextService implements IActionHandler, Disposable, IDiagra
|
|
|
181
189
|
};
|
|
182
190
|
}
|
|
183
191
|
|
|
184
|
-
/**
|
|
185
|
-
* Notifies the service about a model root change. This method should not be called
|
|
186
|
-
* directly. It is called by the `CommandStack` after a model update has been processed.
|
|
187
|
-
* @throws an error if the notifier is not a `CommandStack`
|
|
188
|
-
* @param root the new model root
|
|
189
|
-
* @param notifier the object that triggered the model root change
|
|
190
|
-
*/
|
|
191
|
-
notifyModelRootChanged(root: Readonly<GModelRoot>, notifier: AnyObject): void {
|
|
192
|
-
if (!(notifier instanceof CommandStack)) {
|
|
193
|
-
throw new Error('Invalid model root change notification. Notifier is not an instance of `CommandStack`.');
|
|
194
|
-
}
|
|
195
|
-
this._modelRoot = root;
|
|
196
|
-
this.onModelRootChangedEmitter.fire(root);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
192
|
handle(action: Action): void {
|
|
200
193
|
if (SetEditModeAction.is(action)) {
|
|
201
194
|
this.handleSetEditModeAction(action);
|
|
@@ -234,14 +227,14 @@ export class EditorContextService implements IActionHandler, Disposable, IDiagra
|
|
|
234
227
|
}
|
|
235
228
|
|
|
236
229
|
get modelRoot(): Readonly<GModelRoot> {
|
|
237
|
-
if (!this.
|
|
230
|
+
if (!this.modelChangeService.currentRoot) {
|
|
238
231
|
throw new Error('Model root not available yet');
|
|
239
232
|
}
|
|
240
|
-
return this.
|
|
233
|
+
return this.modelChangeService.currentRoot;
|
|
241
234
|
}
|
|
242
235
|
|
|
243
236
|
get viewport(): Readonly<GModelRoot & Viewport> | undefined {
|
|
244
|
-
return this.
|
|
237
|
+
return this.modelRoot ? findParentByFeature(this.modelRoot, isViewport) : undefined;
|
|
245
238
|
}
|
|
246
239
|
|
|
247
240
|
get viewportData(): Readonly<Viewport> {
|
|
@@ -255,7 +248,7 @@ export class EditorContextService implements IActionHandler, Disposable, IDiagra
|
|
|
255
248
|
|
|
256
249
|
get canvasBounds(): Readonly<Bounds> {
|
|
257
250
|
// default value aligned with the initialization of canvasBounds in GModelRoot
|
|
258
|
-
return this.
|
|
251
|
+
return this.modelRoot?.canvasBounds ?? Bounds.EMPTY;
|
|
259
252
|
}
|
|
260
253
|
|
|
261
254
|
get selectedElements(): Readonly<GModelElement>[] {
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { Action, Emitter, Event, IActionHandler, ICommand, TYPES, ViewerOptions } from '@eclipse-glsp/sprotty';
|
|
17
|
-
import { inject, injectable } from 'inversify';
|
|
16
|
+
import { Action, Disposable, Emitter, Event, IActionHandler, ICommand, TYPES, ViewerOptions } from '@eclipse-glsp/sprotty';
|
|
17
|
+
import { inject, injectable, preDestroy } from 'inversify';
|
|
18
18
|
import { FocusStateChangedAction } from './focus-state-change-action';
|
|
19
19
|
|
|
20
20
|
export interface FocusChange {
|
|
@@ -29,7 +29,7 @@ export interface FocusChange {
|
|
|
29
29
|
* Allows querying of the current focus state and the focused root diagram element and the currently focused element within the diagram.
|
|
30
30
|
*/
|
|
31
31
|
@injectable()
|
|
32
|
-
export class FocusTracker implements IActionHandler {
|
|
32
|
+
export class FocusTracker implements IActionHandler, Disposable {
|
|
33
33
|
protected inActiveCssClass = 'inactive';
|
|
34
34
|
protected _hasFocus = true;
|
|
35
35
|
protected _focusElement: HTMLOrSVGElement | null;
|
|
@@ -77,4 +77,9 @@ export class FocusTracker implements IActionHandler {
|
|
|
77
77
|
}
|
|
78
78
|
this.onFocusChangedEmitter.fire({ hasFocus: this.hasFocus, focusElement: this.focusElement, diagramElement: this.diagramElement });
|
|
79
79
|
}
|
|
80
|
+
|
|
81
|
+
@preDestroy()
|
|
82
|
+
dispose(): void {
|
|
83
|
+
this.onFocusChangedEmitter.dispose();
|
|
84
|
+
}
|
|
80
85
|
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2025 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 {
|
|
17
|
+
BoundsAwareViewportCommand,
|
|
18
|
+
Disposable,
|
|
19
|
+
DisposableCollection,
|
|
20
|
+
Emitter,
|
|
21
|
+
Event,
|
|
22
|
+
GModelRoot,
|
|
23
|
+
ICommand,
|
|
24
|
+
ICommandStack,
|
|
25
|
+
LazyInjector,
|
|
26
|
+
SetModelCommand,
|
|
27
|
+
SetViewportCommand,
|
|
28
|
+
TYPES,
|
|
29
|
+
UpdateModelCommand,
|
|
30
|
+
Viewport,
|
|
31
|
+
almostEquals,
|
|
32
|
+
isViewport
|
|
33
|
+
} from '@eclipse-glsp/sprotty';
|
|
34
|
+
import { inject, postConstruct, preDestroy } from 'inversify';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Service that tracks changes to the model root and the viewport.
|
|
38
|
+
* Allows to register listeners that are notified when the model root or the viewport changes.
|
|
39
|
+
* The current model root can be queried at any time.
|
|
40
|
+
*/
|
|
41
|
+
export interface IModelChangeService {
|
|
42
|
+
/** The current model root */
|
|
43
|
+
readonly currentRoot: Readonly<GModelRoot> | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Event that is fired when the model root of the diagram changes i.e. after the `CommandStack` has processed a model update.
|
|
46
|
+
*/
|
|
47
|
+
onModelRootChanged: Event<Readonly<GModelRoot>>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Event that is fired when the viewport of the diagram changes i.e. after the `CommandStack` has processed a viewport update.
|
|
51
|
+
* By default, this event is only fired if the viewport was changed via a `SetViewportCommand` or `BoundsAwareViewportCommand`
|
|
52
|
+
*/
|
|
53
|
+
onViewportChanged: Event<ViewportChange>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Event data for the {@link IModelChangeService.onViewportChanged} event.
|
|
58
|
+
*/
|
|
59
|
+
export interface ViewportChange {
|
|
60
|
+
/** The new viewport */
|
|
61
|
+
newViewport: Readonly<Viewport>;
|
|
62
|
+
/** The old viewport */
|
|
63
|
+
oldViewport?: Readonly<Viewport>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export class ModelChangeService implements IModelChangeService, Disposable {
|
|
67
|
+
@inject(LazyInjector)
|
|
68
|
+
protected lazyInjector: LazyInjector;
|
|
69
|
+
protected _currentRoot?: Readonly<GModelRoot>;
|
|
70
|
+
protected lastViewport?: Readonly<Viewport>;
|
|
71
|
+
protected toDispose = new DisposableCollection();
|
|
72
|
+
|
|
73
|
+
get currentRoot(): Readonly<GModelRoot> | undefined {
|
|
74
|
+
return this._currentRoot;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
protected get commandStack(): ICommandStack {
|
|
78
|
+
return this.lazyInjector.get<ICommandStack>(TYPES.ICommandStack);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
protected onModelRootChangedEmitter = new Emitter<Readonly<GModelRoot>>();
|
|
82
|
+
get onModelRootChanged(): Event<Readonly<GModelRoot>> {
|
|
83
|
+
return this.onModelRootChangedEmitter.event;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
protected onViewportChangedEmitter = new Emitter<ViewportChange>();
|
|
87
|
+
get onViewportChanged(): Event<ViewportChange> {
|
|
88
|
+
return this.onViewportChangedEmitter.event;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@postConstruct()
|
|
92
|
+
protected initialize(): void {
|
|
93
|
+
this.toDispose.push(this.onModelRootChangedEmitter, this.onViewportChangedEmitter);
|
|
94
|
+
this.commandStack.onCommandExecuted(data => this.handleCommandExecution(data.command, data.newRoot));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@preDestroy()
|
|
98
|
+
dispose(): void {
|
|
99
|
+
this.toDispose.dispose();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
protected handleCommandExecution(command: ICommand, newRoot: GModelRoot): void {
|
|
103
|
+
if (this.isModelRootChangeCommand(command)) {
|
|
104
|
+
this.handleModelRootChangeCommand(command, newRoot);
|
|
105
|
+
}
|
|
106
|
+
if (this.isViewportChangeCommand(command)) {
|
|
107
|
+
this.handleViewportChangeCommand(command, newRoot);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
protected isModelRootChangeCommand(command: ICommand): boolean {
|
|
112
|
+
return command instanceof SetModelCommand || command instanceof UpdateModelCommand;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
protected isViewportChangeCommand(command: ICommand): boolean {
|
|
116
|
+
return command instanceof SetViewportCommand || command instanceof BoundsAwareViewportCommand;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
protected handleModelRootChangeCommand(command: ICommand, newRoot: GModelRoot): void {
|
|
120
|
+
this._currentRoot = newRoot;
|
|
121
|
+
this.lastViewport = this.toViewport(newRoot);
|
|
122
|
+
this.onModelRootChangedEmitter.fire(newRoot);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
protected handleViewportChangeCommand(command: ICommand, newRoot: GModelRoot): void {
|
|
126
|
+
const viewport = this.toViewport(newRoot);
|
|
127
|
+
if (!viewport) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (this.hasViewportChanged(viewport)) {
|
|
132
|
+
this.onViewportChangedEmitter.fire({ newViewport: viewport, oldViewport: this.lastViewport });
|
|
133
|
+
this.lastViewport = viewport;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
protected hasViewportChanged(newViewport: Readonly<Viewport>): boolean {
|
|
138
|
+
if (!this.lastViewport) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
return !(
|
|
142
|
+
almostEquals(newViewport.zoom, this.lastViewport.zoom) &&
|
|
143
|
+
almostEquals(newViewport.scroll.x, this.lastViewport.scroll.x) &&
|
|
144
|
+
almostEquals(newViewport.scroll.y, this.lastViewport.scroll.y)
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
protected toViewport(root: Readonly<GModelRoot>): Readonly<Viewport> | undefined {
|
|
149
|
+
return isViewport(root) ? { scroll: root.scroll, zoom: root.zoom } : undefined;
|
|
150
|
+
}
|
|
151
|
+
}
|