@eclipse-glsp/client 2.2.0-next.336 → 2.2.0-next.337

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 (169) hide show
  1. package/css/ghost-element.css +7 -0
  2. package/lib/base/default.module.d.ts.map +1 -1
  3. package/lib/base/default.module.js +1 -2
  4. package/lib/base/default.module.js.map +1 -1
  5. package/lib/base/drag-aware-mouse-listener.d.ts +4 -1
  6. package/lib/base/drag-aware-mouse-listener.d.ts.map +1 -1
  7. package/lib/base/drag-aware-mouse-listener.js +12 -2
  8. package/lib/base/drag-aware-mouse-listener.js.map +1 -1
  9. package/lib/base/feedback/feedback-action-dispatcher-default.d.ts +34 -0
  10. package/lib/base/feedback/feedback-action-dispatcher-default.d.ts.map +1 -0
  11. package/lib/base/feedback/feedback-action-dispatcher-default.js +120 -0
  12. package/lib/base/feedback/feedback-action-dispatcher-default.js.map +1 -0
  13. package/lib/base/feedback/feedback-action-dispatcher.d.ts +2 -17
  14. package/lib/base/feedback/feedback-action-dispatcher.d.ts.map +1 -1
  15. package/lib/base/feedback/feedback-action-dispatcher.js +1 -100
  16. package/lib/base/feedback/feedback-action-dispatcher.js.map +1 -1
  17. package/lib/base/feedback/{feeback-emitter.d.ts → feedback-emitter.d.ts} +8 -1
  18. package/lib/base/feedback/feedback-emitter.d.ts.map +1 -0
  19. package/lib/base/feedback/{feeback-emitter.js → feedback-emitter.js} +21 -6
  20. package/lib/base/feedback/feedback-emitter.js.map +1 -0
  21. package/lib/base/feedback/index.d.ts +2 -1
  22. package/lib/base/feedback/index.d.ts.map +1 -1
  23. package/lib/base/feedback/index.js +2 -1
  24. package/lib/base/feedback/index.js.map +1 -1
  25. package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts.map +1 -1
  26. package/lib/features/accessibility/view-key-tools/movement-key-tool.js +1 -1
  27. package/lib/features/accessibility/view-key-tools/movement-key-tool.js.map +1 -1
  28. package/lib/features/change-bounds/model.d.ts +5 -1
  29. package/lib/features/change-bounds/model.d.ts.map +1 -1
  30. package/lib/features/change-bounds/model.js +36 -10
  31. package/lib/features/change-bounds/model.js.map +1 -1
  32. package/lib/features/change-bounds/movement-restrictor.d.ts +1 -0
  33. package/lib/features/change-bounds/movement-restrictor.d.ts.map +1 -1
  34. package/lib/features/change-bounds/movement-restrictor.js +8 -9
  35. package/lib/features/change-bounds/movement-restrictor.js.map +1 -1
  36. package/lib/features/debug/debug-bounds-decorator.d.ts.map +1 -1
  37. package/lib/features/debug/debug-bounds-decorator.js +6 -6
  38. package/lib/features/debug/debug-bounds-decorator.js.map +1 -1
  39. package/lib/features/debug/debug-module.js +1 -1
  40. package/lib/features/debug/debug-module.js.map +1 -1
  41. package/lib/features/element-template/mouse-tracking-element-position-listener.d.ts +6 -4
  42. package/lib/features/element-template/mouse-tracking-element-position-listener.d.ts.map +1 -1
  43. package/lib/features/element-template/mouse-tracking-element-position-listener.js +11 -12
  44. package/lib/features/element-template/mouse-tracking-element-position-listener.js.map +1 -1
  45. package/lib/features/grid/grid-module.d.ts.map +1 -1
  46. package/lib/features/grid/grid-module.js +1 -1
  47. package/lib/features/grid/grid-module.js.map +1 -1
  48. package/lib/features/helper-lines/helper-line-manager-default.d.ts +14 -2
  49. package/lib/features/helper-lines/helper-line-manager-default.d.ts.map +1 -1
  50. package/lib/features/helper-lines/helper-line-manager-default.js +56 -15
  51. package/lib/features/helper-lines/helper-line-manager-default.js.map +1 -1
  52. package/lib/features/hints/model.d.ts +5 -1
  53. package/lib/features/hints/model.d.ts.map +1 -1
  54. package/lib/features/hints/model.js.map +1 -1
  55. package/lib/features/select/select-mouse-listener.d.ts.map +1 -1
  56. package/lib/features/select/select-mouse-listener.js +1 -1
  57. package/lib/features/select/select-mouse-listener.js.map +1 -1
  58. package/lib/features/tool-palette/tool-palette.d.ts.map +1 -1
  59. package/lib/features/tool-palette/tool-palette.js +2 -2
  60. package/lib/features/tool-palette/tool-palette.js.map +1 -1
  61. package/lib/features/tools/base-tools.d.ts +1 -1
  62. package/lib/features/tools/base-tools.d.ts.map +1 -1
  63. package/lib/features/tools/change-bounds/change-bounds-manager.d.ts +11 -4
  64. package/lib/features/tools/change-bounds/change-bounds-manager.d.ts.map +1 -1
  65. package/lib/features/tools/change-bounds/change-bounds-manager.js +46 -13
  66. package/lib/features/tools/change-bounds/change-bounds-manager.js.map +1 -1
  67. package/lib/features/tools/change-bounds/change-bounds-tool-feedback.d.ts.map +1 -1
  68. package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js +3 -3
  69. package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js.map +1 -1
  70. package/lib/features/tools/change-bounds/change-bounds-tool-module.js +1 -1
  71. package/lib/features/tools/change-bounds/change-bounds-tool-module.js.map +1 -1
  72. package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.d.ts +2 -2
  73. package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.d.ts.map +1 -1
  74. package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js +3 -6
  75. package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js.map +1 -1
  76. package/lib/features/tools/change-bounds/change-bounds-tool.d.ts +3 -2
  77. package/lib/features/tools/change-bounds/change-bounds-tool.d.ts.map +1 -1
  78. package/lib/features/tools/change-bounds/change-bounds-tool.js +7 -27
  79. package/lib/features/tools/change-bounds/change-bounds-tool.js.map +1 -1
  80. package/lib/features/tools/change-bounds/change-bounds-tracker.d.ts +8 -2
  81. package/lib/features/tools/change-bounds/change-bounds-tracker.d.ts.map +1 -1
  82. package/lib/features/tools/change-bounds/change-bounds-tracker.js +22 -5
  83. package/lib/features/tools/change-bounds/change-bounds-tracker.js.map +1 -1
  84. package/lib/features/tools/edge-creation/edge-creation-tool.d.ts +4 -1
  85. package/lib/features/tools/edge-creation/edge-creation-tool.d.ts.map +1 -1
  86. package/lib/features/tools/edge-creation/edge-creation-tool.js +12 -10
  87. package/lib/features/tools/edge-creation/edge-creation-tool.js.map +1 -1
  88. package/lib/features/tools/edge-edit/edge-edit-tool-feedback.d.ts +1 -1
  89. package/lib/features/tools/edge-edit/edge-edit-tool-feedback.d.ts.map +1 -1
  90. package/lib/features/tools/edge-edit/edge-edit-tool-feedback.js +3 -3
  91. package/lib/features/tools/edge-edit/edge-edit-tool-feedback.js.map +1 -1
  92. package/lib/features/tools/edge-edit/edge-edit-tool.d.ts +1 -1
  93. package/lib/features/tools/edge-edit/edge-edit-tool.d.ts.map +1 -1
  94. package/lib/features/tools/edge-edit/edge-edit-tool.js +3 -3
  95. package/lib/features/tools/edge-edit/edge-edit-tool.js.map +1 -1
  96. package/lib/features/tools/node-creation/container-manager.d.ts +41 -0
  97. package/lib/features/tools/node-creation/container-manager.d.ts.map +1 -0
  98. package/lib/features/tools/node-creation/container-manager.js +73 -0
  99. package/lib/features/tools/node-creation/container-manager.js.map +1 -0
  100. package/lib/features/tools/node-creation/index.d.ts +3 -0
  101. package/lib/features/tools/node-creation/index.d.ts.map +1 -1
  102. package/lib/features/tools/node-creation/index.js +3 -0
  103. package/lib/features/tools/node-creation/index.js.map +1 -1
  104. package/lib/features/tools/node-creation/insert-indicator.d.ts +30 -0
  105. package/lib/features/tools/node-creation/insert-indicator.d.ts.map +1 -0
  106. package/lib/features/tools/node-creation/insert-indicator.js +40 -0
  107. package/lib/features/tools/node-creation/insert-indicator.js.map +1 -0
  108. package/lib/features/tools/node-creation/node-creation-module.d.ts.map +1 -1
  109. package/lib/features/tools/node-creation/node-creation-module.js +5 -0
  110. package/lib/features/tools/node-creation/node-creation-module.js.map +1 -1
  111. package/lib/features/tools/node-creation/node-creation-tool.d.ts +23 -14
  112. package/lib/features/tools/node-creation/node-creation-tool.d.ts.map +1 -1
  113. package/lib/features/tools/node-creation/node-creation-tool.js +79 -75
  114. package/lib/features/tools/node-creation/node-creation-tool.js.map +1 -1
  115. package/lib/features/tools/node-creation/node-creation-views.d.ts +25 -0
  116. package/lib/features/tools/node-creation/node-creation-views.d.ts.map +1 -0
  117. package/lib/features/tools/node-creation/node-creation-views.js +60 -0
  118. package/lib/features/tools/node-creation/node-creation-views.js.map +1 -0
  119. package/lib/utils/gmodel-util.d.ts +2 -0
  120. package/lib/utils/gmodel-util.d.ts.map +1 -1
  121. package/lib/utils/gmodel-util.js.map +1 -1
  122. package/lib/views/ggraph-view.d.ts.map +1 -1
  123. package/lib/views/ggraph-view.js +2 -2
  124. package/lib/views/ggraph-view.js.map +1 -1
  125. package/lib/views/glsp-projection-view.d.ts.map +1 -1
  126. package/lib/views/glsp-projection-view.js +2 -2
  127. package/lib/views/glsp-projection-view.js.map +1 -1
  128. package/package.json +3 -3
  129. package/src/base/default.module.ts +1 -2
  130. package/src/base/drag-aware-mouse-listener.ts +17 -1
  131. package/src/base/feedback/feedback-action-dispatcher-default.ts +119 -0
  132. package/src/base/feedback/feedback-action-dispatcher.ts +2 -106
  133. package/src/base/feedback/feedback-emitter.spec.ts +176 -0
  134. package/src/base/feedback/{feeback-emitter.ts → feedback-emitter.ts} +24 -5
  135. package/src/base/feedback/index.ts +2 -1
  136. package/src/base/selection-service.spec.ts +1 -1
  137. package/src/features/accessibility/view-key-tools/movement-key-tool.ts +1 -1
  138. package/src/features/change-bounds/model.ts +38 -13
  139. package/src/features/change-bounds/movement-restrictor.ts +11 -11
  140. package/src/features/debug/debug-bounds-decorator.tsx +7 -7
  141. package/src/features/debug/debug-module.ts +1 -1
  142. package/src/features/element-template/mouse-tracking-element-position-listener.ts +14 -22
  143. package/src/features/grid/grid-module.ts +2 -2
  144. package/src/features/helper-lines/helper-line-manager-default.ts +66 -10
  145. package/src/features/hints/model.ts +6 -1
  146. package/src/features/hints/type-hint-provider.spec.ts +1 -1
  147. package/src/features/select/select-mouse-listener.ts +2 -2
  148. package/src/features/tool-palette/tool-palette.ts +2 -3
  149. package/src/features/tools/base-tools.ts +1 -1
  150. package/src/features/tools/change-bounds/change-bounds-manager.ts +71 -13
  151. package/src/features/tools/change-bounds/change-bounds-tool-feedback.ts +5 -2
  152. package/src/features/tools/change-bounds/change-bounds-tool-module.ts +1 -1
  153. package/src/features/tools/change-bounds/change-bounds-tool-move-feedback.ts +4 -8
  154. package/src/features/tools/change-bounds/change-bounds-tool.ts +9 -55
  155. package/src/features/tools/change-bounds/change-bounds-tracker.ts +26 -5
  156. package/src/features/tools/edge-creation/edge-creation-tool.ts +13 -6
  157. package/src/features/tools/edge-edit/edge-edit-tool-feedback.ts +1 -1
  158. package/src/features/tools/edge-edit/edge-edit-tool.ts +2 -3
  159. package/src/features/tools/node-creation/container-manager.ts +76 -0
  160. package/src/features/tools/node-creation/index.ts +3 -0
  161. package/src/features/tools/node-creation/insert-indicator.ts +41 -0
  162. package/src/features/tools/node-creation/node-creation-module.ts +13 -1
  163. package/src/features/tools/node-creation/node-creation-tool.ts +98 -90
  164. package/src/features/tools/node-creation/node-creation-views.tsx +49 -0
  165. package/src/utils/gmodel-util.ts +4 -1
  166. package/src/views/ggraph-view.tsx +3 -3
  167. package/src/views/glsp-projection-view.tsx +2 -3
  168. package/lib/base/feedback/feeback-emitter.d.ts.map +0 -1
  169. package/lib/base/feedback/feeback-emitter.js.map +0 -1
