@eclipse-glsp-examples/workflow-server 0.9.0-next.397cddd.4
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 +37 -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/layout/workflow-layout-configurator.d.ts +22 -0
- package/lib/layout/workflow-layout-configurator.d.ts.map +1 -0
- package/lib/layout/workflow-layout-configurator.js +38 -0
- package/lib/layout/workflow-layout-configurator.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 +27 -0
- package/lib/workflow-diagram-module.d.ts.map +1 -0
- package/lib/workflow-diagram-module.js +99 -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 +61 -0
- package/src/app.ts +35 -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/layout/workflow-layout-configurator.ts +28 -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,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
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
/* eslint-disable @typescript-eslint/padding-line-between-statements */
|
|
17
|
+
export namespace ModelTypes {
|
|
18
|
+
export const LABEL_HEADING = 'label:heading';
|
|
19
|
+
export const LABEL_TEXT = 'label:text';
|
|
20
|
+
export const COMP_HEADER = 'comp:header';
|
|
21
|
+
export const LABEL_ICON = 'label:icon';
|
|
22
|
+
export const WEIGHTED_EDGE = 'edge:weighted';
|
|
23
|
+
export const ICON = 'icon';
|
|
24
|
+
export const ACTIVITY_NODE = 'activityNode';
|
|
25
|
+
export const DECISION_NODE = `${ACTIVITY_NODE}:decision`;
|
|
26
|
+
export const MERGE_NODE = `${ACTIVITY_NODE}:merge`;
|
|
27
|
+
export const FORK_NODE = `${ACTIVITY_NODE}:fork`;
|
|
28
|
+
export const JOIN_NODE = `${ACTIVITY_NODE}:join`;
|
|
29
|
+
export const TASK = 'task';
|
|
30
|
+
export const MANUAL_TASK = `${TASK}:manual`;
|
|
31
|
+
export const AUTOMATED_TASK = `${TASK}:automated`;
|
|
32
|
+
export const CATEGORY = 'category';
|
|
33
|
+
export const STRUCTURE = 'struct';
|
|
34
|
+
|
|
35
|
+
export function toNodeType(type: string): string {
|
|
36
|
+
switch (type) {
|
|
37
|
+
case DECISION_NODE:
|
|
38
|
+
return 'decisionNode';
|
|
39
|
+
case MERGE_NODE:
|
|
40
|
+
return 'mergeNode';
|
|
41
|
+
case FORK_NODE:
|
|
42
|
+
return 'forkNode';
|
|
43
|
+
case JOIN_NODE:
|
|
44
|
+
return 'joinNode';
|
|
45
|
+
case MANUAL_TASK:
|
|
46
|
+
return 'manual';
|
|
47
|
+
case AUTOMATED_TASK:
|
|
48
|
+
return 'automated';
|
|
49
|
+
case CATEGORY:
|
|
50
|
+
return 'category';
|
|
51
|
+
default:
|
|
52
|
+
return 'unknown';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
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 { DefaultTypes, EdgeTypeHint, ShapeTypeHint } from '@eclipse-glsp/protocol';
|
|
17
|
+
import {
|
|
18
|
+
DiagramConfiguration,
|
|
19
|
+
GCompartment,
|
|
20
|
+
GEdge,
|
|
21
|
+
getDefaultMapping,
|
|
22
|
+
GLabel,
|
|
23
|
+
GModelElementConstructor,
|
|
24
|
+
ServerLayoutKind
|
|
25
|
+
} from '@eclipse-glsp/server-node';
|
|
26
|
+
import { injectable } from 'inversify';
|
|
27
|
+
import { ActivityNode, Category, TaskNode } from './graph-extension';
|
|
28
|
+
import { ModelTypes as types } from './util/model-types';
|
|
29
|
+
|
|
30
|
+
@injectable()
|
|
31
|
+
export class WorkflowDiagramConfiguration implements DiagramConfiguration {
|
|
32
|
+
get typeMapping(): Map<string, GModelElementConstructor> {
|
|
33
|
+
const mapping = getDefaultMapping();
|
|
34
|
+
mapping.set(types.LABEL_HEADING, GLabel);
|
|
35
|
+
mapping.set(types.LABEL_TEXT, GLabel);
|
|
36
|
+
mapping.set(types.COMP_HEADER, GCompartment);
|
|
37
|
+
mapping.set(types.LABEL_ICON, GLabel);
|
|
38
|
+
mapping.set(types.WEIGHTED_EDGE, GEdge);
|
|
39
|
+
mapping.set(types.ICON, GCompartment);
|
|
40
|
+
mapping.set(types.ACTIVITY_NODE, ActivityNode);
|
|
41
|
+
mapping.set(types.TASK, TaskNode);
|
|
42
|
+
mapping.set(types.CATEGORY, Category);
|
|
43
|
+
mapping.set(types.STRUCTURE, GCompartment);
|
|
44
|
+
return mapping;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
get shapeTypeHints(): ShapeTypeHint[] {
|
|
48
|
+
return [
|
|
49
|
+
createDefaultShapeTypeHint(types.MANUAL_TASK),
|
|
50
|
+
createDefaultShapeTypeHint(types.AUTOMATED_TASK),
|
|
51
|
+
createDefaultShapeTypeHint(types.FORK_NODE),
|
|
52
|
+
createDefaultShapeTypeHint(types.JOIN_NODE),
|
|
53
|
+
createDefaultShapeTypeHint(types.DECISION_NODE),
|
|
54
|
+
createDefaultShapeTypeHint(types.MERGE_NODE),
|
|
55
|
+
{
|
|
56
|
+
elementTypeId: types.CATEGORY,
|
|
57
|
+
repositionable: true,
|
|
58
|
+
deletable: true,
|
|
59
|
+
resizable: true,
|
|
60
|
+
reparentable: true,
|
|
61
|
+
containableElementTypeIds: [
|
|
62
|
+
types.DECISION_NODE,
|
|
63
|
+
types.MERGE_NODE,
|
|
64
|
+
types.FORK_NODE,
|
|
65
|
+
types.JOIN_NODE,
|
|
66
|
+
types.AUTOMATED_TASK,
|
|
67
|
+
types.MANUAL_TASK,
|
|
68
|
+
types.CATEGORY
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
get edgeTypeHints(): EdgeTypeHint[] {
|
|
75
|
+
return [
|
|
76
|
+
createDefaultEdgeTypeHint(DefaultTypes.EDGE),
|
|
77
|
+
{
|
|
78
|
+
elementTypeId: types.WEIGHTED_EDGE,
|
|
79
|
+
repositionable: true,
|
|
80
|
+
deletable: true,
|
|
81
|
+
routable: true,
|
|
82
|
+
sourceElementTypeIds: [types.DECISION_NODE],
|
|
83
|
+
targetElementTypeIds: [types.MANUAL_TASK, types.AUTOMATED_TASK, types.FORK_NODE, types.JOIN_NODE]
|
|
84
|
+
}
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
layoutKind = ServerLayoutKind.MANUAL;
|
|
89
|
+
needsClientLayout = true;
|
|
90
|
+
animatedUpdate = true;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function createDefaultShapeTypeHint(elementId: string): ShapeTypeHint {
|
|
94
|
+
return { elementTypeId: elementId, repositionable: true, deletable: true, resizable: true, reparentable: true };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function createDefaultEdgeTypeHint(elementId: string): EdgeTypeHint {
|
|
98
|
+
return {
|
|
99
|
+
elementTypeId: elementId,
|
|
100
|
+
repositionable: true,
|
|
101
|
+
deletable: true,
|
|
102
|
+
routable: true,
|
|
103
|
+
sourceElementTypeIds: [
|
|
104
|
+
types.MANUAL_TASK,
|
|
105
|
+
types.AUTOMATED_TASK,
|
|
106
|
+
types.DECISION_NODE,
|
|
107
|
+
types.MERGE_NODE,
|
|
108
|
+
types.FORK_NODE,
|
|
109
|
+
types.JOIN_NODE,
|
|
110
|
+
types.CATEGORY
|
|
111
|
+
],
|
|
112
|
+
targetElementTypeIds: [
|
|
113
|
+
types.MANUAL_TASK,
|
|
114
|
+
types.AUTOMATED_TASK,
|
|
115
|
+
types.DECISION_NODE,
|
|
116
|
+
types.MERGE_NODE,
|
|
117
|
+
types.FORK_NODE,
|
|
118
|
+
types.JOIN_NODE,
|
|
119
|
+
types.CATEGORY
|
|
120
|
+
]
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
ClassMultiBinding,
|
|
18
|
+
CommandPaletteActionProvider,
|
|
19
|
+
ContextMenuItemProvider,
|
|
20
|
+
DefaultToolPaletteItemProvider,
|
|
21
|
+
DiagramConfiguration,
|
|
22
|
+
GLSPServer,
|
|
23
|
+
GModelDiagramModule,
|
|
24
|
+
GModelIndex,
|
|
25
|
+
InstanceMultiBinding,
|
|
26
|
+
JsonRpcGLSPServer,
|
|
27
|
+
LabelEditValidator,
|
|
28
|
+
ModelValidator,
|
|
29
|
+
NavigationTargetProvider,
|
|
30
|
+
NavigationTargetResolver,
|
|
31
|
+
OperationHandlerConstructor,
|
|
32
|
+
PopupModelFactory,
|
|
33
|
+
ServerModule,
|
|
34
|
+
ToolPaletteItemProvider
|
|
35
|
+
} from '@eclipse-glsp/server-node';
|
|
36
|
+
import { injectable, interfaces } from 'inversify';
|
|
37
|
+
import { CreateAutomatedTaskHandler } from './handler/create-automated-task-handler';
|
|
38
|
+
import { CreateCategoryHandler } from './handler/create-category-handler';
|
|
39
|
+
import { CreateDecisionNodeHandler } from './handler/create-decision-node-handler';
|
|
40
|
+
import { CreateEdgeHandler } from './handler/create-edge-handler';
|
|
41
|
+
import { CreateForkNodeHandler } from './handler/create-fork-node-handler';
|
|
42
|
+
import { CreateJoinNodeHandler } from './handler/create-join-node-handler';
|
|
43
|
+
import { CreateManualTaskHandler } from './handler/create-manual-task-handler';
|
|
44
|
+
import { CreateMergeNodeHandler } from './handler/create-merge-node-handler';
|
|
45
|
+
import { CreateWeightedEdgeHandler } from './handler/create-weighted-edge-handler';
|
|
46
|
+
import { WorkflowLabelEditValidator } from './labeledit/workflow-label-edit-validator';
|
|
47
|
+
import { WorkflowModelValidator } from './marker/workflow-model-validator';
|
|
48
|
+
import { WorkflowNavigationTargetResolver } from './model/workflow-navigation-target-resolver';
|
|
49
|
+
import { NextNodeNavigationTargetProvider } from './provider/next-node-navigation-target-provider';
|
|
50
|
+
import { NodeDocumentationNavigationTargetProvider } from './provider/node-documentation-navigation-target-provider';
|
|
51
|
+
import { PreviousNodeNavigationTargetProvider } from './provider/previous-node-navigation-target-provider';
|
|
52
|
+
import { WorkflowCommandPaletteActionProvider } from './provider/workflow-command-palette-action-provider';
|
|
53
|
+
import { WorkflowContextMenuItemProvider } from './provider/workflow-context-menu-item-provider';
|
|
54
|
+
import { WorkflowDiagramConfiguration } from './workflow-diagram-configuration';
|
|
55
|
+
import { WorkflowGLSPServer } from './workflow-glsp-server';
|
|
56
|
+
import { WorkflowModelIndex } from './workflow-model-index';
|
|
57
|
+
import { WorkflowPopupFactory } from './workflow-popup-factory';
|
|
58
|
+
|
|
59
|
+
@injectable()
|
|
60
|
+
export class WorkflowServerModule extends ServerModule {
|
|
61
|
+
configure(bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind): void {
|
|
62
|
+
super.configure(bind, unbind, isBound, rebind);
|
|
63
|
+
bind(WorkflowGLSPServer).toSelf().inSingletonScope();
|
|
64
|
+
rebind(GLSPServer).toService(WorkflowGLSPServer);
|
|
65
|
+
rebind(JsonRpcGLSPServer).toService(WorkflowGLSPServer);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@injectable()
|
|
70
|
+
export class WorkflowDiagramModule extends GModelDiagramModule {
|
|
71
|
+
get diagramType(): string {
|
|
72
|
+
return 'workflow-diagram';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
protected configure(bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind): void {
|
|
76
|
+
super.configure(bind, unbind, isBound, rebind);
|
|
77
|
+
bind(DiagramConfiguration).to(WorkflowDiagramConfiguration).inSingletonScope();
|
|
78
|
+
bind(NavigationTargetResolver).to(WorkflowNavigationTargetResolver).inSingletonScope();
|
|
79
|
+
bind(ContextMenuItemProvider).to(WorkflowContextMenuItemProvider).inSingletonScope();
|
|
80
|
+
bind(CommandPaletteActionProvider).to(WorkflowCommandPaletteActionProvider).inSingletonScope();
|
|
81
|
+
bind(LabelEditValidator).to(WorkflowLabelEditValidator).inSingletonScope();
|
|
82
|
+
bind(PopupModelFactory).to(WorkflowPopupFactory).inSingletonScope();
|
|
83
|
+
bind(ModelValidator).to(WorkflowModelValidator).inSingletonScope();
|
|
84
|
+
bind(ToolPaletteItemProvider).to(DefaultToolPaletteItemProvider).inSingletonScope();
|
|
85
|
+
rebind(GModelIndex).to(WorkflowModelIndex).inSingletonScope();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
protected configureOperationHandlers(binding: InstanceMultiBinding<OperationHandlerConstructor>): void {
|
|
89
|
+
super.configureOperationHandlers(binding);
|
|
90
|
+
binding.add(CreateAutomatedTaskHandler);
|
|
91
|
+
binding.add(CreateManualTaskHandler);
|
|
92
|
+
binding.add(CreateJoinNodeHandler);
|
|
93
|
+
binding.add(CreateForkNodeHandler);
|
|
94
|
+
binding.add(CreateEdgeHandler);
|
|
95
|
+
binding.add(CreateWeightedEdgeHandler);
|
|
96
|
+
binding.add(CreateMergeNodeHandler);
|
|
97
|
+
binding.add(CreateDecisionNodeHandler);
|
|
98
|
+
binding.add(CreateCategoryHandler);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
protected configureNavigationTargetProviders(binding: ClassMultiBinding<NavigationTargetProvider>): void {
|
|
102
|
+
super.configureNavigationTargetProviders(binding);
|
|
103
|
+
binding.add(NextNodeNavigationTargetProvider);
|
|
104
|
+
binding.add(PreviousNodeNavigationTargetProvider);
|
|
105
|
+
binding.add(NodeDocumentationNavigationTargetProvider);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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, ArgsUtil, DefaultGLSPServer, InitializeResult, Logger, MaybePromise } from '@eclipse-glsp/server-node';
|
|
17
|
+
import { inject, injectable } from 'inversify';
|
|
18
|
+
|
|
19
|
+
@injectable()
|
|
20
|
+
export class WorkflowGLSPServer extends DefaultGLSPServer {
|
|
21
|
+
MESSAGE_KEY = 'message';
|
|
22
|
+
TIMESTAMP_KEY = 'timestamp';
|
|
23
|
+
|
|
24
|
+
@inject(Logger)
|
|
25
|
+
protected logger: Logger;
|
|
26
|
+
|
|
27
|
+
protected handleInitializeArgs(result: InitializeResult, args: Args | undefined): MaybePromise<InitializeResult> {
|
|
28
|
+
if (!args) {
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
const timestamp = ArgsUtil.get(args, this.TIMESTAMP_KEY);
|
|
32
|
+
const message = ArgsUtil.get(args, this.MESSAGE_KEY);
|
|
33
|
+
|
|
34
|
+
this.logger.debug(`${timestamp}: ${message}`);
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -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, GModelIndex } from '@eclipse-glsp/server-node';
|
|
17
|
+
import { injectable } from 'inversify';
|
|
18
|
+
import { ModelTypes } from './util/model-types';
|
|
19
|
+
|
|
20
|
+
@injectable()
|
|
21
|
+
export class WorkflowModelIndex extends GModelIndex {
|
|
22
|
+
getAllEdges(): GEdge[] {
|
|
23
|
+
const edges: GEdge[] = super.getAllEdges();
|
|
24
|
+
this.getElements(ModelTypes.WEIGHTED_EDGE).forEach(weighted => {
|
|
25
|
+
if (weighted instanceof GEdge) {
|
|
26
|
+
edges.push(weighted);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return edges;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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, GModelRoot, GPreRenderedElement, PopupModelFactory, RequestPopupModelAction } from '@eclipse-glsp/server-node';
|
|
17
|
+
import { TaskNode } from './graph-extension';
|
|
18
|
+
import { injectable } from 'inversify';
|
|
19
|
+
|
|
20
|
+
const NL = '<br/>';
|
|
21
|
+
|
|
22
|
+
@injectable()
|
|
23
|
+
export class WorkflowPopupFactory implements PopupModelFactory {
|
|
24
|
+
createPopupModel(element: GModelElement, action: RequestPopupModelAction): GModelRoot | undefined {
|
|
25
|
+
if (element && element instanceof TaskNode) {
|
|
26
|
+
const popupTitle = GPreRenderedElement.builder()
|
|
27
|
+
.id('popup-title')
|
|
28
|
+
.code(`<div class="sprotty-popup-title">${element.name}</div>`)
|
|
29
|
+
.build();
|
|
30
|
+
|
|
31
|
+
const popupBody = GPreRenderedElement.builder()
|
|
32
|
+
.id('popup-body')
|
|
33
|
+
.code(`<div class="sprotty-popup-body">${this.generateBody(element)}</div>`)
|
|
34
|
+
.build();
|
|
35
|
+
|
|
36
|
+
return GModelRoot.builder().type('html').canvasBounds(action.bounds).id('sprotty-popup').add(popupTitle).add(popupBody).build();
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private generateBody(task: TaskNode): string {
|
|
42
|
+
return `Type: ${task.taskType} ${NL}
|
|
43
|
+
Duration: ${task.duration} ${NL}
|
|
44
|
+
Reference: ${task.references} ${NL}`;
|
|
45
|
+
}
|
|
46
|
+
}
|