@eclipse-glsp-examples/workflow-glsp 0.9.0-next.fd1a8bb6 → 0.10.0-next.5dad48d.159

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.
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (c) 2020 EclipseSource and others.
2
+ * Copyright (c) 2020-2021 EclipseSource and others.
3
3
  *
4
4
  * This program and the accompanying materials are made available under the
5
5
  * terms of the Eclipse Public License v. 2.0 which is available at
@@ -13,20 +13,23 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import download from "mvn-artifact-download";
17
- import { join, resolve } from "path";
16
+ import download from 'mvn-artifact-download';
17
+ import { join, resolve } from 'path';
18
18
 
19
- const downloadDir = resolve(join(__dirname)) + "/../../..";
20
- const mavenRepository = "https://oss.sonatype.org/content/repositories/snapshots/";
21
- const groupId = "org.eclipse.glsp.example";
22
- const artifactId = "org.eclipse.glsp.example.workflow";
23
- const version = "0.9.0";
24
- const classifier = "glsp";
19
+ const downloadDir = resolve(join(__dirname)) + '/../../..';
20
+ const mavenRepository = 'https://oss.sonatype.org/content/repositories/snapshots/';
21
+ const groupId = 'org.eclipse.glsp.example';
22
+ const artifactId = 'org.eclipse.glsp.example.workflow';
23
+ const version = '0.9.0';
24
+ const classifier = 'glsp';
25
25
 
26
- console.log("Downloading latest version of the Workflow Example Java Server from the maven repository...");
27
- download({ groupId, artifactId, version, classifier, isSnapShot: true }, downloadDir, mavenRepository)
28
- .then(() => console.log("Download completed. Start the server using this command: \njava -jar org.eclipse.glsp.example.workflow-"
29
- + version + "-SNAPSHOT-glsp.jar org.eclipse.glsp.example.workflow.launch.ExampleServerLauncher --port=8081 --websocket\n\n"
30
- + "After starting the server, access the following file locally in your browser to see the running example:\n"
31
- + "./examples/workflow-standalone/app/diagram.html"
32
- ));
26
+ console.log('Downloading latest version of the Workflow Example Java Server from the maven repository...');
27
+ download({ groupId, artifactId, version, classifier, isSnapShot: true }, downloadDir, mavenRepository).then(() =>
28
+ console.log(
29
+ 'Download completed. Start the server using this command: \njava -jar org.eclipse.glsp.example.workflow-' +
30
+ version +
31
+ '-SNAPSHOT-glsp.jar org.eclipse.glsp.example.workflow.launch.ExampleServerLauncher --port=8081 --websocket\n\n' +
32
+ 'After starting the server, access the following file locally in your browser to see the running example:\n' +
33
+ './examples/workflow-standalone/app/diagram.html'
34
+ )
35
+ );
package/src/di.config.ts CHANGED
@@ -13,75 +13,40 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import '../css/diagram.css';
17
- import 'balloon-css/balloon.min.css';
18
- import 'sprotty/css/edit-label.css';
19
-
20
16
  import {
21
- boundsModule,
22
- buttonModule,
23
17
  configureDefaultModelElements,
24
18
  configureModelElement,
25
19
  ConsoleLogger,
26
- defaultGLSPModule,
27
- defaultModule,
28
- DefaultTypes,
20
+ createClientContainer,
29
21
  DeleteElementContextMenuItemProvider,
30
22
  DiamondNodeView,
31
- edgeIntersectionModule,
32
- edgeLayoutModule,
33
23
  editLabelFeature,
34
- expandModule,
35
- exportModule,
36
- fadeModule,
37
- GLSP_TYPES,
38
- glspCommandPaletteModule,
39
- glspContextMenuModule,
40
- glspDecorationModule,
41
- glspEditLabelModule,
42
- glspHoverModule,
43
- glspMouseToolModule,
44
- glspSelectModule,
45
- glspServerCopyPasteModule,
46
- glspViewportModule,
47
24
  GridSnapper,
48
- labelEditUiModule,
49
- layoutCommandsModule,
50
25
  LogLevel,
51
- markerNavigatorModule,
52
- modelHintsModule,
53
- modelSourceModule,
54
- modelSourceWatcherModule,
55
- navigationModule,
56
- NoOverlapMovmentRestrictor,
57
- openModule,
58
26
  overrideViewerOptions,
59
- paletteModule,
60
27
  RectangularNodeView,
61
28
  RevealNamedElementActionProvider,
62
29
  RoundedCornerNodeView,
63
- routingModule,
64
30
  SCompartment,
65
31
  SCompartmentView,
66
32
  SEdge,
67
33
  SLabel,
68
34
  SLabelView,
69
- toolFeedbackModule,
70
- toolsModule,
71
- TYPES,
72
- validationModule,
73
- zorderModule
35
+ StructureCompartmentView,
36
+ TYPES
74
37
  } from '@eclipse-glsp/client';