@@ -15,7 +15,7 @@
15
15
  ********************************************************************************/
16
16
  /* eslint-disable max-len */
17
17
 
18
- import { Bounds, GModelElement, IVNodePostprocessor, Point, TYPES, isDecoration, isSizeable, setClass, svg } from '@eclipse-glsp/sprotty';
18
+ import { Bounds, GModelElement, IVNodePostprocessor, Point, isDecoration, isSizeable, setClass, svg } from '@eclipse-glsp/sprotty';
19
19
  import { inject, injectable, optional } from 'inversify';
20
20
  import { VNode } from 'snabbdom';
21
21
  import { GGraph } from '../../model';
@@ -29,7 +29,7 @@ export const CSS_DEBUG_BOUNDS = 'debug-bounds';
29
29
 
30
30
  @injectable()
31
31
  export class DebugBoundsDecorator implements IVNodePostprocessor {
32
- @inject(TYPES.IDebugManager) @optional() protected debugManager?: DebugManager;
32
+ @inject(DebugManager) @optional() protected debugManager?: DebugManager;
33
33
 
34
34
  decorate(vnode: VNode, element: GModelElement): VNode {
35
35
  if (!this.debugManager?.isDebugEnabled) {
@@ -87,7 +87,7 @@ export class DebugBoundsDecorator implements IVNodePostprocessor {
87
87
  }
88
88
 
89
89
  protected renderTopLeftCorner(element: BoundsAwareModelElement): VNode {
90
- const position = Bounds.topLeft(element.bounds);
90
+ const position = Bounds.position(element.bounds);
91
91
  const topLeft = Bounds.topLeft(element.bounds);
92
92
  const corner = Point.subtract(topLeft, position);
93
93
  return (
@@ -104,7 +104,7 @@ export class DebugBoundsDecorator implements IVNodePostprocessor {
104
104
  }
105
105
 
106
106
  protected renderTopRightCorner(element: BoundsAwareModelElement): VNode {
107
- const position = Bounds.topLeft(element.bounds);
107
+ const position = Bounds.position(element.bounds);
108
108
  const topRight = Bounds.topRight(element.bounds);
109
109
  const corner = Point.subtract(topRight, position);
110
110
  return (
@@ -121,7 +121,7 @@ export class DebugBoundsDecorator implements IVNodePostprocessor {
121
121
  }
122
122
 
123
123
  protected renderBottomLeftCorner(element: BoundsAwareModelElement): VNode {
124
- const position = Bounds.topLeft(element.bounds);
124
+ const position = Bounds.position(element.bounds);
125
125
  const bottomLeft = Bounds.bottomLeft(element.bounds);
126
126
  const corner = Point.subtract(bottomLeft, position);
127
127
  return (
@@ -138,7 +138,7 @@ export class DebugBoundsDecorator implements IVNodePostprocessor {
138
138
  }
139
139
 
140
140
  protected renderBottomRightCorner(element: BoundsAwareModelElement): VNode {
141
- const position = Bounds.topLeft(element.bounds);
141
+ const position = Bounds.position(element.bounds);
142
142
  const bottomRight = Bounds.bottomRight(element.bounds);
143
143
  const corner = Point.subtract(bottomRight, position);
144
144
  return (
@@ -156,7 +156,7 @@ export class DebugBoundsDecorator implements IVNodePostprocessor {
156
156
 
157
157
  protected renderCenter(element: BoundsAwareModelElement): VNode {
158
158
  const bounds = element.bounds;
159
- const position = Bounds.topLeft(bounds);
159
+ const position = Bounds.position(bounds);
160
160
  const center = Bounds.center(bounds);
161
161
  const corner = Point.subtract(center, position);
162
162
  return (
@@ -25,7 +25,7 @@ export const debugModule = new FeatureModule((bind, unbind, isBound, rebind) =>
25
25
 
26
26
  configureCommand(context, EnableDebugModeCommand);
27
27
 
28
- bindAsService(bind, TYPES.IDebugManager, DebugManager);
28
+ bind(DebugManager).toSelf().inSingletonScope();
29
29
  configureActionHandler(context, EnableDebugModeAction.KIND, DebugManager);
30
30
 
31
31
  bindAsService(context, TYPES.IVNodePostprocessor, DebugBoundsDecorator);
@@ -17,16 +17,12 @@
17
17
  import { Action, Dimension, GModelElement, MoveAction, Point, isBoundsAware, isMoveable } from '@eclipse-glsp/sprotty';
18
18
  import { DragAwareMouseListener } from '../../base/drag-aware-mouse-listener';
19
19
  import { CSS_HIDDEN, ModifyCSSFeedbackAction } from '../../base/feedback/css-feedback';
20
- import { FeedbackEmitter } from '../../base/feedback/feeback-emitter';
20
+ import { FeedbackEmitter } from '../../base/feedback/feedback-emitter';
21
21
  import { MoveableElement, getAbsolutePosition } from '../../utils';
22
- import {
23
- CSS_RESIZE_MODE,
24
- ChangeBoundsManager,
25
- ChangeBoundsTracker,
26
- FeedbackAwareTool,
27
- MoveFinishedEventAction,
28
- TrackedElementMove
29
- } from '../tools';
22
+ import { FeedbackAwareTool } from '../tools/base-tools';
23
+ import { ChangeBoundsManager } from '../tools/change-bounds/change-bounds-manager';
24
+ import { MoveFinishedEventAction } from '../tools/change-bounds/change-bounds-tool-feedback';
25
+ import { ChangeBoundsTracker, TrackedMove } from '../tools/change-bounds/change-bounds-tracker';
30
26
 
31
27
  export interface PositioningTool extends FeedbackAwareTool {
32
28
  readonly changeBoundsManager: ChangeBoundsManager;
@@ -51,16 +47,16 @@ export class MouseTrackingElementPositionListener extends DragAwareMouseListener
51
47
  return !element || !isMoveable(element) ? undefined : element;
52
48
  }
53
49
 
54
- override mouseMove(target: GModelElement, event: MouseEvent): Action[] {
55
- super.mouseMove(target, event);
56
- const element = this.getTrackedElement(target, event);
50
+ override mouseMove(ctx: GModelElement, event: MouseEvent): Action[] {
51
+ super.mouseMove(ctx, event);
52
+ const element = this.getTrackedElement(ctx, event);
57
53
  if (!element) {
58
54
  return [];
59
55
  }
60
56
  if (!this.tracker.isTracking()) {
61
- this.initialize(element, target, event);
57
+ this.initialize(element, ctx, event);
62
58
  }
63
- const move = this.tracker.moveElements([element], { snap: event, restrict: event, validate: true });
59
+ const move = this.tracker.moveElements([element], { snap: event, restrict: event });
64
60
  const elementMove = move.elementMoves[0];
65
61
  if (!elementMove) {
66
62
  return [];
@@ -71,7 +67,7 @@ export class MouseTrackingElementPositionListener extends DragAwareMouseListener
71
67
  MoveAction.create([{ elementId: this.elementId, toPosition: elementMove.toPosition }], { animate: false }),
72
68
  MoveFinishedEventAction.create()
73
69
  );
74
- this.addMoveFeeback(elementMove);
70
+ this.addMoveFeedback(move, ctx, event);
75
71
  this.moveGhostFeedback.submit();
76
72
  this.tracker.updateTrackingPosition(elementMove.moveVector);
77
73
  return [];
@@ -89,13 +85,9 @@ export class MouseTrackingElementPositionListener extends DragAwareMouseListener
89
85
  : mousePosition;
90
86
  }
91
87
 
92
- protected addMoveFeeback(move: TrackedElementMove): void {
93
- this.tool.changeBoundsManager.addRestrictionFeedback(this.moveGhostFeedback, move);
94
- this.moveGhostFeedback.add(ModifyCSSFeedbackAction.create({ elements: [move.element.id], remove: [CSS_HIDDEN] }));
95
- this.moveGhostFeedback.add(
96
- ModifyCSSFeedbackAction.create({ add: [CSS_RESIZE_MODE] }),
97
- ModifyCSSFeedbackAction.create({ remove: [CSS_RESIZE_MODE] })
98
- );
88
+ protected addMoveFeedback(move: TrackedMove, ctx: GModelElement, event: MouseEvent): void {
89
+ this.moveGhostFeedback.add(ModifyCSSFeedbackAction.create({ elements: [this.elementId], remove: [CSS_HIDDEN] }));
90
+ this.tool.changeBoundsManager.addMoveFeedback(this.moveGhostFeedback, move, ctx, event);
99
91
  }
100
92
 
101
93
  override dispose(): void {
@@ -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
 
17
- import { FeatureModule, TYPES, bindAsService, configureActionHandler, configureCommand } from '@eclipse-glsp/sprotty';
17
+ import { FeatureModule, TYPES, configureActionHandler, configureCommand } from '@eclipse-glsp/sprotty';
18
18
  import '../../../css/grid.css';
19
19
  import { GridManager } from './grid-manager';
20
20
  import { ShowGridAction, ShowGridCommand } from './grid-model';
@@ -27,7 +27,7 @@ export const gridModule = new FeatureModule((bind, unbind, isBound, rebind) => {
27
27
 
28
28
  configureCommand(context, ShowGridCommand);
29
29
 
30
- bindAsService(bind, TYPES.IGridManager, GridManager);
30
+ bind(GridManager).toSelf().inSingletonScope();
31
31
  configureActionHandler(context, ShowGridAction.KIND, GridManager);
32
32
 
33
33
  bind(TYPES.ISnapper).to(GridSnapper);
@@ -30,6 +30,7 @@ import { FeedbackEmitter } from '../../base';
30
30
  import { IFeedbackActionDispatcher } from '../../base/feedback/feedback-action-dispatcher';
31
31
  import { ISelectionListener, SelectionService } from '../../base/selection-service';
32
32
  import { SetBoundsFeedbackAction } from '../bounds/set-bounds-feedback-command';
33
+ import { ResizeHandleLocation, SResizeHandle } from '../change-bounds/model';
33
34
  import { Grid } from '../grid';
34
35
  import { MoveFinishedEventAction, MoveInitializedEventAction } from '../tools/change-bounds/change-bounds-tool-feedback';
35
36
  import {
@@ -165,32 +166,87 @@ export class HelperLineManager implements IActionHandler, ISelectionListener, IH
165
166
  if (!isSnap) {
166
167
  return 0;
167
168
  }
168
- return direction === Direction.Left || direction === Direction.Right
169
- ? this.options.minimumMoveDelta.x
170
- : this.options.minimumMoveDelta.y;
169
+ const minimumMoveDelta = this.options.minimumMoveDelta;
170
+ return direction === Direction.Left || direction === Direction.Right ? minimumMoveDelta.x : minimumMoveDelta.y;
171
171
  }
172
172
 
173
- getMinimumMoveVector(element: GModelElement, isSnap: boolean, directions: Direction[]): Vector | undefined {
173
+ getMinimumMoveVector(element: GModelElement, isSnap: boolean, move: Direction[]): Vector | undefined {
174
174
  if (!isSnap) {
175
175
  return undefined;
176
176
  }
177
177
 
178
- const helperLines = element.root.children.filter(child => isHelperLine(child)) as HelperLine[];
179
- if (helperLines.length === 0) {
178
+ const state = this.getHelperLineState(element);
179
+ if (state.helperLines.length === 0) {
180
180
  return undefined;
181
181
  }
182
182
 
183
183
  const minimum: Writable<Vector> = { ...Vector.ZERO };
184
- if (directions.includes(Direction.Left) && helperLines.some(line => line.isLeft || line.isCenter)) {
184
+ const resize =
185
+ element instanceof SResizeHandle
186
+ ? ResizeHandleLocation.direction(element.location)
187
+ : [Direction.Left, Direction.Right, Direction.Up, Direction.Down];
188
+
189
+ if ((state.types.left || state.types.center) && move.includes(Direction.Left) && resize.includes(Direction.Left)) {
185
190
  minimum.x = this.getMinimumMoveDelta(element, isSnap, Direction.Left);
186
- } else if (directions.includes(Direction.Right) && helperLines.some(line => line.isRight || line.isCenter)) {
191
+ } else if ((state.types.right || state.types.center) && move.includes(Direction.Right) && resize.includes(Direction.Right)) {
187
192
  minimum.x = this.getMinimumMoveDelta(element, isSnap, Direction.Right);
188
193
  }
189
- if (directions.includes(Direction.Up) && helperLines.some(line => line.isTop || line.isMiddle)) {
194
+ if ((state.types.top || state.types.middle) && move.includes(Direction.Up) && resize.includes(Direction.Up)) {
190
195
  minimum.y = this.getMinimumMoveDelta(element, isSnap, Direction.Up);
191
- } else if (directions.includes(Direction.Down) && helperLines.some(line => line.isBottom || line.isMiddle)) {
196
+ } else if ((state.types.bottom || state.types.middle) && move.includes(Direction.Down) && resize.includes(Direction.Down)) {
192
197
  minimum.y = this.getMinimumMoveDelta(element, isSnap, Direction.Down);
193
198
  }
194
199
  return Vector.isZero(minimum) ? undefined : minimum;
195
200
  }
201
+
202
+ protected getHelperLineState(element: GModelElement): HelperLineState {
203
+ const helperLines = element.root.children.filter(isHelperLine) || [];
204
+ const types = {
205
+ left: false,
206
+ right: false,
207
+ top: false,
208
+ bottom: false,
209
+ center: false,
210
+ middle: false
211
+ };
212
+ for (const line of helperLines) {
213
+ switch (line.lineType) {
214
+ case HelperLineType.Left:
215
+ case HelperLineType.LeftRight:
216
+ types.left = true;
217
+ break;
218
+ case HelperLineType.Right:
219
+ case HelperLineType.RightLeft:
220
+ types.right = true;
221
+ break;
222
+ case HelperLineType.Top:
223
+ case HelperLineType.TopBottom:
224
+ types.top = true;
225
+ break;
226
+ case HelperLineType.Bottom:
227
+ case HelperLineType.BottomTop:
228
+ types.bottom = true;
229
+ break;
230
+ case HelperLineType.Center:
231
+ types.center = true;
232
+ break;
233
+ case HelperLineType.Middle:
234
+ types.middle = true;
235
+ break;
236
+ }
237
+ }
238
+ return { helperLines, types };
239
+ }
240
+ }
241
+
242
+ export interface HelperLineState {
243
+ helperLines: HelperLine[];
244
+ types: {
245
+ left: boolean;
246
+ right: boolean;
247
+ top: boolean;
248
+ bottom: boolean;
249
+ center: boolean;
250
+ middle: boolean;
251
+ };
196
252
  }
@@ -24,7 +24,12 @@ export interface Containable {
24
24
  isContainableElement(input: GModelElement | GModelElementSchema | string): boolean;
25
25
  }
26
26
 
27
- export function isContainable(element: GModelElement): element is GModelElement & Containable {
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 {
28
33
  return element.hasFeature(containerFeature);
29
34
  }
30
35
 
@@ -37,7 +37,7 @@ import { Container } from 'inversify';
37
37
  import * as sinon from 'sinon';
38
38
  import { FeedbackEmitter } from '../../base';
39
39
  import { GLSPActionDispatcher } from '../../base/action-dispatcher';
40
- import { FeedbackActionDispatcher } from '../../base/feedback/feedback-action-dispatcher';
40
+ import { FeedbackActionDispatcher } from '../../base/feedback/feedback-action-dispatcher-default';
41
41
  import { GEdge } from '../../model';
42
42
  import { isResizable } from '../change-bounds/model';
43
43
  import { isReconnectable } from '../reconnect/model';
@@ -13,7 +13,7 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { Action, BringToFrontAction, GModelElement, SelectAction, SelectMouseListener, TYPES } from '@eclipse-glsp/sprotty';
16
+ import { Action, BringToFrontAction, GModelElement, SelectAction, SelectMouseListener } from '@eclipse-glsp/sprotty';
17
17
  import { inject, injectable, optional } from 'inversify';
18
18
  import { Ranked } from '../../base/ranked';
19
19
  import { SelectableElement } from '../../utils';
@@ -28,7 +28,7 @@ import { ChangeBoundsManager } from '../tools';
28
28
  export class RankedSelectMouseListener extends SelectMouseListener implements Ranked {
29
29
  rank: number = Ranked.DEFAULT_RANK - 100; /* we want to be executed before all default mouse listeners */
30
30
 
31
- @inject(TYPES.IChangeBoundsManager) @optional() readonly changeBoundsManager?: ChangeBoundsManager;
31
+ @inject(ChangeBoundsManager) @optional() readonly changeBoundsManager?: ChangeBoundsManager;
32
32
 
33
33
  protected override handleSelectTarget(
34
34
  selectableTarget: SelectableElement,
@@ -26,7 +26,6 @@ import {
26
26
  SetContextActions,
27
27
  SetModelAction,
28
28
  SetUIExtensionVisibilityAction,
29
- TYPES,
30
29
  TriggerNodeCreationAction,
31
30
  UpdateModelAction,
32
31
  codiconCSSClasses,
@@ -78,11 +77,11 @@ export class ToolPalette extends AbstractUIExtension implements IActionHandler,
78
77
  @inject(FocusTracker)
79
78
  protected focusTracker: FocusTracker;
80
79
 
81
- @inject(TYPES.IGridManager)
80
+ @inject(GridManager)
82
81
  @optional()
83
82
  protected gridManager?: GridManager;
84
83
 
85
- @inject(TYPES.IDebugManager)
84
+ @inject(DebugManager)
86
85
  @optional()
87
86
  protected debugManager?: DebugManager;
88
87
 
@@ -17,8 +17,8 @@ import { Action, Disposable, DisposableCollection, IActionHandler, TYPES } from
17
17
  import { inject, injectable } from 'inversify';
18
18
  import { GLSPActionDispatcher } from '../../base/action-dispatcher';
19
19
  import { EditorContextService } from '../../base/editor-context-service';
20
- import { FeedbackEmitter } from '../../base/feedback/feeback-emitter';
21
20
  import { IFeedbackActionDispatcher, IFeedbackEmitter, MaybeActions } from '../../base/feedback/feedback-action-dispatcher';
21
+ import { FeedbackEmitter } from '../../base/feedback/feedback-emitter';
22
22
  import { EnableToolsAction, Tool } from '../../base/tool-manager/tool';
23
23
  import { GLSPKeyTool } from '../../base/view/key-tool';
24
24
  import { GLSPMouseTool } from '../../base/view/mouse-tool';
@@ -28,19 +28,32 @@ import {
28
28
  isLocateable
29
29
  } from '@eclipse-glsp/sprotty';
30
30
  import { inject, injectable, optional } from 'inversify';
31
- import { FeedbackEmitter } from '../../../base';
31
+ import {
32
+ CursorCSS,
33
+ FeedbackEmitter,
34
+ ModifyCSSFeedbackAction,
35
+ applyCssClasses,
36
+ cursorFeedbackAction,
37
+ deleteCssClasses,
38
+ toggleCssClasses
39
+ } from '../../../base';
32
40
  import { isValidMove, minDimensions } from '../../../utils';
33
41
  import { LayoutAware } from '../../bounds/layout-data';
34
42
  import {
35
43
  IMovementRestrictor,
36
44
  ResizeHandleLocation,
45
+ SResizeHandle,
37
46
  movementRestrictionFeedback,
38
47
  removeMovementRestrictionFeedback
39
48
  } from '../../change-bounds';
49
+ import { GridManager } from '../../grid';
40
50
  import { IHelperLineManager } from '../../helper-lines';
41
- import { ChangeBoundsTracker, TrackedElementMove } from './change-bounds-tracker';
51
+ import { InsertIndicator } from '../node-creation/insert-indicator';
52
+ import { ChangeBoundsTracker, TrackedElementMove, TrackedElementResize, TrackedMove, TrackedResize } from './change-bounds-tracker';
42
53
 
43
54
  export const CSS_RESIZE_MODE = 'resize-mode';
55
+ export const CSS_RESTRICTED_RESIZE = 'resize-not-allowed';
56
+ export const CSS_ACTIVE_HANDLE = 'active';
44
57
 
45
58
  @injectable()
46
59
  export class ChangeBoundsManager {
@@ -48,7 +61,8 @@ export class ChangeBoundsManager {
48
61
  @inject(MousePositionTracker) readonly positionTracker: MousePositionTracker,
49
62
  @optional() @inject(TYPES.IMovementRestrictor) readonly movementRestrictor?: IMovementRestrictor,
50
63
  @optional() @inject(TYPES.ISnapper) readonly snapper?: ISnapper,
51
- @optional() @inject(TYPES.IHelperLineManager) readonly helperLineManager?: IHelperLineManager
64
+ @optional() @inject(TYPES.IHelperLineManager) readonly helperLineManager?: IHelperLineManager,
65
+ @optional() @inject(GridManager) protected gridManager?: GridManager
52
66
  ) {}
53
67
 
54
68
  unsnapModifier(): KeyboardModifier | undefined {
@@ -102,7 +116,7 @@ export class ChangeBoundsManager {
102
116
  }
103
117
 
104
118
  restrictMovement(element: GModelElement, movement: Movement): Movement {
105
- const minimumMovement = this.helperLineManager?.getMinimumMoveVector(element, true, movement.direction);
119
+ const minimumMovement = this.getMinimumMovement(element, movement);
106
120
  if (!minimumMovement) {
107
121
  return movement;
108
122
  }
@@ -116,23 +130,67 @@ export class ChangeBoundsManager {
116
130
  return Point.move(movement.from, targetPosition);
117
131
  }
118
132
 
119
- addRestrictionFeedback(feedback: FeedbackEmitter, move: TrackedElementMove): FeedbackEmitter {
133
+ protected getMinimumMovement(element: GModelElement, movement: Movement): Vector | undefined {
134
+ return element instanceof InsertIndicator && this.gridManager
135
+ ? this.gridManager.grid
136
+ : this.helperLineManager?.getMinimumMoveVector(element, true, movement.direction);
137
+ }
138
+
139
+ addMoveFeedback(feedback: FeedbackEmitter, trackedMove: TrackedMove, ctx?: GModelElement, event?: MouseEvent): FeedbackEmitter {
140
+ // cursor feedback on graph
141
+ feedback.add(cursorFeedbackAction(CursorCSS.MOVE), cursorFeedbackAction(CursorCSS.DEFAULT));
142
+
143
+ // restriction feedback on each element
144
+ trackedMove.elementMoves.forEach(move => this.addMoveRestrictionFeedback(feedback, move, ctx, event));
145
+
146
+ return feedback;
147
+ }
148
+
149
+ addResizeFeedback(feedback: FeedbackEmitter, resize: TrackedResize, ctx?: GModelElement, event?: MouseEvent): FeedbackEmitter {
150
+ // graph feedback
151
+ feedback.add(
152
+ ModifyCSSFeedbackAction.create({ add: [CSS_RESIZE_MODE] }),
153
+ ModifyCSSFeedbackAction.create({ remove: [CSS_RESIZE_MODE] })
154
+ );
155
+
156
+ // cursor feedback on graph
157
+ const cursorClass = SResizeHandle.getCursorCss(resize.handleMove.element);
158
+ feedback.add(cursorFeedbackAction(cursorClass), cursorFeedbackAction(CursorCSS.DEFAULT));
159
+
160
+ // handle feedback
161
+ const handle = resize.handleMove.element;
162
+ feedback.add(applyCssClasses(handle, CSS_ACTIVE_HANDLE), deleteCssClasses(handle, CSS_ACTIVE_HANDLE));
163
+ feedback.add(toggleCssClasses(handle, !resize.valid.size, CSS_RESTRICTED_RESIZE), deleteCssClasses(handle, CSS_RESTRICTED_RESIZE));
164
+
165
+ // restriction feedback on each element
166
+ resize.elementResizes.forEach(elementResize => {
167
+ this.addMoveRestrictionFeedback(feedback, elementResize, ctx, event);
168
+ feedback.add(
169
+ toggleCssClasses(elementResize.element, !elementResize.valid.size, CSS_RESTRICTED_RESIZE),
170
+ deleteCssClasses(elementResize.element, CSS_RESTRICTED_RESIZE)
171
+ );
172
+ });
173
+ return feedback;
174
+ }
175
+
176
+ addMoveRestrictionFeedback(
177
+ feedback: FeedbackEmitter,
178
+ change: TrackedElementResize | TrackedElementMove,
179
+ ctx?: GModelElement,
180
+ event?: MouseEvent
181
+ ): FeedbackEmitter {
120
182
  if (this.movementRestrictor) {
183
+ const valid = TrackedElementMove.is(change) ? change.valid : change.valid.move;
121
184
  feedback.add(
122
- movementRestrictionFeedback(move.element, this.movementRestrictor!, move.valid),
123
- removeMovementRestrictionFeedback(move.element, this.movementRestrictor!)
185
+ movementRestrictionFeedback(change.element, this.movementRestrictor, valid),
186
+ removeMovementRestrictionFeedback(change.element, this.movementRestrictor)
124
187
  );
125
188
  }
126
189
  return feedback;
127
190
  }
128
191
 
129
192
  defaultResizeLocations(): ResizeHandleLocation[] {
130
- return [
131
- ResizeHandleLocation.TopLeft,
132
- ResizeHandleLocation.TopRight,
133
- ResizeHandleLocation.BottomRight,
134
- ResizeHandleLocation.BottomLeft
135
- ];
193
+ return ResizeHandleLocation.CORNERS;
136
194
  }
137
195
 
138
196
  useSymmetricResize(arg: MouseEvent | KeyboardEvent | any): boolean {
@@ -71,7 +71,7 @@ export class ShowChangeBoundsToolResizeFeedbackCommand extends FeedbackCommand {
71
71
  static readonly KIND = ShowChangeBoundsToolResizeFeedbackAction.KIND;
72
72
 
73
73
  @inject(TYPES.Action) protected action: ShowChangeBoundsToolResizeFeedbackAction;
74
- @inject(TYPES.IChangeBoundsManager) protected changeBoundsManager: ChangeBoundsManager;
74
+ @inject(ChangeBoundsManager) protected changeBoundsManager: ChangeBoundsManager;
75
75
 
76
76
  execute(context: CommandExecutionContext): CommandReturn {
77
77
  const index = context.root.index;
@@ -81,7 +81,10 @@ export class ShowChangeBoundsToolResizeFeedbackCommand extends FeedbackCommand {
81
81
  if (this.action.elementId) {
82
82
  const resizeElement = index.getById(this.action.elementId);
83
83
  if (resizeElement && isResizable(resizeElement)) {
84
- addResizeHandles(resizeElement, this.action.resizeLocations ?? this.changeBoundsManager.defaultResizeLocations());
84
+ addResizeHandles(
85
+ resizeElement,
86
+ this.action.resizeLocations ?? resizeElement.resizeLocations ?? this.changeBoundsManager.defaultResizeLocations()
87
+ );
85
88
  }
86
89
  }
87
90
  return context.root;
@@ -23,7 +23,7 @@ import { SResizeHandleView } from './view';
23
23
 
24
24
  export const changeBoundsToolModule = new FeatureModule((bind, unbind, isBound, rebind) => {
25
25
  const context = { bind, unbind, isBound, rebind };
26
- bindAsService(context, TYPES.IChangeBoundsManager, ChangeBoundsManager);
26
+ bind(ChangeBoundsManager).toSelf().inSingletonScope();
27
27
  bindAsService(context, TYPES.IDefaultTool, ChangeBoundsTool);
28
28
  configureCommand(context, ShowChangeBoundsToolResizeFeedbackCommand);
29
29
  configureCommand(context, HideChangeBoundsToolResizeFeedbackCommand);
@@ -19,7 +19,7 @@ import { DebouncedFunc, debounce } from 'lodash';
19
19
  import { ChangeBoundsTracker, TrackedMove } from '.';
20
20
  import { DragAwareMouseListener } from '../../../base/drag-aware-mouse-listener';
21
21
  import { CursorCSS, cursorFeedbackAction } from '../../../base/feedback/css-feedback';
22
- import { FeedbackEmitter } from '../../../base/feedback/feeback-emitter';
22
+ import { FeedbackEmitter } from '../../../base/feedback/feedback-emitter';
23
23
  import { MoveableElement, filter, getElements, isNonRoutableSelectedMovableBoundsAware, removeDescendants } from '../../../utils';
24
24
  import { SResizeHandle } from '../../change-bounds/model';
25
25
  import { ChangeBoundsTool } from './change-bounds-tool';
@@ -128,7 +128,7 @@ export class FeedbackMoveMouseListener extends DragAwareMouseListener {
128
128
  // cancel any pending move
129
129
  this.pendingMoveInitialized?.cancel();
130
130
  this.moveFeedback.add(this.createMoveAction(move), () => this.resetElementPositions(target));
131
- this.addMovementFeedback(move, target, event);
131
+ this.addMoveFeedback(move, target, event);
132
132
  this.tracker.updateTrackingPosition(move);
133
133
  this.moveFeedback.submit();
134
134
  return [];
@@ -142,12 +142,8 @@ export class FeedbackMoveMouseListener extends DragAwareMouseListener {
142
142
  );
143
143
  }
144
144
 
145
- protected addMovementFeedback(trackedMove: TrackedMove, ctx: GModelElement, event: MouseEvent): void {
146
- // cursor feedback
147
- this.moveFeedback.add(cursorFeedbackAction(CursorCSS.MOVE), cursorFeedbackAction(CursorCSS.DEFAULT));
148
-
149
- // restriction feedback
150
- trackedMove.elementMoves.forEach(move => this.tool.changeBoundsManager.addRestrictionFeedback(this.moveFeedback, move));
145
+ protected addMoveFeedback(trackedMove: TrackedMove, ctx: GModelElement, event: MouseEvent): void {
146
+ this.tool.changeBoundsManager.addMoveFeedback(this.moveFeedback, trackedMove, ctx, event);
151
147
  }
152
148
 
153
149
  protected initializeElementsToMove(root: GModelRoot): void {