├── .prettierrc ├── examples ├── workflow-standalone │ ├── server │ │ └── .gitkeep │ ├── src │ │ ├── globals.d.ts │ │ ├── features │ │ │ └── direct-task-editing │ │ │ │ ├── standalone-task-editor-module.ts │ │ │ │ └── task-editor-key-listener.ts │ │ └── url-parameters.ts │ ├── tsconfig.json │ ├── app │ │ └── diagram.html │ ├── package.json │ └── css │ │ └── diagram.css └── workflow-glsp │ ├── tsconfig.json │ ├── src │ ├── index.ts │ ├── direct-task-editing │ │ └── task-editor-module.ts │ ├── workflow-startup.ts │ └── workflow-snapper.ts │ ├── README.md │ └── package.json ├── .nycrc ├── tsconfig.eslint.json ├── .eslintignore ├── .prettierignore ├── .mocharc ├── packages ├── protocol │ ├── tsconfig.json │ ├── src │ │ ├── .indexignore │ │ ├── utils │ │ │ ├── math-util.ts │ │ │ ├── geometry-util.ts │ │ │ └── test-util.ts │ │ ├── di │ │ │ ├── index.ts │ │ │ └── re-decorate.ts │ │ ├── client-server-protocol │ │ │ └── jsonrpc │ │ │ │ └── worker-connection-provider.ts │ │ └── model │ │ │ └── default-types.ts │ ├── README.md │ ├── .eslintrc.js │ └── package.json ├── glsp-sprotty │ ├── tsconfig.json │ ├── .eslintrc.js │ ├── README.md │ ├── src │ │ └── index.ts │ └── package.json └── client │ ├── tsconfig.json │ ├── README.md │ ├── src │ ├── re-exports.ts │ ├── features │ │ ├── grid │ │ │ ├── grid.ts │ │ │ ├── grid-style.ts │ │ │ ├── grid-snapper.spec.ts │ │ │ └── grid-module.ts │ │ ├── accessibility │ │ │ ├── keyboard-pointer │ │ │ │ ├── constants.ts │ │ │ │ └── actions.ts │ │ │ ├── keyboard-grid │ │ │ │ └── constants.ts │ │ │ ├── actions.ts │ │ │ ├── edge-autocomplete │ │ │ │ └── action.ts │ │ │ ├── focus-tracker │ │ │ │ └── focus-tracker-module.ts │ │ │ ├── toast │ │ │ │ └── toast-module.ts │ │ │ ├── view-key-tools │ │ │ │ └── view-key-tools-module.ts │ │ │ ├── accessibility-module.ts │ │ │ └── element-navigation │ │ │ │ └── element-navigation-module.ts │ │ ├── tools │ │ │ ├── marquee-selection │ │ │ │ ├── model.ts │ │ │ │ ├── view.tsx │ │ │ │ └── marquee-selection-module.ts │ │ │ ├── deletion │ │ │ │ └── deletion-tool-module.ts │ │ │ ├── edge-creation │ │ │ │ ├── view.tsx │ │ │ │ └── edege-creation-module.ts │ │ │ ├── node-creation │ │ │ │ ├── insert-indicator.ts │ │ │ │ └── node-creation-module.ts │ │ │ ├── tool-focus-loss-module.ts │ │ │ ├── change-bounds │ │ │ │ └── change-bounds-tool-module.ts │ │ │ └── edge-edit │ │ │ │ └── edge-edit-module.ts │ │ ├── save │ │ │ ├── save-keylistener.ts │ │ │ └── save-module.ts │ │ ├── svg-metadata │ │ │ └── svg-metadata-module.ts │ │ ├── zorder │ │ │ ├── zorder-module.ts │ │ │ └── bring-to-front-command.ts │ │ ├── decoration │ │ │ └── decoration-module.ts │ │ ├── source-model-watcher │ │ │ └── source-model-watcher-module.ts │ │ ├── change-bounds │ │ │ └── snap.ts │ │ ├── label-edit-ui │ │ │ ├── label-edit-ui-module.ts │ │ │ └── label-edit-ui.ts │ │ ├── element-template │ │ │ └── element-template-module.ts │ │ ├── status │ │ │ └── status-module.ts │ │ ├── undo-redo │ │ │ ├── undo-redo-module.ts │ │ │ └── undo-redo-key-listener.ts │ │ ├── hints │ │ │ ├── type-hints-module.ts │ │ │ └── model.ts │ │ ├── label-edit │ │ │ ├── label-edit-module.ts │ │ │ └── edit-label-tool.ts │ │ ├── export │ │ │ └── export-svg-action-handler.ts │ │ ├── search-palette │ │ │ └── search-palette-key-listener.ts │ │ ├── layout │ │ │ ├── layout-module.ts │ │ │ └── trigger-layout-action-handler.ts │ │ ├── tool-palette │ │ │ └── tool-palette-module.ts │ │ ├── debug │ │ │ └── debug-module.ts │ │ ├── command-palette │ │ │ ├── command-palette-module.ts │ │ │ └── command-palette-tool.ts │ │ ├── navigation │ │ │ └── navigation-module.ts │ │ ├── select │ │ │ ├── select-feedback-command.ts │ │ │ └── select-module.ts │ │ ├── viewport │ │ │ ├── zoom-viewport-action.ts │ │ │ └── glsp-scroll-mouse-listener.ts │ │ ├── copy-paste │ │ │ └── copy-paste-modules.ts │ │ ├── context-menu │ │ │ └── context-menu-module.ts │ │ └── bounds │ │ │ └── layout-data.ts │ ├── base │ │ ├── auto-complete │ │ │ └── auto-complete-actions.ts │ │ ├── ui-extension │ │ │ └── ui-extension-registry.ts │ │ ├── view │ │ │ ├── view-registry.ts │ │ │ └── key-tool.ts │ │ ├── focus │ │ │ └── focus-state-change-action.ts │ │ ├── shortcuts │ │ │ └── shortcuts-module.ts │ │ ├── args-feature.ts │ │ ├── feedback │ │ │ ├── feedback-command.ts │ │ │ └── set-model-command.ts │ │ ├── mouse-position-tracker.ts │ │ └── selection-clearing-mouse-listener.ts │ ├── utils │ │ ├── html-utils.ts │ │ └── marker.ts │ └── views │ │ ├── routing-point-handle-view.tsx │ │ └── compartments.tsx │ ├── css │ ├── change-bounds.css │ ├── autocomplete-palette.css │ ├── debug.css │ ├── navigation.css │ ├── helper-lines.css │ ├── ghost-element.css │ ├── decoration.css │ ├── search.css │ ├── toast.css │ ├── grid.css │ ├── keyboard.css │ ├── keyboard-tool-palette.css │ ├── status-overlay.css │ └── command-palette.css │ ├── .eslintrc.js │ └── package.json ├── lerna.json ├── .gitignore ├── .github ├── ISSUE_TEMPLATE │ └── config.yml ├── workflows │ ├── prepare-release.yml │ └── e2e.yml └── PULL_REQUEST_TEMPLATE.md ├── tsconfig.json ├── .vscode ├── extensions.json ├── tasks.json ├── settings.json └── launch.json ├── SECURITY.md ├── .eslintrc.js └── package.json /.prettierrc: -------------------------------------------------------------------------------- 1 | "@eclipse-glsp/prettier-config" 2 | -------------------------------------------------------------------------------- /examples/workflow-standalone/server/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.nycrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@eclipse-glsp/nyc-config" 3 | } 4 | -------------------------------------------------------------------------------- /examples/workflow-standalone/src/globals.d.ts: -------------------------------------------------------------------------------- 1 | declare const GLSP_SERVER_HOST: string; 2 | declare const GLSP_SERVER_PORT: string; 3 | -------------------------------------------------------------------------------- /tsconfig.eslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@eclipse-glsp/ts-config", 3 | "compilerOptions": { 4 | "noEmit": true 5 | }, 6 | "include": ["packages/*/src", "examples/*/src"] 7 | } 8 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | # Compiled output 2 | **/dist/ 3 | **/lib/ 4 | **/node_modules/ 5 | 6 | # Build files 7 | **/.eslintrc.js 8 | **/esbuild.js 9 | 10 | # Other generated files 11 | **/*.map 12 | 13 | **/scripts/ -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | node_modules/ 3 | 4 | # Build outputs 5 | lib/ 6 | dist/ 7 | 8 | # Generated files 9 | *.min.js 10 | *.min.css 11 | 12 | # Lock files 13 | package-lock.json 14 | yarn.lock 15 | 16 | # Logs 17 | *.log -------------------------------------------------------------------------------- /.mocharc: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/mocharc", 3 | "extends": "@eclipse-glsp/mocha-config", 4 | "require": [ 5 | "ts-node/register", 6 | "tsconfig-paths/register", 7 | "reflect-metadata/Reflect", 8 | "ignore-styles" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /packages/protocol/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@eclipse-glsp/ts-config/mocha", 3 | "compilerOptions": { 4 | "composite": true, 5 | "rootDir": "src", 6 | "outDir": "lib", 7 | "reactNamespace": "JSX" 8 | }, 9 | "include": ["src"], 10 | "exclude": ["**/*.spec.ts"] 11 | } 12 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.6.0-next", 3 | "npmClient": "yarn", 4 | "command": { 5 | "run": { 6 | "stream": true 7 | }, 8 | "publish": { 9 | "forcePublish": true, 10 | "skipGit": true, 11 | "registry": "https://registry.npmjs.org/" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .nyc_output/ 3 | coverage 4 | 5 | node_modules/ 6 | lib/ 7 | artifacts/ 8 | 9 | examples/workflow-standalone/app 10 | 11 | *.ttf 12 | *.log 13 | *.jar 14 | 15 | !packages/client/src/lib 16 | tsconfig.tsbuildinfo 17 | eslint.xml 18 | report.xml 19 | **/ctrf 20 | examples/workflow-standalone/server 21 | -------------------------------------------------------------------------------- /packages/glsp-sprotty/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@eclipse-glsp/ts-config", 3 | "compilerOptions": { 4 | "composite": true, 5 | "rootDir": "src", 6 | "outDir": "lib", 7 | "reactNamespace": "JSX" 8 | }, 9 | "include": ["src"], 10 | "references": [ 11 | { 12 | "path": "../protocol" 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /examples/workflow-glsp/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@eclipse-glsp/ts-config", 3 | "compilerOptions": { 4 | "composite": true, 5 | "rootDir": "src", 6 | "outDir": "lib", 7 | "reactNamespace": "JSX", 8 | "skipLibCheck": true, 9 | "resolveJsonModule": true 10 | }, 11 | "include": ["src"], 12 | "references": [ 13 | { 14 | "path": "../../packages/client" 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /packages/client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@eclipse-glsp/ts-config/mocha", 3 | "compilerOptions": { 4 | "composite": true, 5 | "rootDir": "src", 6 | "resolveJsonModule": true, 7 | "outDir": "lib", 8 | "reactNamespace": "JSX" 9 | }, 10 | "include": ["src", "src/**/*.json"], 11 | "exclude": ["**/*.spec.ts"], 12 | "references": [ 13 | { 14 | "path": "../glsp-sprotty" 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /packages/protocol/src/.indexignore: -------------------------------------------------------------------------------- 1 | # do not export test-util in index to avoid a necessary dependency on test frameworks such as chai 2 | # adopters can still use the functionality by importing it through the complete path 3 | utils/test-util.ts 4 | # do not export the DI utilities to avoid a necessary dependency on reflect-metadata/inversify 5 | # This is reexported in @eclipse-glsp/client & @eclipse-glsp/server so that adopters can still use it 6 | di -------------------------------------------------------------------------------- /examples/workflow-standalone/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@eclipse-glsp/ts-config/tsconfig.json", 3 | "compilerOptions": { 4 | "composite": true, 5 | "rootDir": "src", 6 | "resolveJsonModule": true, 7 | "outDir": "lib" 8 | }, 9 | "include": ["src", "lib", "css", "app"], 10 | "references": [ 11 | { 12 | "path": "../../packages/client" 13 | }, 14 | { 15 | "path": "../workflow-glsp" 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Question 4 | url: https://github.com/eclipse-glsp/glsp/discussions 5 | about: Please ask questions on the Eclipse GLSP discussions page. 6 | - name: Create issue in GLSP umbrella project 7 | url: https://github.com/eclipse-glsp/glsp/issues/new/choose 8 | about: Please create new issues in the GLSP umbrella project, as we are tracking the issues for all components of GLSP there. 9 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@eclipse-glsp/ts-config/mocha", 3 | "include": [], 4 | "compilerOptions": { 5 | "composite": true, 6 | "resolveJsonModule": true 7 | }, 8 | "references": [ 9 | { 10 | "path": "./packages/protocol" 11 | }, 12 | { 13 | "path": "./packages/glsp-sprotty" 14 | }, 15 | { 16 | "path": "./packages/client" 17 | }, 18 | { 19 | "path": "./examples/workflow-glsp" 20 | }, 21 | { 22 | "path": "./examples/workflow-standalone" 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /packages/glsp-sprotty/.eslintrc.js: -------------------------------------------------------------------------------- 1 | /** @type {import('eslint').Linter.Config} */ 2 | module.exports = { 3 | extends: '../../.eslintrc.js', 4 | rules: { 5 | 'no-restricted-imports': [ 6 | 'warn', 7 | { 8 | name: 'sprotty-protocol', 9 | message: 'Please use @eclipse-glsp/sprotty instead' 10 | }, 11 | { 12 | name: 'sprotty-protocol/*', 13 | message: "Please use '@eclipse-glsp/protocol' instead" 14 | } 15 | ] 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. 3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp 4 | // List of extensions which should be recommended for users of this workspace. 5 | "recommendations": [ 6 | "dbaeumer.vscode-eslint", 7 | "esbenp.prettier-vscode", 8 | "DavidAnson.vscode-markdownlint" 9 | ], 10 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace. 11 | "unwantedRecommendations": [] 12 | } 13 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Eclipse GLSP Vulnerability Reporting Policy 2 | 3 | If you think or suspect that you have discovered a new security vulnerability in this project, please do not disclose it on GitHub, e.g. in an issue, a PR, or a discussion. Any such disclosure will be removed/deleted on sight, to promote orderly disclosure, as per the Eclipse Foundation Security Policy (1). 4 | 5 | Instead, please report any potential vulnerability to the Eclipse Foundation Security Team. Make sure to provide a concise description of the issue, a CWE, and other supporting information. 6 | 7 | (1) Eclipse Foundation Vulnerability Reporting Policy: 8 | -------------------------------------------------------------------------------- /examples/workflow-standalone/app/diagram.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /packages/client/README.md: -------------------------------------------------------------------------------- 1 | # Eclipse GLSP - Client 2 | 3 | A web-based diagram client framework for the [Graphical Language Server Platform (GLSP)](https://github.com/eclipse-glsp/glsp) based on [Eclipse Sprotty](https://github.com/eclipse/sprotty). 4 | 5 | ## Building 6 | 7 | This project is built with `yarn` and is available from npm via [@eclipse-glsp/client](https://www.npmjs.com/package/@eclipse-glsp/client). 8 | 9 | ## More information 10 | 11 | For more information, please visit the [Eclipse GLSP Umbrella repository](https://github.com/eclipse-glsp/glsp) and the [Eclipse GLSP Website](https://www.eclipse.org/glsp/). 12 | If you have questions, please raise them in the [discussions](https://github.com/eclipse-glsp/glsp/discussions) and have a look at our [communication and support options](https://www.eclipse.org/glsp/contact/). 13 | 14 | ![alt](https://www.eclipse.org/glsp/images/diagramanimated.gif) 15 | -------------------------------------------------------------------------------- /packages/glsp-sprotty/README.md: -------------------------------------------------------------------------------- 1 | # Eclipse GLSP - Client 2 | 3 | A web-based diagram client framework for the [Graphical Language Server Platform (GLSP)](https://github.com/eclipse-glsp/glsp) based on [Eclipse Sprotty](https://github.com/eclipse/sprotty). 4 | 5 | ## Building 6 | 7 | This project is built with `yarn` and is available from npm via [@eclipse-glsp/client](https://www.npmjs.com/package/@eclipse-glsp/client). 8 | 9 | ## More information 10 | 11 | For more information, please visit the [Eclipse GLSP Umbrella repository](https://github.com/eclipse-glsp/glsp) and the [Eclipse GLSP Website](https://www.eclipse.org/glsp/). 12 | If you have questions, please raise them in the [discussions](https://github.com/eclipse-glsp/glsp/discussions) and have a look at our [communication and support options](https://www.eclipse.org/glsp/contact/). 13 | 14 | ![alt](https://www.eclipse.org/glsp/images/diagramanimated.gif) 15 | -------------------------------------------------------------------------------- /packages/client/src/re-exports.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023 EclipseSource 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 | export * from '@eclipse-glsp/sprotty'; 17 | -------------------------------------------------------------------------------- /packages/client/css/change-bounds.css: -------------------------------------------------------------------------------- 1 | .sprotty-resize-handle[data-kind='top-left'] { 2 | cursor: nw-resize; 3 | } 4 | 5 | .sprotty-resize-handle[data-kind='top'] { 6 | cursor: n-resize; 7 | } 8 | 9 | .sprotty-resize-handle[data-kind='top-right'] { 10 | cursor: ne-resize; 11 | } 12 | 13 | .sprotty-resize-handle[data-kind='right'] { 14 | cursor: e-resize; 15 | } 16 | 17 | .sprotty-resize-handle[data-kind='bottom-right'] { 18 | cursor: se-resize; 19 | } 20 | 21 | .sprotty-resize-handle[data-kind='bottom'] { 22 | cursor: s-resize; 23 | } 24 | 25 | .sprotty-resize-handle[data-kind='bottom-left'] { 26 | cursor: sw-resize; 27 | } 28 | 29 | .sprotty-resize-handle[data-kind='left'] { 30 | cursor: w-resize; 31 | } 32 | 33 | .sprotty-resize-handle.resize-not-allowed { 34 | fill: var(--glsp-error-foreground); 35 | } 36 | 37 | .sprotty g .resize-not-allowed > .sprotty-node { 38 | stroke: var(--glsp-error-foreground); 39 | stroke-width: 1.5px; 40 | } 41 | -------------------------------------------------------------------------------- /packages/protocol/README.md: -------------------------------------------------------------------------------- 1 | # Eclipse GLSP - Protocol 2 | 3 | The generic client-server communication protocol for the [Graphical Language Server Platform (GLSP)](https://github.com/eclipse-glsp/glsp) and a json-rpc based default implementation. 4 | In addition, this package provides shared common code and utility libraries for GLSP components. 5 | 6 | This project is built with `yarn` and is available from npm via [@eclipse-glsp/protocol](https://www.npmjs.com/package/@eclipse-glsp/protocol). 7 | 8 | ## More information 9 | 10 | For more information, please visit the [Eclipse GLSP Umbrella repository](https://github.com/eclipse-glsp/glsp) and the [Eclipse GLSP Website](https://www.eclipse.org/glsp/). 11 | If you have questions, please raise them in the [discussions](https://github.com/eclipse-glsp/glsp/discussions) and have a look at our [communication and support options](https://www.eclipse.org/glsp/contact/). 12 | 13 | ![alt](https://www.eclipse.org/glsp/images/diagramanimated.gif) 14 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | /** @type {import('eslint').Linter.Config} */ 2 | module.exports = { 3 | root: true, 4 | extends: '@eclipse-glsp', 5 | 6 | parserOptions: { 7 | tsconfigRootDir: __dirname, 8 | project: 'tsconfig.eslint.json' 9 | }, 10 | rules: { 11 | 'no-restricted-imports': [ 12 | 'warn', 13 | { 14 | name: 'sprotty', 15 | message: "The sprotty default exports are customized and reexported by GLSP. Please use '@eclipse-glsp/client' instead" 16 | }, 17 | { 18 | name: 'sprotty-protocol', 19 | message: 20 | "The sprotty-protocol default exports are customized and reexported by GLSP. Please use '@eclipse-glsp/client' instead" 21 | } 22 | ], 23 | '@typescript-eslint/no-unused-vars': [ 24 | 'error', 25 | { 26 | args: 'none', 27 | varsIgnorePattern: 'svg|html' 28 | } 29 | ] 30 | } 31 | }; 32 | -------------------------------------------------------------------------------- /packages/client/css/autocomplete-palette.css: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023 Business Informatics Group (TU Wien) 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 | 17 | .autocomplete-palette { 18 | position: absolute; 19 | left: 20px; 20 | top: 20px; 21 | width: 400px; 22 | } 23 | -------------------------------------------------------------------------------- /packages/protocol/src/utils/math-util.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 Axon Ivy AG 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 | 17 | export function equalUpTo(one: number, other: number, epsilon: number = Number.EPSILON): boolean { 18 | return Math.abs(one - other) <= epsilon; 19 | } 20 | -------------------------------------------------------------------------------- /packages/client/src/features/grid/grid.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024-2025 Axon Ivy AG 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/sprotty'; 17 | 18 | export type Grid = Point; 19 | export namespace Grid { 20 | export const DEFAULT: Grid = { x: 10, y: 10 }; 21 | } 22 | -------------------------------------------------------------------------------- /packages/protocol/src/di/index.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 EclipseSource 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 | export * from './container-configuration'; 17 | export * from './feature-module'; 18 | export * from './inversify-util'; 19 | export * from './lazy-injector'; 20 | export * from './re-decorate'; 21 | -------------------------------------------------------------------------------- /packages/client/css/debug.css: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 Axon Ivy AG 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 | 17 | .debug-bounds:has(> .debug-bounds-decoration) { 18 | fill-opacity: 0.5; 19 | } 20 | 21 | .debug-bounds-decoration { 22 | fill: none; 23 | stroke: black; 24 | stroke-width: 1px; 25 | } 26 | -------------------------------------------------------------------------------- /packages/glsp-sprotty/src/index.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024-2025 EclipseSource 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 | export * from './api-override'; 17 | export * from './feature-modules'; 18 | export * from './layout-override'; 19 | export * from './re-exports'; 20 | export * from './svg-views-override'; 21 | export * from './types'; 22 | -------------------------------------------------------------------------------- /packages/client/.eslintrc.js: -------------------------------------------------------------------------------- 1 | /** @type {import('eslint').Linter.Config} */ 2 | module.exports = { 3 | extends: '../../.eslintrc.js', 4 | rules: { 5 | 'no-restricted-imports': [ 6 | 'warn', 7 | { 8 | name: 'sprotty', 9 | message: 'Please use @eclipse-glsp/sprotty instead' 10 | }, 11 | { 12 | name: 'sprotty/*', 13 | message: 'Please use @eclipse-glsp/sprotty instead' 14 | }, 15 | { 16 | name: 'sprotty-protocol', 17 | message: 'Please use @eclipse-glsp/sprotty instead' 18 | }, 19 | { 20 | name: 'sprotty-protocol/*', 21 | message: 'Please use @eclipse-glsp/sprotty instead' 22 | }, 23 | { 24 | name: '@eclipse-glsp/protocol', 25 | message: 'Please use @eclipse-glsp/sprotty instead' 26 | }, 27 | { 28 | name: '@eclipse-glsp/protocol/*', 29 | message: 'Please use @eclipse-glsp/sprotty instead' 30 | } 31 | ] 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /packages/protocol/src/utils/geometry-util.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 EclipseSource 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 | 17 | /** 18 | * A direction in 2D space. 19 | */ 20 | export const Direction = { 21 | Left: 'left', 22 | Right: 'right', 23 | Up: 'up', 24 | Down: 'down' 25 | } as const; 26 | export type Direction = (typeof Direction)[keyof typeof Direction]; 27 | -------------------------------------------------------------------------------- /packages/client/src/features/accessibility/keyboard-pointer/constants.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023 Business Informatics Group (TU Wien) 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 | 17 | export namespace KeyboardPointerMetadata { 18 | export const ID = 'keyboard-pointer'; 19 | export const CRICLE_HEIGHT = 16; 20 | export const CIRCLE_WIDTH = 16; 21 | export const TAB_INDEX = 10; 22 | } 23 | -------------------------------------------------------------------------------- /.github/workflows/prepare-release.yml: -------------------------------------------------------------------------------- 1 | name: Prepare Release 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | release_type: 7 | description: 'Release type (major, minor, patch, next, or custom)' 8 | required: true 9 | type: choice 10 | options: 11 | - major 12 | - minor 13 | - patch 14 | - next 15 | - custom 16 | custom_version: 17 | description: 'Custom version (required if release_type is custom)' 18 | required: false 19 | type: string 20 | branch: 21 | description: 'Branch to use for the release repo (default: default branch)' 22 | required: false 23 | type: string 24 | draft: 25 | description: 'Create PR as draft' 26 | required: false 27 | type: boolean 28 | default: false 29 | 30 | jobs: 31 | prepare-release: 32 | uses: eclipse-glsp/glsp/.github/workflows/prepare-release.yml@master 33 | with: 34 | release_type: ${{ inputs.release_type }} 35 | custom_version: ${{ inputs.custom_version }} 36 | release_repo: glsp-client 37 | branch: ${{ inputs.branch }} 38 | draft: ${{ inputs.draft }} 39 | -------------------------------------------------------------------------------- /packages/client/src/features/accessibility/keyboard-grid/constants.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023 Business Informatics Group (TU Wien) 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 | 17 | export namespace KeyboardGridMetadata { 18 | export const ID = 'keyboard-grid'; 19 | export const TAB_INDEX = 15; 20 | } 21 | 22 | export namespace KeyboardNodeGridMetadata { 23 | export const ID = 'keyboard-node-grid'; 24 | } 25 | -------------------------------------------------------------------------------- /packages/client/src/features/tools/marquee-selection/model.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2021-2023 EclipseSource 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 { boundsFeature, Point, RectangularNode } from '@eclipse-glsp/sprotty'; 17 | 18 | export class MarqueeNode extends RectangularNode { 19 | static override readonly DEFAULT_FEATURES = [boundsFeature]; 20 | startPoint: Point; 21 | endPoint: Point; 22 | } 23 | -------------------------------------------------------------------------------- /examples/workflow-glsp/src/index.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 EclipseSource 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 | export * from './direct-task-editing/direct-task-editor'; 17 | export * from './direct-task-editing/task-editor-module'; 18 | export * from './model'; 19 | export * from './workflow-diagram-module'; 20 | export * from './workflow-snapper'; 21 | export * from './workflow-startup'; 22 | export * from './workflow-views'; 23 | -------------------------------------------------------------------------------- /examples/workflow-glsp/README.md: -------------------------------------------------------------------------------- 1 | # workflow-glsp 2 | 3 | This package contains the configuration for the GLSP diagrams of the Workflow example language. 4 | It contains the base code that is independent from the actual application framework and integration variant. 5 | Separating this base configuration and the actual integration code means that it can be reused for various different integration variants of the GLSP Workflow example language e.g in a Theia application, Standalone application, VS Code plugin or integrated into the Eclipse IDE. 6 | 7 | ## Building 8 | 9 | This package is built with `yarn` and is available from npm via [@eclipse-glsp-examples/workflow-glsp](https://www.npmjs.com/package/@eclipse-glsp-examples/worfklow-glsp) 10 | 11 | ## More information 12 | 13 | For more information, please visit the [Eclipse GLSP Umbrella repository](https://github.com/eclipse-glsp/glsp) and the [Eclipse GLSP Website](https://www.eclipse.org/glsp/). 14 | If you have questions, please raise them in the [discussions](https://github.com/eclipse-glsp/glsp/discussions) and have a look at our [communication and support options](https://www.eclipse.org/glsp/contact/). 15 | 16 | ![alt](https://www.eclipse.org/glsp/images/diagramanimated.gif) 17 | -------------------------------------------------------------------------------- /packages/protocol/.eslintrc.js: -------------------------------------------------------------------------------- 1 | /** @type {import('eslint').Linter.Config} */ 2 | module.exports = { 3 | extends: '../../.eslintrc.js', 4 | rules: { 5 | 'no-restricted-imports': [ 6 | 'warn', 7 | { 8 | name: 'sprotty', 9 | message: "The protocol package should not have any direct 'sprotty' dependencies. Try to use 'sprotty-protocol' instead" 10 | }, 11 | { 12 | name: 'sprotty/*', 13 | message: "The protocol package should not have any direct 'sprotty' dependencies. Try to use 'sprotty-protocol' instead" 14 | }, 15 | 'error', 16 | { 17 | name: '@eclipse-glsp/client', 18 | message: 19 | "Circular dependency! This package is consumed by '@eclipse-glsp' client. Consider moving the conflicting file into this package." 20 | }, 21 | { 22 | name: '@eclipse-glsp/client/*', 23 | message: 24 | "Circular dependency! This package is consumed by '@eclipse-glsp' client. Consider moving the conflicting file into this package." 25 | } 26 | ] 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "[Client] Build all", 8 | "detail": "Build all glsp-client packages & examples", 9 | "type": "shell", 10 | "group": "build", 11 | "command": "yarn", 12 | "presentation": { 13 | "reveal": "always", 14 | "panel": "new" 15 | }, 16 | "problemMatcher": ["$tsc", "$eslint-stylish"] 17 | }, 18 | { 19 | "label": "[Client] Watch all", 20 | "detail": "Watch all glsp-client packages & examples", 21 | "type": "shell", 22 | "group": "build", 23 | "command": "yarn watch", 24 | "presentation": { 25 | "reveal": "always", 26 | "panel": "new" 27 | }, 28 | "problemMatcher": ["$tsc-watch"] 29 | }, 30 | { 31 | "label": "[Client] Open Workflow Standalone example (Chrome)", 32 | "type": "shell", 33 | "group": "test", 34 | "presentation": { 35 | "reveal": "always", 36 | "panel": "new" 37 | }, 38 | "command": "google-chrome examples/workflow-standalone/app/diagram.html" 39 | } 40 | ] 41 | } 42 | -------------------------------------------------------------------------------- /packages/client/css/navigation.css: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023 Business Informatics Group (TU Wien) 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 | 17 | :root { 18 | --glsp-navigation-highlight: rgba(136, 68, 68, 0.2); 19 | } 20 | 21 | .sprotty-edge.navigable-element { 22 | stroke: var(--glsp-navigation-highlight); 23 | } 24 | 25 | .sprotty-edge.navigable-element .sprotty-edge.arrow { 26 | fill: var(--glsp-navigation-highlight); 27 | stroke: var(--glsp-navigation-highlight); 28 | } 29 | -------------------------------------------------------------------------------- /packages/client/css/helper-lines.css: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023 EclipseSource 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 | 17 | .helper-line { 18 | pointer-events: none; 19 | stroke: #1d80d1; 20 | stroke-width: 1; 21 | opacity: 1; 22 | } 23 | 24 | .selection-bounds { 25 | pointer-events: none; 26 | fill: blue; 27 | fill-opacity: 0.05; 28 | stroke-linejoin: miter; 29 | stroke-linecap: round; 30 | stroke: darkblue; 31 | stroke-width: 0.5; 32 | stroke-dasharray: 2; 33 | } 34 | -------------------------------------------------------------------------------- /packages/protocol/src/di/re-decorate.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 EclipseSource 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 | 17 | import { decorate, injectable } from 'inversify'; 18 | import { JsonrpcClientProxy } from '../client-server-protocol/jsonrpc/base-jsonrpc-glsp-client'; 19 | 20 | // Decorate `JsonrpcClientProxy` as injectable for anyone who imports the di functionality, such as the client package, 21 | // the Theia integration package and the server package. 22 | decorate(injectable(), JsonrpcClientProxy); 23 | -------------------------------------------------------------------------------- /examples/workflow-glsp/src/direct-task-editing/task-editor-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 { bindAsService, FeatureModule, TYPES } from '@eclipse-glsp/client'; 17 | import { TaskEditor } from './direct-task-editor'; 18 | 19 | export const taskEditorModule = new FeatureModule( 20 | (bind, _unbind, _isBound) => { 21 | bindAsService(bind, TYPES.IUIExtension, TaskEditor); 22 | }, 23 | { featureId: Symbol('taskEditorModule') } 24 | ); 25 | -------------------------------------------------------------------------------- /packages/client/src/features/grid/grid-style.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 Axon Ivy AG 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 | 17 | export namespace GridProperty { 18 | export const GRID_BACKGROUND_X = '--grid-background-x'; 19 | export const GRID_BACKGROUND_Y = '--grid-background-y'; 20 | export const GRID_BACKGROUND_WIDTH = '--grid-background-width'; 21 | export const GRID_BACKGROUND_HEIGHT = '--grid-background-height'; 22 | export const GRID_BACKGROUND_ZOOM = '--grid-background-zoom'; 23 | export const GRID_COLOR = '--grid-color'; 24 | } 25 | -------------------------------------------------------------------------------- /packages/client/src/features/save/save-keylistener.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2023 EclipseSource 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 { Action, KeyListener, GModelRoot, SaveModelAction, matchesKeystroke } from '@eclipse-glsp/sprotty'; 17 | 18 | export class SaveModelKeyboardListener extends KeyListener { 19 | override keyDown(_element: GModelRoot, event: KeyboardEvent): Action[] { 20 | if (matchesKeystroke(event, 'KeyS', 'ctrlCmd')) { 21 | return [SaveModelAction.create()]; 22 | } 23 | return []; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/client/src/features/svg-metadata/svg-metadata-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023-2024 Business Informatics Group (TU Wien) 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 | 17 | import { FeatureModule, TYPES } from '@eclipse-glsp/sprotty'; 18 | import { MetadataPlacer } from './metadata-placer'; 19 | 20 | export const svgMetadataModule = new FeatureModule( 21 | bind => { 22 | bind(MetadataPlacer).toSelf().inSingletonScope(); 23 | bind(TYPES.IVNodePostprocessor).toService(MetadataPlacer); 24 | }, 25 | { featureId: Symbol('svgMetadata') } 26 | ); 27 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 11 | 12 | #### What it does 13 | 14 | 15 | 16 | #### How to test 17 | 18 | 19 | 20 | #### Follow-ups 21 | 22 | 23 | 24 | #### Changelog 25 | 26 | 27 | 28 | - [ ] This PR should be mentioned in the changelog 29 | - [ ] This PR introduces a breaking change (if yes, provide more details below for the changelog and the migration guide) 30 | -------------------------------------------------------------------------------- /packages/client/css/ghost-element.css: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023 EclipseSource 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 | 17 | .ghost-element { 18 | /* we are a true ghost so we do not want to be used as a target for any mouse event */ 19 | pointer-events: none; 20 | opacity: 0.8; 21 | } 22 | 23 | .ghost-element.hidden { 24 | width: 0; 25 | height: 0; 26 | visibility: hidden; 27 | } 28 | 29 | .sprotty-node.insert-indicator:not(.selected) { 30 | pointer-events: none; 31 | fill: none; 32 | stroke: black; /* same color as default color for edges */ 33 | stroke-width: 1.5px; 34 | } 35 | -------------------------------------------------------------------------------- /packages/client/src/features/zorder/zorder-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2025 EclipseSource 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 { FeatureModule, configureCommand } from '@eclipse-glsp/sprotty'; 17 | import { boundsModule } from '../bounds/bounds-module'; 18 | import { BringToFrontCommand } from './bring-to-front-command'; 19 | 20 | export const zorderModule = new FeatureModule( 21 | (bind, _unbind, isBound) => { 22 | const context = { bind, isBound }; 23 | configureCommand(context, BringToFrontCommand); 24 | }, 25 | { featureId: Symbol('zorder'), requires: [boundsModule] } 26 | ); 27 | -------------------------------------------------------------------------------- /packages/client/src/features/decoration/decoration-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2025 EclipseSource 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 { FeatureModule, TYPES, bindAsService } from '@eclipse-glsp/sprotty'; 17 | import '../../../css/decoration.css'; 18 | import { GlspDecorationPlacer } from './decoration-placer'; 19 | 20 | export const decorationModule = new FeatureModule( 21 | bind => { 22 | bindAsService(bind, TYPES.IVNodePostprocessor, GlspDecorationPlacer); 23 | bind(TYPES.ISvgExportPostprocessor).toService(GlspDecorationPlacer); 24 | }, 25 | { featureId: Symbol('decoration') } 26 | ); 27 | -------------------------------------------------------------------------------- /packages/client/src/base/auto-complete/auto-complete-actions.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2020-2023 EclipseSource 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 { hasStringProp, LabeledAction } from '@eclipse-glsp/sprotty'; 17 | 18 | /** A special {@link LabeledAction} that has a `text` property in addition to the `label */ 19 | export interface AutoCompleteValue extends LabeledAction { 20 | readonly text: string; 21 | } 22 | 23 | export namespace AutoCompleteValue { 24 | export function is(object: any): object is AutoCompleteValue { 25 | return LabeledAction.is(object) && hasStringProp(object, 'text'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/workflow-glsp/src/workflow-startup.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 EclipseSource 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 | 17 | import { IDiagramStartup, IGridManager } from '@eclipse-glsp/client'; 18 | import { MaybePromise, TYPES } from '@eclipse-glsp/sprotty'; 19 | import { inject, injectable, optional } from 'inversify'; 20 | 21 | @injectable() 22 | export class WorkflowStartup implements IDiagramStartup { 23 | rank = -1; 24 | 25 | @inject(TYPES.IGridManager) @optional() protected gridManager?: IGridManager; 26 | 27 | preRequestModel(): MaybePromise { 28 | this.gridManager?.setGridVisible(true); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/client/src/features/source-model-watcher/source-model-watcher-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 { FeatureModule, SourceModelChangedAction, configureActionHandler } from '@eclipse-glsp/sprotty'; 17 | import { SourceModelChangedActionHandler } from './source-model-changed-action-handler'; 18 | 19 | export const sourceModelWatcherModule = new FeatureModule( 20 | (bind, _unbind, isBound) => { 21 | configureActionHandler({ bind, isBound }, SourceModelChangedAction.KIND, SourceModelChangedActionHandler); 22 | }, 23 | { featureId: Symbol('sourceModelWatcher') } 24 | ); 25 | -------------------------------------------------------------------------------- /examples/workflow-glsp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@eclipse-glsp-examples/workflow-glsp", 3 | "version": "2.6.0-next", 4 | "description": "GLSP diagrams for the Workflow DSL", 5 | "keywords": [ 6 | "glsp", 7 | "workflow", 8 | "diagram", 9 | "example" 10 | ], 11 | "homepage": "https://www.eclipse.org/glsp/", 12 | "bugs": "https://github.com/eclipse-glsp/glsp/issues", 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/eclipse-glsp/glsp-client.git" 16 | }, 17 | "license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)", 18 | "author": { 19 | "name": "Eclipse GLSP" 20 | }, 21 | "contributors": [ 22 | { 23 | "name": "Eclipse GLSP Project", 24 | "email": "glsp-dev@eclipse.org", 25 | "url": "https://projects.eclipse.org/projects/ecd.glsp" 26 | } 27 | ], 28 | "main": "lib/index", 29 | "types": "lib/index", 30 | "files": [ 31 | "lib", 32 | "src", 33 | "css" 34 | ], 35 | "scripts": { 36 | "build": "tsc -b", 37 | "clean": "rimraf *.tsbuildinfo lib", 38 | "generate:index": "glsp generateIndex src -f -s", 39 | "lint": "eslint --ext .ts,.tsx ./src", 40 | "watch": "tsc -w" 41 | }, 42 | "dependencies": { 43 | "@eclipse-glsp/client": "2.6.0-next", 44 | "balloon-css": "^0.5.0" 45 | }, 46 | "devDependencies": { 47 | "mvn-artifact-download": "5.1.0" 48 | }, 49 | "publishConfig": { 50 | "access": "public" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /packages/client/src/features/tools/deletion/deletion-tool-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 { FeatureModule, TYPES, bindAsService } from '@eclipse-glsp/sprotty'; 17 | import { DelKeyDeleteTool, MouseDeleteTool } from './delete-tool'; 18 | 19 | export const deletionToolModule = new FeatureModule( 20 | (bind, unbind, isBound, rebind) => { 21 | const context = { bind, unbind, isBound, rebind }; 22 | bindAsService(context, TYPES.IDefaultTool, DelKeyDeleteTool); 23 | bindAsService(context, TYPES.ITool, MouseDeleteTool); 24 | }, 25 | { featureId: Symbol('deletionTool') } 26 | ); 27 | -------------------------------------------------------------------------------- /packages/client/src/features/change-bounds/snap.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2020-2024 EclipseSource 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/no-shadow */ 17 | import { KeyboardModifier } from '@eclipse-glsp/sprotty'; 18 | 19 | /** 20 | * @deprecated Use {@link ChangeBoundsManager.useSnap} instead which may be customized. 21 | */ 22 | export function useSnap(event: MouseEvent | KeyboardEvent): boolean { 23 | return !event.shiftKey; 24 | } 25 | 26 | /** 27 | * @deprecated Use {@link ChangeBoundsManager.unsnapModifier} instead which may be customized. 28 | */ 29 | export function unsnapModifier(): KeyboardModifier { 30 | return 'shift'; 31 | } 32 | -------------------------------------------------------------------------------- /packages/client/css/decoration.css: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2020-2021 EclipseSource 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 | 17 | .sprotty-issue-background { 18 | fill: var(--glsp-issue-background); 19 | background-color: var(--glsp-issue-background); 20 | } 21 | 22 | .sprotty-issue.sprotty-error { 23 | fill: var(--glsp-error-foreground); 24 | background-color: var(--glsp-error-foreground); 25 | } 26 | 27 | .sprotty-issue.sprotty-warning { 28 | fill: var(--glsp-warning-foreground); 29 | background-color: var(--glsp-warning-foreground); 30 | } 31 | 32 | .sprotty-issue.sprotty-info { 33 | fill: var(--glsp-info-foreground); 34 | background-color: var(--glsp-info-foreground); 35 | } 36 | -------------------------------------------------------------------------------- /packages/client/css/search.css: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023-2025 Business Informatics Group (TU Wien) 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 | 17 | :root { 18 | --glsp-search-highlight: #130bf7; 19 | } 20 | 21 | .search-hidden { 22 | opacity: 0.4; 23 | } 24 | 25 | .search-highlighted .sprotty-node { 26 | stroke-width: 1.5px; 27 | stroke-width: 2px; 28 | stroke-dashoffset: 5; 29 | stroke-dasharray: 5, 5; 30 | stroke-linecap: round; 31 | stroke: var(--glsp-search-highlight); 32 | } 33 | 34 | .sprotty-edge.search-highlighted, 35 | .sprotty-edge.search-highlighted .sprotty-edge.arrow { 36 | fill: var(--glsp-search-highlight); 37 | stroke: var(--glsp-search-highlight); 38 | } 39 | -------------------------------------------------------------------------------- /packages/client/src/features/accessibility/actions.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023 Business Informatics Group (TU Wien) 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 { Action, hasStringProp } from '@eclipse-glsp/sprotty'; 17 | 18 | export interface FocusDomAction extends Action { 19 | kind: typeof FocusDomAction.KIND; 20 | id: string; 21 | } 22 | 23 | export namespace FocusDomAction { 24 | export const KIND = 'focusDomAction'; 25 | 26 | export function is(object: any): object is FocusDomAction { 27 | return Action.hasKind(object, KIND) && hasStringProp(object, 'id'); 28 | } 29 | 30 | export function create(id: string): FocusDomAction { 31 | return { kind: KIND, id }; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/client/src/features/save/save-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 { FeatureModule, TYPES, bindAsService } from '@eclipse-glsp/sprotty'; 17 | import { SaveModelKeyboardListener } from './save-keylistener'; 18 | 19 | /** 20 | * Feature module that is intended for the standalone deployment of GLSP (i.e. plain webapp) 21 | * When integrated into an application frame (e.g Theia/VS Code) this module is typically omitted and/or replaced 22 | * with an application native module. 23 | */ 24 | export const saveModule = new FeatureModule( 25 | bind => { 26 | bindAsService(bind, TYPES.KeyListener, SaveModelKeyboardListener); 27 | }, 28 | { featureId: Symbol('save') } 29 | ); 30 | -------------------------------------------------------------------------------- /packages/client/src/features/label-edit-ui/label-edit-ui-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 EclipseSource 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 { EditLabelAction, EditLabelActionHandler, FeatureModule, TYPES, configureActionHandler } from '@eclipse-glsp/sprotty'; 17 | import { GlspEditLabelUI } from './label-edit-ui'; 18 | 19 | export const labelEditUiModule = new FeatureModule( 20 | (bind, unbind, isBound, rebind, ...rest) => { 21 | const context = { bind, unbind, isBound, rebind }; 22 | configureActionHandler(context, EditLabelAction.KIND, EditLabelActionHandler); 23 | bind(GlspEditLabelUI).toSelf().inSingletonScope(); 24 | bind(TYPES.IUIExtension).toService(GlspEditLabelUI); 25 | }, 26 | { featureId: Symbol('labelEditUi') } 27 | ); 28 | -------------------------------------------------------------------------------- /packages/client/src/features/element-template/element-template-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 { FeatureModule, configureCommand } from '@eclipse-glsp/sprotty'; 17 | import { AddTemplateElementsFeedbackCommand } from './add-template-element'; 18 | import { RemoveTemplateElementsFeedbackCommand } from './remove-template-element'; 19 | 20 | export const elementTemplateModule = new FeatureModule( 21 | (bind, unbind, isBound, rebind) => { 22 | const context = { bind, unbind, isBound, rebind }; 23 | configureCommand(context, AddTemplateElementsFeedbackCommand); 24 | configureCommand(context, RemoveTemplateElementsFeedbackCommand); 25 | }, 26 | { featureId: Symbol('elementTemplate') } 27 | ); 28 | -------------------------------------------------------------------------------- /packages/client/src/features/status/status-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023-2024 EclipseSource 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 | 17 | import { FeatureModule, StatusAction, TYPES, bindAsService, configureActionHandler } from '@eclipse-glsp/sprotty'; 18 | import '../../../css/status-overlay.css'; 19 | import { StatusOverlay } from './status-overlay'; 20 | 21 | export const statusModule = new FeatureModule( 22 | (bind, unbind, isBound, rebind) => { 23 | const context = { bind, unbind, isBound, rebind }; 24 | bindAsService(context, TYPES.IUIExtension, StatusOverlay); 25 | bind(TYPES.IDiagramStartup).toService(StatusOverlay); 26 | configureActionHandler(context, StatusAction.KIND, StatusOverlay); 27 | }, 28 | { featureId: Symbol('status') } 29 | ); 30 | -------------------------------------------------------------------------------- /packages/client/src/features/tools/edge-creation/view.tsx: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 | /** @jsx svg */ 17 | import { GModelElement, IView, Point, RenderingContext, svg } from '@eclipse-glsp/sprotty'; 18 | import { injectable } from 'inversify'; 19 | import { VNode } from 'snabbdom'; 20 | 21 | /** 22 | * This view is used for the invisible end of the feedback edge. 23 | * A feedback edge is shown as a visual feedback when creating edges. 24 | */ 25 | @injectable() 26 | export class FeedbackEdgeEndView implements IView { 27 | render(model: Readonly, context: RenderingContext): VNode { 28 | const position: Point = (model as any).position ?? Point.ORIGIN; 29 | return ; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /packages/client/src/features/undo-redo/undo-redo-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023-2024 EclipseSource 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 | 17 | import { bindAsService, FeatureModule, TYPES } from '@eclipse-glsp/sprotty'; 18 | import { GLSPUndoRedoKeyListener } from './undo-redo-key-listener'; 19 | 20 | /** 21 | * Feature module that is intended for the standalone deployment of GLSP (i.e. plain webapp) 22 | * When integrated into an application frame (e.g Theia/VS Code) this module is typically omitted and/or replaced 23 | * with an application native module. 24 | */ 25 | export const undoRedoModule = new FeatureModule( 26 | (bind, unbind, isBound, rebind) => { 27 | bindAsService(bind, TYPES.KeyListener, GLSPUndoRedoKeyListener); 28 | }, 29 | { featureId: Symbol('undoRedo') } 30 | ); 31 | -------------------------------------------------------------------------------- /packages/client/css/toast.css: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023 Business Informatics Group (TU Wien) 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 | .toast { 17 | position: absolute; 18 | bottom: 48px; /* same as top of toolbar by default */ 19 | display: grid; 20 | grid-template-columns: 1fr 1fr 1fr; 21 | grid-column-gap: 1rem; 22 | left: 40px; /* same as right of toolbar by default */ 23 | } 24 | 25 | .toast-column-left { 26 | grid-column: 1 / span 1; 27 | } 28 | 29 | .toast-column-center { 30 | grid-column: 2 / span 1; 31 | } 32 | 33 | .toast-column-right { 34 | grid-column: 3 / span 1; 35 | } 36 | 37 | .toast-container { 38 | display: inline-block; 39 | min-width: 256px; 40 | max-width: 516px; 41 | background-color: #ccc; 42 | color: #000; 43 | padding: 0.5rem; 44 | } 45 | -------------------------------------------------------------------------------- /packages/glsp-sprotty/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@eclipse-glsp/sprotty", 3 | "version": "2.6.0-next", 4 | "description": "Augmented reexport of the sprotty API for GLSP", 5 | "homepage": "https://www.eclipse.org/glsp/", 6 | "bugs": "https://github.com/eclipse-glsp/glsp/issues", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/eclipse-glsp/glsp-client.git" 10 | }, 11 | "license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)", 12 | "author": { 13 | "name": "Eclipse GLSP" 14 | }, 15 | "contributors": [ 16 | { 17 | "name": "Eclipse GLSP Project", 18 | "email": "glsp-dev@eclipse.org", 19 | "url": "https://projects.eclipse.org/projects/ecd.glsp" 20 | } 21 | ], 22 | "main": "lib/index", 23 | "types": "lib/index", 24 | "files": [ 25 | "lib", 26 | "src" 27 | ], 28 | "scripts": { 29 | "build": "tsc -b", 30 | "clean": "rimraf lib *.tsbuildinfo", 31 | "generate:index": "glsp generateIndex src -f -s", 32 | "lint": "eslint --ext .ts,.tsx ./src", 33 | "watch": "tsc -w" 34 | }, 35 | "dependencies": { 36 | "@eclipse-glsp/protocol": "2.6.0-next", 37 | "autocompleter": "^9.1.0", 38 | "snabbdom": "~3.5.1", 39 | "sprotty": "1.4.0", 40 | "sprotty-protocol": "1.4.0", 41 | "vscode-jsonrpc": "8.2.0" 42 | }, 43 | "devDependencies": { 44 | "@types/jsdom": "^21.1.3", 45 | "@vscode/codicons": "^0.0.25", 46 | "snabbdom-to-html": "^7.1.0" 47 | }, 48 | "peerDependencies": { 49 | "inversify": "^6.1.3" 50 | }, 51 | "publishConfig": { 52 | "access": "public" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /examples/workflow-glsp/src/workflow-snapper.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 EclipseSource 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 | 17 | import { GModelElement, GRoutingHandle, GridSnapper, Point } from '@eclipse-glsp/client'; 18 | import { injectable } from 'inversify'; 19 | 20 | @injectable() 21 | export class WorkflowSnapper extends GridSnapper { 22 | override snap(position: Point, element: GModelElement): Point { 23 | // we snap our edges to the center of the elements and our elements to the grid, 24 | // so to allow for nicer angles and more fine-grained control, we allow routing points to be snapped half-grid 25 | return element instanceof GRoutingHandle 26 | ? Point.snapToGrid(position, Point.divideScalar(this.grid, 2)) 27 | : super.snap(position, element); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/client/src/utils/html-utils.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2023 EclipseSource 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 { AnyObject, hasNumberProp } from '@eclipse-glsp/sprotty'; 17 | 18 | export function createElementFromHTML(html: string): HTMLElement | undefined { 19 | const template = document.createElement('template'); 20 | html = html.trim(); // Never return a text node of whitespace as the result 21 | template.innerHTML = html; 22 | const node = template.content.firstChild; 23 | if (node && node instanceof HTMLElement) { 24 | return node as HTMLElement; 25 | } 26 | return undefined; 27 | } 28 | 29 | export function isMouseEvent(object: unknown): object is MouseEvent { 30 | return AnyObject.is(object) && hasNumberProp(object, 'pageX') && hasNumberProp(object, 'pageY'); 31 | } 32 | -------------------------------------------------------------------------------- /examples/workflow-standalone/src/features/direct-task-editing/standalone-task-editor-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 EclipseSource 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 | 17 | import { taskEditorModule } from '@eclipse-glsp-examples/workflow-glsp'; 18 | import { FeatureModule, TYPES, bindAsService } from '@eclipse-glsp/client'; 19 | import '../../../css/command-palette.css'; 20 | import { TaskEditorKeyListener } from './task-editor-key-listener'; 21 | 22 | export const standaloneTaskEditorModule = new FeatureModule( 23 | (bind, unbind, isBound, rebind) => { 24 | const context = { bind, unbind, isBound, rebind }; 25 | bindAsService(context, TYPES.KeyListener, TaskEditorKeyListener); 26 | }, 27 | { 28 | featureId: Symbol('standaloneTaskEditor'), 29 | requires: taskEditorModule 30 | } 31 | ); 32 | -------------------------------------------------------------------------------- /packages/client/src/features/grid/grid-snapper.spec.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2022-2024 EclipseSource 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 | 17 | import { GModelElement } from '@eclipse-glsp/sprotty'; 18 | import { expect } from 'chai'; 19 | import { GridSnapper } from './grid-snapper'; 20 | 21 | describe('GridSnapper', () => { 22 | it('snap', () => { 23 | const element = new GModelElement(); 24 | const snapper = new GridSnapper(); 25 | expect(snapper.snap({ x: 0, y: 0 }, element)).to.be.deep.equals({ x: 0, y: 0 }); 26 | expect(snapper.snap({ x: 4, y: 5 }, element)).to.be.deep.equals({ x: 0, y: 10 }); 27 | expect(snapper.snap({ x: 8, y: 11 }, element)).to.be.deep.equals({ x: 10, y: 10 }); 28 | expect(snapper.snap({ x: -7, y: -4 }, element)).to.be.deep.equals({ x: -10, y: -0 }); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /packages/client/src/features/hints/type-hints-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 { FeatureModule, SetTypeHintsAction, TYPES, bindAsService, configureActionHandler, configureCommand } from '@eclipse-glsp/sprotty'; 17 | import { ApplyTypeHintsCommand, TypeHintProvider } from './type-hint-provider'; 18 | 19 | export const typeHintsModule = new FeatureModule( 20 | (bind, unbind, isBound) => { 21 | const context = { bind, unbind, isBound }; 22 | bindAsService(context, TYPES.ITypeHintProvider, TypeHintProvider); 23 | bind(TYPES.IDiagramStartup).toService(TypeHintProvider); 24 | configureActionHandler(context, SetTypeHintsAction.KIND, TypeHintProvider); 25 | configureCommand(context, ApplyTypeHintsCommand); 26 | }, 27 | { featureId: Symbol('typeHints') } 28 | ); 29 | -------------------------------------------------------------------------------- /packages/client/css/grid.css: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 Axon Ivy AG 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 | 17 | .grid-background .sprotty-graph, 18 | .grid-background.sprotty-graph { 19 | --grid-stroke-width: calc(1px * var(--grid-background-zoom)); 20 | --grid-stroke-width-half: calc(var(--grid-stroke-width) / 2); 21 | --grid-color: rgba(0, 0, 0, 0.1); 22 | background-image: linear-gradient(to right, var(--grid-color) var(--grid-stroke-width), transparent var(--grid-stroke-width)), 23 | linear-gradient(to bottom, var(--grid-color) var(--grid-stroke-width), transparent var(--grid-stroke-width)); 24 | background-size: var(--grid-background-width) var(--grid-background-height); 25 | background-position: calc(var(--grid-background-x) - var(--grid-stroke-width-half)) 26 | calc(var(--grid-background-y) - var(--grid-stroke-width-half)); 27 | } 28 | -------------------------------------------------------------------------------- /packages/client/src/features/tools/edge-creation/edege-creation-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 { FeatureModule, TYPES, TriggerEdgeCreationAction, bindAsService, configureActionHandler } from '@eclipse-glsp/sprotty'; 17 | import { configureDanglingFeedbackEdge } from './dangling-edge-feedback'; 18 | import { EdgeCreationTool } from './edge-creation-tool'; 19 | 20 | export const edgeCreationToolModule = new FeatureModule( 21 | (bind, unbind, isBound, rebind) => { 22 | const context = { bind, unbind, isBound, rebind }; 23 | bindAsService(context, TYPES.ITool, EdgeCreationTool); 24 | configureActionHandler(context, TriggerEdgeCreationAction.KIND, EdgeCreationTool); 25 | configureDanglingFeedbackEdge(context); 26 | }, 27 | { featureId: Symbol('edgeCreationTool') } 28 | ); 29 | -------------------------------------------------------------------------------- /packages/client/src/base/ui-extension/ui-extension-registry.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 EclipseSource 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 | 17 | import { IUIExtension, LazyInjector, MaybePromise, TYPES, UIExtensionRegistry } from '@eclipse-glsp/sprotty'; 18 | import { inject, injectable } from 'inversify'; 19 | import { IDiagramStartup } from '../model/diagram-loader'; 20 | 21 | @injectable() 22 | export class GLSPUIExtensionRegistry extends UIExtensionRegistry implements IDiagramStartup { 23 | @inject(LazyInjector) 24 | protected lazyInjector: LazyInjector; 25 | 26 | constructor(@inject(TYPES.EmptyArray) extensions: IUIExtension[]) { 27 | super(extensions); 28 | } 29 | 30 | preLoadDiagram(): MaybePromise { 31 | this.lazyInjector.getAll(TYPES.IUIExtension).forEach(extension => this.register(extension.id(), extension)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/client/src/features/label-edit/label-edit-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 { ApplyLabelEditCommand, FeatureModule, TYPES, bindAsService, configureCommand } from '@eclipse-glsp/sprotty'; 17 | import { DirectLabelEditTool } from './edit-label-tool'; 18 | import { BalloonLabelValidationDecorator, ServerEditLabelValidator } from './edit-label-validator'; 19 | 20 | export const labelEditModule = new FeatureModule( 21 | (bind, _unbind, isBound, _rebind) => { 22 | bind(TYPES.IEditLabelValidator).to(ServerEditLabelValidator); 23 | bind(TYPES.IEditLabelValidationDecorator).to(BalloonLabelValidationDecorator); 24 | bindAsService(bind, TYPES.IDefaultTool, DirectLabelEditTool); 25 | configureCommand({ bind, isBound }, ApplyLabelEditCommand); 26 | }, 27 | { featureId: Symbol('labelEdit') } 28 | ); 29 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // If one would like to add/remove/modify user preferences without modifying the content of the 2 | // workspace settings file, then one would need to modify the `settings.json` under here: 3 | // - Windows: %APPDATA%\Code\User\settings.json 4 | // - Linux: $HOME/.config/Code/User/settings.json 5 | // - Mac: $HOME/Library/Application Support/Code/User/settings.json 6 | { 7 | "editor.formatOnSave": true, 8 | "editor.codeActionsOnSave": { 9 | "source.fixAll.eslint": "always", 10 | "source.organizeImports": "always" 11 | }, 12 | "eslint.validate": ["javascript", "typescript"], 13 | "search.exclude": { 14 | "**/node_modules": true, 15 | "**/lib": true 16 | }, 17 | "task.autoDetect": "off", 18 | "typescript.tsdk": "node_modules/typescript/lib", 19 | "[css]": { 20 | "editor.defaultFormatter": "esbenp.prettier-vscode" 21 | }, 22 | "[javascript]": { 23 | "editor.defaultFormatter": "esbenp.prettier-vscode" 24 | }, 25 | "[javascriptreact]": { 26 | "editor.defaultFormatter": "esbenp.prettier-vscode" 27 | }, 28 | "[json]": { 29 | "editor.defaultFormatter": "esbenp.prettier-vscode" 30 | }, 31 | "[markdown]": { 32 | "editor.defaultFormatter": "esbenp.prettier-vscode" 33 | }, 34 | "[typescript]": { 35 | "editor.defaultFormatter": "esbenp.prettier-vscode" 36 | }, 37 | "[typescriptreact]": { 38 | "editor.defaultFormatter": "esbenp.prettier-vscode" 39 | }, 40 | "[yaml]": { 41 | "editor.defaultFormatter": "esbenp.prettier-vscode" 42 | }, 43 | "markdownlint.config": { 44 | "MD007": { 45 | "indent": 4 46 | }, 47 | "MD030": { 48 | "ul_single": 3, 49 | "ul_multi": 3 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /packages/client/src/features/undo-redo/undo-redo-key-listener.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023 EclipseSource 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 | 17 | import { Action, KeyListener, RedoAction, GModelElement, UndoAction, isMac, matchesKeystroke } from '@eclipse-glsp/sprotty'; 18 | 19 | /** 20 | * Key listener that listens to the typical keyboard shortcuts for undo/redo and dispatches the corresponding actions. 21 | */ 22 | export class GLSPUndoRedoKeyListener extends KeyListener { 23 | override keyDown(element: GModelElement, event: KeyboardEvent): Action[] { 24 | if (matchesKeystroke(event, 'KeyZ', 'ctrlCmd')) { 25 | return [UndoAction.create()]; 26 | } 27 | if (matchesKeystroke(event, 'KeyZ', 'ctrlCmd', 'shift') || (!isMac() && matchesKeystroke(event, 'KeyY', 'ctrlCmd'))) { 28 | return [RedoAction.create()]; 29 | } 30 | return []; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "type": "node", 6 | "request": "launch", 7 | "name": "Run current test", 8 | "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", 9 | "args": ["--config", "${workspaceRoot}/.mocharc", "--timeout", "0", "${file}"], 10 | "console": "integratedTerminal", 11 | "internalConsoleOptions": "neverOpen", 12 | "env": { 13 | "TS_NODE_PROJECT": "${workspaceFolder}/tsconfig.json" 14 | } 15 | }, 16 | { 17 | "type": "node", 18 | "request": "launch", 19 | "name": "Run tests", 20 | "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", 21 | "args": [ 22 | "--config", 23 | "${workspaceRoot}/.mocharc", 24 | "--timeout", 25 | "0", 26 | "${workspaceFolder}/packages/client/src/**/*.spec.ts" 27 | ], 28 | "env": { 29 | "TS_NODE_PROJECT": "${workspaceFolder}/tsconfig.json" 30 | }, 31 | "console": "integratedTerminal", 32 | "internalConsoleOptions": "neverOpen" 33 | }, 34 | { 35 | "type": "node", 36 | "request": "launch", 37 | "name": "Run tests (protocol)", 38 | "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", 39 | "args": [ 40 | "--config", 41 | "${workspaceRoot}/.mocharc", 42 | "--timeout", 43 | "0", 44 | "${workspaceFolder}/packages/protocol/src/**/*.spec.ts" 45 | ], 46 | "env": { 47 | "TS_NODE_PROJECT": "${workspaceFolder}/tsconfig.json" 48 | }, 49 | "console": "integratedTerminal", 50 | "internalConsoleOptions": "neverOpen" 51 | } 52 | ] 53 | } 54 | -------------------------------------------------------------------------------- /packages/client/src/views/routing-point-handle-view.tsx: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2025 EclipseSource 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 { SRoutingHandleView, type GRoutingHandle, type RenderingContext, type RoutedPoint } from '@eclipse-glsp/sprotty'; 17 | import { injectable } from 'inversify'; 18 | import type { VNode } from 'snabbdom'; 19 | import { isReconnectHandle } from '../features/reconnect/model'; 20 | 21 | @injectable() 22 | export class GRoutingHandleView extends SRoutingHandleView { 23 | override render(handle: Readonly, context: RenderingContext, args?: { route?: RoutedPoint[] }): VNode { 24 | // We have our own handle view for the reconnect handles 25 | if (!isReconnectHandle(handle) && (handle.kind === 'source' || handle.kind === 'target')) { 26 | return undefined as any; 27 | } 28 | 29 | return super.render(handle, context, args); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /packages/client/src/features/accessibility/keyboard-pointer/actions.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023 Business Informatics Group (TU Wien) 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 { Action, hasNumberProp } from '@eclipse-glsp/sprotty'; 17 | 18 | export interface SetKeyboardPointerRenderPositionAction extends Action { 19 | kind: typeof SetKeyboardPointerRenderPositionAction.KIND; 20 | x: number; 21 | y: number; 22 | } 23 | 24 | export namespace SetKeyboardPointerRenderPositionAction { 25 | export const KIND = 'setKeyboardPointerRenderPositionAction'; 26 | 27 | export function is(object: any): object is SetKeyboardPointerRenderPositionAction { 28 | return Action.hasKind(object, KIND) && hasNumberProp(object, 'x') && hasNumberProp(object, 'y'); 29 | } 30 | 31 | export function create(x: number, y: number): SetKeyboardPointerRenderPositionAction { 32 | return { kind: KIND, x, y }; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/client/src/features/export/export-svg-action-handler.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023 EclipseSource 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 { saveAs } from 'file-saver'; 17 | import { injectable } from 'inversify'; 18 | import { ExportSvgAction, IActionHandler } from '@eclipse-glsp/sprotty'; 19 | 20 | /** 21 | * The default handler for {@link ExportSvgAction}s. This generic handler can be used in 22 | * any GLSP project independent of the target platform. However, platform integration modules typically 23 | * * this handler is rebound to an application specific handler in platform integration modules 24 | * (e.g. the Theia integration) 25 | */ 26 | @injectable() 27 | export class ExportSvgActionHandler implements IActionHandler { 28 | handle(action: ExportSvgAction): void { 29 | const blob = new Blob([action.svg], { type: 'text/plain;charset=utf-8' }); 30 | saveAs(blob, 'diagram.svg'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/client/src/features/search-palette/search-palette-key-listener.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023-2025 Business Informatics Group (TU Wien) 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 | 17 | import { Action, GModelElement, KeyListener, matchesKeystroke, SetUIExtensionVisibilityAction } from '@eclipse-glsp/sprotty'; 18 | import { injectable } from 'inversify'; 19 | import { SearchAutocompletePalette } from './search-palette'; 20 | 21 | @injectable() 22 | export class SearchPaletteKeyListener extends KeyListener { 23 | override keyDown(element: GModelElement, event: KeyboardEvent): Action[] { 24 | if (matchesKeystroke(event, 'KeyF', 'ctrlCmd')) { 25 | return [ 26 | SetUIExtensionVisibilityAction.create({ 27 | extensionId: SearchAutocompletePalette.ID, 28 | visible: true 29 | }) 30 | ]; 31 | } 32 | return []; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/client/src/features/accessibility/edge-autocomplete/action.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023 Business Informatics Group (TU Wien) 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 { Action, hasObjectProp, hasStringProp } from '@eclipse-glsp/sprotty'; 17 | 18 | export interface SetEdgeTargetSelectionAction extends Action { 19 | kind: typeof SetEdgeTargetSelectionAction.KIND; 20 | elementId: string; 21 | context: string; 22 | } 23 | 24 | export namespace SetEdgeTargetSelectionAction { 25 | export const KIND = 'setEdgeTargetSelectionAction'; 26 | 27 | export function is(object: any): object is SetEdgeTargetSelectionAction { 28 | return Action.hasKind(object, KIND) && hasStringProp(object, 'elementId') && hasObjectProp(object, 'context'); 29 | } 30 | 31 | export function create(elementId: string, context: string): SetEdgeTargetSelectionAction { 32 | return { kind: KIND, elementId, context }; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/client/src/views/compartments.tsx: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2021-2025 EclipseSource 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 | /** @jsx svg */ 17 | import { Dimension, GCompartment, RenderingContext, ShapeView, svg } from '@eclipse-glsp/sprotty'; 18 | import { injectable } from 'inversify'; 19 | import { VNode } from 'snabbdom'; 20 | 21 | @injectable() 22 | export class StructureCompartmentView extends ShapeView { 23 | render(model: Readonly, context: RenderingContext): VNode | undefined { 24 | if (!this.isVisible(model, context)) { 25 | return undefined; 26 | } 27 | const rectSize = Dimension.isValid(model.size) ? model.size : Dimension.ZERO; 28 | return ( 29 | 30 | 31 | {context.renderChildren(model)} 32 | 33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/workflow-standalone/src/url-parameters.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2023 EclipseSource 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 | 17 | export function getParameters(): Record { 18 | let search = window.location.search.substring(1); 19 | const result: Record = {}; 20 | while (search.length > 0) { 21 | const nextParamIndex = search.indexOf('&'); 22 | let param: string; 23 | if (nextParamIndex < 0) { 24 | param = search; 25 | search = ''; 26 | } else { 27 | param = search.substring(0, nextParamIndex); 28 | search = search.substring(nextParamIndex + 1); 29 | } 30 | const valueIndex = param.indexOf('='); 31 | if (valueIndex > 0 && valueIndex < param.length - 1) { 32 | result[param.substring(0, valueIndex)] = decodeURIComponent(param.substring(valueIndex + 1)); 33 | } 34 | } 35 | return result; 36 | } 37 | -------------------------------------------------------------------------------- /packages/client/src/base/view/view-registry.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2023 EclipseSource 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 { IView, ViewRegistry } from '@eclipse-glsp/sprotty'; 17 | import { injectable } from 'inversify'; 18 | 19 | /** 20 | * Allows to look up the IView for a given GModelElement based on its type. 21 | */ 22 | @injectable() 23 | export class GViewRegistry extends ViewRegistry { 24 | /* Overwrite the `register` method to only log an info message (instead of thrown an error) if 25 | an existing registration is overwritten */ 26 | override register(key: string, instance: IView): void { 27 | if (key === undefined) { 28 | throw new Error('Key is undefined'); 29 | } 30 | if (this.hasKey(key)) { 31 | // do not throw error but log overwriting 32 | console.log(`View instance for type '${key}' will be overwritten.`); 33 | } 34 | this.elements.set(key, instance); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/client/src/features/layout/layout-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2025 EclipseSource 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 { FeatureModule, TriggerLayoutAction, configureActionHandler } from '@eclipse-glsp/sprotty'; 17 | import { 18 | AlignElementsAction, 19 | AlignElementsActionHandler, 20 | ResizeElementsAction, 21 | ResizeElementsActionHandler 22 | } from './layout-elements-action'; 23 | import { TriggerLayoutActionHandler } from './trigger-layout-action-handler'; 24 | 25 | export const layoutModule = new FeatureModule( 26 | (bind, _unbind, isBound) => { 27 | const context = { bind, isBound }; 28 | configureActionHandler(context, ResizeElementsAction.KIND, ResizeElementsActionHandler); 29 | configureActionHandler(context, AlignElementsAction.KIND, AlignElementsActionHandler); 30 | configureActionHandler(context, TriggerLayoutAction.KIND, TriggerLayoutActionHandler); 31 | }, 32 | { featureId: Symbol('layout') } 33 | ); 34 | -------------------------------------------------------------------------------- /packages/client/src/features/label-edit-ui/label-edit-ui.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 EclipseSource 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 { EditLabelUI } from '@eclipse-glsp/sprotty'; 17 | import { injectable } from 'inversify'; 18 | import { CSS_HIDDEN_EXTENSION_CLASS, CSS_UI_EXTENSION_CLASS } from '../../base/ui-extension/ui-extension'; 19 | 20 | @injectable() 21 | export class GlspEditLabelUI extends EditLabelUI { 22 | protected override initializeContents(containerElement: HTMLElement): void { 23 | super.initializeContents(containerElement); 24 | containerElement.classList.add(CSS_UI_EXTENSION_CLASS); 25 | } 26 | 27 | protected override setContainerVisible(visible: boolean): void { 28 | if (visible) { 29 | this.containerElement?.classList.remove(CSS_HIDDEN_EXTENSION_CLASS); 30 | this.editControl.focus(); 31 | } else { 32 | this.containerElement?.classList.add(CSS_HIDDEN_EXTENSION_CLASS); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/workflow-standalone/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "workflow-standalone", 3 | "version": "2.6.0-next", 4 | "private": true, 5 | "description": "Standalone browser-app for the Workflow example", 6 | "homepage": "https://www.eclipse.org/glsp/", 7 | "bugs": "https://github.com/eclipse-glsp/glsp/issues", 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/eclipse-glsp/glsp-client.git" 11 | }, 12 | "author": { 13 | "name": "Eclipse GLSP" 14 | }, 15 | "contributors": [ 16 | { 17 | "name": "Eclipse GLSP Project", 18 | "email": "glsp-dev@eclipse.org", 19 | "url": "https://projects.eclipse.org/projects/ecd.glsp" 20 | } 21 | ], 22 | "main": "lib", 23 | "types": "lib", 24 | "scripts": { 25 | "build": "yarn compile && yarn bundle", 26 | "bundle": "webpack", 27 | "clean": "rimraf lib *.tsbuildinfo app/bundle.js app/bundle.js.map app/css", 28 | "compile": "tsc -b", 29 | "lint": "eslint --ext .ts,.tsx ./src", 30 | "start:exampleServer": "yarn ts-node ./scripts/start-example-server.ts", 31 | "watch": "tsc -w && yarn watch:bundle", 32 | "watch:bundle": "webpack -w" 33 | }, 34 | "dependencies": { 35 | "@eclipse-glsp-examples/workflow-glsp": "2.6.0-next", 36 | "@eclipse-glsp/client": "2.6.0-next", 37 | "inversify-logger-middleware": "^3.1.0" 38 | }, 39 | "devDependencies": { 40 | "@types/tar": "6.1.5", 41 | "circular-dependency-plugin": "^5.2.2", 42 | "css-loader": "^6.7.1", 43 | "inversify": "^6.1.3", 44 | "path-browserify": "^1.0.1", 45 | "process": "^0.11.10", 46 | "source-map-loader": "^4.0.0", 47 | "style-loader": "^3.3.1", 48 | "webpack": "^5.74.0", 49 | "webpack-cli": "^4.10.0" 50 | }, 51 | "publishConfig": { 52 | "access": "public" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /packages/client/src/features/accessibility/focus-tracker/focus-tracker-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023-2024 Business Informatics Group (TU Wien) 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 | 17 | import { BindingContext, FeatureModule, TYPES, bindAsService } from '@eclipse-glsp/sprotty'; 18 | import { FocusTrackerTool } from './focus-tracker-tool'; 19 | 20 | /** 21 | * Handles actions for tracking the focus of the cursor. 22 | */ 23 | 24 | export const focusTrackerModule = new FeatureModule( 25 | (bind, unbind, isBound, rebind) => { 26 | const context = { bind, unbind, isBound, rebind }; 27 | configureFocusTrackerTool(context); 28 | }, 29 | { featureId: Symbol('focusTracker') } 30 | ); 31 | 32 | export function configureFocusTrackerTool(context: BindingContext): void { 33 | bindAsService(context, TYPES.IDefaultTool, FocusTrackerTool); 34 | } 35 | 36 | export { 37 | /** Deprecated use {@link focusTrackerModule} instead */ 38 | focusTrackerModule as glspFocusTrackerModule 39 | }; 40 | -------------------------------------------------------------------------------- /packages/client/src/base/view/key-tool.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023-2024 EclipseSource 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 { Disposable, KeyListener, KeyTool, LazyInjector, MaybePromise, TYPES } from '@eclipse-glsp/sprotty'; 17 | import { inject, injectable } from 'inversify'; 18 | import { IDiagramStartup } from '../model/diagram-loader'; 19 | 20 | @injectable() 21 | export class GLSPKeyTool extends KeyTool implements IDiagramStartup { 22 | @inject(LazyInjector) 23 | protected lazyInjector: LazyInjector; 24 | 25 | constructor(@inject(TYPES.EmptyArray) keyListeners: KeyListener[]) { 26 | super(keyListeners); 27 | } 28 | 29 | registerListener(keyListener: KeyListener): Disposable { 30 | super.register(keyListener); 31 | return Disposable.create(() => this.deregister(keyListener)); 32 | } 33 | 34 | preLoadDiagram(): MaybePromise { 35 | this.lazyInjector.getAll(TYPES.KeyListener).forEach(listener => this.register(listener)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /packages/client/src/features/tool-palette/tool-palette-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 { bindAsService, configureActionHandler, FeatureModule, SetModelAction, TYPES, UpdateModelAction } from '@eclipse-glsp/sprotty'; 17 | import '../../../css/tool-palette.css'; 18 | import { EnableDefaultToolsAction } from '../../base/tool-manager/tool'; 19 | import { ToolPalette } from './tool-palette'; 20 | 21 | export const toolPaletteModule = new FeatureModule( 22 | (bind, _unbind, isBound, _rebind) => { 23 | bindAsService(bind, TYPES.IUIExtension, ToolPalette); 24 | bind(TYPES.IDiagramStartup).toService(ToolPalette); 25 | configureActionHandler({ bind, isBound }, EnableDefaultToolsAction.KIND, ToolPalette); 26 | configureActionHandler({ bind, isBound }, UpdateModelAction.KIND, ToolPalette); 27 | configureActionHandler({ bind, isBound }, SetModelAction.KIND, ToolPalette); 28 | }, 29 | { featureId: Symbol('toolPalette') } 30 | ); 31 | -------------------------------------------------------------------------------- /packages/client/src/features/debug/debug-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 Axon Ivy AG 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 | 17 | import { FeatureModule, TYPES, bindAsService, configureActionHandler, configureCommand } from '@eclipse-glsp/sprotty'; 18 | import '../../../css/debug.css'; 19 | import { DebugBoundsDecorator } from './debug-bounds-decorator'; 20 | import { DebugManager } from './debug-manager'; 21 | import { EnableDebugModeAction, EnableDebugModeCommand } from './debug-model'; 22 | 23 | export const debugModule = new FeatureModule( 24 | (bind, unbind, isBound, rebind) => { 25 | const context = { bind, unbind, isBound, rebind }; 26 | 27 | configureCommand(context, EnableDebugModeCommand); 28 | 29 | bindAsService(context, TYPES.IDebugManager, DebugManager); 30 | configureActionHandler(context, EnableDebugModeAction.KIND, DebugManager); 31 | 32 | bindAsService(context, TYPES.IVNodePostprocessor, DebugBoundsDecorator); 33 | }, 34 | { featureId: Symbol('debug') } 35 | ); 36 | -------------------------------------------------------------------------------- /packages/protocol/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@eclipse-glsp/protocol", 3 | "version": "2.6.0-next", 4 | "description": "The protocol definition for client-server communication in GLSP", 5 | "keywords": [ 6 | "eclipse", 7 | "graphics", 8 | "diagram", 9 | "modeling", 10 | "visualization", 11 | "glsp", 12 | "diagram editor" 13 | ], 14 | "homepage": "https://www.eclipse.org/glsp/", 15 | "bugs": "https://github.com/eclipse-glsp/glsp/issues", 16 | "repository": { 17 | "type": "git", 18 | "url": "https://github.com/eclipse-glsp/glsp-client.git" 19 | }, 20 | "license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)", 21 | "author": { 22 | "name": "Eclipse GLSP" 23 | }, 24 | "contributors": [ 25 | { 26 | "name": "Eclipse GLSP Project", 27 | "email": "glsp-dev@eclipse.org", 28 | "url": "https://projects.eclipse.org/projects/ecd.glsp" 29 | } 30 | ], 31 | "main": "lib/index", 32 | "types": "lib/index", 33 | "files": [ 34 | "lib", 35 | "src" 36 | ], 37 | "scripts": { 38 | "build": "tsc -b", 39 | "clean": "rimraf lib *.tsbuildinfo coverage .nyc_output", 40 | "generate:index": "glsp generateIndex src/di src -f -s", 41 | "lint": "eslint --ext .ts,.tsx ./src", 42 | "test": "mocha --config ../../.mocharc \"./src/**/*.spec.?(ts|tsx)\"", 43 | "test:ci": "yarn test --reporter mocha-ctrf-json-reporter", 44 | "test:coverage": "nyc yarn test", 45 | "watch": "tsc -w" 46 | }, 47 | "dependencies": { 48 | "sprotty-protocol": "1.4.0", 49 | "uuid": "~10.0.0", 50 | "vscode-jsonrpc": "8.2.0" 51 | }, 52 | "devDependencies": { 53 | "@types/uuid": "~9.0.8" 54 | }, 55 | "peerDependencies": { 56 | "inversify": "^6.1.3" 57 | }, 58 | "publishConfig": { 59 | "access": "public" 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /packages/client/src/features/command-palette/command-palette-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 { CommandPaletteActionProviderRegistry, FeatureModule, TYPES, bindAsService } from '@eclipse-glsp/sprotty'; 17 | import '../../../css/command-palette.css'; 18 | import { GlspCommandPalette } from './command-palette'; 19 | import { CommandPaletteTool } from './command-palette-tool'; 20 | import { ServerCommandPaletteActionProvider } from './server-command-palette-provider'; 21 | 22 | export const commandPaletteModule = new FeatureModule( 23 | bind => { 24 | bindAsService(bind, TYPES.IUIExtension, GlspCommandPalette); 25 | bind(TYPES.ICommandPaletteActionProviderRegistry).to(CommandPaletteActionProviderRegistry).inSingletonScope(); 26 | bindAsService(bind, TYPES.ICommandPaletteActionProvider, ServerCommandPaletteActionProvider); 27 | bindAsService(bind, TYPES.IDefaultTool, CommandPaletteTool); 28 | }, 29 | { featureId: Symbol('commandPalette') } 30 | ); 31 | -------------------------------------------------------------------------------- /packages/client/src/features/grid/grid-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023-2025 Axon Ivy AG 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 | 17 | import { FeatureModule, TYPES, bindAsService, configureActionHandler, configureCommand } from '@eclipse-glsp/sprotty'; 18 | import '../../../css/grid.css'; 19 | import { Grid } from './grid'; 20 | import { GridManager } from './grid-manager'; 21 | import { ShowGridAction, ShowGridCommand } from './grid-model'; 22 | import { GridSnapper } from './grid-snapper'; 23 | 24 | export const gridModule = new FeatureModule( 25 | (bind, unbind, isBound, rebind) => { 26 | const context = { bind, unbind, isBound, rebind }; 27 | 28 | bind(TYPES.Grid).toConstantValue(Grid.DEFAULT); 29 | 30 | configureCommand(context, ShowGridCommand); 31 | 32 | bindAsService(context, TYPES.IGridManager, GridManager); 33 | configureActionHandler(context, ShowGridAction.KIND, GridManager); 34 | 35 | bind(TYPES.ISnapper).to(GridSnapper); 36 | }, 37 | { featureId: Symbol('grid') } 38 | ); 39 | -------------------------------------------------------------------------------- /packages/client/src/base/focus/focus-state-change-action.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2021-2023 EclipseSource 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 { Action, hasBooleanProp } from '@eclipse-glsp/sprotty'; 17 | 18 | /** 19 | * A `FocusStateChangedAction` is dispatched by the client whenever the 20 | * diagram focus changes (i.e. focus loss or focus gain). 21 | */ 22 | export interface FocusStateChangedAction extends Action { 23 | kind: typeof FocusStateChangedAction.KIND; 24 | /** 25 | * The new focus state of the diagram. 26 | */ 27 | hasFocus: boolean; 28 | } 29 | 30 | export namespace FocusStateChangedAction { 31 | export const KIND = 'focusStateChanged'; 32 | 33 | export function is(object: any): object is FocusStateChangedAction { 34 | return Action.hasKind(object, KIND) && hasBooleanProp(object, 'hasFocus'); 35 | } 36 | 37 | export function create(hasFocus = true): FocusStateChangedAction { 38 | return { 39 | kind: KIND, 40 | hasFocus 41 | }; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /packages/protocol/src/client-server-protocol/jsonrpc/worker-connection-provider.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023-2024 EclipseSource 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 { BrowserMessageReader, BrowserMessageWriter, MessageConnection, createMessageConnection } from 'vscode-jsonrpc/browser'; 17 | import { GLSPConnectionHandler } from './ws-connection-provider'; 18 | 19 | export class GLSPWebWorkerProvider { 20 | protected worker: Worker; 21 | 22 | constructor(protected url: string) {} 23 | 24 | protected createWebWorker(url: string): Worker { 25 | return new Worker(url); 26 | } 27 | 28 | listen(handler: GLSPConnectionHandler): MessageConnection { 29 | this.worker = this.createWebWorker(this.url); 30 | const wwConnection = createMessageConnection(new BrowserMessageReader(this.worker), new BrowserMessageWriter(this.worker)); 31 | 32 | handler.logger?.warn('GLSPWebWorkerProvider Initializing!'); 33 | handler.onConnection?.(wwConnection); 34 | 35 | return wwConnection; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /packages/client/src/features/layout/trigger-layout-action-handler.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2025 EclipseSource 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 { Action, IActionHandler, ICommand, LayoutOperation, TriggerLayoutAction } from '@eclipse-glsp/sprotty'; 17 | import { inject, injectable } from 'inversify'; 18 | import { EditorContextService } from '../../base/editor-context-service'; 19 | 20 | /** 21 | * The handler for {@link TriggerLayoutAction}s. 22 | * This handler provides some client-level information to the layout operation. 23 | */ 24 | @injectable() 25 | export class TriggerLayoutActionHandler implements IActionHandler { 26 | @inject(EditorContextService) protected editorContext: EditorContextService; 27 | 28 | handle(action: TriggerLayoutAction): ICommand | Action | void { 29 | return LayoutOperation.create(this.editorContext.get().selectedElementIds, { 30 | args: action.args, 31 | canvasBounds: this.editorContext.canvasBounds, 32 | viewport: this.editorContext.viewportData 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/client/css/keyboard.css: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023 Business Informatics Group (TU Wien) 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 | 17 | .grid-container { 18 | display: grid; 19 | position: absolute; 20 | top: 0.5rem; 21 | bottom: 0.5rem; 22 | left: 0.5rem; 23 | right: 0.5rem; 24 | grid-template-columns: auto auto auto; 25 | } 26 | 27 | .grid-container.grid-visible { 28 | opacity: 0.7; 29 | visibility: visible; 30 | } 31 | 32 | .grid-container.grid-hidden { 33 | opacity: 0; 34 | visibility: hidden; 35 | } 36 | 37 | .grid-container:focus { 38 | opacity: 1; 39 | } 40 | 41 | .grid-item { 42 | border: 1px solid rgba(0, 0, 0, 0.6); 43 | padding: 1rem; 44 | /* Fix overlapping borders */ 45 | margin: 0 -1px -1px 0; 46 | } 47 | 48 | .grid-item-number { 49 | border-radius: 50%; 50 | width: 1.5rem; 51 | height: 1.5rem; 52 | padding: 0.5rem; 53 | 54 | background: #fff; 55 | border: 2px solid #666; 56 | color: black; 57 | text-align: center; 58 | 59 | font: 60 | bold 1.3rem Arial, 61 | sans-serif; 62 | } 63 | -------------------------------------------------------------------------------- /packages/client/src/features/label-edit/edit-label-tool.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2020-2023 EclipseSource 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 { injectable } from 'inversify'; 17 | import { EditLabelKeyListener, EditLabelMouseListener, KeyListener, MouseListener } from '@eclipse-glsp/sprotty'; 18 | import { BaseEditTool } from '../tools/base-tools'; 19 | 20 | @injectable() 21 | export class DirectLabelEditTool extends BaseEditTool { 22 | static readonly ID = 'glsp.direct-label-edit-tool'; 23 | 24 | get id(): string { 25 | return DirectLabelEditTool.ID; 26 | } 27 | 28 | protected createEditLabelMouseListener(): MouseListener { 29 | return new EditLabelMouseListener(); 30 | } 31 | 32 | protected createEditLabelKeyListener(): KeyListener { 33 | return new EditLabelKeyListener(); 34 | } 35 | 36 | enable(): void { 37 | this.toDisposeOnDisable.push( 38 | this.mouseTool.registerListener(this.createEditLabelMouseListener()), 39 | this.keyTool.registerListener(this.createEditLabelKeyListener()) 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /packages/client/src/base/shortcuts/shortcuts-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023-2025 Business Informatics Group (TU Wien) 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 | 17 | import { bindAsService, FeatureModule, TYPES } from '@eclipse-glsp/sprotty'; 18 | import '../../../css/key-shortcut.css'; 19 | import { AvailableShortcutsUIExtension } from './available-shortcuts-extension'; 20 | import { AvailableShortcutsTool } from './available-shortcuts-tool'; 21 | 22 | /** 23 | * Feature module that is intended for the standalone deployment of GLSP (i.e. plain webapp) 24 | * When integrated into an application frame (e.g Theia/VS Code) this module is typically omitted and/or replaced 25 | * with an application native module. 26 | */ 27 | export const standaloneShortcutsModule = new FeatureModule( 28 | (bind, unbind, isBound, rebind) => { 29 | const context = { bind, unbind, isBound, rebind }; 30 | 31 | bindAsService(context, TYPES.IDefaultTool, AvailableShortcutsTool); 32 | bindAsService(context, TYPES.IUIExtension, AvailableShortcutsUIExtension); 33 | }, 34 | { featureId: Symbol('standaloneShortcuts') } 35 | ); 36 | -------------------------------------------------------------------------------- /packages/client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@eclipse-glsp/client", 3 | "version": "2.6.0-next", 4 | "description": "A sprotty-based client for GLSP", 5 | "keywords": [ 6 | "eclipse", 7 | "graphics", 8 | "diagram", 9 | "modeling", 10 | "visualization", 11 | "glsp", 12 | "diagram editor" 13 | ], 14 | "homepage": "https://www.eclipse.org/glsp/", 15 | "bugs": "https://github.com/eclipse-glsp/glsp/issues", 16 | "repository": { 17 | "type": "git", 18 | "url": "https://github.com/eclipse-glsp/glsp-client.git" 19 | }, 20 | "license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)", 21 | "author": { 22 | "name": "Eclipse GLSP" 23 | }, 24 | "contributors": [ 25 | { 26 | "name": "Eclipse GLSP Project", 27 | "email": "glsp-dev@eclipse.org", 28 | "url": "https://projects.eclipse.org/projects/ecd.glsp" 29 | } 30 | ], 31 | "main": "lib/index", 32 | "types": "lib/index", 33 | "files": [ 34 | "lib", 35 | "src", 36 | "css" 37 | ], 38 | "scripts": { 39 | "build": "tsc -b", 40 | "clean": "rimraf lib *.tsbuildinfo coverage .nyc_output", 41 | "generate:index": "glsp generateIndex src -f -s", 42 | "lint": "eslint --ext .ts,.tsx ./src", 43 | "test": "mocha --config ../../.mocharc \"./src/**/*.spec.?(ts|tsx)\"", 44 | "test:ci": "yarn test --reporter mocha-ctrf-json-reporter", 45 | "test:coverage": "nyc yarn test", 46 | "watch": "tsc -w" 47 | }, 48 | "dependencies": { 49 | "@eclipse-glsp/sprotty": "2.6.0-next", 50 | "autocompleter": "^9.1.2", 51 | "file-saver": "^2.0.5", 52 | "lodash": "4.17.21", 53 | "snabbdom": "~3.5.1", 54 | "vscode-jsonrpc": "8.2.0" 55 | }, 56 | "devDependencies": { 57 | "@types/file-saver": "^2.0.5", 58 | "@types/lodash": "4.14.191" 59 | }, 60 | "peerDependencies": { 61 | "inversify": "^6.1.3" 62 | }, 63 | "publishConfig": { 64 | "access": "public" 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /packages/client/src/features/hints/model.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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, GModelElementSchema } from '@eclipse-glsp/sprotty'; 17 | 18 | export const containerFeature = Symbol('containable'); 19 | 20 | /** 21 | * Feature extension interface for {@link containerFeature}. 22 | */ 23 | export interface Containable { 24 | isContainableElement(input: GModelElement | GModelElementSchema | string): boolean; 25 | } 26 | 27 | /** 28 | * A union type for all elements that can contain other elements. 29 | */ 30 | export type ContainerElement = GModelElement & Containable; 31 | 32 | export function isContainable(element: GModelElement): element is ContainerElement { 33 | return element.hasFeature(containerFeature); 34 | } 35 | 36 | export const reparentFeature = Symbol('reparentFeature'); 37 | 38 | /** 39 | * Feature extension interface for {@link reparentFeature}. 40 | */ 41 | export interface Reparentable {} 42 | 43 | export function isReparentable(element: GModelElement): element is GModelElement & Reparentable { 44 | return element.hasFeature(reparentFeature); 45 | } 46 | -------------------------------------------------------------------------------- /examples/workflow-standalone/src/features/direct-task-editing/task-editor-key-listener.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 EclipseSource 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 { TaskEditor } from '@eclipse-glsp-examples/workflow-glsp'; 17 | import { 18 | Action, 19 | EditorContextService, 20 | GModelRoot, 21 | KeyListener, 22 | SetUIExtensionVisibilityAction, 23 | matchesKeystroke 24 | } from '@eclipse-glsp/client'; 25 | import { inject, injectable } from 'inversify'; 26 | 27 | @injectable() 28 | export class TaskEditorKeyListener extends KeyListener { 29 | @inject(EditorContextService) 30 | protected editorContext: EditorContextService; 31 | 32 | override keyDown(_element: GModelRoot, event: KeyboardEvent): Action[] { 33 | if (matchesKeystroke(event, 'F2', 'ctrlCmd')) { 34 | return [ 35 | SetUIExtensionVisibilityAction.create({ 36 | extensionId: TaskEditor.ID, 37 | visible: true, 38 | contextElementsId: [this.editorContext.selectedElements[0].id] 39 | }) 40 | ]; 41 | } 42 | return []; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/client/src/features/tools/node-creation/insert-indicator.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 EclipseSource 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 | 17 | import { Args, Dimension, FeatureSet, GNode, boundsFeature, createFeatureSet, moveFeature } from '@eclipse-glsp/sprotty'; 18 | import { v4 as uuid } from 'uuid'; 19 | import { ArgsAware, argsFeature } from '../../../base/args-feature'; 20 | 21 | export const ARG_LENGTH = 'length'; 22 | 23 | export class InsertIndicator extends GNode implements ArgsAware { 24 | static override readonly DEFAULT_FEATURES = [boundsFeature, moveFeature, argsFeature]; 25 | 26 | static TYPE = 'node:insert-indicator'; 27 | 28 | override id: string = uuid(); 29 | override type: string = InsertIndicator.TYPE; 30 | override features?: FeatureSet = createFeatureSet(InsertIndicator.DEFAULT_FEATURES); 31 | override cssClasses: string[] = ['insert-indicator', 'sprotty-node']; 32 | override size: Dimension = Dimension.ZERO; 33 | args: Args = {}; 34 | 35 | constructor(length?: number) { 36 | super(); 37 | if (length) { 38 | this.args = { [ARG_LENGTH]: length }; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /.github/workflows/e2e.yml: -------------------------------------------------------------------------------- 1 | name: 'E2E' 2 | 3 | concurrency: 4 | group: playwright-${{ github.ref }} 5 | cancel-in-progress: true 6 | on: 7 | workflow_dispatch: 8 | push: 9 | branches: [master] 10 | pull_request: 11 | branches: [master] 12 | 13 | jobs: 14 | playwright: 15 | name: E2E Tests 16 | timeout-minutes: 120 17 | runs-on: ubuntu-latest 18 | env: 19 | STANDALONE_URL: 'file://${{ github.workspace }}/glsp-client/examples/workflow-standalone/app/diagram.html' 20 | GLSP_SERVER_PORT: '8081' 21 | GLSP_SERVER_PLAYWRIGHT_MANAGED: 'true' 22 | GLSP_WEBSOCKET_PATH: 'workflow' 23 | THEIA_URL: 'http://localhost:3000' 24 | VSCODE_VSIX_ID: 'eclipse-glsp.workflow-vscode-example' 25 | VSCODE_VSIX_PATH: '${{ github.workspace }}/.../vscode-example-2.3.0-next.vsix' 26 | GLSP_SERVER_DEBUG: 'true' 27 | GLSP_SERVER_TYPE: 'node' 28 | 29 | steps: 30 | - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 31 | with: 32 | path: 'glsp-client' 33 | - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 34 | with: 35 | repository: 'eclipse-glsp/glsp-playwright' 36 | path: 'glsp-playwright' 37 | - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 38 | with: 39 | node-version: '20' 40 | - name: Install dependencies 41 | run: | 42 | cd glsp-client 43 | yarn 44 | cd ../glsp-playwright 45 | yarn 46 | - name: Run Playwright tests 47 | id: run_playwright_tests 48 | run: | 49 | cd glsp-playwright 50 | yarn test:standalone 51 | - name: Upload Playwright report 52 | uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 53 | if: always() 54 | with: 55 | name: playwright-report 56 | path: glsp-playwright/examples/workflow-test/playwright-report/ 57 | -------------------------------------------------------------------------------- /packages/client/src/features/navigation/navigation-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2020-2024 EclipseSource 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 { FeatureModule, NavigateToExternalTargetAction, NavigateToTargetAction, configureActionHandler } from '@eclipse-glsp/sprotty'; 17 | import { NavigateAction, NavigationActionHandler, ProcessNavigationArgumentsAction } from './navigation-action-handler'; 18 | import { NavigationTargetResolver } from './navigation-target-resolver'; 19 | 20 | export const navigationModule = new FeatureModule( 21 | (bind, _unbind, isBound) => { 22 | bind(NavigationTargetResolver).toSelf().inSingletonScope(); 23 | bind(NavigationActionHandler).toSelf().inSingletonScope(); 24 | configureActionHandler({ bind, isBound }, NavigateAction.KIND, NavigationActionHandler); 25 | configureActionHandler({ bind, isBound }, NavigateToTargetAction.KIND, NavigationActionHandler); 26 | configureActionHandler({ bind, isBound }, ProcessNavigationArgumentsAction.KIND, NavigationActionHandler); 27 | configureActionHandler({ bind, isBound }, NavigateToExternalTargetAction.KIND, NavigationActionHandler); 28 | }, 29 | { featureId: Symbol('navigation') } 30 | ); 31 | -------------------------------------------------------------------------------- /packages/client/src/features/command-palette/command-palette-tool.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2023 EclipseSource 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 { inject, injectable, postConstruct } from 'inversify'; 17 | import { CommandPaletteKeyListener, KeyListener, KeyTool } from '@eclipse-glsp/sprotty'; 18 | import { Tool } from '../../base/tool-manager/tool'; 19 | 20 | @injectable() 21 | export class CommandPaletteTool implements Tool { 22 | static ID = 'glsp.command-palette-tool'; 23 | 24 | protected commandPaletteKeyListener: KeyListener; 25 | @inject(KeyTool) protected keyTool: KeyTool; 26 | 27 | @postConstruct() 28 | protected postConstruct(): void { 29 | this.commandPaletteKeyListener = this.createCommandPaletteKeyListener(); 30 | } 31 | 32 | get id(): string { 33 | return CommandPaletteTool.ID; 34 | } 35 | 36 | enable(): void { 37 | this.keyTool.register(this.commandPaletteKeyListener); 38 | } 39 | 40 | disable(): void { 41 | this.keyTool.deregister(this.commandPaletteKeyListener); 42 | } 43 | 44 | protected createCommandPaletteKeyListener(): KeyListener { 45 | return new CommandPaletteKeyListener(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /packages/client/src/features/select/select-feedback-command.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2023 EclipseSource 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 { inject, injectable } from 'inversify'; 17 | import { Command, CommandExecutionContext, GModelRoot, SelectAction, SprottySelectCommand, TYPES } from '@eclipse-glsp/sprotty'; 18 | import { SelectFeedbackAction } from '../../base/selection-service'; 19 | 20 | @injectable() 21 | export class SelectFeedbackCommand extends Command { 22 | static readonly KIND = SelectFeedbackAction.KIND; 23 | private sprottySelectCommand: SprottySelectCommand; 24 | 25 | constructor(@inject(TYPES.Action) public action: SelectFeedbackAction) { 26 | super(); 27 | this.sprottySelectCommand = new SprottySelectCommand({ ...action, kind: SelectAction.KIND }); 28 | } 29 | 30 | execute(context: CommandExecutionContext): GModelRoot { 31 | return this.sprottySelectCommand.execute(context); 32 | } 33 | 34 | undo(context: CommandExecutionContext): GModelRoot { 35 | return this.sprottySelectCommand.undo(context); 36 | } 37 | 38 | redo(context: CommandExecutionContext): GModelRoot { 39 | return this.sprottySelectCommand.redo(context); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /packages/client/src/features/tools/marquee-selection/view.tsx: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2021-2024 EclipseSource 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 | /** @jsx svg */ 17 | import { RectangularNodeView, RenderingContext, svg } from '@eclipse-glsp/sprotty'; 18 | import { injectable } from 'inversify'; 19 | import { VNode } from 'snabbdom'; 20 | import { MarqueeNode } from './model'; 21 | 22 | @injectable() 23 | export class MarqueeView extends RectangularNodeView { 24 | override render(node: MarqueeNode, context: RenderingContext): VNode { 25 | const graph = ( 26 | 27 | 37 | 38 | ); 39 | return graph; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /packages/client/src/features/viewport/zoom-viewport-action.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024-2025 EclipseSource 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 | 17 | import { Action } from '@eclipse-glsp/sprotty'; 18 | 19 | export interface ZoomFactors { 20 | in: number; 21 | out: number; 22 | } 23 | 24 | export namespace ZoomFactors { 25 | export const DEFAULT = { in: 1.2, out: 0.8 }; 26 | } 27 | 28 | /** 29 | * Zooms the diagram canvas. 30 | * If `elementIds` is provided, the zoom is centered on the elements with the given identifiers. 31 | */ 32 | export interface ZoomAction extends Action { 33 | kind: typeof ZoomAction.KIND; 34 | /** 35 | * Specifies the elements to be zoomed in/out 36 | */ 37 | elementIds?: string[]; 38 | /** 39 | * Specifies the amount by which the viewport should be zoomed 40 | */ 41 | zoomFactor: number; 42 | } 43 | 44 | export namespace ZoomAction { 45 | export const KIND = 'zoom'; 46 | 47 | export function is(object: any): object is ZoomAction { 48 | return Action.hasKind(object, KIND); 49 | } 50 | 51 | export function create(options: { elementIds?: string[]; zoomFactor: number }): ZoomAction { 52 | return { kind: KIND, ...options }; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /packages/client/src/features/accessibility/toast/toast-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023-2024 Business Informatics Group (TU Wien) 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 { bindAsService, BindingContext, configureActionHandler, FeatureModule, TYPES } from '@eclipse-glsp/sprotty'; 17 | import '../../../../css/toast.css'; 18 | import { HideToastAction, ShowToastMessageAction } from './toast-handler'; 19 | import { Toast } from './toast-tool'; 20 | 21 | /** 22 | * Handles toast/user notification actions. 23 | */ 24 | 25 | export const toastModule = new FeatureModule( 26 | (bind, unbind, isBound, rebind) => { 27 | const context = { bind, unbind, isBound, rebind }; 28 | configureToastTool(context); 29 | }, 30 | { featureId: Symbol('toast') } 31 | ); 32 | 33 | export function configureToastTool(context: BindingContext): void { 34 | bindAsService(context, TYPES.IUIExtension, Toast); 35 | context.bind(TYPES.IDiagramStartup).toService(Toast); 36 | configureActionHandler(context, ShowToastMessageAction.KIND, Toast); 37 | configureActionHandler(context, HideToastAction.KIND, Toast); 38 | } 39 | 40 | export { 41 | /** Deprecated use {@link toastModule} instead */ 42 | toastModule as glspToastModule 43 | }; 44 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "parent", 3 | "version": "2.6.0-next", 4 | "private": true, 5 | "workspaces": [ 6 | "packages/*", 7 | "examples/*" 8 | ], 9 | "scripts": { 10 | "all": "yarn clean && yarn install && yarn lint && yarn test", 11 | "build": "yarn compile && yarn bundle", 12 | "bundle": "yarn standalone bundle", 13 | "check:headers": "glsp checkHeaders . -t lastCommit", 14 | "check:pr": "yarn all && yarn format:check && yarn check:headers", 15 | "clean": "lerna run clean && rimraf coverage .nyc_output", 16 | "compile": "tsc -b", 17 | "format": "prettier --write .", 18 | "format:check": "prettier --check .", 19 | "generate:index": "lerna run generate:index && yarn lint:fix", 20 | "lint": "eslint --ext .ts,.tsx .", 21 | "lint:ci": "yarn lint --output-file eslint_report.json --format json", 22 | "lint:fix": " yarn lint --fix", 23 | "prepare": "yarn build", 24 | "publish:latest": "lerna publish from-package --no-git-reset -y", 25 | "publish:next": "lerna publish preminor --exact --canary --preid next --dist-tag next --no-git-reset --no-git-tag-version --no-push --ignore-scripts --yes", 26 | "standalone": "yarn --cwd ./examples/workflow-standalone", 27 | "start:exampleServer": "yarn standalone start:exampleServer", 28 | "test": "lerna run test --no-bail", 29 | "test:ci": "lerna run test:ci --no-bail", 30 | "test:coverage": "lerna run test:coverage", 31 | "test:coverage:ci": "yarn glsp coverageReport", 32 | "upgrade:next": "glsp updateNext", 33 | "watch": "concurrently --kill-others -n tsc,standalone -c red,yellow \"tsc -b -w --preserveWatchOutput\" \"yarn -s standalone watch:bundle\"" 34 | }, 35 | "devDependencies": { 36 | "@eclipse-glsp/dev": "next", 37 | "@types/lodash": "4.14.191", 38 | "@types/node": "20.x", 39 | "concurrently": "^8.2.2", 40 | "lerna": "^9.0.0", 41 | "mocha-ctrf-json-reporter": "^0.0.9", 42 | "typescript": "^5.9.2" 43 | }, 44 | "engines": { 45 | "node": ">=20", 46 | "yarn": ">=1.7.0 <2" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /packages/client/src/utils/marker.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2023 EclipseSource 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 { GParentElement, MarkerKind } from '@eclipse-glsp/sprotty'; 17 | import { GIssueMarker } from '../features/validation/issue-marker'; 18 | 19 | export namespace MarkerPredicates { 20 | export const ALL = (): boolean => true; 21 | export const ERRORS = (marker: GIssueMarker): boolean => hasIssueWithSeverity(marker, MarkerKind.ERROR); 22 | export const WARNINGS = (marker: GIssueMarker): boolean => hasIssueWithSeverity(marker, MarkerKind.WARNING); 23 | export const INFOS = (marker: GIssueMarker): boolean => hasIssueWithSeverity(marker, MarkerKind.INFO); 24 | 25 | export function hasIssueWithSeverity(marker: GIssueMarker, severity: 'info' | 'warning' | 'error'): boolean { 26 | return marker.issues.find(issue => issue.severity === severity) !== undefined; 27 | } 28 | } 29 | 30 | export function collectIssueMarkers(root: GParentElement): GIssueMarker[] { 31 | const markers = []; 32 | for (const child of root.children) { 33 | if (child instanceof GIssueMarker) { 34 | markers.push(child); 35 | } 36 | markers.push(...collectIssueMarkers(child)); 37 | } 38 | return markers; 39 | } 40 | -------------------------------------------------------------------------------- /packages/client/src/base/args-feature.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2020-2023 EclipseSource 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, GModelElement } from '@eclipse-glsp/sprotty'; 17 | 18 | export const argsFeature = Symbol('argsFeature'); 19 | 20 | /** 21 | * Adds an optional `args` property to a {@link GModelElement}. This allows 22 | * to add arbitrary arguments to the element (on client or server side) without having 23 | * to extend the model class. 24 | * 25 | * Feature extension interface for {@link argsFeature}. 26 | */ 27 | export interface ArgsAware { 28 | args?: Args; 29 | } 30 | 31 | export function isArgsAware(element?: GModelElement): element is GModelElement & ArgsAware { 32 | return element !== undefined && element.hasFeature(argsFeature); 33 | } 34 | 35 | export function hasArgs(element?: GModelElement): element is GModelElement & Required { 36 | return element !== undefined && isArgsAware(element) && element.args !== undefined; 37 | } 38 | 39 | export function ensureArgs(element?: GModelElement): element is GModelElement & Required { 40 | if (!isArgsAware(element)) { 41 | return false; 42 | } 43 | if (element.args === undefined) { 44 | element.args = {}; 45 | } 46 | return true; 47 | } 48 | -------------------------------------------------------------------------------- /packages/client/src/features/tools/marquee-selection/marquee-selection-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 { FeatureModule, TYPES, bindAsService, configureCommand, configureModelElement } from '@eclipse-glsp/sprotty'; 17 | import { MarqueeMouseTool } from './marquee-mouse-tool'; 18 | import { MarqueeTool } from './marquee-tool'; 19 | import { DrawMarqueeCommand, MARQUEE, RemoveMarqueeCommand } from './marquee-tool-feedback'; 20 | import { MarqueeNode } from './model'; 21 | import { MarqueeView } from './view'; 22 | import { MarqueeUtil } from './marquee-behavior'; 23 | 24 | export const marqueeSelectionToolModule = new FeatureModule( 25 | (bind, unbind, isBound, rebind) => { 26 | const context = { bind, unbind, isBound, rebind }; 27 | context.bind(MarqueeUtil).toSelf().inSingletonScope(); 28 | bindAsService(context, TYPES.IDefaultTool, MarqueeTool); 29 | bindAsService(context, TYPES.ITool, MarqueeMouseTool); 30 | 31 | configureCommand(context, DrawMarqueeCommand); 32 | configureCommand(context, RemoveMarqueeCommand); 33 | 34 | configureModelElement(context, MARQUEE, MarqueeNode, MarqueeView); 35 | }, 36 | { featureId: Symbol('marqueeSelectionTool') } 37 | ); 38 | -------------------------------------------------------------------------------- /packages/client/src/features/zorder/bring-to-front-command.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2025 EclipseSource 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 | 17 | import { 18 | LayoutContainer, 19 | LayoutRegistry, 20 | SprottyBringToFrontCommand, 21 | TYPES, 22 | ZOrderElement, 23 | isLayoutContainer 24 | } from '@eclipse-glsp/sprotty'; 25 | import { inject, injectable } from 'inversify'; 26 | 27 | @injectable() 28 | export class BringToFrontCommand extends SprottyBringToFrontCommand { 29 | @inject(TYPES.LayoutRegistry) protected layoutRegistry: LayoutRegistry; 30 | 31 | protected getLayoutContainer(zorder: ZOrderElement): LayoutContainer | undefined { 32 | return isLayoutContainer(zorder.element.parent) ? zorder.element.parent : undefined; 33 | } 34 | 35 | protected shouldBringToFront(zorder: ZOrderElement): boolean { 36 | // only re-order children if the layout supports it 37 | const layoutContainer = this.getLayoutContainer(zorder); 38 | return !layoutContainer || (this.layoutRegistry.get(layoutContainer.layout)?.orderAgnostic ?? true); 39 | } 40 | 41 | protected override bringToFront(zorder: ZOrderElement): void { 42 | if (this.shouldBringToFront(zorder)) { 43 | super.bringToFront(zorder); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /packages/client/src/features/tools/tool-focus-loss-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2022-2024 EclipseSource 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 { Action, FeatureModule, IActionHandler, ICommand, configureActionHandler } from '@eclipse-glsp/sprotty'; 17 | import { injectable } from 'inversify'; 18 | import { FocusStateChangedAction } from '../../base/focus/focus-state-change-action'; 19 | import { EnableDefaultToolsAction } from '../../base/tool-manager/tool'; 20 | 21 | /** 22 | * Action handler that enables the default tools when the diagram lost focus. 23 | * @see FocusStateChangedAction 24 | */ 25 | @injectable() 26 | export class EnableDefaultToolsOnFocusLossHandler implements IActionHandler { 27 | handle(action: Action): void | Action | ICommand { 28 | if (FocusStateChangedAction.is(action) && !action.hasFocus) { 29 | return EnableDefaultToolsAction.create(); 30 | } 31 | } 32 | } 33 | 34 | /** 35 | * Enables the default tools in the tool manager if the diagram looses focus. 36 | */ 37 | export const toolFocusLossModule = new FeatureModule( 38 | (bind, _unbind, isBound) => { 39 | configureActionHandler({ bind, isBound }, FocusStateChangedAction.KIND, EnableDefaultToolsOnFocusLossHandler); 40 | }, 41 | { featureId: Symbol('toolFocusLoss ') } 42 | ); 43 | -------------------------------------------------------------------------------- /packages/client/src/features/viewport/glsp-scroll-mouse-listener.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2021-2023 EclipseSource 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 { injectable } from 'inversify'; 17 | import { Action, IActionHandler, ICommand, ScrollMouseListener, GModelElement } from '@eclipse-glsp/sprotty'; 18 | import { EnableDefaultToolsAction, EnableToolsAction } from '../../base/tool-manager/tool'; 19 | import { MarqueeMouseTool } from '../tools/marquee-selection/marquee-mouse-tool'; 20 | 21 | @injectable() 22 | export class GLSPScrollMouseListener extends ScrollMouseListener implements IActionHandler { 23 | preventScrolling = false; 24 | 25 | handle(action: Action): void | Action | ICommand { 26 | if (action.kind === EnableToolsAction.KIND) { 27 | if ((action as EnableToolsAction).toolIds.includes(MarqueeMouseTool.ID)) { 28 | this.preventScrolling = true; 29 | } 30 | } else if (action.kind === EnableDefaultToolsAction.KIND) { 31 | this.preventScrolling = false; 32 | } 33 | } 34 | 35 | override mouseDown(target: GModelElement, event: MouseEvent): (Action | Promise)[] { 36 | if (this.preventScrolling) { 37 | return []; 38 | } 39 | return super.mouseDown(target, event); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /packages/client/src/features/tools/change-bounds/change-bounds-tool-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 { FeatureModule, TYPES, bindAsService, configureCommand, configureView } from '@eclipse-glsp/sprotty'; 17 | import '../../../../css/change-bounds.css'; 18 | import { GResizeHandle } from '../../change-bounds/model'; 19 | import { ChangeBoundsManager } from './change-bounds-manager'; 20 | import { ChangeBoundsTool } from './change-bounds-tool'; 21 | import { HideChangeBoundsToolResizeFeedbackCommand, ShowChangeBoundsToolResizeFeedbackCommand } from './change-bounds-tool-feedback'; 22 | import { GResizeHandleView } from './view'; 23 | 24 | export const changeBoundsToolModule = new FeatureModule( 25 | (bind, unbind, isBound, rebind) => { 26 | const context = { bind, unbind, isBound, rebind }; 27 | bindAsService(context, TYPES.IChangeBoundsManager, ChangeBoundsManager); 28 | bindAsService(context, TYPES.IDefaultTool, ChangeBoundsTool); 29 | configureCommand(context, ShowChangeBoundsToolResizeFeedbackCommand); 30 | configureCommand(context, HideChangeBoundsToolResizeFeedbackCommand); 31 | configureView(context, GResizeHandle.TYPE, GResizeHandleView); 32 | }, 33 | { featureId: Symbol('changeBoundsTool') } 34 | ); 35 | -------------------------------------------------------------------------------- /packages/client/src/base/feedback/feedback-command.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 deprecation/deprecation */ 17 | import { Command, CommandExecutionContext, CommandReturn, ICommand } from '@eclipse-glsp/sprotty'; 18 | import { Ranked } from '../ranked'; 19 | 20 | export abstract class FeedbackCommand extends Command implements Ranked { 21 | /** @deprecated Use rank instead. Please note that a lower rank implies higher priority, so the order is reversed. */ 22 | readonly priority?: number = 0; 23 | 24 | // backwards compatibility: convert any existing priority to an equivalent rank 25 | readonly rank: number = this.priority ? -this.priority : Ranked.DEFAULT_RANK; 26 | 27 | undo(context: CommandExecutionContext): CommandReturn { 28 | return context.root; 29 | } 30 | 31 | redo(context: CommandExecutionContext): CommandReturn { 32 | return context.root; 33 | } 34 | } 35 | 36 | /** Used for backwards compatibility, otherwise use Ranked.getRank or Ranked sort functions. */ 37 | export function getFeedbackRank(command: ICommand): number { 38 | const feedbackCommand = command as Partial; 39 | return feedbackCommand?.priority ? -feedbackCommand.priority : feedbackCommand.rank ?? Ranked.DEFAULT_RANK; 40 | } 41 | -------------------------------------------------------------------------------- /packages/client/src/features/tools/node-creation/node-creation-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 | FeatureModule, 18 | TYPES, 19 | TriggerNodeCreationAction, 20 | bindAsService, 21 | configureActionHandler, 22 | configureModelElement 23 | } from '@eclipse-glsp/sprotty'; 24 | import { elementTemplateModule } from '../../element-template/element-template-module'; 25 | import { ContainerManager } from './container-manager'; 26 | import { InsertIndicator } from './insert-indicator'; 27 | import { NodeCreationTool } from './node-creation-tool'; 28 | import { InsertIndicatorView } from './node-creation-views'; 29 | 30 | export const nodeCreationToolModule = new FeatureModule( 31 | (bind, unbind, isBound, rebind) => { 32 | const context = { bind, unbind, isBound, rebind }; 33 | bindAsService(context, TYPES.IContainerManager, ContainerManager); 34 | bindAsService(context, TYPES.ITool, NodeCreationTool); 35 | configureActionHandler(context, TriggerNodeCreationAction.KIND, NodeCreationTool); 36 | configureModelElement(context, InsertIndicator.TYPE, InsertIndicator, InsertIndicatorView); 37 | }, 38 | { 39 | featureId: Symbol('nodeCreationTool'), 40 | requires: elementTemplateModule 41 | } 42 | ); 43 | -------------------------------------------------------------------------------- /packages/client/src/features/copy-paste/copy-paste-modules.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 { bindAsService, FeatureModule, TYPES } from '@eclipse-glsp/sprotty'; 17 | import { LocalClipboardService, ServerCopyPasteHandler } from './copy-paste-handler'; 18 | import { CopyPasteStartup } from './copy-paste-standalone'; 19 | 20 | export const copyPasteModule = new FeatureModule( 21 | (bind, _unbind, isBound) => { 22 | bind(TYPES.ICopyPasteHandler).to(ServerCopyPasteHandler); 23 | bind(TYPES.IAsyncClipboardService).to(LocalClipboardService).inSingletonScope(); 24 | }, 25 | { featureId: Symbol('copyPaste') } 26 | ); 27 | 28 | /** 29 | * Feature module that is intended for the standalone deployment of GLSP (i.e. plain webapp) 30 | * When integrated into an application frame (e.g Theia/VS Code) this module is typically omitted and/or replaced 31 | * with an application native module. 32 | */ 33 | export const standaloneCopyPasteModule = new FeatureModule( 34 | (bind, _unbind, isBound) => { 35 | bindAsService(bind, TYPES.IDiagramStartup, CopyPasteStartup); 36 | bind(TYPES.IGModelRootListener).toService(CopyPasteStartup); 37 | }, 38 | { 39 | featureId: Symbol('standaloneCopyPaste'), 40 | requires: copyPasteModule 41 | } 42 | ); 43 | -------------------------------------------------------------------------------- /packages/client/src/features/tools/edge-edit/edge-edit-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 { FeatureModule, TYPES, bindAsService, configureCommand } from '@eclipse-glsp/sprotty'; 17 | import { configureDanglingFeedbackEdge } from '../edge-creation/dangling-edge-feedback'; 18 | import { EdgeEditTool } from './edge-edit-tool'; 19 | import { 20 | DrawFeedbackEdgeSourceCommand, 21 | HideEdgeReconnectHandlesFeedbackCommand, 22 | ShowEdgeReconnectHandlesFeedbackCommand, 23 | SwitchRoutingModeCommand 24 | } from './edge-edit-tool-feedback'; 25 | 26 | export const edgeEditToolModule = new FeatureModule( 27 | (bind, unbind, isBound, rebind) => { 28 | const context = { bind, unbind, isBound, rebind }; 29 | bindAsService(context, TYPES.IDefaultTool, EdgeEditTool); 30 | 31 | // reconnect edge tool feedback 32 | configureCommand(context, ShowEdgeReconnectHandlesFeedbackCommand); 33 | configureCommand(context, HideEdgeReconnectHandlesFeedbackCommand); 34 | configureCommand(context, DrawFeedbackEdgeSourceCommand); 35 | configureCommand(context, SwitchRoutingModeCommand); 36 | 37 | // dangling edge feedback 38 | configureDanglingFeedbackEdge(context); 39 | }, 40 | { featureId: Symbol('edgeEditTool') } 41 | ); 42 | -------------------------------------------------------------------------------- /packages/client/css/keyboard-tool-palette.css: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023 Business Informatics Group (TU Wien) 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 | 17 | .accessibility-tool-palette .header-tools i { 18 | position: relative; 19 | } 20 | 21 | .accessibility-tool-palette .tool-button .key-shortcut, 22 | .accessibility-tool-palette .header-tools .key-shortcut { 23 | display: none; 24 | position: absolute; 25 | 26 | border-radius: 50%; 27 | width: 0.5rem; 28 | height: 0.5rem; 29 | padding: 0.5rem; 30 | 31 | background: #fff; 32 | border: 2px solid #666; 33 | color: black; 34 | text-align: center; 35 | 36 | font: 37 | bold 0.8rem Arial, 38 | sans-serif; 39 | line-height: 0.5rem; 40 | } 41 | 42 | .accessibility-tool-palette .tool-button .key-shortcut { 43 | left: -2rem; 44 | } 45 | 46 | .accessibility-tool-palette .header-tools .key-shortcut { 47 | top: -2.5rem; 48 | right: -0.3rem; 49 | } 50 | 51 | .accessibility-show-shortcuts:focus-within .header-tools .key-shortcut, 52 | .accessibility-show-shortcuts:focus-within .tool-button .key-shortcut { 53 | display: block; 54 | } 55 | 56 | .accessibility-tool-palette.collapsible-palette { 57 | overflow: visible; 58 | } 59 | 60 | .accessibility-tool-palette.collapsible-palette + .minimize-palette-button { 61 | top: 50px; 62 | } 63 | -------------------------------------------------------------------------------- /packages/client/src/features/accessibility/view-key-tools/view-key-tools-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2025 EclipseSource 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 | 17 | import { bindAsService, BindingContext, configureActionHandler, FeatureModule, TYPES } from '@eclipse-glsp/sprotty'; 18 | import { viewportModule } from '../../viewport/viewport-modules'; 19 | import { KeyboardGridCellSelectedAction, KeyboardGridKeyboardEventAction } from '../keyboard-grid/action'; 20 | import { DeselectKeyTool } from './deselect-key-tool'; 21 | import { GridCellZoomTool } from './grid-cell-zoom-key-tool'; 22 | 23 | export const viewKeyToolsModule = new FeatureModule( 24 | (bind, _unbind, isBound, rebind) => { 25 | const context = { bind, isBound, rebind }; 26 | configureViewKeyTools(context); 27 | }, 28 | { 29 | featureId: Symbol('viewKeyTools'), 30 | requires: viewportModule 31 | } 32 | ); 33 | 34 | export function configureViewKeyTools(context: Pick): void { 35 | bindAsService(context, TYPES.IDefaultTool, GridCellZoomTool); 36 | configureActionHandler(context, KeyboardGridCellSelectedAction.KIND, GridCellZoomTool); 37 | configureActionHandler(context, KeyboardGridKeyboardEventAction.KIND, GridCellZoomTool); 38 | bindAsService(context, TYPES.IDefaultTool, DeselectKeyTool); 39 | } 40 | -------------------------------------------------------------------------------- /packages/client/src/base/mouse-position-tracker.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 EclipseSource 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 | rank: number; 7 | * http://www.eclipse.org/legal/epl-2.0. 8 | * 9 | * This Source Code may also be made available under the following Secondary 10 | * Licenses when the conditions for such availability set forth in the Eclipse 11 | * Public License v. 2.0 are satisfied: GNU General Public License, version 2 12 | * with the GNU Classpath Exception which is available at 13 | * https://www.gnu.org/software/classpath/license.html. 14 | * 15 | * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 16 | ********************************************************************************/ 17 | import { Action, GModelElement, MousePositionTracker, Point } from '@eclipse-glsp/sprotty'; 18 | import { injectable } from 'inversify'; 19 | import { Ranked } from './ranked'; 20 | 21 | @injectable() 22 | export class GLSPMousePositionTracker extends MousePositionTracker implements Ranked { 23 | /* we want to be executed before all default mouse listeners since we are just tracking the position and others may need it */ 24 | rank = Ranked.DEFAULT_RANK - 200; 25 | 26 | override mouseMove(target: GModelElement, event: MouseEvent): (Action | Promise)[] { 27 | // we cannot simply use the offsetX and offsetY properties of the event since they also consider nested HTML elements 28 | // such as foreignObjects or the projection bars divs. Instead, we manually translate the client coordinates to the diagram 29 | const globalOrigin = target.root.canvasBounds; 30 | const clientToPosition = { x: event.clientX, y: event.clientY }; 31 | const rootToPosition = Point.subtract(clientToPosition, globalOrigin); 32 | const positionOnDiagram = target.root.parentToLocal(rootToPosition); 33 | this.lastPosition = positionOnDiagram; 34 | return []; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /examples/workflow-standalone/css/diagram.css: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2021 EclipseSource 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 | :root { 17 | --glsp-info-foreground: blue; 18 | } 19 | 20 | .sprotty-graph, 21 | .grid-background { 22 | background: rgb(179, 196, 202); 23 | } 24 | 25 | .sprotty-node { 26 | fill: #cdc; 27 | stroke: rgb(0, 0, 0); 28 | } 29 | 30 | .sprotty-edge { 31 | stroke: black; 32 | } 33 | 34 | .sprotty-edge.arrow { 35 | fill: black; 36 | } 37 | 38 | .sprotty-edge.selected { 39 | stroke: #844; 40 | } 41 | 42 | .sprotty-edge.selected > .arrow { 43 | fill: #844; 44 | stroke: #844; 45 | } 46 | 47 | .forkOrJoin > .sprotty-node { 48 | fill: black; 49 | } 50 | 51 | .forkOrJoin > .sprotty-node.selected { 52 | stroke: rgb(87, 87, 214); 53 | } 54 | 55 | polygon.sprotty-node { 56 | stroke: black; 57 | } 58 | 59 | .sprotty-node.selected { 60 | stroke: rgb(87, 87, 214); 61 | } 62 | 63 | .bordered-projection-bar { 64 | border-color: #a1a1a1; 65 | } 66 | 67 | .sprotty-viewport { 68 | border-width: 1px; 69 | border-color: #555555; 70 | } 71 | 72 | .sprotty-projection-bar.horizontal.bordered-projection-bar { 73 | height: 15px; 74 | } 75 | 76 | .sprotty-projection-bar.vertical.bordered-projection-bar { 77 | width: 15px; 78 | } 79 | 80 | .projection-scroll-bar { 81 | background-color: #555555; 82 | } 83 | -------------------------------------------------------------------------------- /packages/client/src/features/accessibility/accessibility-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023-2025 Business Informatics Group (TU Wien) 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 | 17 | import { FeatureModule } from '@eclipse-glsp/sprotty'; 18 | import { configureElementNavigationTool } from './element-navigation/element-navigation-module'; 19 | import { configureFocusTrackerTool } from './focus-tracker/focus-tracker-module'; 20 | import { configureKeyboardToolPaletteTool } from './keyboard-tool-palette/keyboard-tool-palette-module'; 21 | import { configureKeyboardControlTools } from './keyboard/keyboard-module'; 22 | import { configureToastTool } from './toast/toast-module'; 23 | import { configureViewKeyTools } from './view-key-tools/view-key-tools-module'; 24 | 25 | /** 26 | * Enables the accessibility tools for a keyboard-only-usage 27 | */ 28 | export const accessibilityModule = new FeatureModule( 29 | (bind, unbind, isBound, rebind) => { 30 | const context = { bind, unbind, isBound, rebind }; 31 | configureViewKeyTools(context); 32 | configureKeyboardToolPaletteTool(context); 33 | configureKeyboardControlTools(context); 34 | configureElementNavigationTool(context); 35 | configureFocusTrackerTool(context); 36 | configureToastTool(context); 37 | }, 38 | { 39 | featureId: Symbol('accessibility') 40 | } 41 | ); 42 | -------------------------------------------------------------------------------- /packages/client/src/features/accessibility/element-navigation/element-navigation-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023-2024 Business Informatics Group (TU Wien) 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 { BindingContext, FeatureModule, TYPES, bindAsService } from '@eclipse-glsp/sprotty'; 17 | import '../../../../css/navigation.css'; 18 | import { ElementNavigatorTool } from './diagram-navigation-tool'; 19 | import { LocalElementNavigator } from './local-element-navigator'; 20 | import { PositionNavigator } from './position-navigator'; 21 | 22 | /** 23 | * Handles element navigation actions. 24 | */ 25 | 26 | export const elementNavigationModule = new FeatureModule( 27 | (bind, unbind, isBound, rebind) => { 28 | const context = { bind, unbind, isBound, rebind }; 29 | configureElementNavigationTool(context); 30 | }, 31 | { featureId: Symbol('elementNavigation') } 32 | ); 33 | 34 | export function configureElementNavigationTool(context: BindingContext): void { 35 | bindAsService(context, TYPES.IDefaultTool, ElementNavigatorTool); 36 | bindAsService(context, TYPES.IElementNavigator, PositionNavigator); 37 | bindAsService(context, TYPES.ILocalElementNavigator, LocalElementNavigator); 38 | } 39 | 40 | export { 41 | /** Deprecated use {@link elementNavigationModule} instead */ 42 | elementNavigationModule as glspElementNavigationModule 43 | }; 44 | -------------------------------------------------------------------------------- /packages/protocol/src/model/default-types.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2021-2022 EclipseSource 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 | 17 | /** 18 | * The default types for graphical model elements available in GLSP. 19 | */ 20 | export namespace DefaultTypes { 21 | // HTML elements 22 | export const HTML = 'html'; 23 | 24 | // generic types 25 | export const FOREIGN_OBJECT = 'foreign-object'; 26 | export const PRE_RENDERED = 'pre-rendered'; 27 | export const SHAPE_PRE_RENDERED = 'shape-pre-rendered'; 28 | 29 | // SVG elements 30 | export const SVG = 'svg'; 31 | 32 | // graph types 33 | export const GRAPH = 'graph'; 34 | export const NODE = 'node'; 35 | export const COMPARTMENT = 'comp'; 36 | export const COMPARTMENT_HEADER = 'comp:header'; 37 | export const EDGE = 'edge'; 38 | export const PORT = 'port'; 39 | export const ROUTING_POINT = 'routing-point'; 40 | export const VOLATILE_ROUTING_POINT = `volatile-${ROUTING_POINT}`; 41 | export const LABEL = 'label'; 42 | 43 | // UI elements 44 | export const BUTTON = 'button'; 45 | export const BUTTON_EXPAND = 'button:expand'; 46 | export const ISSUE_MARKER = 'marker'; 47 | 48 | // shapes 49 | export const NODE_CIRCLE = 'node:circle'; 50 | export const NODE_RECTANGLE = 'node:rectangle'; 51 | export const NODE_DIAMOND = 'node:diamond'; 52 | } 53 | -------------------------------------------------------------------------------- /packages/client/src/features/context-menu/context-menu-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 { ContextMenuProviderRegistry, FeatureModule, IContextMenuService, TYPES, bindAsService } from '@eclipse-glsp/sprotty'; 17 | import { GLSPContextMenuMouseListener } from './glsp-context-menu-mouse-listener'; 18 | import { ServerContextMenuItemProvider } from './server-context-menu-provider'; 19 | 20 | export const contextMenuModule = new FeatureModule( 21 | bind => { 22 | bind(TYPES.IContextMenuServiceProvider).toProvider(ctx => async () => { 23 | if (ctx.container.isBound(TYPES.IContextMenuService)) { 24 | return ctx.container.get(TYPES.IContextMenuService); 25 | } 26 | console.warn("'TYPES.IContextMenuService' is not bound. Use no-op implementation instead"); 27 | // eslint-disable-next-line @typescript-eslint/no-empty-function 28 | return { show: () => {} }; 29 | }); 30 | 31 | bindAsService(bind, TYPES.MouseListener, GLSPContextMenuMouseListener); 32 | bind(TYPES.IContextMenuProviderRegistry).to(ContextMenuProviderRegistry); 33 | bindAsService(bind, TYPES.IContextMenuItemProvider, ServerContextMenuItemProvider); 34 | }, 35 | { featureId: Symbol('contextMenu') } 36 | ); 37 | -------------------------------------------------------------------------------- /packages/protocol/src/utils/test-util.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023 EclipseSource 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 | 17 | import { expect } from 'chai'; 18 | import { MaybePromise } from './type-util'; 19 | 20 | /* 21 | * Utility classes used for testing. 22 | * Only available in the testing context. Should not be used in production code. 23 | */ 24 | 25 | /** 26 | * Creates a promise that resolves after the given timeout 27 | * @param timeout the timeout in milliseconds 28 | * @returns 29 | */ 30 | export async function delay(timeout: number): Promise { 31 | return new Promise(resolve => setTimeout(resolve, timeout)); 32 | } 33 | 34 | /** 35 | * Consumes a maybe async function and checks for error 36 | * @param method - The function to check 37 | * @param message - Optional message to match with error message 38 | */ 39 | export async function expectToThrowAsync(toEvaluate: () => MaybePromise, message?: string): Promise { 40 | let err: unknown | undefined = undefined; 41 | try { 42 | await toEvaluate(); 43 | } catch (error) { 44 | err = error; 45 | } 46 | if (message) { 47 | expect(err instanceof Error, 'The error cause should be an instance of Error').to.be.true; 48 | expect((err as Error)?.message).to.be.equal(message); 49 | } else { 50 | expect(err).to.be.an('Error'); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /packages/client/css/status-overlay.css: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2023 EclipseSource 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 | 17 | .sprotty-status { 18 | position: absolute; 19 | top: 5px; 20 | left: 10px; 21 | display: flex; 22 | align-items: center; 23 | } 24 | 25 | .sprotty-status .fatal { 26 | color: var(--glsp-error-foreground); 27 | } 28 | 29 | .sprotty-status .error { 30 | color: var(--glsp-error-foreground); 31 | } 32 | 33 | .sprotty-status .warning { 34 | color: var(--glsp-warning-foreground); 35 | } 36 | 37 | .sprotty-status .info { 38 | color: var(--glsp-info-foreground); 39 | } 40 | 41 | .sprotty-error { 42 | fill: var(--glsp-issue-background); 43 | color: var(--glsp-error-foreground); 44 | } 45 | 46 | .sprotty-warning { 47 | fill: var(--glsp-issue-background); 48 | color: var(--glsp-warning-foreground); 49 | } 50 | 51 | .sprotty-info { 52 | fill: var(--glsp-issue-background); 53 | color: var(); 54 | } 55 | 56 | .sprotty-infoRow .codicon { 57 | margin-right: 8px; 58 | } 59 | .sprotty-status .ok { 60 | visibility: hidden; 61 | } 62 | 63 | .sprotty-status-message { 64 | visibility: hidden; 65 | padding-left: 10px; 66 | } 67 | 68 | .sprotty-status-message.fatal { 69 | visibility: visible; 70 | padding-left: 10px; 71 | } 72 | 73 | .sprotty-status:hover .sprotty-status-message { 74 | visibility: visible; 75 | } 76 | -------------------------------------------------------------------------------- /packages/client/css/command-palette.css: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2021 EclipseSource 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 | 17 | .command-palette { 18 | position: fixed; 19 | transition: opacity 0.3s linear; 20 | box-shadow: 21 | 0 4px 8px 0 rgba(0, 0, 0, 0.2), 22 | 0 6px 20px 0 rgba(0, 0, 0, 0.19); 23 | overflow: visible; 24 | } 25 | 26 | .command-palette-suggestions { 27 | background: white; 28 | z-index: 1000; 29 | overflow: auto; 30 | box-sizing: border-box; 31 | border: 1px solid rgba(60, 60, 60, 0.6); 32 | box-shadow: 33 | 0 4px 8px 0 rgba(0, 0, 0, 0.2), 34 | 0 6px 20px 0 rgba(0, 0, 0, 0.19); 35 | } 36 | 37 | .command-palette-suggestions .icon { 38 | padding-right: 0.3em; 39 | display: flex; 40 | align-self: center; 41 | } 42 | 43 | .command-palette-suggestions em { 44 | font-weight: bold; 45 | font-style: normal; 46 | } 47 | 48 | .command-palette-suggestions > div { 49 | padding: 0 4px; 50 | display: flex; 51 | } 52 | 53 | .command-palette-suggestions .group { 54 | background: #eee; 55 | } 56 | 57 | .command-palette-suggestions > div:hover:not(.group), 58 | .command-palette-suggestions > div.selected { 59 | cursor: pointer; 60 | } 61 | 62 | .command-palette-suggestions > div:hover:not(.group) { 63 | background: #e0e0e0; 64 | } 65 | 66 | .command-palette-suggestions > div.selected { 67 | background: #bbdefb; 68 | } 69 | -------------------------------------------------------------------------------- /packages/client/src/features/bounds/layout-data.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 Axon Ivy AG 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 | 17 | import { Dimension, LayoutData } from '@eclipse-glsp/sprotty'; 18 | 19 | export interface LayoutAware { 20 | layoutData: LayoutData; 21 | } 22 | 23 | export namespace LayoutAware { 24 | export function is(element: T): element is T & LayoutAware { 25 | return 'layoutData' in element; 26 | } 27 | 28 | export function getLayoutData(element: T): LayoutData | undefined { 29 | return is(element) ? element.layoutData : undefined; 30 | } 31 | 32 | export function setLayoutData(element: T, data: LayoutData): void { 33 | (element as LayoutAware).layoutData = data; 34 | } 35 | 36 | export function setComputedDimensions(element: T, computedDimensions: Dimension): void { 37 | ensureLayoutAware(element).layoutData.computedDimensions = computedDimensions; 38 | } 39 | 40 | export function getComputedDimensions(element: T): Dimension | undefined { 41 | return getLayoutData(element)?.computedDimensions; 42 | } 43 | 44 | function ensureLayoutAware(element: T): T & LayoutAware { 45 | (element as LayoutAware).layoutData = (element as LayoutAware).layoutData ?? {}; 46 | return element as T & LayoutAware; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /packages/client/src/features/select/select-module.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2019-2024 EclipseSource 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 { FeatureModule, SelectKeyboardListener, TYPES, bindAsService, configureCommand } from '@eclipse-glsp/sprotty'; 17 | import { SelectAllCommand, SelectCommand } from '../../base/selection-service'; 18 | import { SelectFeedbackCommand } from './select-feedback-command'; 19 | import { RankedSelectMouseListener } from './select-mouse-listener'; 20 | 21 | export const selectModule = new FeatureModule( 22 | (bind, _unbind, isBound) => { 23 | const context = { bind, isBound }; 24 | configureCommand(context, SelectCommand); 25 | configureCommand(context, SelectAllCommand); 26 | configureCommand(context, SelectFeedbackCommand); 27 | bindAsService(context, TYPES.MouseListener, RankedSelectMouseListener); 28 | }, 29 | { featureId: Symbol('select') } 30 | ); 31 | 32 | /** 33 | * Feature module that is intended for the standalone deployment of GLSP (i.e. plain webapp) 34 | * When integrated into an application frame (e.g Theia/VS Code) this module is typically omitted and/or replaced 35 | * with an application native module. 36 | */ 37 | export const standaloneSelectModule = new FeatureModule( 38 | bind => { 39 | bindAsService(bind, TYPES.KeyListener, SelectKeyboardListener); 40 | }, 41 | { featureId: Symbol('standaloneSelect'), requires: selectModule } 42 | ); 43 | -------------------------------------------------------------------------------- /packages/client/src/base/feedback/set-model-command.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2024 EclipseSource 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 { CommandExecutionContext, GModelRoot, ILogger, SetModelAction, SetModelCommand, TYPES } from '@eclipse-glsp/sprotty'; 17 | import { inject, injectable, optional } from 'inversify'; 18 | import { IFeedbackActionDispatcher } from './feedback-action-dispatcher'; 19 | 20 | @injectable() 21 | export class FeedbackAwareSetModelCommand extends SetModelCommand { 22 | @inject(TYPES.ILogger) 23 | protected logger: ILogger; 24 | 25 | @inject(TYPES.IFeedbackActionDispatcher) 26 | @optional() 27 | protected feedbackActionDispatcher?: IFeedbackActionDispatcher; 28 | 29 | constructor(@inject(TYPES.Action) action: SetModelAction) { 30 | super(action); 31 | } 32 | 33 | override execute(context: CommandExecutionContext): GModelRoot { 34 | const root = super.execute(context); 35 | this.applyFeedback(root, context); 36 | return root; 37 | } 38 | 39 | protected applyFeedback(newRoot: GModelRoot, context: CommandExecutionContext): void { 40 | // Create a temporary context which defines the `newRoot` as `root` 41 | // This way we do not corrupt the redo/undo behavior of the super class 42 | const tempContext: CommandExecutionContext = { ...context, root: newRoot }; 43 | this.feedbackActionDispatcher?.applyFeedbackCommands(tempContext); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /packages/client/src/base/selection-clearing-mouse-listener.ts: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2020-2023 EclipseSource 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 { injectable } from 'inversify'; 17 | import { MouseListener, GModelElement } from '@eclipse-glsp/sprotty'; 18 | 19 | /** 20 | * A mouse listener that clears the document selection on click 21 | * 22 | * Clicking on SVG elements doesn't update the document selection. In the context of diagramming 23 | * with GLSP, this is unnatural, as the user would expect that clicking in the diagram (e.g. to 24 | * select a diagram element) would clear any other selection state in the DOM. From a technical 25 | * point of view, an active selection in the document after clicking into the diagram may also 26 | * lead to bogus target elements in certain browser events, such as clipboard events, etc. 27 | * 28 | * This listener helps to overcome this problem by actively clearing any existing selection in 29 | * the document, if the user clicks into the diagram. 30 | */ 31 | @injectable() 32 | export class SelectionClearingMouseListener extends MouseListener { 33 | override mouseDown(_target: GModelElement, event: MouseEvent): never[] { 34 | const selection = document.getSelection(); 35 | // eslint-disable-next-line no-null/no-null 36 | if (selection === null) { 37 | return []; 38 | } 39 | selection.removeAllRanges(); 40 | selection.addRange(document.createRange()); 41 | return []; 42 | } 43 | } 44 | --------------------------------------------------------------------------------