Skip to content

Commit c78f825

Browse files
committed
GLSP-31: Update workflow example (standalone)
Part-of: eclipse-glsp/glsp#1693 - Redesign standalone example app - Central diagram widget - Proper title bar - Additional toggleable section for keyboard bindings Add/introduce following features - Context menu support - Server-side provided context menus - Navigation/Marker menu entries - Edit task menu entries - Title bar with - Diagram menu similar to Theia integration - Including layout commands - Dirty state marker - Undo/Redo buttons - Theming support - 5 seletable themes - light/dark mode variants - Theme switcher in title bar - Extended urlParameter configuration - grid,readonly,mcp,theme,mode Fixes eclipse-glsp/glsp#31 - Fixes an issue with the GLSP Projection view which did not calculate scrollbars correctly for the diagrams that are off-center (don't start at 0,0) - Fixes an issue with the GLSPWebSocketConnectionHandler which did not properly try to reconnect if it was launched before the server was available - Add comment section to claude.md
1 parent e8e03fe commit c78f825

36 files changed

Lines changed: 3463 additions & 2231 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ examples/workflow-standalone/server
2424

2525
.claude/local.settings.json
2626
.claude/plans
27+
28+
.playwright-cli

CLAUDE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ Eclipse GLSP Client monorepo. Provides the sprotty-based client framework for th
1616
- After completing any code changes, always run the `/verify` skill before reporting completion
1717
- If verification fails, run the `/fix` skill to auto-fix issues, then re-run `/verify`
1818

19+
## Commenting Style
20+
21+
- **TSDoc (`/** ... \*/`) on the public API\*\*: document exported interfaces, types, classes, methods, and notable properties/getters. Describe intent and behavior, not the obvious signature.
22+
- **Cross-reference with `{@link Symbol}`** instead of writing bare type/method names in prose.
23+
- **Document non-trivial methods** with `@param`/`@returns` (and `@throws` where relevant). Skip them for self-explanatory one-liners.
24+
- **Deprecations** use the fixed form `/** @deprecated Use {@link Replacement} instead */`.
25+
- **Inline `//` comments explain _why_, not _what_** — keep them short and lowercase, and reserve them for non-obvious decisions or rationale.
26+
- **Mark known limitations** with `// FIXME:` / `// TODO:`, and justify suppressions with `// eslint-disable-next-line <rule>`.
27+
- Don't restate code in comments; let clear naming carry the _what_.
28+
- Copyright headers are required on every file but are handled by `/verify` + `/fix` — don't add them manually.
29+
1930
## Inter-Package Import Rules
2031

2132
These are enforced by ESLint and are easy to get wrong:

examples/workflow-glsp/src/workflow-diagram-module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import '../css/diagram.css';
5454
import { taskEditorModule } from './direct-task-editing/task-editor-module';
5555
import { BranchingNode, CategoryNode, Icon, SynchronizationNode, TaskNode, WeightedEdge } from './model';
5656
import { WorkflowSnapper } from './workflow-snapper';
57-
import { WorkflowStartup } from './workflow-startup';
57+
import { GridDefaultVisible, WorkflowStartup } from './workflow-startup';
5858
import { IconView, WorkflowEdgeView } from './workflow-views';
5959

6060
export const workflowDiagramModule = new FeatureModule(
@@ -92,6 +92,8 @@ export const workflowDiagramModule = new FeatureModule(
9292
});
9393

9494
bindAsService(context, TYPES.IDiagramStartup, WorkflowStartup);
95+
bind(GridDefaultVisible).toConstantValue(true);
96+
9597
bindOrRebind(context, TYPES.ISnapper).to(WorkflowSnapper);
9698
},
9799
{ featureId: Symbol('workflowDiagram') }

examples/workflow-glsp/src/workflow-startup.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (c) 2024 EclipseSource and others.
2+
* Copyright (c) 2024-2026 EclipseSource and others.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -18,13 +18,22 @@ import { IDiagramStartup, IGridManager } from '@eclipse-glsp/client';
1818
import { MaybePromise, TYPES } from '@eclipse-glsp/sprotty';
1919
import { inject, injectable, optional } from 'inversify';
2020

21+
/**
22+
* Injection symbol for the initial grid visibility applied by the {@link WorkflowStartup}.
23+
* Defaults to `true` (grid shown); rebind to override (e.g. the standalone app derives it from a url
24+
* parameter).
25+
*/
26+
export const GridDefaultVisible = Symbol('GridDefaultVisible');
27+
2128
@injectable()
2229
export class WorkflowStartup implements IDiagramStartup {
2330
rank = -1;
2431

2532
@inject(TYPES.IGridManager) @optional() protected gridManager?: IGridManager;
2633

34+
@inject(GridDefaultVisible) @optional() protected gridDefaultVisible?: boolean;
35+
2736
preRequestModel(): MaybePromise<void> {
28-
this.gridManager?.setGridVisible(true);
37+
this.gridManager?.setGridVisible(this.gridDefaultVisible ?? true);
2938
}
3039
}

examples/workflow-glsp/src/workflow-views.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class WorkflowEdgeView extends PolylineEdgeViewWithGapsOnIntersections {
4141
<path
4242
class-sprotty-edge={true}
4343
class-arrow={true}
44-
d='M 1,0 L 10,-4 L 10,4 Z'
44+
d='M 0,0 L 9,-3.5 L 9,3.5 Z'
4545
transform={`rotate(${toDegrees(angleOfPoint(Point.subtract(p1, p2)))} ${p2.x} ${p2.y}) translate(${p2.x} ${p2.y})`}
4646
/>
4747
);
@@ -77,7 +77,7 @@ export class IconView extends ShapeView {
7777

7878
d={icon}
7979
/>
80-
<rect class-icon-background x={0} y={0} width={25} height={20} />
80+
<rect class-icon-background x={0} y={0} width={25} height={20} rx={4} ry={4} />
8181
{context.renderChildren(element)}
8282
</g>
8383
);

examples/workflow-standalone/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,22 @@ All `start` and `dev` scripts support the following flags:
100100
- `--client-port <port>` – Set the webpack dev server port (default: 8082 in Node mode, 8083 in Browser mode)
101101

102102
The server bundle download can also be skipped by setting the `SKIP_DOWNLOAD=true` environment variable.
103+
104+
## URL Parameters
105+
106+
The running application reads the following query parameters from the diagram URL. They are independent and can be combined, e.g.:
107+
108+
```
109+
http://localhost:8082/diagram.html?grid&theme=ember&mode=dark
110+
```
111+
112+
| Parameter | Values | Default | Description |
113+
| ---------- | ------------------------------------------------ | ------------- | ---------------------------------------------------------------------------------------------- |
114+
| `readonly` | _flag_ (presence only) | editable | Open the diagram in read-only mode (editing disabled). |
115+
| `grid` | _flag_ (presence only) | off | Show the background grid. |
116+
| `theme` | `tide`, `graphite`, `ember`, `orchid`, `verdant` | `tide` | Set the color theme. Persisted in local storage, so it also updates the in-app theme switcher. |
117+
| `mode` | `light`, `dark` | OS preference | Set light or dark appearance. Persisted in local storage. |
118+
| `mcp` | _flag_ (presence only) | off | Enable the MCP server integration (Node mode only). Also available via the `*:mcp` scripts. |
119+
120+
Flag parameters only need to be present (their value is ignored), e.g. `?grid` or `?readonly`.
121+
Invalid `theme`/`mode` values are ignored and fall back to the stored value or, for `mode`, the OS preference.

0 commit comments

Comments
 (0)