@eclipse-glsp-examples/workflow-server 0.9.0-next.5ce3b9a.1
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/LICENSE +277 -0
- package/lib/app.d.ts +2 -0
- package/lib/app.d.ts.map +1 -0
- package/lib/app.js +34 -0
- package/lib/app.js.map +1 -0
- package/lib/graph-extension.d.ts +60 -0
- package/lib/graph-extension.d.ts.map +1 -0
- package/lib/graph-extension.js +156 -0
- package/lib/graph-extension.js.map +1 -0
- package/lib/handler/create-activity-node-handler.d.ts +23 -0
- package/lib/handler/create-activity-node-handler.d.ts.map +1 -0
- package/lib/handler/create-activity-node-handler.js +45 -0
- package/lib/handler/create-activity-node-handler.js.map +1 -0
- package/lib/handler/create-automated-task-handler.d.ts +9 -0
- package/lib/handler/create-automated-task-handler.d.ts.map +1 -0
- package/lib/handler/create-automated-task-handler.js +42 -0
- package/lib/handler/create-automated-task-handler.js.map +1 -0
- package/lib/handler/create-category-handler.d.ts +25 -0
- package/lib/handler/create-category-handler.d.ts.map +1 -0
- package/lib/handler/create-category-handler.js +41 -0
- package/lib/handler/create-category-handler.js.map +1 -0
- package/lib/handler/create-decision-node-handler.d.ts +9 -0
- package/lib/handler/create-decision-node-handler.d.ts.map +1 -0
- package/lib/handler/create-decision-node-handler.js +42 -0
- package/lib/handler/create-decision-node-handler.js.map +1 -0
- package/lib/handler/create-edge-handler.d.ts +22 -0
- package/lib/handler/create-edge-handler.d.ts.map +1 -0
- package/lib/handler/create-edge-handler.js +31 -0
- package/lib/handler/create-edge-handler.js.map +1 -0
- package/lib/handler/create-fork-node-handler.d.ts +6 -0
- package/lib/handler/create-fork-node-handler.d.ts.map +1 -0
- package/lib/handler/create-fork-node-handler.js +39 -0
- package/lib/handler/create-fork-node-handler.js.map +1 -0
- package/lib/handler/create-fork-or-join-node-handler.d.ts +22 -0
- package/lib/handler/create-fork-or-join-node-handler.d.ts.map +1 -0
- package/lib/handler/create-fork-or-join-node-handler.js +21 -0
- package/lib/handler/create-fork-or-join-node-handler.js.map +1 -0
- package/lib/handler/create-join-node-handler.d.ts +6 -0
- package/lib/handler/create-join-node-handler.d.ts.map +1 -0
- package/lib/handler/create-join-node-handler.js +39 -0
- package/lib/handler/create-join-node-handler.js.map +1 -0
- package/lib/handler/create-manual-task-handler.d.ts +9 -0
- package/lib/handler/create-manual-task-handler.d.ts.map +1 -0
- package/lib/handler/create-manual-task-handler.js +42 -0
- package/lib/handler/create-manual-task-handler.js.map +1 -0
- package/lib/handler/create-merge-node-handler.d.ts +9 -0
- package/lib/handler/create-merge-node-handler.d.ts.map +1 -0
- package/lib/handler/create-merge-node-handler.js +42 -0
- package/lib/handler/create-merge-node-handler.js.map +1 -0
- package/lib/handler/create-task-handler.d.ts +24 -0
- package/lib/handler/create-task-handler.d.ts.map +1 -0
- package/lib/handler/create-task-handler.js +48 -0
- package/lib/handler/create-task-handler.js.map +1 -0
- package/lib/handler/create-weighted-edge-handler.d.ts +22 -0
- package/lib/handler/create-weighted-edge-handler.d.ts.map +1 -0
- package/lib/handler/create-weighted-edge-handler.js +33 -0
- package/lib/handler/create-weighted-edge-handler.js.map +1 -0
- package/lib/handler/create-workflow-node-operation-handler.d.ts +24 -0
- package/lib/handler/create-workflow-node-operation-handler.d.ts.map +1 -0
- package/lib/handler/create-workflow-node-operation-handler.js +62 -0
- package/lib/handler/create-workflow-node-operation-handler.js.map +1 -0
- package/lib/handler/grid-snapper.d.ts +22 -0
- package/lib/handler/grid-snapper.d.ts.map +1 -0
- package/lib/handler/grid-snapper.js +20 -0
- package/lib/handler/grid-snapper.js.map +1 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +21 -0
- package/lib/index.js.map +1 -0
- package/lib/labeledit/workflow-label-edit-validator.d.ts +21 -0
- package/lib/labeledit/workflow-label-edit-validator.d.ts.map +1 -0
- package/lib/labeledit/workflow-label-edit-validator.js +55 -0
- package/lib/labeledit/workflow-label-edit-validator.js.map +1 -0
- package/lib/marker/workflow-model-validator.d.ts +29 -0
- package/lib/marker/workflow-model-validator.d.ts.map +1 -0
- package/lib/marker/workflow-model-validator.js +150 -0
- package/lib/marker/workflow-model-validator.js.map +1 -0
- package/lib/model/workflow-navigation-target-resolver.d.ts +24 -0
- package/lib/model/workflow-navigation-target-resolver.d.ts.map +1 -0
- package/lib/model/workflow-navigation-target-resolver.js +40 -0
- package/lib/model/workflow-navigation-target-resolver.js.map +1 -0
- package/lib/provider/abstract-next-or-previous-navigation-target-provider.d.ts +29 -0
- package/lib/provider/abstract-next-or-previous-navigation-target-provider.d.ts.map +1 -0
- package/lib/provider/abstract-next-or-previous-navigation-target-provider.js +60 -0
- package/lib/provider/abstract-next-or-previous-navigation-target-provider.js.map +1 -0
- package/lib/provider/next-node-navigation-target-provider.d.ts +24 -0
- package/lib/provider/next-node-navigation-target-provider.d.ts.map +1 -0
- package/lib/provider/next-node-navigation-target-provider.js +28 -0
- package/lib/provider/next-node-navigation-target-provider.js.map +1 -0
- package/lib/provider/node-documentation-navigation-target-provider.d.ts +24 -0
- package/lib/provider/node-documentation-navigation-target-provider.d.ts.map +1 -0
- package/lib/provider/node-documentation-navigation-target-provider.js +50 -0
- package/lib/provider/node-documentation-navigation-target-provider.js.map +1 -0
- package/lib/provider/previous-node-navigation-target-provider.d.ts +24 -0
- package/lib/provider/previous-node-navigation-target-provider.d.ts.map +1 -0
- package/lib/provider/previous-node-navigation-target-provider.js +28 -0
- package/lib/provider/previous-node-navigation-target-provider.js.map +1 -0
- package/lib/provider/workflow-command-palette-action-provider.d.ts +25 -0
- package/lib/provider/workflow-command-palette-action-provider.d.ts.map +1 -0
- package/lib/provider/workflow-command-palette-action-provider.js +92 -0
- package/lib/provider/workflow-command-palette-action-provider.js.map +1 -0
- package/lib/provider/workflow-context-menu-item-provider.d.ts +21 -0
- package/lib/provider/workflow-context-menu-item-provider.d.ts.map +1 -0
- package/lib/provider/workflow-context-menu-item-provider.js +54 -0
- package/lib/provider/workflow-context-menu-item-provider.js.map +1 -0
- package/lib/util/model-types.d.ts +35 -0
- package/lib/util/model-types.d.ts.map +1 -0
- package/lib/util/model-types.js +60 -0
- package/lib/util/model-types.js.map +1 -0
- package/lib/workflow-diagram-configuration.d.ts +28 -0
- package/lib/workflow-diagram-configuration.d.ts.map +1 -0
- package/lib/workflow-diagram-configuration.js +125 -0
- package/lib/workflow-diagram-configuration.js.map +1 -0
- package/lib/workflow-diagram-module.d.ts +28 -0
- package/lib/workflow-diagram-module.d.ts.map +1 -0
- package/lib/workflow-diagram-module.js +100 -0
- package/lib/workflow-diagram-module.js.map +1 -0
- package/lib/workflow-glsp-server.d.ts +23 -0
- package/lib/workflow-glsp-server.d.ts.map +1 -0
- package/lib/workflow-glsp-server.js +54 -0
- package/lib/workflow-glsp-server.js.map +1 -0
- package/lib/workflow-model-index.d.ts +20 -0
- package/lib/workflow-model-index.d.ts.map +1 -0
- package/lib/workflow-model-index.js +43 -0
- package/lib/workflow-model-index.js.map +1 -0
- package/lib/workflow-popup-factory.d.ts +21 -0
- package/lib/workflow-popup-factory.d.ts.map +1 -0
- package/lib/workflow-popup-factory.js +54 -0
- package/lib/workflow-popup-factory.js.map +1 -0
- package/package.json +63 -0
- package/src/app.ts +32 -0
- package/src/graph-extension.ts +186 -0
- package/src/handler/create-activity-node-handler.ts +34 -0
- package/src/handler/create-automated-task-handler.ts +30 -0
- package/src/handler/create-category-handler.ts +36 -0
- package/src/handler/create-decision-node-handler.ts +30 -0
- package/src/handler/create-edge-handler.ts +25 -0
- package/src/handler/create-fork-node-handler.ts +24 -0
- package/src/handler/create-fork-or-join-node-handler.ts +26 -0
- package/src/handler/create-join-node-handler.ts +24 -0
- package/src/handler/create-manual-task-handler.ts +30 -0
- package/src/handler/create-merge-node-handler.ts +30 -0
- package/src/handler/create-task-handler.ts +38 -0
- package/src/handler/create-weighted-edge-handler.ts +27 -0
- package/src/handler/create-workflow-node-operation-handler.ts +56 -0
- package/src/handler/grid-snapper.ts +32 -0
- package/src/index.ts +19 -0
- package/src/labeledit/workflow-label-edit-validator.ts +39 -0
- package/src/marker/workflow-model-validator.ts +137 -0
- package/src/model/workflow-navigation-target-resolver.ts +40 -0
- package/src/provider/abstract-next-or-previous-navigation-target-provider.ts +53 -0
- package/src/provider/next-node-navigation-target-provider.ts +31 -0
- package/src/provider/node-documentation-navigation-target-provider.ts +52 -0
- package/src/provider/previous-node-navigation-target-provider.ts +31 -0
- package/src/provider/workflow-command-palette-action-provider.ts +124 -0
- package/src/provider/workflow-context-menu-item-provider.ts +38 -0
- package/src/util/model-types.ts +55 -0
- package/src/workflow-diagram-configuration.ts +122 -0
- package/src/workflow-diagram-module.ts +107 -0
- package/src/workflow-glsp-server.ts +37 -0
- package/src/workflow-model-index.ts +31 -0
- package/src/workflow-popup-factory.ts +46 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022 STMicroelectronics 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
|
+
CreateNodeOperation,
|
|
18
|
+
CreateNodeOperationHandler,
|
|
19
|
+
GCompartment,
|
|
20
|
+
GModelElement,
|
|
21
|
+
GModelState,
|
|
22
|
+
Point
|
|
23
|
+
} from '@eclipse-glsp/server-node';
|
|
24
|
+
import { injectable, inject } from 'inversify';
|
|
25
|
+
import { Category } from '../graph-extension';
|
|
26
|
+
import { ModelTypes } from '../util/model-types';
|
|
27
|
+
import { GridSnapper } from './grid-snapper';
|
|
28
|
+
|
|
29
|
+
@injectable()
|
|
30
|
+
export abstract class CreateWorkflowNodeOperationHandler extends CreateNodeOperationHandler {
|
|
31
|
+
@inject(GModelState)
|
|
32
|
+
protected modelState: GModelState;
|
|
33
|
+
|
|
34
|
+
getLocation(operation: CreateNodeOperation): Point | undefined {
|
|
35
|
+
return GridSnapper.snap(operation.location);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getContainer(operation: CreateNodeOperation): GModelElement | undefined {
|
|
39
|
+
const container = super.getContainer(operation);
|
|
40
|
+
|
|
41
|
+
if (container instanceof Category) {
|
|
42
|
+
const structComp = this.getCategoryCompartment(container);
|
|
43
|
+
if (structComp) {
|
|
44
|
+
return structComp;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return container;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getCategoryCompartment(category: Category): GCompartment | undefined {
|
|
51
|
+
return category.children
|
|
52
|
+
.filter(child => child instanceof GCompartment)
|
|
53
|
+
.map(child => child as GCompartment)
|
|
54
|
+
.find(comp => ModelTypes.STRUCTURE === comp.type);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022 STMicroelectronics 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 { Point } from '@eclipse-glsp/server-node';
|
|
17
|
+
|
|
18
|
+
export class GridSnapper {
|
|
19
|
+
public static GRID_X = 10.0;
|
|
20
|
+
public static GRID_Y = 10.0;
|
|
21
|
+
|
|
22
|
+
public static snap(originalPoint: Point | undefined): Point | undefined {
|
|
23
|
+
if (originalPoint) {
|
|
24
|
+
return {
|
|
25
|
+
x: Math.round(originalPoint.x / this.GRID_X) * this.GRID_X,
|
|
26
|
+
y: Math.round(originalPoint.y / this.GRID_Y) * this.GRID_Y
|
|
27
|
+
};
|
|
28
|
+
} else {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022 STMicroelectronics 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 'reflect-metadata';
|
|
17
|
+
import { launch } from './app';
|
|
18
|
+
|
|
19
|
+
launch();
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022 STMicroelectronics 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 { GModelElement, GModelState, LabelEditValidator, ValidationStatus } from '@eclipse-glsp/server-node';
|
|
17
|
+
import { inject, injectable } from 'inversify';
|
|
18
|
+
import { TaskNode } from '../graph-extension';
|
|
19
|
+
|
|
20
|
+
@injectable()
|
|
21
|
+
export class WorkflowLabelEditValidator implements LabelEditValidator {
|
|
22
|
+
@inject(GModelState)
|
|
23
|
+
protected modelState: GModelState;
|
|
24
|
+
|
|
25
|
+
validate(label: string, element: GModelElement): ValidationStatus {
|
|
26
|
+
if (label.length < 1) {
|
|
27
|
+
return { severity: ValidationStatus.Severity.ERROR, message: 'Name must not be empty' };
|
|
28
|
+
}
|
|
29
|
+
const taskNodes = this.modelState.index.getAllByClass<TaskNode>(TaskNode);
|
|
30
|
+
const hasDuplicate = taskNodes
|
|
31
|
+
.filter(e => !(e.id === element.id))
|
|
32
|
+
.map(task => task.name)
|
|
33
|
+
.some(name => name === label);
|
|
34
|
+
if (hasDuplicate) {
|
|
35
|
+
return { severity: ValidationStatus.Severity.WARNING, message: 'Name should be unique' };
|
|
36
|
+
}
|
|
37
|
+
return { severity: ValidationStatus.Severity.OK };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022 STMicroelectronics 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 { GModelElement, Marker, ModelValidator, GModelState, MarkerKind, GCompartment, GLabel } from '@eclipse-glsp/server-node';
|
|
17
|
+
import { inject, injectable } from 'inversify';
|
|
18
|
+
import { ActivityNode, TaskNode } from '../graph-extension';
|
|
19
|
+
|
|
20
|
+
@injectable()
|
|
21
|
+
export class WorkflowModelValidator implements ModelValidator {
|
|
22
|
+
@inject(GModelState)
|
|
23
|
+
protected readonly modelState: GModelState;
|
|
24
|
+
|
|
25
|
+
validate(elements: GModelElement[]): Marker[] {
|
|
26
|
+
const markers: Marker[] = [];
|
|
27
|
+
for (const element of elements) {
|
|
28
|
+
if (element instanceof TaskNode) {
|
|
29
|
+
markers.push(...this.validateTaskNode(element));
|
|
30
|
+
} else if (element instanceof ActivityNode) {
|
|
31
|
+
if (element.nodeType === 'decisionNode') {
|
|
32
|
+
markers.push(...this.validateDecisionNode(element));
|
|
33
|
+
} else if (element.nodeType === 'mergeNode') {
|
|
34
|
+
markers.push(...this.validateMergeNode(element));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (element.children) {
|
|
38
|
+
markers.push(...this.validate(element.children));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return markers;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
protected validateTaskNode(taskNode: TaskNode): Marker[] {
|
|
45
|
+
const markers: Marker[] = [];
|
|
46
|
+
const automated = this.validateTaskNode_isAutomated(taskNode);
|
|
47
|
+
if (automated) {
|
|
48
|
+
markers.push(automated);
|
|
49
|
+
}
|
|
50
|
+
const upperCase = this.validateTaskNode_labelStartsUpperCase(taskNode);
|
|
51
|
+
if (upperCase) {
|
|
52
|
+
markers.push(upperCase);
|
|
53
|
+
}
|
|
54
|
+
return markers;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
protected validateTaskNode_isAutomated(taskNode: TaskNode): Marker | undefined {
|
|
58
|
+
if (taskNode.taskType === 'automated') {
|
|
59
|
+
return { kind: MarkerKind.INFO, description: 'This is an automated task', elementId: taskNode.id, label: 'Automated task' };
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
protected validateTaskNode_labelStartsUpperCase(taskNode: TaskNode): Marker | undefined {
|
|
65
|
+
const gCompartment = taskNode.children.find(child => child instanceof GCompartment);
|
|
66
|
+
if (gCompartment) {
|
|
67
|
+
const gLabels = gCompartment.children.filter(child => child instanceof GLabel).map(element => element as GLabel);
|
|
68
|
+
if (gLabels.length > 0 && gLabels[0].text.charAt(0) === gLabels[0].text.charAt(0).toLowerCase()) {
|
|
69
|
+
return {
|
|
70
|
+
kind: MarkerKind.WARNING,
|
|
71
|
+
description: 'Task node names should start with upper case letters',
|
|
72
|
+
elementId: taskNode.id,
|
|
73
|
+
label: 'Task node label in upper case'
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
protected validateDecisionNode(decisionNode: ActivityNode): Marker[] {
|
|
81
|
+
const markers: Marker[] = [];
|
|
82
|
+
const oneIncoming = this.validateDecisionNode_hasOneIncomingEdge(decisionNode);
|
|
83
|
+
if (oneIncoming) {
|
|
84
|
+
markers.push(oneIncoming);
|
|
85
|
+
}
|
|
86
|
+
return markers;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
protected validateDecisionNode_hasOneIncomingEdge(decisionNode: ActivityNode): Marker | undefined {
|
|
90
|
+
const edges = this.modelState.index.getIncomingEdges(decisionNode);
|
|
91
|
+
if (edges.length > 1) {
|
|
92
|
+
return {
|
|
93
|
+
kind: MarkerKind.ERROR,
|
|
94
|
+
description: 'Decision node may only have one incoming edge.',
|
|
95
|
+
elementId: decisionNode.id,
|
|
96
|
+
label: 'Too many incoming edges'
|
|
97
|
+
};
|
|
98
|
+
} else if (edges.length === 0) {
|
|
99
|
+
return {
|
|
100
|
+
kind: MarkerKind.ERROR,
|
|
101
|
+
description: 'Decision node must have one incoming edge.',
|
|
102
|
+
elementId: decisionNode.id,
|
|
103
|
+
label: 'Missing incoming edge'
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
protected validateMergeNode(mergeNode: ActivityNode): Marker[] {
|
|
110
|
+
const markers: Marker[] = [];
|
|
111
|
+
const oneOutgoing = this.validateMergeNode_hasOneOutgoingEdge(mergeNode);
|
|
112
|
+
if (oneOutgoing) {
|
|
113
|
+
markers.push(oneOutgoing);
|
|
114
|
+
}
|
|
115
|
+
return markers;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
protected validateMergeNode_hasOneOutgoingEdge(mergeNode: ActivityNode): Marker | undefined {
|
|
119
|
+
const edges = this.modelState.index.getOutgoingEdges(mergeNode);
|
|
120
|
+
if (edges.length > 1) {
|
|
121
|
+
return {
|
|
122
|
+
kind: MarkerKind.ERROR,
|
|
123
|
+
description: 'Merge node may only have one outgoing edge.',
|
|
124
|
+
elementId: mergeNode.id,
|
|
125
|
+
label: 'Too many outgoing edges'
|
|
126
|
+
};
|
|
127
|
+
} else if (edges.length === 0) {
|
|
128
|
+
return {
|
|
129
|
+
kind: MarkerKind.ERROR,
|
|
130
|
+
description: 'Merge node must have one outgoing edge.',
|
|
131
|
+
elementId: mergeNode.id,
|
|
132
|
+
label: 'Missing outgoing edge'
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022 STMicroelectronics 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 { NavigationTarget } from '@eclipse-glsp/protocol';
|
|
17
|
+
import { GModelState } from '@eclipse-glsp/server-node';
|
|
18
|
+
import { NavigationTargetResolution } from '@eclipse-glsp/server-node/lib/features/navigation/navigation-target-resolution';
|
|
19
|
+
import { NavigationTargetResolver } from '@eclipse-glsp/server-node/lib/features/navigation/navigation-target-resolver';
|
|
20
|
+
import { inject, injectable } from 'inversify';
|
|
21
|
+
import { TaskNode } from '../graph-extension';
|
|
22
|
+
|
|
23
|
+
@injectable()
|
|
24
|
+
export class WorkflowNavigationTargetResolver extends NavigationTargetResolver {
|
|
25
|
+
@inject(GModelState)
|
|
26
|
+
protected readonly modelState: GModelState;
|
|
27
|
+
|
|
28
|
+
async resolve(navigationTarget: NavigationTarget): Promise<NavigationTargetResolution> {
|
|
29
|
+
if (navigationTarget.args && navigationTarget.args['name']) {
|
|
30
|
+
const name = navigationTarget.args['name'];
|
|
31
|
+
const taskNodes = this.modelState.index.getAllByClass<TaskNode>(TaskNode);
|
|
32
|
+
const element = taskNodes.find(node => name === node.name);
|
|
33
|
+
if (element) {
|
|
34
|
+
return new NavigationTargetResolution([element.id]);
|
|
35
|
+
}
|
|
36
|
+
return new NavigationTargetResolution([], this.createArgsWithWarning(`Couldn't find element with name ${name}`));
|
|
37
|
+
}
|
|
38
|
+
return NavigationTargetResolution.EMPTY;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022 STMicroelectronics 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 { Args, EditorContext, NavigationTarget } from '@eclipse-glsp/protocol';
|
|
17
|
+
import { NavigationTargetProvider } from '@eclipse-glsp/server-node/lib/features/navigation/navigation-target-provider';
|
|
18
|
+
import { inject, injectable } from 'inversify';
|
|
19
|
+
import { GEdge, GModelState } from '@eclipse-glsp/server-node';
|
|
20
|
+
import { TaskNode } from '../graph-extension';
|
|
21
|
+
|
|
22
|
+
@injectable()
|
|
23
|
+
export abstract class AbstractNextOrPreviousNavigationTargetProvider implements NavigationTargetProvider {
|
|
24
|
+
abstract targetTypeId: string;
|
|
25
|
+
|
|
26
|
+
@inject(GModelState)
|
|
27
|
+
protected readonly modelState: GModelState;
|
|
28
|
+
|
|
29
|
+
getTargets(editorContext: EditorContext): NavigationTarget[] {
|
|
30
|
+
const sourceUri = this.modelState.sourceUri;
|
|
31
|
+
const edges: GEdge[] = [];
|
|
32
|
+
editorContext.selectedElementIds
|
|
33
|
+
.map(id => this.modelState.index.get(id))
|
|
34
|
+
.filter(e => e instanceof TaskNode)
|
|
35
|
+
.map(e => e as TaskNode)
|
|
36
|
+
.map(taskNode => edges.push(...this.getEdges(taskNode)));
|
|
37
|
+
return edges.map(edge => this.getSourceOrTarget(edge)).map(id => this.createNavigationTarget(sourceUri, id));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
protected createNavigationTarget(sourceURI: string | undefined, id: string): NavigationTarget {
|
|
41
|
+
return { uri: sourceURI ?? '', args: this.createElementIdMap(id) };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
protected createElementIdMap(id: string): Args {
|
|
45
|
+
const map: Args = {};
|
|
46
|
+
map[NavigationTarget.ELEMENT_IDS] = id;
|
|
47
|
+
return map;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
protected abstract getEdges(taskNode: TaskNode): GEdge[];
|
|
51
|
+
|
|
52
|
+
protected abstract getSourceOrTarget(edge: GEdge): string;
|
|
53
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022 STMicroelectronics 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 { GEdge } from '@eclipse-glsp/graph';
|
|
17
|
+
import { TaskNode } from '../graph-extension';
|
|
18
|
+
import { AbstractNextOrPreviousNavigationTargetProvider } from './abstract-next-or-previous-navigation-target-provider';
|
|
19
|
+
import { injectable } from 'inversify';
|
|
20
|
+
|
|
21
|
+
@injectable()
|
|
22
|
+
export class NextNodeNavigationTargetProvider extends AbstractNextOrPreviousNavigationTargetProvider {
|
|
23
|
+
targetTypeId = 'next';
|
|
24
|
+
protected getEdges(taskNode: TaskNode): GEdge[] {
|
|
25
|
+
return this.modelState.index.getOutgoingEdges(taskNode);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
protected getSourceOrTarget(edge: GEdge): string {
|
|
29
|
+
return edge.targetId;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022 STMicroelectronics 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 { Args, EditorContext, NavigationTarget } from '@eclipse-glsp/protocol';
|
|
17
|
+
import { GModelState } from '@eclipse-glsp/server-node';
|
|
18
|
+
import { NavigationTargetProvider } from '@eclipse-glsp/server-node/lib/features/navigation/navigation-target-provider';
|
|
19
|
+
import { inject, injectable } from 'inversify';
|
|
20
|
+
import { TaskNode } from '../graph-extension';
|
|
21
|
+
import { JsonOpenerOptions } from '@eclipse-glsp/server-node/lib/features/navigation/json-opener-options';
|
|
22
|
+
|
|
23
|
+
@injectable()
|
|
24
|
+
export class NodeDocumentationNavigationTargetProvider implements NavigationTargetProvider {
|
|
25
|
+
targetTypeId = 'documentation';
|
|
26
|
+
|
|
27
|
+
@inject(GModelState)
|
|
28
|
+
protected readonly modelState: GModelState;
|
|
29
|
+
|
|
30
|
+
getTargets(editorContext: EditorContext): NavigationTarget[] {
|
|
31
|
+
if (editorContext.selectedElementIds.length === 1) {
|
|
32
|
+
const taskNode = this.modelState.index.findByClass(editorContext.selectedElementIds[0], TaskNode);
|
|
33
|
+
if (!taskNode || !(taskNode.id === 'task0')) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const sourceUri = this.modelState.sourceUri;
|
|
38
|
+
if (!sourceUri) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const docUri = sourceUri.replace('.wf', '.md');
|
|
43
|
+
const args: Args = {};
|
|
44
|
+
args['jsonOpenerOptions'] = new JsonOpenerOptions({
|
|
45
|
+
start: { line: 2, character: 3 },
|
|
46
|
+
end: { line: 2, character: 7 }
|
|
47
|
+
}).toJson();
|
|
48
|
+
return [{ uri: docUri, args: args }];
|
|
49
|
+
}
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022 STMicroelectronics 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 { GEdge } from '@eclipse-glsp/graph';
|
|
17
|
+
import { TaskNode } from '../graph-extension';
|
|
18
|
+
import { AbstractNextOrPreviousNavigationTargetProvider } from './abstract-next-or-previous-navigation-target-provider';
|
|
19
|
+
import { injectable } from 'inversify';
|
|
20
|
+
|
|
21
|
+
@injectable()
|
|
22
|
+
export class PreviousNodeNavigationTargetProvider extends AbstractNextOrPreviousNavigationTargetProvider {
|
|
23
|
+
targetTypeId = 'previous';
|
|
24
|
+
protected getEdges(taskNode: TaskNode): GEdge[] {
|
|
25
|
+
return this.modelState.index.getIncomingEdges(taskNode);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
protected getSourceOrTarget(edge: GEdge): string {
|
|
29
|
+
return edge.sourceId;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022 STMicroelectronics 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
|
+
Args,
|
|
18
|
+
CommandPaletteActionProvider,
|
|
19
|
+
CreateEdgeOperation,
|
|
20
|
+
CreateNodeOperation,
|
|
21
|
+
DefaultTypes,
|
|
22
|
+
DeleteElementOperation,
|
|
23
|
+
GModelElement,
|
|
24
|
+
GModelState,
|
|
25
|
+
GNode,
|
|
26
|
+
LabeledAction,
|
|
27
|
+
ORIGIN_POINT,
|
|
28
|
+
Point
|
|
29
|
+
} from '@eclipse-glsp/server-node';
|
|
30
|
+
import { inject, injectable } from 'inversify';
|
|
31
|
+
import { TaskNode } from '../graph-extension';
|
|
32
|
+
import { ModelTypes } from '../util/model-types';
|
|
33
|
+
|
|
34
|
+
@injectable()
|
|
35
|
+
export class WorkflowCommandPaletteActionProvider extends CommandPaletteActionProvider {
|
|
36
|
+
@inject(GModelState)
|
|
37
|
+
protected modelState: GModelState;
|
|
38
|
+
|
|
39
|
+
getPaletteActions(selectedElementIds: string[], selectedElements: GModelElement[], position: Point, args?: Args): LabeledAction[] {
|
|
40
|
+
const actions: LabeledAction[] = [];
|
|
41
|
+
if (this.modelState.isReadonly) {
|
|
42
|
+
return actions;
|
|
43
|
+
}
|
|
44
|
+
const index = this.modelState.index;
|
|
45
|
+
// Create actions
|
|
46
|
+
actions.push(
|
|
47
|
+
new LabeledAction(
|
|
48
|
+
'Create Automated Task',
|
|
49
|
+
[new CreateNodeOperation(ModelTypes.AUTOMATED_TASK, position ?? ORIGIN_POINT)],
|
|
50
|
+
'fa-plus-square'
|
|
51
|
+
),
|
|
52
|
+
new LabeledAction(
|
|
53
|
+
'Create Manual Task',
|
|
54
|
+
[new CreateNodeOperation(ModelTypes.MANUAL_TASK, position ?? ORIGIN_POINT)],
|
|
55
|
+
'fa-plus-square'
|
|
56
|
+
),
|
|
57
|
+
new LabeledAction(
|
|
58
|
+
'Create Merge Node',
|
|
59
|
+
[new CreateNodeOperation(ModelTypes.MERGE_NODE, position ?? ORIGIN_POINT)],
|
|
60
|
+
'fa-plus-square'
|
|
61
|
+
),
|
|
62
|
+
new LabeledAction(
|
|
63
|
+
'Create Decision Node',
|
|
64
|
+
[new CreateNodeOperation(ModelTypes.DECISION_NODE, position ?? ORIGIN_POINT)],
|
|
65
|
+
'fa-plus-square'
|
|
66
|
+
),
|
|
67
|
+
new LabeledAction('Create Category', [new CreateNodeOperation(ModelTypes.CATEGORY, position ?? ORIGIN_POINT)], 'fa-plus-square')
|
|
68
|
+
);
|
|
69
|
+
// Create edge action between two nodes
|
|
70
|
+
if (selectedElements.length === 1) {
|
|
71
|
+
const element = selectedElements[0];
|
|
72
|
+
if (element instanceof GNode) {
|
|
73
|
+
actions.push(...this.createEdgeActions(element, index.getAllByClass(TaskNode)));
|
|
74
|
+
}
|
|
75
|
+
} else if (selectedElements.length === 2) {
|
|
76
|
+
const source = selectedElements[0];
|
|
77
|
+
const target = selectedElements[1];
|
|
78
|
+
if (source instanceof TaskNode && target instanceof TaskNode) {
|
|
79
|
+
actions.push(
|
|
80
|
+
this.createEdgeAction(`Create Edge from ${this.getLabel(source)} to ${this.getLabel(target)}`, source, target)
|
|
81
|
+
);
|
|
82
|
+
actions.push(
|
|
83
|
+
this.createWeightedEdgeAction(
|
|
84
|
+
`Create Weighted Edge from ${this.getLabel(source)} to ${this.getLabel(target)}`,
|
|
85
|
+
source,
|
|
86
|
+
target
|
|
87
|
+
)
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Delete action
|
|
92
|
+
if (selectedElements.length === 1) {
|
|
93
|
+
actions.push(new LabeledAction('Delete', [new DeleteElementOperation(selectedElementIds)], 'fa-minus-square'));
|
|
94
|
+
} else if (selectedElements.length > 1) {
|
|
95
|
+
actions.push(new LabeledAction('Delete All', [new DeleteElementOperation(selectedElementIds)], 'fa-minus-square'));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return actions;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private createEdgeActions(source: GNode, targets: GNode[]): LabeledAction[] {
|
|
102
|
+
const actions: LabeledAction[] = [];
|
|
103
|
+
targets.forEach(node => actions.push(this.createEdgeAction(`Create Edge to ${this.getLabel(node)}`, source, node)));
|
|
104
|
+
targets.forEach(node =>
|
|
105
|
+
actions.push(this.createWeightedEdgeAction(`Create Weighted Edge to ${this.getLabel(node)}`, source, node))
|
|
106
|
+
);
|
|
107
|
+
return actions;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private createWeightedEdgeAction(label: string, source: GNode, node: GNode): LabeledAction {
|
|
111
|
+
return new LabeledAction(label, [new CreateEdgeOperation(ModelTypes.WEIGHTED_EDGE, source.id, node.id)], 'fa-plus-square');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private createEdgeAction(label: string, source: GNode, node: GNode): LabeledAction {
|
|
115
|
+
return new LabeledAction(label, [new CreateEdgeOperation(DefaultTypes.EDGE, source.id, node.id)], 'fa-plus-square');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private getLabel(node: GNode): string {
|
|
119
|
+
if (node instanceof TaskNode) {
|
|
120
|
+
return node.name;
|
|
121
|
+
}
|
|
122
|
+
return node.id;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022 STMicroelectronics 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 { Args, ContextMenuItemProvider, CreateNodeOperation, GModelState, MenuItem, Point } from '@eclipse-glsp/server-node';
|
|
17
|
+
import { inject, injectable } from 'inversify';
|
|
18
|
+
import { GridSnapper } from '../handler/grid-snapper';
|
|
19
|
+
import { ModelTypes } from '../util/model-types';
|
|
20
|
+
|
|
21
|
+
@injectable()
|
|
22
|
+
export class WorkflowContextMenuItemProvider extends ContextMenuItemProvider {
|
|
23
|
+
@inject(GModelState)
|
|
24
|
+
protected modelState: GModelState;
|
|
25
|
+
|
|
26
|
+
getItems(selectedElementIds: string[], position: Point, args?: Args): MenuItem[] {
|
|
27
|
+
if (this.modelState.isReadonly) {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
const snappedPosition = GridSnapper.snap(position);
|
|
31
|
+
const newAutTask = new MenuItem('newAutoTask', 'Automated Task', [
|
|
32
|
+
new CreateNodeOperation(ModelTypes.AUTOMATED_TASK, snappedPosition)
|
|
33
|
+
]);
|
|
34
|
+
const newManTask = new MenuItem('newManualTask', 'Manual Task', [new CreateNodeOperation(ModelTypes.MANUAL_TASK, snappedPosition)]);
|
|
35
|
+
const newChildMenu = new MenuItem('new', 'New', undefined, [newAutTask, newManTask], 'add', '0_new');
|
|
36
|
+
return [newChildMenu];
|
|
37
|
+
}
|
|
38
|
+
}
|