@eclipse-glsp/client 2.1.0-next.295 → 2.1.0-next.297

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.
Files changed (125) hide show
  1. package/css/ghost-element.css +25 -0
  2. package/css/glsp-sprotty.css +5 -0
  3. package/lib/base/args-feature.d.ts +2 -1
  4. package/lib/base/args-feature.d.ts.map +1 -1
  5. package/lib/base/args-feature.js +12 -2
  6. package/lib/base/args-feature.js.map +1 -1
  7. package/lib/base/command-stack.d.ts +22 -3
  8. package/lib/base/command-stack.d.ts.map +1 -1
  9. package/lib/base/command-stack.js +2 -2
  10. package/lib/base/command-stack.js.map +1 -1
  11. package/lib/base/default.module.d.ts +1 -1
  12. package/lib/base/default.module.d.ts.map +1 -1
  13. package/lib/base/default.module.js +2 -2
  14. package/lib/base/default.module.js.map +1 -1
  15. package/lib/base/feedback/css-feedback.d.ts +17 -0
  16. package/lib/base/feedback/css-feedback.d.ts.map +1 -1
  17. package/lib/base/feedback/css-feedback.js +4 -2
  18. package/lib/base/feedback/css-feedback.js.map +1 -1
  19. package/lib/base/selection-service.d.ts +18 -3
  20. package/lib/base/selection-service.d.ts.map +1 -1
  21. package/lib/base/selection-service.js +1 -1
  22. package/lib/base/selection-service.js.map +1 -1
  23. package/lib/default-modules.d.ts +1 -1
  24. package/lib/default-modules.d.ts.map +1 -1
  25. package/lib/default-modules.js +2 -0
  26. package/lib/default-modules.js.map +1 -1
  27. package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette-module.d.ts.map +1 -1
  28. package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette-module.js +4 -2
  29. package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette-module.js.map +1 -1
  30. package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.d.ts +16 -1
  31. package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.d.ts.map +1 -1
  32. package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.js +9 -10
  33. package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.js.map +1 -1
  34. package/lib/features/bounds/bounds-module.d.ts.map +1 -1
  35. package/lib/features/bounds/bounds-module.js +4 -0
  36. package/lib/features/bounds/bounds-module.js.map +1 -1
  37. package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts +2 -2
  38. package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts.map +1 -1
  39. package/lib/features/bounds/glsp-hidden-bounds-updater.js +7 -3
  40. package/lib/features/bounds/glsp-hidden-bounds-updater.js.map +1 -1
  41. package/lib/features/bounds/local-bounds.d.ts +34 -0
  42. package/lib/features/bounds/local-bounds.d.ts.map +1 -0
  43. package/lib/features/bounds/local-bounds.js +99 -0
  44. package/lib/features/bounds/local-bounds.js.map +1 -0
  45. package/lib/features/bounds/set-bounds-feedback-command.d.ts +33 -0
  46. package/lib/features/bounds/set-bounds-feedback-command.d.ts.map +1 -0
  47. package/lib/features/bounds/set-bounds-feedback-command.js +74 -0
  48. package/lib/features/bounds/set-bounds-feedback-command.js.map +1 -0
  49. package/lib/features/change-bounds/model.d.ts +1 -1
  50. package/lib/features/change-bounds/model.d.ts.map +1 -1
  51. package/lib/features/change-bounds/model.js +0 -1
  52. package/lib/features/change-bounds/model.js.map +1 -1
  53. package/lib/features/decoration/decoration-placer.d.ts +16 -1
  54. package/lib/features/decoration/decoration-placer.d.ts.map +1 -1
  55. package/lib/features/decoration/decoration-placer.js +3 -3
  56. package/lib/features/decoration/decoration-placer.js.map +1 -1
  57. package/lib/features/element-template/add-template-element.d.ts +39 -0
  58. package/lib/features/element-template/add-template-element.d.ts.map +1 -0
  59. package/lib/features/element-template/add-template-element.js +107 -0
  60. package/lib/features/element-template/add-template-element.js.map +1 -0
  61. package/lib/features/element-template/element-template-module.d.ts +18 -0
  62. package/lib/features/element-template/element-template-module.d.ts.map +1 -0
  63. package/lib/features/element-template/element-template-module.js +27 -0
  64. package/lib/features/element-template/element-template-module.js.map +1 -0
  65. package/lib/features/element-template/mouse-tracking-element-position-listener.d.ts +38 -0
  66. package/lib/features/element-template/mouse-tracking-element-position-listener.d.ts.map +1 -0
  67. package/lib/features/element-template/mouse-tracking-element-position-listener.js +102 -0
  68. package/lib/features/element-template/mouse-tracking-element-position-listener.js.map +1 -0
  69. package/lib/features/element-template/remove-template-element.d.ts +32 -0
  70. package/lib/features/element-template/remove-template-element.d.ts.map +1 -0
  71. package/lib/features/element-template/remove-template-element.js +66 -0
  72. package/lib/features/element-template/remove-template-element.js.map +1 -0
  73. package/lib/features/tool-palette/tool-palette-module.d.ts.map +1 -1
  74. package/lib/features/tool-palette/tool-palette-module.js +2 -0
  75. package/lib/features/tool-palette/tool-palette-module.js.map +1 -1
  76. package/lib/features/tool-palette/tool-palette.d.ts +22 -4
  77. package/lib/features/tool-palette/tool-palette.d.ts.map +1 -1
  78. package/lib/features/tool-palette/tool-palette.js +35 -11
  79. package/lib/features/tool-palette/tool-palette.js.map +1 -1
  80. package/lib/features/tools/change-bounds/change-bounds-tool.d.ts +1 -1
  81. package/lib/features/tools/change-bounds/change-bounds-tool.d.ts.map +1 -1
  82. package/lib/features/tools/change-bounds/change-bounds-tool.js +6 -5
  83. package/lib/features/tools/change-bounds/change-bounds-tool.js.map +1 -1
  84. package/lib/features/tools/change-bounds/view.d.ts +16 -1
  85. package/lib/features/tools/change-bounds/view.d.ts.map +1 -1
  86. package/lib/features/tools/change-bounds/view.js +1 -1
  87. package/lib/features/tools/change-bounds/view.js.map +1 -1
  88. package/lib/features/tools/node-creation/node-creation-module.d.ts.map +1 -1
  89. package/lib/features/tools/node-creation/node-creation-module.js +2 -1
  90. package/lib/features/tools/node-creation/node-creation-module.js.map +1 -1
  91. package/lib/features/tools/node-creation/node-creation-tool.d.ts +24 -3
  92. package/lib/features/tools/node-creation/node-creation-tool.d.ts.map +1 -1
  93. package/lib/features/tools/node-creation/node-creation-tool.js +41 -11
  94. package/lib/features/tools/node-creation/node-creation-tool.js.map +1 -1
  95. package/lib/index.d.ts +4 -0
  96. package/lib/index.d.ts.map +1 -1
  97. package/lib/index.js +4 -0
  98. package/lib/index.js.map +1 -1
  99. package/lib/tsconfig.tsbuildinfo +1 -1
  100. package/package.json +3 -3
  101. package/src/base/args-feature.ts +12 -2
  102. package/src/base/command-stack.ts +10 -5
  103. package/src/base/default.module.ts +2 -2
  104. package/src/base/feedback/css-feedback.ts +4 -1
  105. package/src/base/selection-service.ts +12 -6
  106. package/src/default-modules.ts +2 -0
  107. package/src/features/accessibility/keyboard-tool-palette/keyboard-tool-palette-module.ts +13 -3
  108. package/src/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.ts +15 -16
  109. package/src/features/bounds/bounds-module.ts +6 -0
  110. package/src/features/bounds/glsp-hidden-bounds-updater.ts +11 -7
  111. package/src/features/bounds/local-bounds.ts +91 -0
  112. package/src/features/bounds/set-bounds-feedback-command.ts +70 -0
  113. package/src/features/change-bounds/model.ts +2 -3
  114. package/src/features/decoration/decoration-placer.ts +3 -3
  115. package/src/features/element-template/add-template-element.ts +109 -0
  116. package/src/features/element-template/element-template-module.ts +24 -0
  117. package/src/features/element-template/mouse-tracking-element-position-listener.ts +110 -0
  118. package/src/features/element-template/remove-template-element.ts +56 -0
  119. package/src/features/tool-palette/tool-palette-module.ts +3 -1
  120. package/src/features/tool-palette/tool-palette.ts +42 -14
  121. package/src/features/tools/change-bounds/change-bounds-tool.ts +12 -10
  122. package/src/features/tools/change-bounds/view.tsx +1 -1
  123. package/src/features/tools/node-creation/node-creation-module.ts +9 -5
  124. package/src/features/tools/node-creation/node-creation-tool.ts +51 -13
  125. package/src/index.ts +4 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclipse-glsp/client",