38
+ import { DefaultTypes } from '@eclipse-glsp/protocol';
39
+ import 'balloon-css/balloon.min.css';
75
40
  import { Container, ContainerModule } from 'inversify';
76
-
41
+ import 'sprotty/css/edit-label.css';
42
+ import '../css/diagram.css';
77
43
  import { directTaskEditor } from './direct-task-editing/di.config';
78
- import { ActivityNode, Icon, TaskNode, WeightedEdge } from './model';
44
+ import { ActivityNode, CategoryNode, Icon, TaskNode, WeightedEdge } from './model';
79
45
  import { IconView, WorkflowEdgeView } from './workflow-views';
80
46
 
81
47
  const workflowDiagramModule = new ContainerModule((bind, unbind, isBound, rebind) => {
82
48
  rebind(TYPES.ILogger).to(ConsoleLogger).inSingletonScope();
83
49
  rebind(TYPES.LogLevel).toConstantValue(LogLevel.warn);
84
- bind(GLSP_TYPES.IMovementRestrictor).to(NoOverlapMovmentRestrictor).inSingletonScope();
85
50
  bind(TYPES.ISnapper).to(GridSnapper);
86
51
  bind(TYPES.ICommandPaletteActionProvider).to(RevealNamedElementActionProvider);
87
52
  bind(TYPES.IContextMenuItemProvider).to(DeleteElementContextMenuItemProvider);
@@ -101,52 +66,16 @@ const workflowDiagramModule = new ContainerModule((bind, unbind, isBound, rebind
101
66
  configureModelElement(context, 'activityNode:decision', ActivityNode, DiamondNodeView);
102
67
  configureModelElement(context, 'activityNode:fork', ActivityNode, RectangularNodeView);
103
68
  configureModelElement(context, 'activityNode:join', ActivityNode, RectangularNodeView);
69
+
70
+ configureModelElement(context, 'category', CategoryNode, RoundedCornerNodeView);
71
+ configureModelElement(context, 'struct', SCompartment, StructureCompartmentView);
104
72
  });
105
73
 
106
74
  export default function createContainer(widgetId: string): Container {
107
- const container = new Container();
108
-
109
- container.load(
110
- defaultModule,
111
- defaultGLSPModule,
112
- glspMouseToolModule,
113
- validationModule,
114
- glspSelectModule,
115
- boundsModule,
116
- glspViewportModule,
117
- toolsModule,
118
- glspHoverModule,
119
- fadeModule,
120
- exportModule,
121
- expandModule,
122
- openModule,
123
- buttonModule,
124
- modelSourceModule,
125
- labelEditUiModule,
126
- glspEditLabelModule,
127
- workflowDiagramModule,
128
- toolFeedbackModule,
129
- modelHintsModule,
130
- glspContextMenuModule,
131
- glspServerCopyPasteModule,
132
- modelSourceWatcherModule,
133
- glspCommandPaletteModule,
134
- paletteModule,
135
- routingModule,
136
- glspDecorationModule,
137
- edgeLayoutModule,
138
- zorderModule,
139
- edgeIntersectionModule,
140
- layoutCommandsModule,
141
- directTaskEditor,
142
- navigationModule,
143
- markerNavigatorModule
144
- );
145
-
75
+ const container = createClientContainer(workflowDiagramModule, directTaskEditor);
146
76
  overrideViewerOptions(container, {
147
77
  baseDiv: widgetId,
148
78
  hiddenDiv: widgetId + '_hidden'
149
79
  });
150
-
151
80
  return container;
152
81
  }
package/src/model.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (c) 2020-2021 EclipseSource and others.
2
+ * Copyright (c) 2020-2022 EclipseSource and others.
3
3
  *
4
4
  * This program and the accompanying materials are made available under the
5
5
  * terms of the Eclipse Public License v. 2.0 which is available at
@@ -53,21 +53,22 @@ export class TaskNode extends RectangularNode implements Nameable, WithEditableL
53
53
  nameFeature,
54
54
  withEditLabelFeature
55
55
  ];
56
- name = '';
57
56
  duration?: number;
58
57
  taskType?: string;
59
58
  reference?: string;
60
59
 
61
60
  get editableLabel(): (SChildElement & EditableLabel) | undefined {
62
- const headerComp = this.children.find(element => element.type === 'comp:header');
63
- if (headerComp) {
64
- const label = headerComp.children.find(element => element.type === 'label:heading');
65
- if (label && isEditableLabel(label)) {
66
- return label;
67
- }
61
+ const label = this.children.find(element => element.type === 'label:heading');
62
+ if (label && isEditableLabel(label)) {
63
+ return label;
68
64
  }
69
65
  return undefined;
70
66
  }
67
+
68
+ get name(): string {
69
+ const labelText = this.editableLabel?.text;
70
+ return labelText ? labelText : '<unknown>';
71
+ }
71
72
  }
72
73
 
73
74
  export function isTaskNode(element: SModelElement): element is TaskNode {
@@ -109,3 +110,28 @@ export class Icon extends SShapeElement implements LayoutContainer {
109
110
  height: 32
110
111
  };
111
112
  }
113
+
114
+ export class CategoryNode extends RectangularNode implements Nameable, WithEditableLabel {
115
+ static readonly DEFAULT_FEATURES = [
116
+ deletableFeature,
117
+ selectFeature,
118
+ boundsFeature,
119
+ moveFeature,
120
+ layoutContainerFeature,
121
+ fadeFeature,
122
+ hoverFeedbackFeature,
123
+ popupFeature,
124
+ nameFeature,
125
+ withEditLabelFeature
126
+ ];
127
+
128
+ name = '';
129
+
130
+ get editableLabel(): (SChildElement & EditableLabel) | undefined {
131
+ const label = this.children.find(element => element.type === 'label:heading');
132
+ if (label && isEditableLabel(label)) {
133
+ return label;
134
+ }
135
+ return undefined;
136
+ }
137
+ }
@@ -1,5 +1,5 @@
1
1
  /********************************************************************************
2
- * Copyright (c) 2019-2021 EclipseSource and others.
2
+ * Copyright (c) 2019-2022 EclipseSource and others.
3
3
  *
4
4
  * This program and the accompanying materials are made available under the
5
5
  * terms of the Eclipse Public License v. 2.0 which is available at
@@ -15,18 +15,18 @@
15
15
  ********************************************************************************/
16
16
  import {
17
17
  angleOfPoint,
18
- IView,
18
+ getSubType,
19
19
  Point,
20
20
  PolylineEdgeViewWithGapsOnIntersections,
21
21
  RenderingContext,
22
22
  SEdge,
23
+ setAttr,
23
24
  toDegrees
24
25
  } from '@eclipse-glsp/client';
25
26
  import { injectable } from 'inversify';
26
27
  import { VNode } from 'snabbdom';
27
- import { svg } from 'sprotty';
28
-
29
- import { Icon } from './model';
28
+ import { findParentByFeature, ShapeView, svg } from 'sprotty';
29
+ import { Icon, isTaskNode } from './model';
30
30
 
31
31
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
32
  const JSX = { createElement: svg };
@@ -41,7 +41,7 @@ export class WorkflowEdgeView extends PolylineEdgeViewWithGapsOnIntersections {
41
41
  <path
42
42
  class-sprotty-edge={true}
43
43
  class-arrow={true}
44
- d='M 1.5,0 L 10,-4 L 10,4 Z'
44
+ d='M 1,0 L 10,-4 L 10,4 Z'
45
45
  transform={`rotate(${toDegrees(angleOfPoint({ x: p1.x - p2.x, y: p1.y - p2.y }))} ${p2.x} ${p2.y}) translate(${p2.x} ${
46
46
  p2.y
47
47
  })`}
@@ -53,18 +53,43 @@ export class WorkflowEdgeView extends PolylineEdgeViewWithGapsOnIntersections {
53
53
  }
54
54
 
55
55
  @injectable()
56
- export class IconView implements IView {
57
- render(element: Icon, context: RenderingContext): VNode {
58
- const radius = this.getRadius();
59
- return (
56
+ export class IconView extends ShapeView {
57
+ render(element: Icon, context: RenderingContext): VNode | undefined {
58
+ const taskNode = findParentByFeature(element, isTaskNode);
59
+ if (!taskNode || !this.isVisible(element, context)) {
60
+ return undefined;
61
+ }
62
+
63
+ let icon;
64
+ if (taskNode.type === 'task:manual') {
65
+ // From codicons: https://github.com/microsoft/vscode-codicons/blob/main/src/icons/account.svg?short_path=8135b2d
66
+ icon =
67
+ // eslint-disable-next-line max-len
68
+ 'M16 7.992C16 3.58 12.416 0 8 0S0 3.58 0 7.992c0 2.43 1.104 4.62 2.832 6.09.016.016.032.016.032.032.144.112.288.224.448.336.08.048.144.111.224.175A7.98 7.98 0 0 0 8.016 16a7.98 7.98 0 0 0 4.48-1.375c.08-.048.144-.111.224-.16.144-.111.304-.223.448-.335.016-.016.032-.016.032-.032 1.696-1.487 2.8-3.676 2.8-6.106zm-8 7.001c-1.504 0-2.88-.48-4.016-1.279.016-.128.048-.255.08-.383a4.17 4.17 0 0 1 .416-.991c.176-.304.384-.576.64-.816.24-.24.528-.463.816-.639.304-.176.624-.304.976-.4A4.15 4.15 0 0 1 8 10.342a4.185 4.185 0 0 1 2.928 1.166c.368.368.656.8.864 1.295.112.288.192.592.24.911A7.03 7.03 0 0 1 8 14.993zm-2.448-7.4a2.49 2.49 0 0 1-.208-1.024c0-.351.064-.703.208-1.023.144-.32.336-.607.576-.847.24-.24.528-.431.848-.575.32-.144.672-.208 1.024-.208.368 0 .704.064 1.024.208.32.144.608.336.848.575.24.24.432.528.576.847.144.32.208.672.208 1.023 0 .368-.064.704-.208 1.023a2.84 2.84 0 0 1-.576.848 2.84 2.84 0 0 1-.848.575 2.715 2.715 0 0 1-2.064 0 2.84 2.84 0 0 1-.848-.575 2.526 2.526 0 0 1-.56-.848zm7.424 5.306c0-.032-.016-.048-.016-.08a5.22 5.22 0 0 0-.688-1.406 4.883 4.883 0 0 0-1.088-1.135 5.207 5.207 0 0 0-1.04-.608 2.82 2.82 0 0 0 .464-.383 4.2 4.2 0 0 0 .624-.784 3.624 3.624 0 0 0 .528-1.934 3.71 3.71 0 0 0-.288-1.47 3.799 3.799 0 0 0-.816-1.199 3.845 3.845 0 0 0-1.2-.8 3.72 3.72 0 0 0-1.472-.287 3.72 3.72 0 0 0-1.472.288 3.631 3.631 0 0 0-1.2.815 3.84 3.84 0 0 0-.8 1.199 3.71 3.71 0 0 0-.288 1.47c0 .352.048.688.144 1.007.096.336.224.64.4.927.16.288.384.544.624.784.144.144.304.271.48.383a5.12 5.12 0 0 0-1.04.624c-.416.32-.784.703-1.088 1.119a4.999 4.999 0 0 0-.688 1.406c-.016.032-.016.064-.016.08C1.776 11.636.992 9.91.992 7.992.992 4.14 4.144.991 8 .991s7.008 3.149 7.008 7.001a6.96 6.96 0 0 1-2.032 4.907z';
69
+ } else {
70
+ // From codicons: https://github.com/microsoft/vscode-codicons/blob/main/src/icons/gear.svg?short_path=8ee3ec4
71
+ icon =
72
+ // eslint-disable-next-line max-len
73
+ 'M9.1 4.4L8.6 2H7.4l-.5 2.4-.7.3-2-1.3-.9.8 1.3 2-.2.7-2.4.5v1.2l2.4.5.3.8-1.3 2 .8.8 2-1.3.8.3.4 2.3h1.2l.5-2.4.8-.3 2 1.3.8-.8-1.3-2 .3-.8 2.3-.4V7.4l-2.4-.5-.3-.8 1.3-2-.8-.8-2 1.3-.7-.2zM9.4 1l.5 2.4L12 2.1l2 2-1.4 2.1 2.4.4v2.8l-2.4.5L14 12l-2 2-2.1-1.4-.5 2.4H6.6l-.5-2.4L4 13.9l-2-2 1.4-2.1L1 9.4V6.6l2.4-.5L2.1 4l2-2 2.1 1.4.4-2.4h2.8zm.6 7c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zM8 9c.6 0 1-.4 1-1s-.4-1-1-1-1 .4-1 1 .4 1 1 1z';
74
+ }
75
+
76
+ const vnode = (
60
77
  <g>
61
- <circle class-sprotty-icon={true} r={radius} cx={radius} cy={radius}></circle>
78
+ <path
79
+ transform={'scale(1.15),translate(0.75,0.75)'}
80
+ // From codicons: https://github.com/microsoft/vscode-codicons/blob/main/src/icons/terminal.svg?short_path=2ffc08e
81
+ // eslint-disable-next-line max-len
82
+ d={icon}
83
+ />
84
+ <rect class-icon-background x={0} y={0} width={25} height={20} />
62
85
  {context.renderChildren(element)}
63
86
  </g>
64
87
  );
65
- }
66
88
 
67
- getRadius(): number {
68
- return 16;
89
+ const subType = getSubType(element);
90
+ if (subType) {
91
+ setAttr(vnode, 'class', subType);
92
+ }
93
+ return vnode;
69
94
  }
70
95
  }