@eclipse-glsp/server 1.1.0-next.3d7585d.42 → 1.1.0-next.44bd1e0.43
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/common/command/command-stack.d.ts +38 -8
- package/lib/common/command/command-stack.d.ts.map +1 -1
- package/lib/common/command/command-stack.js +75 -6
- package/lib/common/command/command-stack.js.map +1 -1
- package/lib/common/command/command-stack.spec.d.ts +2 -0
- package/lib/common/command/command-stack.spec.d.ts.map +1 -0
- package/lib/common/command/command-stack.spec.js +207 -0
- package/lib/common/command/command-stack.spec.js.map +1 -0
- package/lib/common/command/command.d.ts +30 -4
- package/lib/common/command/command.d.ts.map +1 -1
- package/lib/common/command/command.js +69 -0
- package/lib/common/command/command.js.map +1 -1
- package/lib/common/command/command.spec.d.ts +2 -0
- package/lib/common/command/command.spec.d.ts.map +1 -0
- package/lib/common/command/command.spec.js +86 -0
- package/lib/common/command/command.spec.js.map +1 -0
- package/lib/common/command/recording-command.d.ts +75 -0
- package/lib/common/command/recording-command.d.ts.map +1 -0
- package/lib/common/command/recording-command.js +99 -0
- package/lib/common/command/recording-command.js.map +1 -0
- package/lib/common/command/recording-command.spec.d.ts +17 -0
- package/lib/common/command/recording-command.spec.d.ts.map +1 -0
- package/lib/common/command/recording-command.spec.js +62 -0
- package/lib/common/command/recording-command.spec.js.map +1 -0
- package/lib/common/command/undo-redo-action-handler.d.ts +28 -0
- package/lib/common/command/undo-redo-action-handler.d.ts.map +1 -0
- package/lib/common/command/undo-redo-action-handler.js +72 -0
- package/lib/common/command/undo-redo-action-handler.js.map +1 -0
- package/lib/common/di/diagram-module.d.ts +3 -0
- package/lib/common/di/diagram-module.d.ts.map +1 -1
- package/lib/common/di/diagram-module.js +12 -0
- package/lib/common/di/diagram-module.js.map +1 -1
- package/lib/common/features/contextactions/tool-palette-item-provider.d.ts +1 -1
- package/lib/common/features/contextactions/tool-palette-item-provider.d.ts.map +1 -1
- package/lib/common/features/contextactions/tool-palette-item-provider.js +2 -4
- package/lib/common/features/contextactions/tool-palette-item-provider.js.map +1 -1
- package/lib/common/{gmodel → features/layout}/computed-bounds-action-handler.d.ts +8 -3
- package/lib/common/features/layout/computed-bounds-action-handler.d.ts.map +1 -0
- package/lib/common/{gmodel → features/layout}/computed-bounds-action-handler.js +8 -3
- package/lib/common/features/layout/computed-bounds-action-handler.js.map +1 -0
- package/lib/common/features/layout/layout-operation-handler.d.ts +12 -3
- package/lib/common/features/layout/layout-operation-handler.d.ts.map +1 -1
- package/lib/common/features/layout/layout-operation-handler.js +26 -10
- package/lib/common/features/layout/layout-operation-handler.js.map +1 -1
- package/lib/common/features/model/model-state.d.ts +0 -2
- package/lib/common/features/model/model-state.d.ts.map +1 -1
- package/lib/common/features/model/model-state.js +0 -1
- package/lib/common/features/model/model-state.js.map +1 -1
- package/lib/common/features/model/model-submission-handler.d.ts +2 -0
- package/lib/common/features/model/model-submission-handler.d.ts.map +1 -1
- package/lib/common/features/model/model-submission-handler.js +7 -2
- package/lib/common/features/model/model-submission-handler.js.map +1 -1
- package/lib/common/features/model/save-model-action-handler.d.ts +2 -2
- package/lib/common/features/model/save-model-action-handler.d.ts.map +1 -1
- package/lib/common/features/model/save-model-action-handler.js +5 -5
- package/lib/common/features/model/save-model-action-handler.js.map +1 -1
- package/lib/common/gmodel/apply-label-edit-operation-handler.d.ts +4 -5
- package/lib/common/gmodel/apply-label-edit-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/apply-label-edit-operation-handler.js +12 -21
- package/lib/common/gmodel/apply-label-edit-operation-handler.js.map +1 -1
- package/lib/common/gmodel/change-bounds-operation-handler.d.ts +9 -6
- package/lib/common/gmodel/change-bounds-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/change-bounds-operation-handler.js +14 -14
- package/lib/common/gmodel/change-bounds-operation-handler.js.map +1 -1
- package/lib/common/gmodel/change-routing-points-operation-handler.d.ts +5 -5
- package/lib/common/gmodel/change-routing-points-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/change-routing-points-operation-handler.js +11 -14
- package/lib/common/gmodel/change-routing-points-operation-handler.js.map +1 -1
- package/lib/common/{operations → gmodel}/cut-operation-handler.d.ts +5 -4
- package/lib/common/gmodel/cut-operation-handler.d.ts.map +1 -0
- package/lib/common/{operations → gmodel}/cut-operation-handler.js +13 -11
- package/lib/common/gmodel/cut-operation-handler.js.map +1 -0
- package/lib/common/gmodel/delete-operation-handler.d.ts +6 -6
- package/lib/common/gmodel/delete-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/delete-operation-handler.js +13 -10
- package/lib/common/gmodel/delete-operation-handler.js.map +1 -1
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.d.ts +11 -7
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.js +12 -13
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.js.map +1 -1
- package/lib/common/gmodel/gmodel-create-node-operation-handler.d.ts +32 -5
- package/lib/common/gmodel/gmodel-create-node-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/gmodel-create-node-operation-handler.js +45 -3
- package/lib/common/gmodel/gmodel-create-node-operation-handler.js.map +1 -1
- package/lib/common/gmodel/gmodel-diagram-module.d.ts +8 -8
- package/lib/common/gmodel/gmodel-diagram-module.d.ts.map +1 -1
- package/lib/common/gmodel/gmodel-diagram-module.js +15 -21
- package/lib/common/gmodel/gmodel-diagram-module.js.map +1 -1
- package/lib/common/gmodel/gmodel-operation-handler.d.ts +23 -0
- package/lib/common/gmodel/gmodel-operation-handler.d.ts.map +1 -0
- package/lib/common/gmodel/gmodel-operation-handler.js +43 -0
- package/lib/common/gmodel/gmodel-operation-handler.js.map +1 -0
- package/lib/common/gmodel/index.d.ts +2 -1
- package/lib/common/gmodel/index.d.ts.map +1 -1
- package/lib/common/gmodel/index.js +2 -1
- package/lib/common/gmodel/index.js.map +1 -1
- package/lib/common/gmodel/paste-operation-handler.d.ts +7 -6
- package/lib/common/gmodel/paste-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/paste-operation-handler.js +20 -15
- package/lib/common/gmodel/paste-operation-handler.js.map +1 -1
- package/lib/common/gmodel/reconnect-edge-operation-handler.d.ts +5 -5
- package/lib/common/gmodel/reconnect-edge-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/reconnect-edge-operation-handler.js +11 -14
- package/lib/common/gmodel/reconnect-edge-operation-handler.js.map +1 -1
- package/lib/common/index.d.ts +2 -1
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +2 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/operations/compound-operation-handler.d.ts +5 -5
- package/lib/common/operations/compound-operation-handler.d.ts.map +1 -1
- package/lib/common/operations/compound-operation-handler.js +37 -9
- package/lib/common/operations/compound-operation-handler.js.map +1 -1
- package/lib/common/operations/create-operation-handler.d.ts +8 -40
- package/lib/common/operations/create-operation-handler.d.ts.map +1 -1
- package/lib/common/operations/create-operation-handler.js +26 -85
- package/lib/common/operations/create-operation-handler.js.map +1 -1
- package/lib/common/operations/operation-action-handler.d.ts +10 -1
- package/lib/common/operations/operation-action-handler.d.ts.map +1 -1
- package/lib/common/operations/operation-action-handler.js +37 -22
- package/lib/common/operations/operation-action-handler.js.map +1 -1
- package/lib/common/operations/operation-handler-registry.d.ts +11 -2
- package/lib/common/operations/operation-handler-registry.d.ts.map +1 -1
- package/lib/common/operations/operation-handler-registry.js +31 -2
- package/lib/common/operations/operation-handler-registry.js.map +1 -1
- package/lib/common/operations/operation-handler.d.ts +28 -11
- package/lib/common/operations/operation-handler.d.ts.map +1 -1
- package/lib/common/operations/operation-handler.js +50 -1
- package/lib/common/operations/operation-handler.js.map +1 -1
- package/lib/common/test/mock-util.d.ts +7 -0
- package/lib/common/test/mock-util.d.ts.map +1 -1
- package/lib/common/test/mock-util.js +20 -37
- package/lib/common/test/mock-util.js.map +1 -1
- package/package.json +4 -3
- package/src/common/command/command-stack.spec.ts +239 -0
- package/src/common/command/command-stack.ts +99 -14
- package/src/common/command/command.spec.ts +93 -0
- package/src/common/command/command.ts +89 -4
- package/src/common/command/recording-command.spec.ts +74 -0
- package/src/common/command/recording-command.ts +119 -0
- package/src/common/command/undo-redo-action-handler.ts +57 -0
- package/src/common/di/diagram-module.ts +13 -0
- package/src/common/features/contextactions/tool-palette-item-provider.ts +2 -4
- package/src/common/{gmodel → features/layout}/computed-bounds-action-handler.ts +9 -4
- package/src/common/features/layout/layout-operation-handler.ts +26 -11
- package/src/common/features/model/model-state.ts +0 -3
- package/src/common/features/model/model-submission-handler.ts +6 -2
- package/src/common/features/model/save-model-action-handler.ts +5 -6
- package/src/common/gmodel/apply-label-edit-operation-handler.ts +13 -15
- package/src/common/gmodel/change-bounds-operation-handler.ts +12 -8
- package/src/common/gmodel/change-routing-points-operation-handler.ts +8 -7
- package/src/common/{operations → gmodel}/cut-operation-handler.ts +9 -8
- package/src/common/gmodel/delete-operation-handler.ts +16 -10
- package/src/common/gmodel/gmodel-create-edge-operation-handler.ts +16 -10
- package/src/common/gmodel/gmodel-create-node-operation-handler.ts +54 -6
- package/src/common/gmodel/gmodel-diagram-module.ts +22 -27
- package/src/common/gmodel/gmodel-operation-handler.ts +31 -0
- package/src/common/gmodel/index.ts +2 -1
- package/src/common/gmodel/paste-operation-handler.ts +19 -11
- package/src/common/gmodel/reconnect-edge-operation-handler.ts +8 -7
- package/src/common/index.ts +2 -1
- package/src/common/operations/compound-operation-handler.ts +14 -12
- package/src/common/operations/create-operation-handler.ts +17 -74
- package/src/common/operations/operation-action-handler.ts +51 -27
- package/src/common/operations/operation-handler-registry.ts +18 -3
- package/src/common/operations/operation-handler.ts +38 -13
- package/src/common/test/mock-util.ts +21 -36
- package/lib/common/gmodel/apply-label-edit-operation-handler.spec.d.ts +0 -2
- package/lib/common/gmodel/apply-label-edit-operation-handler.spec.d.ts.map +0 -1
- package/lib/common/gmodel/apply-label-edit-operation-handler.spec.js +0 -38
- package/lib/common/gmodel/apply-label-edit-operation-handler.spec.js.map +0 -1
- package/lib/common/gmodel/computed-bounds-action-handler.d.ts.map +0 -1
- package/lib/common/gmodel/computed-bounds-action-handler.js.map +0 -1
- package/lib/common/operations/cut-operation-handler.d.ts.map +0 -1
- package/lib/common/operations/cut-operation-handler.js.map +0 -1
- package/src/common/gmodel/apply-label-edit-operation-handler.spec.ts +0 -40
|
@@ -1,90 +1,31 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
3
|
+
exports.CreateOperationHandler = void 0;
|
|
4
|
+
/********************************************************************************
|
|
5
|
+
* Copyright (c) 2022-2023 STMicroelectronics and others.
|
|
6
|
+
*
|
|
7
|
+
* This program and the accompanying materials are made available under the
|
|
8
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
9
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
10
|
+
*
|
|
11
|
+
* This Source Code may also be made available under the following Secondary
|
|
12
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
13
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
14
|
+
* with the GNU Classpath Exception which is available at
|
|
15
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
16
|
+
*
|
|
17
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
18
|
+
********************************************************************************/
|
|
13
19
|
const protocol_1 = require("@eclipse-glsp/protocol");
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Returns a list of {@link TriggerElementCreationAction}s for registered element types.
|
|
24
|
-
*
|
|
25
|
-
* @returns A list of {@link TriggerElementCreationAction}s.
|
|
26
|
-
*/
|
|
27
|
-
getTriggerActions() {
|
|
28
|
-
if (this.operationType === protocol_1.CreateNodeOperation.KIND) {
|
|
29
|
-
return this.elementTypeIds.map(typeId => protocol_1.TriggerNodeCreationAction.create(typeId));
|
|
30
|
-
}
|
|
31
|
-
else if (this.operationType === protocol_1.CreateEdgeOperation.KIND) {
|
|
32
|
-
return this.elementTypeIds.map(typeId => protocol_1.TriggerEdgeCreationAction.create(typeId));
|
|
33
|
-
}
|
|
34
|
-
return [];
|
|
20
|
+
const operation_handler_1 = require("./operation-handler");
|
|
21
|
+
var CreateOperationHandler;
|
|
22
|
+
(function (CreateOperationHandler) {
|
|
23
|
+
function is(object) {
|
|
24
|
+
return (object instanceof operation_handler_1.OperationHandler &&
|
|
25
|
+
(0, protocol_1.hasStringProp)(object, 'label') &&
|
|
26
|
+
(0, protocol_1.hasArrayProp)(object, 'elementTypeIds') &&
|
|
27
|
+
(0, protocol_1.hasFunctionProp)(object, 'getTriggerActions'));
|
|
35
28
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
CreateOperationHandler = __decorate([
|
|
41
|
-
(0, inversify_1.injectable)()
|
|
42
|
-
], CreateOperationHandler);
|
|
43
|
-
exports.CreateOperationHandler = CreateOperationHandler;
|
|
44
|
-
/**
|
|
45
|
-
* Abstract base implementation for {@link CreateOperationHandler} that
|
|
46
|
-
* create an element that is represented with a {@link GNode} in the graphical model.
|
|
47
|
-
*/
|
|
48
|
-
let CreateNodeOperationHandler = class CreateNodeOperationHandler extends CreateOperationHandler {
|
|
49
|
-
get operationType() {
|
|
50
|
-
return protocol_1.CreateNodeOperation.KIND;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Retrieve the graphical model element that should contain the newly created {@link GNode}.
|
|
54
|
-
* If `undefined` is returned the {@link GNode} should be added directly to the diagram root.
|
|
55
|
-
* @param operation The currently handled operation.
|
|
56
|
-
* @returns The container {@link GModeElement} or `undefined`.
|
|
57
|
-
*/
|
|
58
|
-
getContainer(operation) {
|
|
59
|
-
const index = this.modelState.index;
|
|
60
|
-
return operation.containerId ? index.get(operation.containerId) : undefined;
|
|
61
|
-
}
|
|
62
|
-
getLocation(operation) {
|
|
63
|
-
return operation.location;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Retrieves the diagram absolute location and the target container from the given {@link CreateNodeOperation}
|
|
67
|
-
* and converts the absolute location to coordinates relative to the given container.
|
|
68
|
-
* Relative coordinates can only be retrieved if the given container element is part of
|
|
69
|
-
* a hierarchy of {@link GBoundsAware} elements. This means each (recursive) parent element need to
|
|
70
|
-
* implement {@link GBoundsAware}. If that is not the case this method returns `undefined`.
|
|
71
|
-
* @param absoluteLocation The diagram absolute position.
|
|
72
|
-
* @param container The container element.
|
|
73
|
-
* @returns The relative position or `undefined`.
|
|
74
|
-
*/
|
|
75
|
-
getRelativeLocation(operation) {
|
|
76
|
-
var _a, _b;
|
|
77
|
-
const container = (_a = this.getContainer(operation)) !== null && _a !== void 0 ? _a : this.modelState.root;
|
|
78
|
-
const absoluteLocation = (_b = this.getLocation(operation)) !== null && _b !== void 0 ? _b : protocol_1.Point.ORIGIN;
|
|
79
|
-
return (0, layout_util_1.getRelativeLocation)(absoluteLocation, container);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
__decorate([
|
|
83
|
-
(0, inversify_1.inject)(model_state_1.ModelState),
|
|
84
|
-
__metadata("design:type", Object)
|
|
85
|
-
], CreateNodeOperationHandler.prototype, "modelState", void 0);
|
|
86
|
-
CreateNodeOperationHandler = __decorate([
|
|
87
|
-
(0, inversify_1.injectable)()
|
|
88
|
-
], CreateNodeOperationHandler);
|
|
89
|
-
exports.CreateNodeOperationHandler = CreateNodeOperationHandler;
|
|
29
|
+
CreateOperationHandler.is = is;
|
|
30
|
+
})(CreateOperationHandler = exports.CreateOperationHandler || (exports.CreateOperationHandler = {}));
|
|
90
31
|
//# sourceMappingURL=create-operation-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-operation-handler.js","sourceRoot":"","sources":["../../../src/common/operations/create-operation-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-operation-handler.js","sourceRoot":"","sources":["../../../src/common/operations/create-operation-handler.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,qDAQgC;AAChC,2DAAuD;AAevD,IAAiB,sBAAsB,CAStC;AATD,WAAiB,sBAAsB;IACnC,SAAgB,EAAE,CAAC,MAAe;QAC9B,OAAO,CACH,MAAM,YAAY,oCAAgB;YAClC,IAAA,wBAAa,EAAC,MAAM,EAAE,OAAO,CAAC;YAC9B,IAAA,uBAAY,EAAC,MAAM,EAAE,gBAAgB,CAAC;YACtC,IAAA,0BAAe,EAAC,MAAM,EAAE,mBAAmB,CAAC,CAC/C,CAAC;IACN,CAAC;IAPe,yBAAE,KAOjB,CAAA;AACL,CAAC,EATgB,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAStC"}
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import { Action, MaybePromise, Operation } from '@eclipse-glsp/protocol';
|
|
17
17
|
import { ActionHandler } from '../actions/action-handler';
|
|
18
|
+
import { Command } from '../command/command';
|
|
19
|
+
import { CommandStack } from '../command/command-stack';
|
|
18
20
|
import { ModelState } from '../features/model/model-state';
|
|
19
21
|
import { ModelSubmissionHandler } from '../features/model/model-submission-handler';
|
|
20
22
|
import { OperationHandler } from './operation-handler';
|
|
@@ -24,10 +26,17 @@ export declare class OperationActionHandler implements ActionHandler {
|
|
|
24
26
|
protected operationHandlerRegistry: OperationHandlerRegistry;
|
|
25
27
|
protected modelSubmissionHandler: ModelSubmissionHandler;
|
|
26
28
|
protected modelState: ModelState;
|
|
29
|
+
protected commandStack: CommandStack;
|
|
27
30
|
constructor(actionKinds: string[]);
|
|
28
31
|
execute(action: Operation): MaybePromise<Action[]>;
|
|
29
|
-
|
|
32
|
+
protected executeOperation(operation: Operation): MaybePromise<Action[]>;
|
|
33
|
+
protected executeHandler(operation: Operation, handler: OperationHandler): Promise<Action[]>;
|
|
34
|
+
protected executeCommand(command: Command): void;
|
|
35
|
+
protected submitModel(): MaybePromise<Action[]>;
|
|
30
36
|
handles(action: Action): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* @Deprecated Use {@link OperationHandlerRegistry#getOperationHandler(Operation) instead}.
|
|
39
|
+
*/
|
|
31
40
|
static getOperationHandler(operation: Operation, registry: OperationHandlerRegistry): OperationHandler | undefined;
|
|
32
41
|
}
|
|
33
42
|
//# sourceMappingURL=operation-action-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-action-handler.d.ts","sourceRoot":"","sources":["../../../src/common/operations/operation-action-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"operation-action-handler.d.ts","sourceRoot":"","sources":["../../../src/common/operations/operation-action-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAuB,MAAM,wBAAwB,CAAC;AAE9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57 @@ exports.OperationActionHandler = void 0;
|
|
|
31
31
|
********************************************************************************/
|
|
32
32
|
const protocol_1 = require("@eclipse-glsp/protocol");
|
|
33
33
|
const inversify_1 = require("inversify");
|
|
34
|
+
const command_stack_1 = require("../command/command-stack");
|
|
34
35
|
const service_identifiers_1 = require("../di/service-identifiers");
|
|
35
36
|
const model_state_1 = require("../features/model/model-state");
|
|
36
37
|
const model_submission_handler_1 = require("../features/model/model-submission-handler");
|
|
38
|
+
const glsp_server_error_1 = require("../utils/glsp-server-error");
|
|
37
39
|
const operation_handler_registry_1 = require("./operation-handler-registry");
|
|
38
40
|
let OperationActionHandler = OperationActionHandler_1 = class OperationActionHandler {
|
|
39
41
|
constructor(actionKinds) {
|
|
40
42
|
this.actionKinds = actionKinds;
|
|
41
43
|
}
|
|
42
44
|
execute(action) {
|
|
43
|
-
if (this.handles(action)) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
if (!this.handles(action)) {
|
|
46
|
+
throw new glsp_server_error_1.GLSPServerError(`Unhandled operation kind: ${action.kind}`);
|
|
47
|
+
}
|
|
48
|
+
if (this.modelState.isReadonly) {
|
|
49
|
+
return [
|
|
50
|
+
protocol_1.ServerMessageAction.create(`Server is in readonly-mode! Could not execute operation: ${action.kind}`, {
|
|
51
|
+
severity: 'WARNING'
|
|
52
|
+
})
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
return this.executeOperation(action);
|
|
56
|
+
}
|
|
57
|
+
executeOperation(operation) {
|
|
58
|
+
const operationHandler = OperationActionHandler_1.getOperationHandler(operation, this.operationHandlerRegistry);
|
|
59
|
+
if (operationHandler) {
|
|
60
|
+
return this.executeHandler(operation, operationHandler);
|
|
55
61
|
}
|
|
56
62
|
return [];
|
|
57
63
|
}
|
|
58
64
|
async executeHandler(operation, handler) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
const command = await handler.execute(operation);
|
|
66
|
+
if (command) {
|
|
67
|
+
this.executeCommand(command);
|
|
68
|
+
}
|
|
69
|
+
return this.modelSubmissionHandler.submitModel('operation');
|
|
70
|
+
}
|
|
71
|
+
executeCommand(command) {
|
|
72
|
+
this.commandStack.execute(command);
|
|
73
|
+
}
|
|
74
|
+
submitModel() {
|
|
64
75
|
return this.modelSubmissionHandler.submitModel('operation');
|
|
65
76
|
}
|
|
66
77
|
handles(action) {
|
|
67
|
-
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
return false;
|
|
78
|
+
return this.actionKinds.includes(action.kind);
|
|
71
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* @Deprecated Use {@link OperationHandlerRegistry#getOperationHandler(Operation) instead}.
|
|
82
|
+
*/
|
|
72
83
|
static getOperationHandler(operation, registry) {
|
|
73
|
-
return
|
|
84
|
+
return registry.getOperationHandler(operation);
|
|
74
85
|
}
|
|
75
86
|
};
|
|
76
87
|
__decorate([
|
|
@@ -85,6 +96,10 @@ __decorate([
|
|
|
85
96
|
(0, inversify_1.inject)(model_state_1.ModelState),
|
|
86
97
|
__metadata("design:type", Object)
|
|
87
98
|
], OperationActionHandler.prototype, "modelState", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
(0, inversify_1.inject)(command_stack_1.CommandStack),
|
|
101
|
+
__metadata("design:type", Object)
|
|
102
|
+
], OperationActionHandler.prototype, "commandStack", void 0);
|
|
88
103
|
OperationActionHandler = OperationActionHandler_1 = __decorate([
|
|
89
104
|
(0, inversify_1.injectable)(),
|
|
90
105
|
__param(0, (0, inversify_1.inject)(service_identifiers_1.Operations)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-action-handler.js","sourceRoot":"","sources":["../../../src/common/operations/operation-action-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,
|
|
1
|
+
{"version":3,"file":"operation-action-handler.js","sourceRoot":"","sources":["../../../src/common/operations/operation-action-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,qDAA8F;AAC9F,yCAA+C;AAG/C,4DAAwD;AACxD,mEAAuD;AACvD,+DAA2D;AAC3D,yFAAoF;AACpF,kEAA6D;AAE7D,6EAAwE;AAGjE,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IAa/B,YAAyC,WAAqB;QAArB,gBAAW,GAAX,WAAW,CAAU;IAAG,CAAC;IAElE,OAAO,CAAC,MAAiB;QACrB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACvB,MAAM,IAAI,mCAAe,CAAC,6BAA6B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;SACzE;QACD,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE;YAC5B,OAAO;gBACH,8BAAmB,CAAC,MAAM,CAAC,4DAA4D,MAAM,CAAC,IAAI,EAAE,EAAE;oBAClG,QAAQ,EAAE,SAAS;iBACtB,CAAC;aACL,CAAC;SACL;QACD,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAES,gBAAgB,CAAC,SAAoB;QAC3C,MAAM,gBAAgB,GAAG,wBAAsB,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,wBAAwB,CAAC,CAAC;QAC9G,IAAI,gBAAgB,EAAE;YAClB,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;SAC3D;QACD,OAAO,EAAE,CAAC;IACd,CAAC;IAES,KAAK,CAAC,cAAc,CAAC,SAAoB,EAAE,OAAyB;QAC1E,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACjD,IAAI,OAAO,EAAE;YACT,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;SAChC;QACD,OAAO,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAChE,CAAC;IAES,cAAc,CAAC,OAAgB;QACrC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAES,WAAW;QACjB,OAAO,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,CAAC,MAAc;QAClB,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IAEH,MAAM,CAAC,mBAAmB,CAAC,SAAoB,EAAE,QAAkC;QAC/E,OAAO,QAAQ,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC;CACJ,CAAA;AA/DG;IAAC,IAAA,kBAAM,EAAC,qDAAwB,CAAC;8BACG,qDAAwB;wEAAC;AAE7D;IAAC,IAAA,kBAAM,EAAC,iDAAsB,CAAC;8BACG,iDAAsB;sEAAC;AAEzD;IAAC,IAAA,kBAAM,EAAC,wBAAU,CAAC;;0DACc;AAEjC;IAAC,IAAA,kBAAM,EAAC,4BAAY,CAAC;;4DACgB;AAX5B,sBAAsB;IADlC,IAAA,sBAAU,GAAE;IAcI,WAAA,IAAA,kBAAM,EAAC,gCAAU,CAAC,CAAA;;GAbtB,sBAAsB,CAgElC;AAhEY,wDAAsB"}
|
|
@@ -13,17 +13,26 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { Args } from '@eclipse-glsp/protocol';
|
|
16
|
+
import { Args, MaybePromise, Operation } from '@eclipse-glsp/protocol';
|
|
17
|
+
import { Command } from '../command/command';
|
|
17
18
|
import { ClientSessionInitializer } from '../session/client-session-initializer';
|
|
18
19
|
import { Registry } from '../utils/registry';
|
|
19
20
|
import { OperationHandler, OperationHandlerConstructor, OperationHandlerFactory } from './operation-handler';
|
|
20
21
|
export declare class OperationHandlerRegistry extends Registry<string, OperationHandler> {
|
|
21
22
|
registerHandler(handler: OperationHandler): boolean;
|
|
23
|
+
getOperationHandler(operation: Operation): OperationHandler | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Returns the matching command for the given operation.
|
|
26
|
+
*
|
|
27
|
+
* @param operation operation
|
|
28
|
+
* @return the matching command for the given operation
|
|
29
|
+
*/
|
|
30
|
+
getExecutableCommand(operation: Operation): MaybePromise<Command | undefined>;
|
|
22
31
|
}
|
|
23
32
|
export declare class OperationHandlerRegistryInitializer implements ClientSessionInitializer {
|
|
24
33
|
protected factory: OperationHandlerFactory;
|
|
25
34
|
protected handlerConstructors: OperationHandlerConstructor[];
|
|
26
35
|
protected registry: OperationHandlerRegistry;
|
|
27
|
-
initialize(
|
|
36
|
+
initialize(_args?: Args): void;
|
|
28
37
|
}
|
|
29
38
|
//# sourceMappingURL=operation-handler-registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-handler-registry.d.ts","sourceRoot":"","sources":["../../../src/common/operations/operation-handler-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"operation-handler-registry.d.ts","sourceRoot":"","sources":["../../../src/common/operations/operation-handler-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,IAAI,EAAmB,YAAY,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExF,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE7G,qBACa,wBAAyB,SAAQ,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAC5E,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO;IASnD,mBAAmB,CAAC,SAAS,EAAE,SAAS,GAAG,gBAAgB,GAAG,SAAS;IAIvE;;;;;OAKG;IACH,oBAAoB,CAAC,SAAS,EAAE,SAAS,GAAG,YAAY,CAAC,OAAO,GAAG,SAAS,CAAC;CAGhF;AAED,qBACa,mCAAoC,YAAW,wBAAwB;IAEhF,SAAS,CAAC,OAAO,EAAE,uBAAuB,CAAC;IAI3C,SAAS,CAAC,mBAAmB,EAAE,2BAA2B,EAAE,CAAM;IAGlE,SAAS,CAAC,QAAQ,EAAE,wBAAwB,CAAC;IAE7C,UAAU,CAAC,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI;CAIjC"}
|
|
@@ -10,13 +10,29 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.OperationHandlerRegistryInitializer = exports.OperationHandlerRegistry = void 0;
|
|
13
|
+
/********************************************************************************
|
|
14
|
+
* Copyright (c) 2022-2023 STMicroelectronics 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 protocol_1 = require("@eclipse-glsp/protocol");
|
|
13
29
|
const inversify_1 = require("inversify");
|
|
14
30
|
const registry_1 = require("../utils/registry");
|
|
15
31
|
const create_operation_handler_1 = require("./create-operation-handler");
|
|
16
32
|
const operation_handler_1 = require("./operation-handler");
|
|
17
33
|
let OperationHandlerRegistry = class OperationHandlerRegistry extends registry_1.Registry {
|
|
18
34
|
registerHandler(handler) {
|
|
19
|
-
if (
|
|
35
|
+
if (create_operation_handler_1.CreateOperationHandler.is(handler)) {
|
|
20
36
|
handler.elementTypeIds.forEach(typeId => this.register(`${handler.operationType}_${typeId}`, handler));
|
|
21
37
|
return true;
|
|
22
38
|
}
|
|
@@ -24,6 +40,19 @@ let OperationHandlerRegistry = class OperationHandlerRegistry extends registry_1
|
|
|
24
40
|
return this.register(handler.operationType, handler);
|
|
25
41
|
}
|
|
26
42
|
}
|
|
43
|
+
getOperationHandler(operation) {
|
|
44
|
+
return protocol_1.CreateOperation.is(operation) ? this.get(`${operation.kind}_${operation.elementTypeId}`) : this.get(operation.kind);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns the matching command for the given operation.
|
|
48
|
+
*
|
|
49
|
+
* @param operation operation
|
|
50
|
+
* @return the matching command for the given operation
|
|
51
|
+
*/
|
|
52
|
+
getExecutableCommand(operation) {
|
|
53
|
+
var _a;
|
|
54
|
+
return (_a = this.getOperationHandler(operation)) === null || _a === void 0 ? void 0 : _a.createCommand(operation);
|
|
55
|
+
}
|
|
27
56
|
};
|
|
28
57
|
OperationHandlerRegistry = __decorate([
|
|
29
58
|
(0, inversify_1.injectable)()
|
|
@@ -33,7 +62,7 @@ let OperationHandlerRegistryInitializer = class OperationHandlerRegistryInitiali
|
|
|
33
62
|
constructor() {
|
|
34
63
|
this.handlerConstructors = [];
|
|
35
64
|
}
|
|
36
|
-
initialize(
|
|
65
|
+
initialize(_args) {
|
|
37
66
|
const handlers = this.handlerConstructors.map(constructor => this.factory(constructor));
|
|
38
67
|
handlers.forEach(handler => this.registry.registerHandler(handler));
|
|
39
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-handler-registry.js","sourceRoot":"","sources":["../../../src/common/operations/operation-handler-registry.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"operation-handler-registry.js","sourceRoot":"","sources":["../../../src/common/operations/operation-handler-registry.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,qDAAwF;AACxF,yCAAyD;AAGzD,gDAA6C;AAC7C,yEAAoE;AACpE,2DAA6G;AAGtG,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,mBAAkC;IAC5E,eAAe,CAAC,OAAyB;QACrC,IAAI,iDAAsB,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE;YACpC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,aAAa,IAAI,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;YACvG,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;SACxD;IACL,CAAC;IAED,mBAAmB,CAAC,SAAoB;QACpC,OAAO,0BAAe,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/H,CAAC;IAED;;;;;OAKG;IACH,oBAAoB,CAAC,SAAoB;;QACrC,OAAO,MAAA,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,0CAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACzE,CAAC;CACJ,CAAA;AAvBY,wBAAwB;IADpC,IAAA,sBAAU,GAAE;GACA,wBAAwB,CAuBpC;AAvBY,4DAAwB;AA0B9B,IAAM,mCAAmC,GAAzC,MAAM,mCAAmC;IAAzC;QAMO,wBAAmB,GAAkC,EAAE,CAAC;IAStE,CAAC;IAJG,UAAU,CAAC,KAAY;QACnB,MAAM,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;QACxF,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;IACxE,CAAC;CACJ,CAAA;AAdG;IAAC,IAAA,kBAAM,EAAC,2CAAuB,CAAC;;oEACW;AAE3C;IAAC,IAAA,kBAAM,EAAC,+CAA2B,CAAC;IACnC,IAAA,oBAAQ,GAAE;;gFACuD;AAElE;IAAC,IAAA,kBAAM,EAAC,wBAAwB,CAAC;8BACb,wBAAwB;qEAAC;AATpC,mCAAmC;IAD/C,IAAA,sBAAU,GAAE;GACA,mCAAmC,CAe/C;AAfY,kFAAmC"}
|
|
@@ -15,33 +15,50 @@
|
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import { MaybePromise, Operation } from '@eclipse-glsp/protocol';
|
|
17
17
|
import { interfaces } from 'inversify';
|
|
18
|
-
|
|
18
|
+
import { Command } from '../command/command';
|
|
19
|
+
import { ModelState } from '../features/model/model-state';
|
|
19
20
|
/**
|
|
20
21
|
* An operation handler can execute {@link Operation}s of a certain type (subclass).
|
|
21
22
|
* The operation handler processes the operation in the {@link OperationHandler.execute()} method. The result
|
|
22
|
-
* of the execution is
|
|
23
|
-
* This
|
|
24
|
-
* applied directly on the `ModelState` using EMF `Command`s and the
|
|
25
|
-
* `ModelState.execute()` method. For more complex diagram languages the
|
|
26
|
-
* GModel state might be updated indirectly and the operation handler manipulates a custom model representation.
|
|
23
|
+
* of the execution is a {@link Command} that captures the corresponding source model changes.
|
|
24
|
+
* This command can be applied on the `CommandStack` and is reversible (undo) and can be reapplied (redo).
|
|
27
25
|
*
|
|
28
26
|
* The `OperationActionHandler` is responsible for retrieving all available (valid) operation handlers for an
|
|
29
27
|
* operation that is dispatched via `ActionDispatcher`.
|
|
30
28
|
*/
|
|
31
|
-
export
|
|
29
|
+
export declare abstract class OperationHandler {
|
|
30
|
+
protected modelState: ModelState;
|
|
32
31
|
/**
|
|
33
32
|
* Returns the operation type that can be handled by this operation handler.
|
|
34
33
|
*
|
|
35
34
|
* @returns the operation type that can be handled.
|
|
36
35
|
*/
|
|
37
|
-
|
|
36
|
+
abstract operationType: string;
|
|
38
37
|
readonly label?: string;
|
|
39
38
|
/**
|
|
40
|
-
*
|
|
39
|
+
* Creates a command that performs the operation in the source model(s). If `undefined` is returned, no update
|
|
40
|
+
* is performed on the model(s).
|
|
41
41
|
*
|
|
42
|
-
* @param operation The operation
|
|
42
|
+
* @param operation The operation to process.
|
|
43
|
+
* @return The created command to be executed on the command stack or `undefined` nothing should be done.
|
|
43
44
|
*/
|
|
44
|
-
|
|
45
|
+
abstract createCommand(operation: Operation): MaybePromise<Command | undefined>;
|
|
46
|
+
/**
|
|
47
|
+
* Executes the operation handler for the given {@link Operation} and returns the corresponding {@link Command}.
|
|
48
|
+
* If the given operation cannot be handled by this handler or the handler execution did not result in any changes
|
|
49
|
+
* `undefined` is returned.
|
|
50
|
+
*
|
|
51
|
+
* @param operation The operation that should be executed or empty if nothing should be done.
|
|
52
|
+
* @returns The command capturing the execution changes or `undefined`
|
|
53
|
+
*/
|
|
54
|
+
execute(operation: Operation): MaybePromise<Command | undefined>;
|
|
55
|
+
/**
|
|
56
|
+
* Validates whether the given {@link Operation} can be handled by this operation handler.
|
|
57
|
+
*
|
|
58
|
+
* @param operation The operation that should be validated.
|
|
59
|
+
* @returns `true` if the given operation can be handled, `false` otherwise.
|
|
60
|
+
*/
|
|
61
|
+
handles(operation: Operation): boolean;
|
|
45
62
|
}
|
|
46
63
|
export declare const OperationHandlerConstructor: unique symbol;
|
|
47
64
|
export type OperationHandlerConstructor = interfaces.Newable<OperationHandler>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-handler.d.ts","sourceRoot":"","sources":["../../../src/common/operations/operation-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,
|
|
1
|
+
{"version":3,"file":"operation-handler.d.ts","sourceRoot":"","sources":["../../../src/common/operations/operation-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAsB,UAAU,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D;;;;;;;;GAQG;AACH,8BACsB,gBAAgB;IAElC,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC;IAEjC;;;;OAIG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAExB;;;;;;OAMG;IACH,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,YAAY,CAAC,OAAO,GAAG,SAAS,CAAC;IAE/E;;;;;;;OAOG;IACH,OAAO,CAAC,SAAS,EAAE,SAAS,GAAG,YAAY,CAAC,OAAO,GAAG,SAAS,CAAC;IAIhE;;;;;OAKG;IACH,OAAO,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO;CAGzC;AAED,eAAO,MAAM,2BAA2B,eAAwC,CAAC;AAEjF,MAAM,MAAM,2BAA2B,GAAG,UAAU,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAE/E,eAAO,MAAM,uBAAuB,eAAoC,CAAC;AAEzE,MAAM,MAAM,uBAAuB,GAAG,CAAC,WAAW,EAAE,2BAA2B,KAAK,gBAAgB,CAAC"}
|
|
@@ -1,7 +1,56 @@
|
|
|
1
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
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.OperationHandlerFactory = exports.OperationHandlerConstructor = exports.OperationHandler = void 0;
|
|
4
|
-
|
|
13
|
+
const inversify_1 = require("inversify");
|
|
14
|
+
const model_state_1 = require("../features/model/model-state");
|
|
15
|
+
/**
|
|
16
|
+
* An operation handler can execute {@link Operation}s of a certain type (subclass).
|
|
17
|
+
* The operation handler processes the operation in the {@link OperationHandler.execute()} method. The result
|
|
18
|
+
* of the execution is a {@link Command} that captures the corresponding source model changes.
|
|
19
|
+
* This command can be applied on the `CommandStack` and is reversible (undo) and can be reapplied (redo).
|
|
20
|
+
*
|
|
21
|
+
* The `OperationActionHandler` is responsible for retrieving all available (valid) operation handlers for an
|
|
22
|
+
* operation that is dispatched via `ActionDispatcher`.
|
|
23
|
+
*/
|
|
24
|
+
let OperationHandler = class OperationHandler {
|
|
25
|
+
/**
|
|
26
|
+
* Executes the operation handler for the given {@link Operation} and returns the corresponding {@link Command}.
|
|
27
|
+
* If the given operation cannot be handled by this handler or the handler execution did not result in any changes
|
|
28
|
+
* `undefined` is returned.
|
|
29
|
+
*
|
|
30
|
+
* @param operation The operation that should be executed or empty if nothing should be done.
|
|
31
|
+
* @returns The command capturing the execution changes or `undefined`
|
|
32
|
+
*/
|
|
33
|
+
execute(operation) {
|
|
34
|
+
return this.handles(operation) ? this.createCommand(operation) : undefined;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Validates whether the given {@link Operation} can be handled by this operation handler.
|
|
38
|
+
*
|
|
39
|
+
* @param operation The operation that should be validated.
|
|
40
|
+
* @returns `true` if the given operation can be handled, `false` otherwise.
|
|
41
|
+
*/
|
|
42
|
+
handles(operation) {
|
|
43
|
+
return this.modelState.root && operation.kind === this.operationType;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, inversify_1.inject)(model_state_1.ModelState),
|
|
48
|
+
__metadata("design:type", Object)
|
|
49
|
+
], OperationHandler.prototype, "modelState", void 0);
|
|
50
|
+
OperationHandler = __decorate([
|
|
51
|
+
(0, inversify_1.injectable)()
|
|
52
|
+
], OperationHandler);
|
|
53
|
+
exports.OperationHandler = OperationHandler;
|
|
5
54
|
exports.OperationHandlerConstructor = Symbol('OperationHandlerConstructor');
|
|
6
55
|
exports.OperationHandlerFactory = Symbol('OperationHandlerFactory');
|
|
7
56
|
//# sourceMappingURL=operation-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-handler.js","sourceRoot":"","sources":["../../../src/common/operations/operation-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"operation-handler.js","sourceRoot":"","sources":["../../../src/common/operations/operation-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAgBA,yCAA2D;AAE3D,+DAA2D;AAE3D;;;;;;;;GAQG;AAEI,IAAe,gBAAgB,GAA/B,MAAe,gBAAgB;IAsBlC;;;;;;;OAOG;IACH,OAAO,CAAC,SAAoB;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,SAAoB;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI,KAAK,IAAI,CAAC,aAAa,CAAC;IACzE,CAAC;CACJ,CAAA;AA1CG;IAAC,IAAA,kBAAM,EAAC,wBAAU,CAAC;;oDACc;AAFf,gBAAgB;IADrC,IAAA,sBAAU,GAAE;GACS,gBAAgB,CA2CrC;AA3CqB,4CAAgB;AA6CzB,QAAA,2BAA2B,GAAG,MAAM,CAAC,6BAA6B,CAAC,CAAC;AAIpE,QAAA,uBAAuB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC"}
|
|
@@ -19,6 +19,7 @@ import { Container } from 'inversify';
|
|
|
19
19
|
import { MessageConnection } from 'vscode-jsonrpc';
|
|
20
20
|
import { ActionDispatcher } from '../actions/action-dispatcher';
|
|
21
21
|
import { ActionHandler, ActionHandlerFactory } from '../actions/action-handler';
|
|
22
|
+
import { Command } from '../command/command';
|
|
22
23
|
import { DiagramConfiguration, ServerLayoutKind } from '../diagram/diagram-configuration';
|
|
23
24
|
import { ContextEditValidator } from '../features/directediting/context-edit-validator';
|
|
24
25
|
import { LabelEditValidator } from '../features/directediting/label-edit-validator';
|
|
@@ -107,4 +108,10 @@ export declare const stubActionHandlerFactory: ActionHandlerFactory;
|
|
|
107
108
|
export declare class StubClientSessionInitializer implements ClientSessionInitializer {
|
|
108
109
|
initialize(args?: Args): void;
|
|
109
110
|
}
|
|
111
|
+
export declare class StubCommand implements Command {
|
|
112
|
+
execute(): void;
|
|
113
|
+
undo(): void;
|
|
114
|
+
redo(): void;
|
|
115
|
+
canUndo?(): boolean;
|
|
116
|
+
}
|
|
110
117
|
//# sourceMappingURL=mock-util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-util.d.ts","sourceRoot":"","sources":["../../../src/common/test/mock-util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;
|
|
1
|
+
{"version":3,"file":"mock-util.d.ts","sourceRoot":"","sources":["../../../src/common/test/mock-util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAIlF,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,wBAAwB,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EACH,MAAM,EACN,aAAa,EACb,IAAI,EACJ,mBAAmB,EACnB,YAAY,EACZ,iCAAiC,EACjC,UAAU,EACV,KAAK,EACL,2BAA2B,EAC3B,aAAa,EACb,gBAAgB,EACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,EAAE,gCAAgC,EAAE,gCAAgC,EAAE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