3
- "version": "2.1.0-next.295+0c22eb6",
3
+ "version": "2.1.0-next.297+b122673",
4
4
  "description": "A sprotty-based client for GLSP",
5
5
  "keywords": [
6
6
  "eclipse",
@@ -47,7 +47,7 @@
47
47
  "watch": "tsc -w"
48
48
  },
49
49
  "dependencies": {
50
- "@eclipse-glsp/sprotty": "2.1.0-next.295+0c22eb6",
50
+ "@eclipse-glsp/sprotty": "2.1.0-next.297+b122673",
51
51
  "autocompleter": "^9.1.0",
52
52
  "file-saver": "^2.0.5",
53
53
  "lodash": "4.17.21"
@@ -59,5 +59,5 @@
59
59
  "publishConfig": {
60
60
  "access": "public"
61
61
  },
62
- "gitHead": "0c22eb65d1e79fca017703f1238ef39bc33c06b9"
62
+ "gitHead": "b12267336155c530066c4197e82f8208b08a6d98"
63
63
  }
@@ -28,10 +28,20 @@ export interface ArgsAware {
28
28
  args?: Args;
29
29
  }
30
30
 
31
- export function isArgsAware(element: GModelElement): element is GModelElement & ArgsAware {
32
- return element.hasFeature(argsFeature);
31
+ export function isArgsAware(element?: GModelElement): element is GModelElement & ArgsAware {
32
+ return element !== undefined && element.hasFeature(argsFeature);
33
33
  }
34
34
 
35
35
  export function hasArgs(element?: GModelElement): element is GModelElement & Required<ArgsAware> {
36
36
  return element !== undefined && isArgsAware(element) && element.args !== undefined;
37
37
  }
38
+
39
+ export function ensureArgs(element?: GModelElement): element is GModelElement & Required<ArgsAware> {
40
+ if (!isArgsAware(element)) {
41
+ return false;
42
+ }
43
+ if (element.args === undefined) {
44
+ element.args = {};
45
+ }
46
+ return true;
47
+ }
@@ -13,33 +13,38 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { injectable, multiInject, optional, preDestroy } from 'inversify';
17
16
  import {
18
17
  CommandStack,
19
18
  Disposable,
20
19
  DisposableCollection,
21
20
  Emitter,
22
21
  Event,
23
- ICommand,
24
22
  GModelRoot,
23
+ ICommand,
25
24
  SetModelCommand,
26
25
  TYPES,
27
26
  UpdateModelCommand
28
27
  } from '@eclipse-glsp/sprotty';
28
+ import { injectable, multiInject, optional, preDestroy } from 'inversify';
29
29
 
30
30
  /**
31
31
  * A hook to listen for model root changes. Will be called after a server update
32
32
  * has been processed
33
33
  */
34
- export interface ISModelRootListener {
34
+ export interface IGModelRootListener {
35
35
  modelRootChanged(root: Readonly<GModelRoot>): void;
36
36
  }
37
37
 
38
+ /**
39
+ * @deprecated Use {@link IGModelRootListener} instead
40
+ */
41
+ export type ISModelRootListener = IGModelRootListener;
42
+
38
43
  @injectable()
39
44
  export class GLSPCommandStack extends CommandStack implements Disposable {
40
- @multiInject(TYPES.ISModelRootListener)
45
+ @multiInject(TYPES.IGModelRootListener)
41
46
  @optional()
42
- protected modelRootListeners: ISModelRootListener[] = [];
47
+ protected modelRootListeners: IGModelRootListener[] = [];
43
48
  protected toDispose = new DisposableCollection();
44
49
 
45
50
  protected override initialize(): void {
@@ -13,7 +13,6 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import '@vscode/codicons/dist/codicon.css';
17
16
  import {
18
17
  ActionHandlerRegistry,
19
18
  FeatureModule,
@@ -30,6 +29,7 @@ import {
30
29
  configureCommand,
31
30
  sprottyDefaultModule
32
31
  } from '@eclipse-glsp/sprotty';
32
+ import '@vscode/codicons/dist/codicon.css';
33
33
  import '../../css/glsp-sprotty.css';
34
34
  import { GLSPActionDispatcher } from './action-dispatcher';
35
35
  import { GLSPActionHandlerRegistry } from './action-handler-registry';
@@ -96,7 +96,7 @@ export const defaultModule = new FeatureModule((bind, unbind, isBound, rebind, .
96
96
  bindOrRebind(context, TYPES.ViewRegistry).to(GViewRegistry).inSingletonScope();
97
97
 
98
98
  bind(SelectionService).toSelf().inSingletonScope();
99
- bind(TYPES.ISModelRootListener).toService(SelectionService);
99
+ bind(TYPES.IGModelRootListener).toService(SelectionService);
100
100
 
101
101
  // Feedback Support ------------------------------------
102
102
  // Generic re-usable feedback modifying css classes
@@ -13,8 +13,8 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { inject, injectable } from 'inversify';
17
16
  import { Action, CommandExecutionContext, GModelElement, GModelRoot, TYPES, hasArrayProp } from '@eclipse-glsp/sprotty';
17
+ import { inject, injectable } from 'inversify';
18
18
  import { addCssClasses, getElements, removeCssClasses } from '../../utils/gmodel-util';
19
19
  import { FeedbackCommand } from './feedback-command';
20
20
 
@@ -69,6 +69,9 @@ export class ModifyCssFeedbackCommand extends FeedbackCommand {
69
69
  }
70
70
  }
71
71
 
72
+ export const CSS_GHOST_ELEMENT = 'ghost-element';
73
+ export const CSS_HIDDEN = 'hidden';
74
+
72
75
  export enum CursorCSS {
73
76
  DEFAULT = 'default-mode',
74
77
  OVERLAP_FORBIDDEN = 'overlap-forbidden-mode',
@@ -13,7 +13,6 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { inject, injectable, multiInject, optional, postConstruct, preDestroy } from 'inversify';
17
16
  import {
18
17
  Action,
19
18
  Command,
@@ -23,9 +22,9 @@ import {
23
22
  Emitter,
24
23
  Event,
25
24
  GChildElement,
26
- ILogger,
27
25
  GModelElement,
28
26
  GModelRoot,
27
+ ILogger,
29
28
  SelectAction,
30
29
  SelectAllAction,
31
30
  Selectable,
@@ -36,8 +35,9 @@ import {
36
35
  isSelectable,
37
36
  pluck
38
37
  } from '@eclipse-glsp/sprotty';
38
+ import { inject, injectable, multiInject, optional, postConstruct, preDestroy } from 'inversify';
39
39
  import { getElements, getMatchingElements } from '../utils/gmodel-util';
40
- import { ISModelRootListener } from './command-stack';
40
+ import { IGModelRootListener } from './command-stack';
41
41
  import { IFeedbackActionDispatcher } from './feedback/feedback-action-dispatcher';
42
42
 
43
43
  export interface ISelectionListener {
@@ -51,7 +51,7 @@ export interface SelectionChange {
51
51
  }
52
52
 
53
53
  @injectable()
54
- export class SelectionService implements ISModelRootListener, Disposable {
54
+ export class SelectionService implements IGModelRootListener, Disposable {
55
55
  protected root: Readonly<GModelRoot>;
56
56
  protected selectedElementIDs: Set<string> = new Set();
57
57
 
@@ -197,7 +197,10 @@ export class SelectCommand extends Command {
197
197
  protected selected: GModelElement[] = [];
198
198
  protected deselected: GModelElement[] = [];
199
199
 
200
- constructor(@inject(TYPES.Action) public action: SelectAction, @inject(SelectionService) public selectionService: SelectionService) {
200
+ constructor(
201
+ @inject(TYPES.Action) public action: SelectAction,
202
+ @inject(SelectionService) public selectionService: SelectionService
203
+ ) {
201
204
  super();
202
205
  }
203
206
 
@@ -234,7 +237,10 @@ export class SelectAllCommand extends Command {
234
237
  static readonly KIND = SprottySelectAllCommand.KIND;
235
238
  protected previousSelection: Map<string, boolean> = new Map<string, boolean>();
236
239
 
237
- constructor(@inject(TYPES.Action) public action: SelectAllAction, @inject(SelectionService) public selectionService: SelectionService) {
240
+ constructor(
241
+ @inject(TYPES.Action) public action: SelectAllAction,
242
+ @inject(SelectionService) public selectionService: SelectionService
243
+ ) {
238
244
  super();
239
245
  }
240
246
 
@@ -39,6 +39,7 @@ import { commandPaletteModule } from './features/command-palette/command-palette
39
39
  import { contextMenuModule } from './features/context-menu/context-menu-module';
40
40
  import { copyPasteModule } from './features/copy-paste/copy-paste-modules';
41
41
  import { decorationModule } from './features/decoration/decoration-module';
42
+ import { elementTemplateModule } from './features/element-template/element-template-module';
42
43
  import { exportModule } from './features/export/export-modules';
43
44
  import { typeHintsModule } from './features/hints/type-hints-module';
44
45
  import { hoverModule } from './features/hover/hover-module';
@@ -90,6 +91,7 @@ export const DEFAULT_MODULES = [
90
91
  edgeCreationToolModule,
91
92
  edgeEditToolModule,
92
93
  deletionToolModule,
94
+ elementTemplateModule,
93
95
  nodeCreationToolModule,
94
96
  changeBoundsToolModule,
95
97
  marqueeSelectionToolModule,
@@ -15,11 +15,19 @@
15
15
  ********************************************************************************/
16
16
  import '../../../../css/keyboard-tool-palette.css';
17
17
 
18
- import { configureActionHandler, TYPES, bindAsService, BindingContext, FeatureModule } from '@eclipse-glsp/sprotty';
18
+ import {
19
+ BindingContext,
20
+ FeatureModule,
21
+ SetModelAction,
22
+ TYPES,
23
+ UpdateModelAction,
24
+ bindAsService,
25
+ configureActionHandler
26
+ } from '@eclipse-glsp/sprotty';
27
+ import { EnableDefaultToolsAction } from '../../../base/tool-manager/tool';
19
28
  import { EnableToolPaletteAction } from '../../tool-palette/tool-palette';
20
- import { KeyboardToolPalette } from './keyboard-tool-palette';
21
29
  import { FocusDomAction } from '../actions';
22
- import { EnableDefaultToolsAction } from '../../../base/tool-manager/tool';
30
+ import { KeyboardToolPalette } from './keyboard-tool-palette';
23
31
 
24
32
  export const keyboardToolPaletteModule = new FeatureModule((bind, unbind, isBound, rebind) => {
25
33
  const context = { bind, unbind, isBound, rebind };
@@ -32,4 +40,6 @@ export function configureKeyboardToolPaletteTool(context: BindingContext): void
32
40
  configureActionHandler(context, EnableDefaultToolsAction.KIND, KeyboardToolPalette);
33
41
  configureActionHandler(context, FocusDomAction.KIND, KeyboardToolPalette);
34
42
  configureActionHandler(context, EnableToolPaletteAction.KIND, KeyboardToolPalette);
43
+ configureActionHandler(context, UpdateModelAction.KIND, KeyboardToolPalette);
44
+ configureActionHandler(context, SetModelAction.KIND, KeyboardToolPalette);
35
45
  }
@@ -13,35 +13,35 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { injectable } from 'inversify';
17
16
  import {
18
- ICommand,
19
- SetUIExtensionVisibilityAction,
20
17
  Action,
18
+ ICommand,
21
19
  PaletteItem,
22
20
  RequestContextActions,
23
21
  RequestMarkersAction,
24
22
  SetContextActions,
23
+ SetUIExtensionVisibilityAction,
25
24
  TriggerNodeCreationAction
26
25
  } from '@eclipse-glsp/sprotty';
26
+ import { injectable } from 'inversify';
27
27
  import { KeyCode, matchesKeystroke } from 'sprotty/lib/utils/keyboard';
28
- import { MouseDeleteTool } from '../../tools/deletion/delete-tool';
29
- import { MarqueeMouseTool } from '../../tools/marquee-selection/marquee-mouse-tool';
28
+ import { EnableDefaultToolsAction, EnableToolsAction } from '../../../base/tool-manager/tool';
30
29
  import {
31
- createIcon,
32
- changeCodiconClass,
33
- createToolGroup,
30
+ EnableToolPaletteAction,
34
31
  ToolPalette,
32
+ changeCodiconClass,
35
33
  compare,
36
- EnableToolPaletteAction
34
+ createIcon,
35
+ createToolGroup
37
36
  } from '../../tool-palette/tool-palette';
38
- import { KeyboardNodeGridMetadata } from '../keyboard-grid/constants';
37
+ import { MouseDeleteTool } from '../../tools/deletion/delete-tool';
38
+ import { MarqueeMouseTool } from '../../tools/marquee-selection/marquee-mouse-tool';
39
39
  import { FocusDomAction } from '../actions';
40
40
  import { EdgeAutocompletePaletteMetadata } from '../edge-autocomplete/edge-autocomplete-palette';
41
- import { EnableDefaultToolsAction, EnableToolsAction } from '../../../base/tool-manager/tool';
42
- import { ShowToastMessageAction } from '../toast/toast-handler';
43
41
  import { ElementNavigatorKeyListener } from '../element-navigation/diagram-navigation-tool';
42
+ import { KeyboardNodeGridMetadata } from '../keyboard-grid/constants';
44
43
  import * as messages from '../toast/messages.json';
44
+ import { ShowToastMessageAction } from '../toast/toast-handler';
45
45
 
46
46
  const SEARCH_ICON_ID = 'search';
47
47
  const PALETTE_ICON_ID = 'symbol-color';
@@ -119,7 +119,7 @@ export class KeyboardToolPalette extends ToolPalette {
119
119
  }
120
120
 
121
121
  override handle(action: Action): ICommand | Action | void {
122
- if (action.kind === EnableToolPaletteAction.KIND) {
122
+ if (EnableToolPaletteAction.is(action)) {
123
123
  const requestAction = RequestContextActions.create({
124
124
  contextId: ToolPalette.ID,
125
125
  editorContext: {
@@ -134,9 +134,6 @@ export class KeyboardToolPalette extends ToolPalette {
134
134
  ]);
135
135
  }
136
136
  });
137
- } else if (action.kind === EnableDefaultToolsAction.KIND) {
138
- this.changeActiveButton();
139
- this.restoreFocus();
140
137
  } else if (FocusDomAction.is(action) && action.id === ToolPalette.ID) {
141
138
  if (this.containerElement.contains(document.activeElement)) {
142
139
  this.toggleShortcutVisibility();
@@ -144,6 +141,8 @@ export class KeyboardToolPalette extends ToolPalette {
144
141
  this.showShortcuts();
145
142
  }
146
143
  this.containerElement.focus();
144
+ } else {
145
+ super.handle(action);
147
146
  }
148
147
  }
149
148
 
@@ -30,6 +30,8 @@ import { FreeFormLayouter } from './freeform-layout';
30
30
  import { GLSPHiddenBoundsUpdater } from './glsp-hidden-bounds-updater';
31
31
  import { HBoxLayouterExt } from './hbox-layout';
32
32
  import { LayouterExt } from './layouter';
33
+ import { LocalComputedBoundsCommand } from './local-bounds';
34
+ import { SetBoundsFeebackCommand } from './set-bounds-feedback-command';
33
35
  import { VBoxLayouterExt } from './vbox-layout';
34
36
 
35
37
  export const boundsModule = new FeatureModule((bind, _unbind, isBound, _rebind) => {
@@ -38,6 +40,10 @@ export const boundsModule = new FeatureModule((bind, _unbind, isBound, _rebind)
38
40
  configureCommand(context, RequestBoundsCommand);
39
41
  bind(HiddenBoundsUpdater).toSelf().inSingletonScope();
40
42
  bindAsService(context, TYPES.HiddenVNodePostprocessor, GLSPHiddenBoundsUpdater);
43
+
44
+ configureCommand(context, LocalComputedBoundsCommand);
45
+ configureCommand(context, SetBoundsFeebackCommand);
46
+
41
47
  bind(TYPES.Layouter).to(LayouterExt).inSingletonScope();
42
48
  bind(TYPES.LayoutRegistry).to(LayoutRegistry).inSingletonScope();
43
49
 
@@ -14,22 +14,23 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
- import { inject, injectable, optional } from 'inversify';
18
- import { VNode } from 'snabbdom';
19
17
  import {
20
18
  Action,
21
19
  ComputedBoundsAction,
22
20
  Deferred,
23
21
  EdgeRouterRegistry,
24
22
  ElementAndRoutingPoints,
23
+ GModelElement,
24
+ GRoutableElement,
25
25
  HiddenBoundsUpdater,
26
26
  IActionDispatcher,
27
27
  RequestAction,
28
- ResponseAction,
29
- GModelElement,
30
- GRoutableElement
28
+ ResponseAction
31
29
  } from '@eclipse-glsp/sprotty';
30
+ import { inject, injectable, optional } from 'inversify';
31
+ import { VNode } from 'snabbdom';
32
32
  import { calcElementAndRoute, isRoutable } from '../../utils/gmodel-util';
33
+ import { LocalComputedBoundsAction, LocalRequestBoundsAction } from './local-bounds';
33
34
 
34
35
  /**
35
36
  * Grabs the bounds from hidden SVG DOM elements, applies layouts, collects routes and fires {@link ComputedBoundsAction}s.
@@ -56,7 +57,7 @@ export class GLSPHiddenBoundsUpdater extends HiddenBoundsUpdater {
56
57
  const actions = this.captureActions(() => super.postUpdate(cause));
57
58
  actions
58
59
  .filter(action => ComputedBoundsAction.is(action))
59
- .forEach(action => this.actionDispatcher.dispatch(this.enhanceAction(action as ComputedBoundsAction)));
60
+ .forEach(action => this.actionDispatcher.dispatch(this.enhanceAction(action as ComputedBoundsAction, cause)));
60
61
  this.element2route = [];
61
62
  }
62
63
 
@@ -72,7 +73,10 @@ export class GLSPHiddenBoundsUpdater extends HiddenBoundsUpdater {
72
73
  }
73
74
  }
74
75
 
75
- protected enhanceAction(action: ComputedBoundsAction): ComputedBoundsAction {
76
+ protected enhanceAction(action: ComputedBoundsAction, cause?: Action): ComputedBoundsAction {
77
+ if (LocalRequestBoundsAction.is(cause)) {
78
+ LocalComputedBoundsAction.mark(action);
79
+ }
76
80
  action.routes = this.element2route.length === 0 ? undefined : this.element2route;
77
81
  return action;
78
82
  }
@@ -0,0 +1,91 @@
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 {
17
+ Action,
18
+ ActionDispatcher,
19
+ Command,
20
+ CommandExecutionContext,
21
+ CommandResult,
22
+ CommandReturn,
23
+ ComputedBoundsAction,
24
+ ComputedBoundsApplicator,
25
+ GModelRoot,
26
+ GModelRootSchema,
27
+ RequestBoundsAction,
28
+ TYPES
29
+ } from '@eclipse-glsp/sprotty';
30
+ import { inject, injectable } from 'inversify';
31
+ import { ServerAction } from '../../base/model/glsp-model-source';
32
+
33
+ export namespace LocalRequestBoundsAction {
34
+ export function is(object: unknown): object is RequestBoundsAction {
35
+ return RequestBoundsAction.is(object) && !ServerAction.is(object);
36
+ }
37
+
38
+ export function fromCommand(context: CommandExecutionContext, actionDispatcher: ActionDispatcher, cause?: Action): CommandResult {
39
+ // do not modify the main model (modelChanged = false) but request local bounds calculation on hidden model
40
+ actionDispatcher.dispatch(RequestBoundsAction.create(context.root as unknown as GModelRootSchema));
41
+ return {
42
+ model: context.root,
43
+ modelChanged: false,
44
+ cause
45
+ };
46
+ }
47
+ }
48
+
49
+ export namespace LocalComputedBoundsAction {
50
+ export function is(object: unknown): object is RequestBoundsAction {
51
+ return ComputedBoundsAction.is(object) && ServerAction.is(object);
52
+ }
53
+
54
+ export function mark(action: ComputedBoundsAction): ComputedBoundsAction {
55
+ // mimic: we mark the computed bounds action as coming from the server so it is not sent to the server and handled locally
56
+ ServerAction.mark(action);
57
+ return action;
58
+ }
59
+ }
60
+
61
+ @injectable()
62
+ export class LocalComputedBoundsCommand extends Command {
63
+ static readonly KIND: string = ComputedBoundsAction.KIND;
64
+
65
+ @inject(ComputedBoundsApplicator) protected readonly computedBoundsApplicator: ComputedBoundsApplicator;
66
+
67
+ constructor(@inject(TYPES.Action) readonly action: ComputedBoundsAction) {
68
+ super();
69
+ }
70
+
71
+ override execute(context: CommandExecutionContext): GModelRoot | CommandResult {
72
+ if (LocalComputedBoundsAction.is(this.action)) {
73
+ // apply computed bounds from the hidden model and return updated model to render new main model
74
+ this.computedBoundsApplicator.apply(context.root as unknown as GModelRootSchema, this.action);
75
+ return context.root;
76
+ }
77
+ // computed bounds action from server -> we do not care and do not trigger any update of the main model
78
+ return {
79
+ model: context.root,
80
+ modelChanged: false
81
+ };
82
+ }
83
+
84
+ override undo(context: CommandExecutionContext): CommandReturn {
85
+ return context.root;
86
+ }
87
+
88
+ override redo(context: CommandExecutionContext): CommandReturn {
89
+ return context.root;
90
+ }
91
+ }
@@ -0,0 +1,70 @@
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 {
17
+ Action,
18
+ CommandExecutionContext,
19
+ CommandReturn,
20
+ ElementAndBounds,
21
+ SetBoundsAction,
22
+ SetBoundsCommand,
23
+ TYPES,
24
+ isLayoutContainer
25
+ } from '@eclipse-glsp/sprotty';
26
+ import { inject, injectable } from 'inversify';
27
+ import { GLSPActionDispatcher } from '../../base/action-dispatcher';
28
+ import { FeedbackCommand } from '../../base/feedback/feedback-command';
29
+ import { LocalRequestBoundsAction } from './local-bounds';
30
+
31
+ export interface SetBoundsFeedbackAction extends Omit<SetBoundsAction, 'kind'> {
32
+ kind: typeof SetBoundsFeedbackAction.KIND;
33
+ }
34
+
35
+ export namespace SetBoundsFeedbackAction {
36
+ export const KIND = 'setBoundsFeedback';
37
+
38
+ export function is(object: any): object is SetBoundsFeedbackAction {
39
+ return Action.hasKind(object, KIND);
40
+ }
41
+
42
+ export function create(bounds: ElementAndBounds[]): SetBoundsFeedbackAction {
43
+ return { kind: KIND, bounds };
44
+ }
45
+ }
46
+
47
+ @injectable()
48
+ export class SetBoundsFeebackCommand extends SetBoundsCommand implements FeedbackCommand {
49
+ static override readonly KIND: string = SetBoundsFeedbackAction.KIND;
50
+
51
+ readonly priority: number = 0;
52
+
53
+ @inject(TYPES.IActionDispatcher) protected actionDispatcher: GLSPActionDispatcher;
54
+
55
+ override execute(context: CommandExecutionContext): CommandReturn {
56
+ super.execute(context);
57
+
58
+ // apply set bounds as layout options so that when we calculate the bounds they are considered by the layouter
59
+ this.action.bounds.forEach(bounds => {
60
+ const element = context.root.index.getById(bounds.elementId);
61
+ if (element && isLayoutContainer(element)) {
62
+ const options = element.layoutOptions ?? {};
63
+ options.prefHeight = bounds.newSize.height;
64
+ options.prefWidth = bounds.newSize.width;
65
+ element.layoutOptions = options;
66
+ }
67
+ });
68
+ return LocalRequestBoundsAction.fromCommand(context, this.actionDispatcher, this.action);
69
+ }
70
+ }
@@ -16,10 +16,10 @@
16
16
  import {
17
17
  BoundsAware,
18
18
  GChildElement,
19
- Hoverable,
20
- Locateable,
21
19
  GModelElement,
22
20
  GParentElement,
21
+ Hoverable,
22
+ Locateable,
23
23
  Selectable,
24
24
  hoverFeedbackFeature,
25
25
  isBoundsAware,
@@ -72,7 +72,6 @@ export class SResizeHandle extends GChildElement implements Hoverable {
72
72
  }
73
73
 
74
74
  export function addResizeHandles(element: GParentElement): void {
75
- removeResizeHandles(element);
76
75
  element.add(new SResizeHandle(ResizeHandleLocation.TopLeft));
77
76
  element.add(new SResizeHandle(ResizeHandleLocation.TopRight));
78
77
  element.add(new SResizeHandle(ResizeHandleLocation.BottomLeft));
@@ -13,8 +13,8 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
+ import { Decoration, DecorationPlacer, GChildElement, GModelElement, GRoutableElement, Point, isSizeable } from '@eclipse-glsp/sprotty';
16
17
  import { injectable } from 'inversify';
17
- import { Decoration, DecorationPlacer, GChildElement, Point, GModelElement, GRoutableElement, isSizeable } from '@eclipse-glsp/sprotty';
18
18
 
19
19
  @injectable()
20
20
  export class GlspDecorationPlacer extends DecorationPlacer {
@@ -26,8 +26,8 @@ export class GlspDecorationPlacer extends DecorationPlacer {
26
26
  }
27
27
  if (isSizeable(element)) {
28
28
  return {
29
- x: GlspDecorationPlacer.DECORATION_OFFSET.x * element.bounds.width,
30
- y: GlspDecorationPlacer.DECORATION_OFFSET.y * element.bounds.height
29
+ x: -GlspDecorationPlacer.DECORATION_OFFSET.x,
30
+ y: -GlspDecorationPlacer.DECORATION_OFFSET.y
31
31
  };
32
32
  }
33
33
  return Point.ORIGIN;