@eclipse-glsp/client 1.1.0-next.383e4e9.264 → 1.1.0-next.3d1b3e6.280
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/decoration.css +0 -7
- package/css/glsp-sprotty.css +7 -0
- package/css/key-shortcut.css +5 -1
- package/{lib/base/source-uri-aware.js → css/navigation.css} +11 -9
- package/css/status-overlay.css +75 -0
- package/css/toast.css +45 -0
- package/lib/base/action-dispatcher.d.ts +8 -2
- package/lib/base/action-dispatcher.d.ts.map +1 -1
- package/lib/base/action-dispatcher.js +15 -7
- package/lib/base/action-dispatcher.js.map +1 -1
- package/lib/base/action-dispatcher.spec.d.ts +2 -0
- package/lib/base/action-dispatcher.spec.d.ts.map +1 -0
- package/lib/base/action-dispatcher.spec.js +78 -0
- package/lib/base/action-dispatcher.spec.js.map +1 -0
- package/lib/base/action-handler-registry.d.ts +25 -0
- package/lib/base/action-handler-registry.d.ts.map +1 -0
- package/lib/{features/tools/base-glsp-creation-tool.js → base/action-handler-registry.js} +20 -25
- package/lib/base/action-handler-registry.js.map +1 -0
- package/lib/base/default.module.d.ts +1 -10
- package/lib/base/default.module.d.ts.map +1 -1
- package/lib/base/default.module.js +20 -30
- package/lib/base/default.module.js.map +1 -1
- package/lib/base/editor-context-service.d.ts +17 -5
- package/lib/base/editor-context-service.d.ts.map +1 -1
- package/lib/base/editor-context-service.js +41 -14
- package/lib/base/editor-context-service.js.map +1 -1
- package/lib/base/feedback/feedback-action-dispatcher.d.ts.map +1 -1
- package/lib/base/feedback/feedback-action-dispatcher.js +5 -3
- package/lib/base/feedback/feedback-action-dispatcher.js.map +1 -1
- package/lib/base/focus/focus-tracker.d.ts +4 -0
- package/lib/base/focus/focus-tracker.d.ts.map +1 -1
- package/lib/base/focus/focus-tracker.js +12 -5
- package/lib/base/focus/focus-tracker.js.map +1 -1
- package/lib/base/model/diagram-loader.d.ts +116 -0
- package/lib/base/model/diagram-loader.d.ts.map +1 -0
- package/lib/base/model/diagram-loader.js +130 -0
- package/lib/base/model/diagram-loader.js.map +1 -0
- package/lib/base/model/glsp-model-source.d.ts +74 -0
- package/lib/base/model/glsp-model-source.d.ts.map +1 -0
- package/lib/base/model/glsp-model-source.js +178 -0
- package/lib/base/model/glsp-model-source.js.map +1 -0
- package/lib/base/{model-initialization-constraint.d.ts → model/model-initialization-constraint.d.ts} +24 -3
- package/lib/base/model/model-initialization-constraint.d.ts.map +1 -0
- package/lib/base/{model-initialization-constraint.js → model/model-initialization-constraint.js} +20 -10
- package/lib/base/model/model-initialization-constraint.js.map +1 -0
- package/lib/base/model/model-initialization-constraint.spec.d.ts +2 -0
- package/lib/base/model/model-initialization-constraint.spec.d.ts.map +1 -0
- package/lib/base/model/model-initialization-constraint.spec.js +97 -0
- package/lib/base/model/model-initialization-constraint.spec.js.map +1 -0
- package/lib/base/selection-service.spec.js +9 -8
- package/lib/base/selection-service.spec.js.map +1 -1
- package/lib/base/tool-manager/tool-manager.d.ts +82 -0
- package/lib/base/tool-manager/tool-manager.d.ts.map +1 -0
- package/lib/base/tool-manager/tool-manager.js +140 -0
- package/lib/base/tool-manager/tool-manager.js.map +1 -0
- package/lib/base/tool-manager/tool.d.ts +54 -0
- package/lib/base/tool-manager/tool.d.ts.map +1 -0
- package/lib/base/tool-manager/tool.js +60 -0
- package/lib/base/tool-manager/tool.js.map +1 -0
- package/lib/default-modules.d.ts +20 -26
- package/lib/default-modules.d.ts.map +1 -1
- package/lib/default-modules.js +31 -29
- package/lib/default-modules.js.map +1 -1
- package/lib/features/accessibility/accessibility-module.d.ts.map +1 -1
- package/lib/features/accessibility/accessibility-module.js +6 -0
- package/lib/features/accessibility/accessibility-module.js.map +1 -1
- package/lib/features/accessibility/element-navigation/diagram-navigation-tool.d.ts +65 -0
- package/lib/features/accessibility/element-navigation/diagram-navigation-tool.d.ts.map +1 -0
- package/lib/features/accessibility/element-navigation/diagram-navigation-tool.js +290 -0
- package/lib/features/accessibility/element-navigation/diagram-navigation-tool.js.map +1 -0
- package/lib/features/accessibility/element-navigation/element-navigation-module.d.ts +24 -0
- package/lib/features/accessibility/element-navigation/element-navigation-module.d.ts.map +1 -0
- package/lib/features/accessibility/element-navigation/element-navigation-module.js +38 -0
- package/lib/features/accessibility/element-navigation/element-navigation-module.js.map +1 -0
- package/lib/features/accessibility/element-navigation/element-navigator.d.ts +26 -0
- package/lib/features/accessibility/element-navigation/element-navigator.d.ts.map +1 -0
- package/{src/base/source-uri-aware.ts → lib/features/accessibility/element-navigation/element-navigator.js} +4 -9
- package/lib/features/accessibility/element-navigation/element-navigator.js.map +1 -0
- package/lib/features/accessibility/element-navigation/left-right-top-bottom-navigator.d.ts +28 -0
- package/lib/features/accessibility/element-navigation/left-right-top-bottom-navigator.d.ts.map +1 -0
- package/lib/features/accessibility/element-navigation/left-right-top-bottom-navigator.js +104 -0
- package/lib/features/accessibility/element-navigation/left-right-top-bottom-navigator.js.map +1 -0
- package/lib/features/accessibility/element-navigation/local-element-navigator.d.ts +35 -0
- package/lib/features/accessibility/element-navigation/local-element-navigator.d.ts.map +1 -0
- package/lib/features/accessibility/element-navigation/local-element-navigator.js +117 -0
- package/lib/features/accessibility/element-navigation/local-element-navigator.js.map +1 -0
- package/lib/features/accessibility/element-navigation/position-navigator.d.ts +32 -0
- package/lib/features/accessibility/element-navigation/position-navigator.d.ts.map +1 -0
- package/lib/features/accessibility/element-navigation/position-navigator.js +80 -0
- package/lib/features/accessibility/element-navigation/position-navigator.js.map +1 -0
- package/lib/features/accessibility/focus-tracker/focus-tracker-module.d.ts +23 -0
- package/lib/features/accessibility/focus-tracker/focus-tracker-module.d.ts.map +1 -0
- package/lib/features/accessibility/focus-tracker/focus-tracker-module.js +33 -0
- package/lib/features/accessibility/focus-tracker/focus-tracker-module.js.map +1 -0
- package/lib/features/accessibility/focus-tracker/focus-tracker-tool.d.ts +37 -0
- package/lib/features/accessibility/focus-tracker/focus-tracker-tool.d.ts.map +1 -0
- package/lib/features/accessibility/focus-tracker/focus-tracker-tool.js +133 -0
- package/lib/features/accessibility/focus-tracker/focus-tracker-tool.js.map +1 -0
- package/lib/features/accessibility/key-shortcut/accessible-key-shortcut-tool.d.ts +2 -2
- package/lib/features/accessibility/key-shortcut/accessible-key-shortcut-tool.d.ts.map +1 -1
- package/lib/features/accessibility/key-shortcut/accessible-key-shortcut-tool.js +2 -2
- package/lib/features/accessibility/key-shortcut/accessible-key-shortcut-tool.js.map +1 -1
- package/lib/features/accessibility/key-shortcut/accessible-key-shortcut.d.ts +1 -0
- package/lib/features/accessibility/key-shortcut/accessible-key-shortcut.d.ts.map +1 -1
- package/lib/features/accessibility/key-shortcut/accessible-key-shortcut.js +15 -3
- package/lib/features/accessibility/key-shortcut/accessible-key-shortcut.js.map +1 -1
- package/lib/features/accessibility/resize-key-tool/resize-key-tool.d.ts +2 -2
- package/lib/features/accessibility/resize-key-tool/resize-key-tool.d.ts.map +1 -1
- package/lib/features/accessibility/resize-key-tool/resize-key-tool.js +22 -15
- package/lib/features/accessibility/resize-key-tool/resize-key-tool.js.map +1 -1
- package/lib/features/accessibility/search/search-palette.d.ts.map +1 -1
- package/lib/features/accessibility/search/search-palette.js +3 -1
- package/lib/features/accessibility/search/search-palette.js.map +1 -1
- package/lib/features/accessibility/search/search-tool.d.ts +2 -1
- package/lib/features/accessibility/search/search-tool.d.ts.map +1 -1
- package/lib/features/accessibility/search/search-tool.js +4 -8
- package/lib/features/accessibility/search/search-tool.js.map +1 -1
- package/lib/features/accessibility/toast/messages.json +16 -0
- package/lib/features/accessibility/toast/toast-handler.d.ts +45 -0
- package/lib/features/accessibility/toast/toast-handler.d.ts.map +1 -0
- package/lib/features/accessibility/toast/toast-handler.js +54 -0
- package/lib/features/accessibility/toast/toast-handler.js.map +1 -0
- package/lib/features/accessibility/toast/toast-module.d.ts +24 -0
- package/lib/features/accessibility/toast/toast-module.d.ts.map +1 -0
- package/lib/features/accessibility/toast/toast-module.js +38 -0
- package/lib/features/accessibility/toast/toast-module.js.map +1 -0
- package/lib/features/accessibility/toast/toast-tool.d.ts +43 -0
- package/lib/features/accessibility/toast/toast-tool.d.ts.map +1 -0
- package/lib/features/accessibility/toast/toast-tool.js +115 -0
- package/lib/features/accessibility/toast/toast-tool.js.map +1 -0
- package/lib/features/accessibility/view-key-tools/deselect-key-tool.d.ts +2 -2
- package/lib/features/accessibility/view-key-tools/deselect-key-tool.d.ts.map +1 -1
- package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts +2 -2
- package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts.map +1 -1
- package/lib/features/accessibility/view-key-tools/movement-key-tool.js +4 -8
- package/lib/features/accessibility/view-key-tools/movement-key-tool.js.map +1 -1
- package/lib/features/accessibility/view-key-tools/zoom-key-tool.d.ts +2 -2
- package/lib/features/accessibility/view-key-tools/zoom-key-tool.d.ts.map +1 -1
- package/lib/features/accessibility/view-key-tools/zoom-key-tool.js +9 -13
- package/lib/features/accessibility/view-key-tools/zoom-key-tool.js.map +1 -1
- package/lib/features/bounds/bounds-module.d.ts.map +1 -1
- package/lib/features/bounds/bounds-module.js +2 -1
- package/lib/features/bounds/bounds-module.js.map +1 -1
- package/lib/features/command-palette/command-palette-tool.d.ts +2 -1
- package/lib/features/command-palette/command-palette-tool.d.ts.map +1 -1
- package/lib/features/command-palette/command-palette-tool.js.map +1 -1
- package/lib/features/command-palette/server-command-palette-provider.d.ts.map +1 -1
- package/lib/features/command-palette/server-command-palette-provider.js +3 -2
- package/lib/features/command-palette/server-command-palette-provider.js.map +1 -1
- package/lib/features/context-menu/context-menu-module.d.ts.map +1 -1
- package/lib/features/context-menu/context-menu-module.js +8 -8
- package/lib/features/context-menu/context-menu-module.js.map +1 -1
- package/lib/features/context-menu/{selection-service-aware-context-menu-mouse-listener.d.ts → glsp-context-menu-mouse-listener.d.ts} +2 -4
- package/lib/features/context-menu/glsp-context-menu-mouse-listener.d.ts.map +1 -0
- package/lib/features/context-menu/{selection-service-aware-context-menu-mouse-listener.js → glsp-context-menu-mouse-listener.js} +7 -12
- package/lib/features/context-menu/glsp-context-menu-mouse-listener.js.map +1 -0
- package/lib/features/context-menu/server-context-menu-provider.d.ts +1 -1
- package/lib/features/context-menu/server-context-menu-provider.d.ts.map +1 -1
- package/lib/features/context-menu/server-context-menu-provider.js +3 -2
- package/lib/features/context-menu/server-context-menu-provider.js.map +1 -1
- package/lib/features/copy-paste/copy-paste-context-menu.d.ts.map +1 -1
- package/lib/features/copy-paste/copy-paste-context-menu.js +1 -4
- package/lib/features/copy-paste/copy-paste-context-menu.js.map +1 -1
- package/lib/features/hints/type-hints-module.d.ts.map +1 -1
- package/lib/features/hints/type-hints-module.js +6 -5
- package/lib/features/hints/type-hints-module.js.map +1 -1
- package/lib/features/hints/type-hints.d.ts +6 -2
- package/lib/features/hints/type-hints.d.ts.map +1 -1
- package/lib/features/hints/type-hints.js +8 -0
- package/lib/features/hints/type-hints.js.map +1 -1
- package/lib/features/hover/hover-module.d.ts.map +1 -1
- package/lib/features/hover/hover-module.js +3 -2
- package/lib/features/hover/hover-module.js.map +1 -1
- package/lib/features/hover/hover.d.ts.map +1 -1
- package/lib/features/hover/hover.js +3 -2
- package/lib/features/hover/hover.js.map +1 -1
- package/lib/features/label-edit/edit-label-tool.d.ts +2 -2
- package/lib/features/label-edit/edit-label-tool.d.ts.map +1 -1
- package/lib/features/label-edit/edit-label-tool.js +2 -2
- package/lib/features/label-edit/edit-label-tool.js.map +1 -1
- package/lib/features/label-edit/edit-label-validator.d.ts.map +1 -1
- package/lib/features/label-edit/edit-label-validator.js +3 -2
- package/lib/features/label-edit/edit-label-validator.js.map +1 -1
- package/lib/features/navigation/navigation-action-handler.d.ts.map +1 -1
- package/lib/features/navigation/navigation-action-handler.js +1 -4
- package/lib/features/navigation/navigation-action-handler.js.map +1 -1
- package/lib/features/navigation/navigation-target-resolver.d.ts +3 -3
- package/lib/features/navigation/navigation-target-resolver.d.ts.map +1 -1
- package/lib/features/navigation/navigation-target-resolver.js +5 -7
- package/lib/features/navigation/navigation-target-resolver.js.map +1 -1
- package/lib/features/select/select-mouse-listener.d.ts +4 -2
- package/lib/features/select/select-mouse-listener.d.ts.map +1 -1
- package/lib/features/select/select-mouse-listener.js +17 -58
- package/lib/features/select/select-mouse-listener.js.map +1 -1
- package/lib/features/source-model-watcher/source-model-changed-action-handler.d.ts.map +1 -1
- package/lib/features/source-model-watcher/source-model-changed-action-handler.js +1 -4
- package/lib/features/source-model-watcher/source-model-changed-action-handler.js.map +1 -1
- package/lib/features/status/status-module.d.ts +19 -0
- package/lib/features/status/status-module.d.ts.map +1 -0
- package/lib/features/status/status-module.js +28 -0
- package/lib/features/status/status-module.js.map +1 -0
- package/lib/features/status/status-overlay.d.ts +25 -0
- package/lib/features/status/status-overlay.d.ts.map +1 -0
- package/lib/features/status/status-overlay.js +124 -0
- package/lib/features/status/status-overlay.js.map +1 -0
- package/lib/features/tool-palette/tool-palette-module.d.ts.map +1 -1
- package/lib/features/tool-palette/tool-palette-module.js +3 -2
- package/lib/features/tool-palette/tool-palette-module.js.map +1 -1
- package/lib/features/tool-palette/tool-palette.d.ts +10 -8
- package/lib/features/tool-palette/tool-palette.d.ts.map +1 -1
- package/lib/features/tool-palette/tool-palette.js +36 -29
- package/lib/features/tool-palette/tool-palette.js.map +1 -1
- package/lib/features/tools/{base-glsp-tool.d.ts → base-tools.d.ts} +14 -4
- package/lib/features/tools/base-tools.d.ts.map +1 -0
- package/lib/features/tools/{base-glsp-tool.js → base-tools.js} +31 -10
- package/lib/features/tools/base-tools.js.map +1 -0
- package/lib/features/tools/change-bounds/change-bounds-tool.d.ts +2 -2
- package/lib/features/tools/change-bounds/change-bounds-tool.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool.js +2 -2
- package/lib/features/tools/change-bounds/change-bounds-tool.js.map +1 -1
- package/lib/features/tools/deletion/delete-tool.d.ts +4 -4
- package/lib/features/tools/deletion/delete-tool.d.ts.map +1 -1
- package/lib/features/tools/deletion/delete-tool.js +4 -3
- package/lib/features/tools/deletion/delete-tool.js.map +1 -1
- package/lib/features/tools/edge-creation/edge-creation-tool.d.ts +2 -2
- package/lib/features/tools/edge-creation/edge-creation-tool.d.ts.map +1 -1
- package/lib/features/tools/edge-creation/edge-creation-tool.js +5 -4
- package/lib/features/tools/edge-creation/edge-creation-tool.js.map +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool.d.ts +2 -2
- package/lib/features/tools/edge-edit/edge-edit-tool.d.ts.map +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool.js +2 -2
- package/lib/features/tools/edge-edit/edge-edit-tool.js.map +1 -1
- package/lib/features/tools/marquee-selection/marquee-mouse-tool.d.ts +2 -2
- package/lib/features/tools/marquee-selection/marquee-mouse-tool.d.ts.map +1 -1
- package/lib/features/tools/marquee-selection/marquee-mouse-tool.js +5 -4
- package/lib/features/tools/marquee-selection/marquee-mouse-tool.js.map +1 -1
- package/lib/features/tools/marquee-selection/marquee-tool.d.ts +2 -2
- package/lib/features/tools/marquee-selection/marquee-tool.d.ts.map +1 -1
- package/lib/features/tools/marquee-selection/marquee-tool.js +4 -3
- package/lib/features/tools/marquee-selection/marquee-tool.js.map +1 -1
- package/lib/features/tools/node-creation/node-creation-tool.d.ts +2 -2
- package/lib/features/tools/node-creation/node-creation-tool.d.ts.map +1 -1
- package/lib/features/tools/node-creation/node-creation-tool.js +4 -3
- package/lib/features/tools/node-creation/node-creation-tool.js.map +1 -1
- package/lib/features/tools/tool-focus-loss-module.d.ts.map +1 -1
- package/lib/features/tools/tool-focus-loss-module.js +2 -1
- package/lib/features/tools/tool-focus-loss-module.js.map +1 -1
- package/lib/features/validation/validate.js +1 -1
- package/lib/features/validation/validate.js.map +1 -1
- package/lib/features/viewport/glsp-scroll-mouse-listener.d.ts.map +1 -1
- package/lib/features/viewport/glsp-scroll-mouse-listener.js +3 -2
- package/lib/features/viewport/glsp-scroll-mouse-listener.js.map +1 -1
- package/lib/features/viewport/reposition.d.ts +38 -0
- package/lib/features/viewport/reposition.d.ts.map +1 -0
- package/lib/features/viewport/reposition.js +109 -0
- package/lib/features/viewport/reposition.js.map +1 -0
- package/lib/features/viewport/viewport-modules.d.ts.map +1 -1
- package/lib/features/viewport/viewport-modules.js +5 -2
- package/lib/features/viewport/viewport-modules.js.map +1 -1
- package/lib/glsp-sprotty/augmented-actions.d.ts +2 -10
- package/lib/glsp-sprotty/augmented-actions.d.ts.map +1 -1
- package/lib/glsp-sprotty/augmented-actions.js +2 -6
- package/lib/glsp-sprotty/augmented-actions.js.map +1 -1
- package/lib/glsp-sprotty/index.d.ts +3 -6
- package/lib/glsp-sprotty/index.d.ts.map +1 -1
- package/lib/glsp-sprotty/index.js +4 -7
- package/lib/glsp-sprotty/index.js.map +1 -1
- package/lib/glsp-sprotty/types.d.ts +5 -82
- package/lib/glsp-sprotty/types.d.ts.map +1 -1
- package/lib/glsp-sprotty/types.js +2 -8
- package/lib/glsp-sprotty/types.js.map +1 -1
- package/lib/index.d.ts +17 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +17 -7
- package/lib/index.js.map +1 -1
- package/lib/standalone-modules.d.ts +11 -2
- package/lib/standalone-modules.d.ts.map +1 -1
- package/lib/standalone-modules.js +37 -1
- package/lib/standalone-modules.js.map +1 -1
- package/lib/views/base-view-module.d.ts.map +1 -1
- package/lib/views/base-view-module.js +2 -1
- package/lib/views/base-view-module.js.map +1 -1
- package/lib/views/glsp-projection-view.d.ts +2 -1
- package/lib/views/glsp-projection-view.d.ts.map +1 -1
- package/lib/views/glsp-projection-view.js +11 -2
- package/lib/views/glsp-projection-view.js.map +1 -1
- package/package.json +4 -4
- package/src/base/action-dispatcher.spec.ts +87 -0
- package/src/base/action-dispatcher.ts +24 -10
- package/src/{features/tools/base-glsp-creation-tool.ts → base/action-handler-registry.ts} +10 -20
- package/src/base/default.module.ts +21 -34
- package/src/base/editor-context-service.ts +49 -16
- package/src/base/feedback/feedback-action-dispatcher.ts +5 -3
- package/src/base/focus/focus-tracker.ts +16 -5
- package/src/base/model/diagram-loader.ts +215 -0
- package/src/base/model/glsp-model-source.ts +199 -0
- package/src/base/model/model-initialization-constraint.spec.ts +95 -0
- package/src/base/{model-initialization-constraint.ts → model/model-initialization-constraint.ts} +43 -10
- package/src/base/selection-service.spec.ts +10 -9
- package/src/base/tool-manager/tool-manager.ts +183 -0
- package/src/base/tool-manager/tool.ts +85 -0
- package/src/default-modules.ts +37 -28
- package/src/features/accessibility/README.md +18 -0
- package/src/features/accessibility/accessibility-module.ts +6 -1
- package/src/features/accessibility/element-navigation/diagram-navigation-tool.ts +307 -0
- package/src/features/accessibility/element-navigation/element-navigation-module.ts +36 -0
- package/src/features/accessibility/element-navigation/element-navigator.ts +57 -0
- package/src/features/accessibility/element-navigation/left-right-top-bottom-navigator.ts +113 -0
- package/src/features/accessibility/element-navigation/local-element-navigator.ts +147 -0
- package/src/features/accessibility/element-navigation/position-navigator.ts +102 -0
- package/src/features/accessibility/focus-tracker/focus-tracker-module.ts +32 -0
- package/src/features/accessibility/focus-tracker/focus-tracker-tool.ts +129 -0
- package/src/features/accessibility/key-shortcut/accessible-key-shortcut-tool.ts +3 -3
- package/src/features/accessibility/key-shortcut/accessible-key-shortcut.ts +18 -3
- package/src/features/accessibility/resize-key-tool/resize-key-tool.ts +30 -16
- package/src/features/accessibility/search/search-palette.ts +4 -2
- package/src/features/accessibility/search/search-tool.ts +8 -9
- package/src/features/accessibility/toast/messages.json +16 -0
- package/src/features/accessibility/toast/toast-handler.ts +69 -0
- package/src/features/accessibility/toast/toast-module.ts +36 -0
- package/src/features/accessibility/toast/toast-tool.ts +108 -0
- package/src/features/accessibility/view-key-tools/deselect-key-tool.ts +2 -2
- package/src/features/accessibility/view-key-tools/movement-key-tool.ts +8 -10
- package/src/features/accessibility/view-key-tools/zoom-key-tool.ts +13 -15
- package/src/features/bounds/bounds-module.ts +2 -2
- package/src/features/command-palette/command-palette-tool.ts +2 -1
- package/src/features/command-palette/server-command-palette-provider.ts +3 -2
- package/src/features/context-menu/context-menu-module.ts +11 -12
- package/src/features/context-menu/{selection-service-aware-context-menu-mouse-listener.ts → glsp-context-menu-mouse-listener.ts} +1 -5
- package/src/features/context-menu/server-context-menu-provider.ts +3 -2
- package/src/features/copy-paste/copy-paste-context-menu.ts +3 -6
- package/src/features/hints/type-hints-module.ts +7 -6
- package/src/features/hints/type-hints.ts +12 -1
- package/src/features/hover/hover-module.ts +1 -2
- package/src/features/hover/hover.ts +2 -3
- package/src/features/label-edit/edit-label-tool.ts +2 -2
- package/src/features/label-edit/edit-label-validator.ts +7 -6
- package/src/features/navigation/navigation-action-handler.ts +5 -8
- package/src/features/navigation/navigation-target-resolver.ts +10 -7
- package/src/features/select/select-mouse-listener.ts +27 -79
- package/src/features/source-model-watcher/source-model-changed-action-handler.ts +3 -6
- package/src/features/status/status-module.ts +26 -0
- package/src/features/status/status-overlay.ts +121 -0
- package/src/features/tool-palette/tool-palette-module.ts +4 -3
- package/src/features/tool-palette/tool-palette.ts +44 -33
- package/src/features/tools/{base-glsp-tool.ts → base-tools.ts} +28 -3
- package/src/features/tools/change-bounds/change-bounds-tool.ts +2 -2
- package/src/features/tools/deletion/delete-tool.ts +4 -5
- package/src/features/tools/edge-creation/edge-creation-tool.ts +3 -3
- package/src/features/tools/edge-edit/edge-edit-tool.ts +2 -2
- package/src/features/tools/marquee-selection/marquee-mouse-tool.ts +3 -3
- package/src/features/tools/marquee-selection/marquee-tool.ts +4 -3
- package/src/features/tools/node-creation/node-creation-tool.ts +3 -3
- package/src/features/tools/tool-focus-loss-module.ts +2 -1
- package/src/features/validation/validate.ts +1 -1
- package/src/features/viewport/glsp-scroll-mouse-listener.ts +2 -9
- package/src/features/viewport/reposition.ts +119 -0
- package/src/features/viewport/viewport-modules.ts +3 -2
- package/src/glsp-sprotty/augmented-actions.ts +1 -16
- package/src/glsp-sprotty/index.ts +4 -7
- package/src/glsp-sprotty/types.ts +6 -8
- package/src/index.ts +17 -7
- package/src/standalone-modules.ts +40 -1
- package/src/views/base-view-module.ts +2 -2
- package/src/views/glsp-projection-view.tsx +18 -8
- package/lib/base/model-initialization-constraint.d.ts.map +0 -1
- package/lib/base/model-initialization-constraint.js.map +0 -1
- package/lib/base/source-uri-aware.d.ts +0 -5
- package/lib/base/source-uri-aware.d.ts.map +0 -1
- package/lib/base/source-uri-aware.js.map +0 -1
- package/lib/base/tool-manager/glsp-tool-manager.d.ts +0 -21
- package/lib/base/tool-manager/glsp-tool-manager.d.ts.map +0 -1
- package/lib/base/tool-manager/glsp-tool-manager.js +0 -113
- package/lib/base/tool-manager/glsp-tool-manager.js.map +0 -1
- package/lib/features/context-menu/selection-service-aware-context-menu-mouse-listener.d.ts.map +0 -1
- package/lib/features/context-menu/selection-service-aware-context-menu-mouse-listener.js.map +0 -1
- package/lib/features/tools/base-glsp-creation-tool.d.ts +0 -10
- package/lib/features/tools/base-glsp-creation-tool.d.ts.map +0 -1
- package/lib/features/tools/base-glsp-creation-tool.js.map +0 -1
- package/lib/features/tools/base-glsp-tool.d.ts.map +0 -1
- package/lib/features/tools/base-glsp-tool.js.map +0 -1
- package/lib/model-source/glsp-diagram-server.d.ts +0 -21
- package/lib/model-source/glsp-diagram-server.d.ts.map +0 -1
- package/lib/model-source/glsp-diagram-server.js +0 -107
- package/lib/model-source/glsp-diagram-server.js.map +0 -1
- package/src/base/tool-manager/glsp-tool-manager.ts +0 -96
- package/src/model-source/glsp-diagram-server.ts +0 -125
|
@@ -0,0 +1,199 @@
|
|
|
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 { inject, injectable, preDestroy } from 'inversify';
|
|
18
|
+
import {
|
|
19
|
+
Action,
|
|
20
|
+
ActionMessage,
|
|
21
|
+
Disposable,
|
|
22
|
+
DisposableCollection,
|
|
23
|
+
DisposeClientSessionParameters,
|
|
24
|
+
GLSPClient,
|
|
25
|
+
ILogger,
|
|
26
|
+
InitializeClientSessionParameters,
|
|
27
|
+
InitializeResult,
|
|
28
|
+
ModelSource,
|
|
29
|
+
SModelRootSchema,
|
|
30
|
+
TYPES
|
|
31
|
+
} from '~glsp-sprotty';
|
|
32
|
+
import { GLSPActionHandlerRegistry } from '../action-handler-registry';
|
|
33
|
+
import { IDiagramOptions } from './diagram-loader';
|
|
34
|
+
/**
|
|
35
|
+
* A helper interface that allows the client to mark actions that have been received from the server.
|
|
36
|
+
*/
|
|
37
|
+
export interface ServerAction extends Action {
|
|
38
|
+
__receivedFromServer: true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export namespace ServerAction {
|
|
42
|
+
export function is(object: unknown): object is ServerAction {
|
|
43
|
+
return Action.is(object) && '__receivedFromServer' in object && object.__receivedFromServer === true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Mark the given action as {@link ServerAction} by attaching the "_receivedFromServer" property
|
|
48
|
+
* @param action The action that should be marked as server action
|
|
49
|
+
*/
|
|
50
|
+
export function mark(action: Action): void {
|
|
51
|
+
(action as ServerAction).__receivedFromServer = true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Central component for enabling the client-server action flow with the help of an underlying {@link GLSPClient}.
|
|
57
|
+
* Handles & forwards actions that are intended for the GLSP server. In addition, it handles {@link ActionMessage}s received
|
|
58
|
+
* from the server and dispatches the corresponding actions locally.
|
|
59
|
+
*
|
|
60
|
+
* Note that in sprotty a {@link ModelSource} is serving the model to the event cycle and
|
|
61
|
+
* is used to commit the local (i.e. client-side) model back to the source.
|
|
62
|
+
* However, in GLSP the update flow is reversed meaning that changes to the source model are applied
|
|
63
|
+
* on the server side and then an update is sent to the client.
|
|
64
|
+
*/
|
|
65
|
+
@injectable()
|
|
66
|
+
export class GLSPModelSource extends ModelSource implements Disposable {
|
|
67
|
+
@inject(TYPES.ILogger)
|
|
68
|
+
protected logger: ILogger;
|
|
69
|
+
|
|
70
|
+
@inject(TYPES.IDiagramOptions)
|
|
71
|
+
protected options: IDiagramOptions;
|
|
72
|
+
|
|
73
|
+
protected toDispose = new DisposableCollection();
|
|
74
|
+
clientId: string;
|
|
75
|
+
|
|
76
|
+
protected _currentRoot: SModelRootSchema;
|
|
77
|
+
protected registry: GLSPActionHandlerRegistry;
|
|
78
|
+
protected glspClient?: GLSPClient;
|
|
79
|
+
|
|
80
|
+
get diagramType(): string {
|
|
81
|
+
return this.options.diagramType;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get sourceUri(): string | undefined {
|
|
85
|
+
return this.options.sourceUri;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Configure forwarding of server-handled actions to the given {@link GLSPClient} and
|
|
90
|
+
* handling of action received from the `GLSPClient` (i.e. server). It is expected that the
|
|
91
|
+
* given GLSP client has already been initialized.
|
|
92
|
+
* @param glspClient The GLSP to use.
|
|
93
|
+
* @throws An error if the given `GLSPClient` has not been initialized yet or if the set of server handled
|
|
94
|
+
* action kinds could not be derived from the initialize result
|
|
95
|
+
*/
|
|
96
|
+
configure(glspClient: GLSPClient): Promise<void> {
|
|
97
|
+
this.glspClient = glspClient;
|
|
98
|
+
if (!glspClient.initializeResult) {
|
|
99
|
+
throw new Error('Could not configure model source. The GLSP client is not initialized yet!');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const initializeParams = this.createInitializeClientSessionParameters(glspClient.initializeResult);
|
|
103
|
+
this.configureServeActions(glspClient.initializeResult);
|
|
104
|
+
|
|
105
|
+
this.toDispose.push(
|
|
106
|
+
glspClient.onActionMessage(message => this.messageReceived(message), this.clientId),
|
|
107
|
+
Disposable.create(() => glspClient.disposeClientSession(this.createDisposeClientSessionParameters()))
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
return glspClient!.initializeClientSession(initializeParams);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
protected createInitializeClientSessionParameters(_initializeResult: InitializeResult): InitializeClientSessionParameters {
|
|
114
|
+
const clientActionKinds = this.registry.getHandledActionKinds();
|
|
115
|
+
return {
|
|
116
|
+
clientSessionId: this.clientId,
|
|
117
|
+
clientActionKinds,
|
|
118
|
+
diagramType: this.diagramType
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
protected createDisposeClientSessionParameters(): DisposeClientSessionParameters {
|
|
123
|
+
return {
|
|
124
|
+
clientSessionId: this.clientId
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
protected configureServeActions(initializeResult: InitializeResult): void {
|
|
129
|
+
const serverActions = initializeResult.serverActions[this.diagramType];
|
|
130
|
+
if (serverActions?.length === 0) {
|
|
131
|
+
throw new Error(`No server-handled actions could be derived from the initialize result for diagramType: ${this.diagramType}!`);
|
|
132
|
+
}
|
|
133
|
+
serverActions.forEach(action => this.registry.register(action, this));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
protected messageReceived(message: ActionMessage): void {
|
|
137
|
+
if (this.clientId !== message.clientId) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const action = message.action;
|
|
141
|
+
ServerAction.mark(action);
|
|
142
|
+
this.logger.log(this, 'receiving', action);
|
|
143
|
+
this.actionDispatcher.dispatch(action);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
override initialize(registry: GLSPActionHandlerRegistry): void {
|
|
147
|
+
// Registering actions here is discouraged and it's recommended
|
|
148
|
+
// to implemented dedicated action handlers.
|
|
149
|
+
if (!this.clientId) {
|
|
150
|
+
this.clientId = this.options.clientId ?? this.viewerOptions.baseDiv;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
this.registry = registry;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
handle(action: Action): void {
|
|
157
|
+
// Handling additional actions here is discouraged and it's recommended
|
|
158
|
+
// to implemented dedicated action handlers.
|
|
159
|
+
if (this.shouldForwardToServer(action)) {
|
|
160
|
+
this.forwardToServer(action);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
protected forwardToServer(action: Action): void {
|
|
165
|
+
const message: ActionMessage = {
|
|
166
|
+
clientId: this.clientId,
|
|
167
|
+
action: action
|
|
168
|
+
};
|
|
169
|
+
this.logger.log(this, 'sending', message);
|
|
170
|
+
if (this.glspClient) {
|
|
171
|
+
this.glspClient.sendActionMessage(message);
|
|
172
|
+
} else {
|
|
173
|
+
throw new Error('GLSPClient is not connected');
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
protected shouldForwardToServer(action: Action): boolean {
|
|
178
|
+
return !ServerAction.is(action);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
commitModel(newRoot: SModelRootSchema): SModelRootSchema {
|
|
182
|
+
/* In GLSP the model update flow is server-driven. i.e. changes to the graphical model are applied
|
|
183
|
+
* on server-side an only the server can issue a model update.
|
|
184
|
+
* The internal/local model should never be committed back to the model source i.e. GLSP server.
|
|
185
|
+
* => no-op implementation that simply returns the `newRoot`
|
|
186
|
+
*/
|
|
187
|
+
this._currentRoot = newRoot;
|
|
188
|
+
return newRoot;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
override get model(): SModelRootSchema {
|
|
192
|
+
return this._currentRoot;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
@preDestroy()
|
|
196
|
+
dispose(): void {
|
|
197
|
+
this.toDispose.dispose();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
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 { expect } from 'chai';
|
|
17
|
+
import { Container } from 'inversify';
|
|
18
|
+
import 'reflect-metadata';
|
|
19
|
+
import * as sinon from 'sinon';
|
|
20
|
+
import { Deferred, EMPTY_ROOT, InitializeCanvasBoundsAction, SetModelAction, UpdateModelAction } from '~glsp-sprotty';
|
|
21
|
+
import { DefaultModelInitializationConstraint, ModelInitializationConstraint } from './model-initialization-constraint';
|
|
22
|
+
const sandbox = sinon.createSandbox();
|
|
23
|
+
const container = new Container();
|
|
24
|
+
let constraint: ModelInitializationConstraint;
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
26
|
+
const listener = sandbox.spy((): void => {});
|
|
27
|
+
|
|
28
|
+
describe('DefaultModelInitializationConstraint', () => {
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
constraint = container.resolve(DefaultModelInitializationConstraint);
|
|
31
|
+
sandbox.reset();
|
|
32
|
+
});
|
|
33
|
+
it('should complete after dispatching non empty SetModelAction and `InitializeCanvasBoundsAction`', () => {
|
|
34
|
+
expect(constraint.isCompleted).to.be.false;
|
|
35
|
+
constraint.notifyDispatched(SetModelAction.create({ id: 'model', type: 'graph' }));
|
|
36
|
+
expect(constraint.isCompleted).to.be.false;
|
|
37
|
+
constraint.notifyDispatched({ kind: InitializeCanvasBoundsAction.KIND });
|
|
38
|
+
expect(constraint.isCompleted).to.be.true;
|
|
39
|
+
});
|
|
40
|
+
it('should complete after dispatching non empty UpdateModelAction and `InitializeCanvasBoundsAction`', () => {
|
|
41
|
+
expect(constraint.isCompleted).to.be.false;
|
|
42
|
+
constraint.notifyDispatched(UpdateModelAction.create({ id: 'model', type: 'graph' }));
|
|
43
|
+
expect(constraint.isCompleted).to.be.false;
|
|
44
|
+
constraint.notifyDispatched({ kind: InitializeCanvasBoundsAction.KIND });
|
|
45
|
+
expect(constraint.isCompleted).to.be.true;
|
|
46
|
+
});
|
|
47
|
+
it('should note complete after dispatching empty SetModelAction and `InitializeCanvasBoundsAction` ', () => {
|
|
48
|
+
expect(constraint.isCompleted).to.be.false;
|
|
49
|
+
constraint.notifyDispatched(SetModelAction.create(EMPTY_ROOT));
|
|
50
|
+
expect(constraint.isCompleted).to.be.false;
|
|
51
|
+
constraint.notifyDispatched({ kind: InitializeCanvasBoundsAction.KIND });
|
|
52
|
+
expect(constraint.isCompleted).to.be.false;
|
|
53
|
+
});
|
|
54
|
+
it('should note complete after dispatching empty UpdateModelAction and `InitializeCanvasBoundsAction ', () => {
|
|
55
|
+
expect(constraint.isCompleted).to.be.false;
|
|
56
|
+
constraint.notifyDispatched(UpdateModelAction.create(EMPTY_ROOT));
|
|
57
|
+
expect(constraint.isCompleted).to.be.false;
|
|
58
|
+
constraint.notifyDispatched({ kind: InitializeCanvasBoundsAction.KIND });
|
|
59
|
+
expect(constraint.isCompleted).to.be.false;
|
|
60
|
+
});
|
|
61
|
+
describe('onInitialized', () => {
|
|
62
|
+
it('returned promise should resolve once the constraint is initialized', async () => {
|
|
63
|
+
const initializeDeferred = new Deferred<void>();
|
|
64
|
+
const initializePromise = constraint.onInitialized();
|
|
65
|
+
initializePromise.then(() => initializeDeferred.resolve());
|
|
66
|
+
expect(initializeDeferred.state).to.be.equal('unresolved');
|
|
67
|
+
// Directly trigger the completion method simplify test logic
|
|
68
|
+
constraint['setCompleted']();
|
|
69
|
+
// Short delay of test execution to ensure that the deferred state is updated.
|
|
70
|
+
await new Promise(resolve => setTimeout(resolve, 5));
|
|
71
|
+
expect(initializeDeferred.state).to.be.equal('resolved');
|
|
72
|
+
});
|
|
73
|
+
it('registered listener should be invoked once the constraint is initialized', () => {
|
|
74
|
+
constraint.onInitialized(listener);
|
|
75
|
+
expect(listener.called).to.be.false;
|
|
76
|
+
// Directly trigger the completion method simplify test logic
|
|
77
|
+
constraint['setCompleted']();
|
|
78
|
+
expect(listener.called).to.be.true;
|
|
79
|
+
});
|
|
80
|
+
it('registered listener should be invoked directly on registration if the constraint is already initialized', () => {
|
|
81
|
+
// Directly trigger the completion method simplify test logic
|
|
82
|
+
constraint['setCompleted']();
|
|
83
|
+
constraint.onInitialized(listener);
|
|
84
|
+
expect(listener.called).to.be.true;
|
|
85
|
+
});
|
|
86
|
+
it('Disposed listener should not be invoked once the constraint is initialized', () => {
|
|
87
|
+
const toDispose = constraint.onInitialized(listener);
|
|
88
|
+
expect(listener.called).to.be.false;
|
|
89
|
+
toDispose.dispose();
|
|
90
|
+
// Directly trigger the completion method simplify test logic
|
|
91
|
+
constraint['setCompleted']();
|
|
92
|
+
expect(listener.called).to.be.false;
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|
package/src/base/{model-initialization-constraint.ts → model/model-initialization-constraint.ts}
RENAMED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import { injectable } from 'inversify';
|
|
17
|
-
import { Action, Deferred, InitializeCanvasBoundsAction, SetModelAction, UpdateModelAction } from '~glsp-sprotty';
|
|
17
|
+
import { Action, Deferred, Disposable, Emitter, InitializeCanvasBoundsAction, SetModelAction, UpdateModelAction } from '~glsp-sprotty';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* The constraint defining when the initialization of the GLSP model is completed.
|
|
@@ -37,21 +37,46 @@ import { Action, Deferred, InitializeCanvasBoundsAction, SetModelAction, UpdateM
|
|
|
37
37
|
@injectable()
|
|
38
38
|
export abstract class ModelInitializationConstraint {
|
|
39
39
|
protected completion: Deferred<void> = new Deferred();
|
|
40
|
-
protected completed = false;
|
|
41
40
|
|
|
41
|
+
protected _isCompleted = false;
|
|
42
42
|
get isCompleted(): boolean {
|
|
43
|
-
return this.
|
|
43
|
+
return this._isCompleted;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
protected
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
protected onInitializedEmitter = new Emitter<void>();
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Register a listener that will be invoked once the initialization process
|
|
50
|
+
* has been completed. If the initialization is already completed on registration
|
|
51
|
+
* the given listener will be invoked right away
|
|
52
|
+
* @param listener
|
|
53
|
+
*/
|
|
54
|
+
onInitialized(listener: () => void): Disposable;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Retrieve a promise that resolves once the initialization process
|
|
58
|
+
* has been completed.
|
|
59
|
+
* @returns the initialization promise
|
|
60
|
+
*/
|
|
61
|
+
onInitialized(): Promise<void>;
|
|
62
|
+
onInitialized(listener?: () => void): Promise<void> | Disposable {
|
|
63
|
+
if (!listener) {
|
|
64
|
+
return this.completion.promise;
|
|
50
65
|
}
|
|
66
|
+
if (this.isCompleted) {
|
|
67
|
+
listener();
|
|
68
|
+
return Disposable.empty();
|
|
69
|
+
}
|
|
70
|
+
return this.onInitializedEmitter.event(listener);
|
|
51
71
|
}
|
|
52
72
|
|
|
53
|
-
|
|
54
|
-
|
|
73
|
+
protected setCompleted(): void {
|
|
74
|
+
if (!this.isCompleted) {
|
|
75
|
+
this._isCompleted = true;
|
|
76
|
+
this.completion.resolve();
|
|
77
|
+
this.onInitializedEmitter.fire();
|
|
78
|
+
this.onInitializedEmitter.dispose();
|
|
79
|
+
}
|
|
55
80
|
}
|
|
56
81
|
|
|
57
82
|
notifyDispatched(action: Action): void {
|
|
@@ -59,10 +84,18 @@ export abstract class ModelInitializationConstraint {
|
|
|
59
84
|
return;
|
|
60
85
|
}
|
|
61
86
|
if (this.isInitializedAfter(action)) {
|
|
62
|
-
this.setCompleted(
|
|
87
|
+
this.setCompleted();
|
|
63
88
|
}
|
|
64
89
|
}
|
|
65
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Central method to check the initialization state. Is invoked
|
|
93
|
+
* for every action dispatched by the `ActionDispatcher` (until the initialization has completed).
|
|
94
|
+
* Should
|
|
95
|
+
* return `true` once the action has been passed which marks the end
|
|
96
|
+
* of the initialization process.
|
|
97
|
+
* @param action The last dispatched action
|
|
98
|
+
*/
|
|
66
99
|
abstract isInitializedAfter(action: Action): boolean;
|
|
67
100
|
}
|
|
68
101
|
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { AssertionError, expect } from 'chai';
|
|
17
17
|
import { Container, injectable } from 'inversify';
|
|
18
18
|
import * as sinon from 'sinon';
|
|
19
|
-
import { Action, Disposable, SGraphFactory,
|
|
19
|
+
import { Action, Disposable, SGraphFactory, SModelRoot, SNode, TYPES, initializeContainer } from '~glsp-sprotty';
|
|
20
20
|
import { defaultModule } from './default.module';
|
|
21
21
|
import { IFeedbackActionDispatcher, IFeedbackEmitter } from './feedback/feedback-action-dispatcher';
|
|
22
22
|
import { ISelectionListener, SelectFeedbackAction, SelectionService } from './selection-service';
|
|
@@ -62,7 +62,6 @@ function createContainer(): Container {
|
|
|
62
62
|
|
|
63
63
|
describe('SelectionService', () => {
|
|
64
64
|
// eslint-disable-next-line deprecation/deprecation
|
|
65
|
-
let graphFactory: SGraphFactory;
|
|
66
65
|
let root: SModelRoot;
|
|
67
66
|
let selectionService: SelectionService;
|
|
68
67
|
let feedbackDispatcher: MockFeedbackActionDispatcher;
|
|
@@ -70,7 +69,6 @@ describe('SelectionService', () => {
|
|
|
70
69
|
beforeEach(() => {
|
|
71
70
|
const container = createContainer();
|
|
72
71
|
// eslint-disable-next-line deprecation/deprecation
|
|
73
|
-
graphFactory = container.get<SGraphFactory>(TYPES.IModelFactory);
|
|
74
72
|
root = createRoot('node1', 'node2', 'node3', 'node4', 'node5');
|
|
75
73
|
selectionService = container.get<SelectionService>(SelectionService);
|
|
76
74
|
feedbackDispatcher = container.get<MockFeedbackActionDispatcher>(TYPES.IFeedbackActionDispatcher);
|
|
@@ -243,13 +241,16 @@ describe('SelectionService', () => {
|
|
|
243
241
|
});
|
|
244
242
|
|
|
245
243
|
function createRoot(...nodes: string[]): SModelRoot {
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
244
|
+
const model = new SModelRoot();
|
|
245
|
+
model.id = 'selection-service-spec';
|
|
246
|
+
model.type = 'graph';
|
|
247
|
+
nodes.forEach(id => {
|
|
248
|
+
const node = new SNode();
|
|
249
|
+
node.type = 'node:circle';
|
|
250
|
+
node.id = id;
|
|
251
|
+
model.add(node);
|
|
252
252
|
});
|
|
253
|
+
return model;
|
|
253
254
|
}
|
|
254
255
|
|
|
255
256
|
function assertSelectionAndFeedback(expectedSelection: string[], expectedDeselection: string[]): void {
|
|
@@ -0,0 +1,183 @@
|
|
|
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
|
+
import { inject, injectable, multiInject, optional } from 'inversify';
|
|
18
|
+
import {
|
|
19
|
+
Action,
|
|
20
|
+
EditMode,
|
|
21
|
+
IActionHandler,
|
|
22
|
+
ICommand,
|
|
23
|
+
KeyListener,
|
|
24
|
+
SModelElement,
|
|
25
|
+
TYPES,
|
|
26
|
+
distinctAdd,
|
|
27
|
+
matchesKeystroke
|
|
28
|
+
} from '~glsp-sprotty';
|
|
29
|
+
import { EditorContextService, EditorContextServiceProvider } from '../editor-context-service';
|
|
30
|
+
import { EnableDefaultToolsAction, EnableToolsAction, Tool } from './tool';
|
|
31
|
+
/**
|
|
32
|
+
* A tool manager coordinates the state of tools in the context of an editor.
|
|
33
|
+
*
|
|
34
|
+
* One instance of a tool manager is intended per editor, coordinating the state of all tools within
|
|
35
|
+
* this editor. A tool can be active or not. A tool manager ensures that activating a set of tools
|
|
36
|
+
* will disable all other tools, allowing them to invoke behavior when they become enabled or disabled.
|
|
37
|
+
*/
|
|
38
|
+
export interface IToolManager {
|
|
39
|
+
/** All tools managed by this tool manager. */
|
|
40
|
+
readonly managedTools: Tool[];
|
|
41
|
+
|
|
42
|
+
/** The tools that are enabled by default, whenever no other tool is enabled. */
|
|
43
|
+
readonly defaultTools: Tool[];
|
|
44
|
+
|
|
45
|
+
/** The currently active tools, which are either specifically enabled tools, or the default tools. */
|
|
46
|
+
readonly activeTools: Tool[];
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Enables the tools with the specified `toolIds`.
|
|
50
|
+
* Therefore, this manager first disables currently active tools and then enable the
|
|
51
|
+
* tools indicated in `toolIds`, making them the currently active tools. If this manager
|
|
52
|
+
* doesn't manage one or more tools specified in `toolIds`, it'll do nothing. If not a
|
|
53
|
+
* single tool that shall be enabled was found in the managed tools, it'll fall back to
|
|
54
|
+
* the default tools.
|
|
55
|
+
*
|
|
56
|
+
* @param tools The tools to be enabled.
|
|
57
|
+
*/
|
|
58
|
+
enable(toolIds: string[]): void;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Enables all default tools.
|
|
62
|
+
*/
|
|
63
|
+
enableDefaultTools(): void;
|
|
64
|
+
|
|
65
|
+
/** Disables all currently active tools. After this call, no tool will be active anymore. */
|
|
66
|
+
disableActiveTools(): void;
|
|
67
|
+
|
|
68
|
+
registerDefaultTools(...tools: Tool[]): void;
|
|
69
|
+
|
|
70
|
+
registerTools(...tools: Tool[]): void;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The default {@link IToolManager} implementation. Allows
|
|
75
|
+
* registration of tools via Dependency Injection.
|
|
76
|
+
*/
|
|
77
|
+
@injectable()
|
|
78
|
+
export class ToolManager implements IToolManager {
|
|
79
|
+
readonly actives: Tool[] = [];
|
|
80
|
+
|
|
81
|
+
protected editorContext?: EditorContextService;
|
|
82
|
+
|
|
83
|
+
constructor(
|
|
84
|
+
@multiInject(TYPES.ITool)
|
|
85
|
+
@optional()
|
|
86
|
+
readonly tools: Tool[] = [],
|
|
87
|
+
@multiInject(TYPES.IDefaultTool)
|
|
88
|
+
@optional()
|
|
89
|
+
readonly defaultTools: Tool[],
|
|
90
|
+
@inject(TYPES.IEditorContextServiceProvider) protected contextServiceProvider: EditorContextServiceProvider
|
|
91
|
+
) {
|
|
92
|
+
this.registerTools(...this.tools);
|
|
93
|
+
this.registerDefaultTools(...this.defaultTools);
|
|
94
|
+
this.enableDefaultTools();
|
|
95
|
+
this.contextServiceProvider().then(editorContext => {
|
|
96
|
+
editorContext.onEditModeChanged(change => this.editModeChanged(change.newValue, change.oldValue));
|
|
97
|
+
this.editorContext = editorContext;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
get managedTools(): Tool[] {
|
|
102
|
+
return this.defaultTools.concat(this.tools);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
get activeTools(): Tool[] {
|
|
106
|
+
return this.actives;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
registerDefaultTools(...tools: Tool[]): void {
|
|
110
|
+
distinctAdd(this.defaultTools, ...tools);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
registerTools(...tools: Tool[]): void {
|
|
114
|
+
distinctAdd(this.tools, ...tools);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
disableActiveTools(): void {
|
|
118
|
+
this.actives.forEach(tool => tool.disable());
|
|
119
|
+
this.actives.splice(0, this.actives.length);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
enableDefaultTools(): void {
|
|
123
|
+
this.enable(this.defaultTools.map(tool => tool.id));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
enable(toolIds: string[]): void {
|
|
127
|
+
this.disableActiveTools();
|
|
128
|
+
let tools = toolIds.map(id => this.tool(id));
|
|
129
|
+
if (this.editorContext && this.editorContext.isReadonly) {
|
|
130
|
+
tools = tools.filter(tool => !tool?.isEditTool);
|
|
131
|
+
}
|
|
132
|
+
tools.forEach(tool => {
|
|
133
|
+
if (tool !== undefined) {
|
|
134
|
+
tool.enable();
|
|
135
|
+
this.actives.push(tool);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
tool(toolId: string): Tool | undefined {
|
|
141
|
+
return this.managedTools.find(tool => tool.id === toolId);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
disableEditTools(): void {
|
|
145
|
+
this.disableActiveTools();
|
|
146
|
+
this.enable(this.defaultTools.filter(tool => !tool.isEditTool).map(tool => tool.id));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
editModeChanged(newValue: string, oldValue: string): void {
|
|
150
|
+
if (oldValue === newValue) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (newValue === EditMode.READONLY) {
|
|
154
|
+
this.disableEditTools();
|
|
155
|
+
} else if (newValue === EditMode.EDITABLE) {
|
|
156
|
+
this.enableDefaultTools();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@injectable()
|
|
162
|
+
export class ToolManagerActionHandler implements IActionHandler {
|
|
163
|
+
@inject(TYPES.IToolManager)
|
|
164
|
+
readonly toolManager: IToolManager;
|
|
165
|
+
|
|
166
|
+
handle(action: Action): void | ICommand | Action {
|
|
167
|
+
if (EnableDefaultToolsAction.is(action)) {
|
|
168
|
+
this.toolManager.enableDefaultTools();
|
|
169
|
+
} else if (EnableToolsAction.is(action)) {
|
|
170
|
+
this.toolManager.enable((action as EnableToolsAction).toolIds);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
@injectable()
|
|
176
|
+
export class DefaultToolsEnablingKeyListener extends KeyListener {
|
|
177
|
+
override keyDown(element: SModelElement, event: KeyboardEvent): Action[] {
|
|
178
|
+
if (matchesKeystroke(event, 'Escape')) {
|
|
179
|
+
return [EnableDefaultToolsAction.create()];
|
|
180
|
+
}
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
}
|