@eclipse-glsp/client 2.2.0-next.329 → 2.2.0-next.331

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 (224) hide show
  1. package/css/change-bounds.css +15 -0
  2. package/css/glsp-sprotty.css +22 -0
  3. package/lib/base/default.module.js +1 -1
  4. package/lib/base/default.module.js.map +1 -1
  5. package/lib/base/drag-aware-mouse-listener.d.ts +5 -2
  6. package/lib/base/drag-aware-mouse-listener.d.ts.map +1 -1
  7. package/lib/base/drag-aware-mouse-listener.js +11 -0
  8. package/lib/base/drag-aware-mouse-listener.js.map +1 -1
  9. package/lib/base/feedback/css-feedback.d.ts +4 -0
  10. package/lib/base/feedback/css-feedback.d.ts.map +1 -1
  11. package/lib/base/feedback/css-feedback.js +4 -0
  12. package/lib/base/feedback/css-feedback.js.map +1 -1
  13. package/lib/base/feedback/feeback-emitter.d.ts +67 -0
  14. package/lib/base/feedback/feeback-emitter.d.ts.map +1 -0
  15. package/lib/base/feedback/feeback-emitter.js +109 -0
  16. package/lib/base/feedback/feeback-emitter.js.map +1 -0
  17. package/lib/base/feedback/feedback-action-dispatcher.d.ts +17 -5
  18. package/lib/base/feedback/feedback-action-dispatcher.d.ts.map +1 -1
  19. package/lib/base/feedback/feedback-action-dispatcher.js +23 -3
  20. package/lib/base/feedback/feedback-action-dispatcher.js.map +1 -1
  21. package/lib/base/feedback/index.d.ts +1 -0
  22. package/lib/base/feedback/index.d.ts.map +1 -1
  23. package/lib/base/feedback/index.js +1 -0
  24. package/lib/base/feedback/index.js.map +1 -1
  25. package/lib/base/index.d.ts +1 -1
  26. package/lib/base/index.d.ts.map +1 -1
  27. package/lib/base/index.js +1 -1
  28. package/lib/base/index.js.map +1 -1
  29. package/lib/base/selection-service.d.ts +3 -2
  30. package/lib/base/selection-service.d.ts.map +1 -1
  31. package/lib/base/selection-service.js.map +1 -1
  32. package/lib/{features/routing/glsp-manhattan-edge-router.d.ts → base/ui-extension/index.d.ts} +4 -6
  33. package/lib/base/ui-extension/index.d.ts.map +1 -0
  34. package/lib/base/ui-extension/index.js +34 -0
  35. package/lib/base/ui-extension/index.js.map +1 -0
  36. package/lib/base/{ui-extension-registry.d.ts → ui-extension/ui-extension-registry.d.ts} +1 -1
  37. package/lib/base/ui-extension/ui-extension-registry.d.ts.map +1 -0
  38. package/lib/base/ui-extension/ui-extension-registry.js.map +1 -0
  39. package/lib/base/ui-extension/ui-extension.d.ts +39 -0
  40. package/lib/base/ui-extension/ui-extension.d.ts.map +1 -0
  41. package/lib/base/ui-extension/ui-extension.js +120 -0
  42. package/lib/base/ui-extension/ui-extension.js.map +1 -0
  43. package/lib/features/accessibility/element-navigation/local-element-navigator.d.ts +3 -3
  44. package/lib/features/accessibility/element-navigation/local-element-navigator.d.ts.map +1 -1
  45. package/lib/features/accessibility/element-navigation/local-element-navigator.js.map +1 -1
  46. package/lib/features/accessibility/move-zoom/move-handler.d.ts +4 -2
  47. package/lib/features/accessibility/move-zoom/move-handler.d.ts.map +1 -1
  48. package/lib/features/accessibility/move-zoom/move-handler.js +10 -4
  49. package/lib/features/accessibility/move-zoom/move-handler.js.map +1 -1
  50. package/lib/features/accessibility/resize-key-tool/resize-key-handler.d.ts +4 -2
  51. package/lib/features/accessibility/resize-key-tool/resize-key-handler.d.ts.map +1 -1
  52. package/lib/features/accessibility/resize-key-tool/resize-key-handler.js +11 -3
  53. package/lib/features/accessibility/resize-key-tool/resize-key-handler.js.map +1 -1
  54. package/lib/features/change-bounds/model.d.ts +8 -8
  55. package/lib/features/change-bounds/model.d.ts.map +1 -1
  56. package/lib/features/change-bounds/model.js +17 -5
  57. package/lib/features/change-bounds/model.js.map +1 -1
  58. package/lib/features/change-bounds/movement-restrictor.d.ts +3 -2
  59. package/lib/features/change-bounds/movement-restrictor.d.ts.map +1 -1
  60. package/lib/features/change-bounds/movement-restrictor.js.map +1 -1
  61. package/lib/features/command-palette/command-palette.d.ts.map +1 -1
  62. package/lib/features/command-palette/command-palette.js +4 -3
  63. package/lib/features/command-palette/command-palette.js.map +1 -1
  64. package/lib/features/element-template/mouse-tracking-element-position-listener.d.ts +15 -5
  65. package/lib/features/element-template/mouse-tracking-element-position-listener.d.ts.map +1 -1
  66. package/lib/features/element-template/mouse-tracking-element-position-listener.js +27 -38
  67. package/lib/features/element-template/mouse-tracking-element-position-listener.js.map +1 -1
  68. package/lib/features/helper-lines/helper-line-manager-default.d.ts +4 -2
  69. package/lib/features/helper-lines/helper-line-manager-default.d.ts.map +1 -1
  70. package/lib/features/helper-lines/helper-line-manager-default.js +8 -12
  71. package/lib/features/helper-lines/helper-line-manager-default.js.map +1 -1
  72. package/lib/features/hints/type-hint-provider.d.ts +3 -0
  73. package/lib/features/hints/type-hint-provider.d.ts.map +1 -1
  74. package/lib/features/hints/type-hint-provider.js +10 -1
  75. package/lib/features/hints/type-hint-provider.js.map +1 -1
  76. package/lib/features/label-edit-ui/label-edit-ui.d.ts.map +1 -1
  77. package/lib/features/label-edit-ui/label-edit-ui.js +4 -3
  78. package/lib/features/label-edit-ui/label-edit-ui.js.map +1 -1
  79. package/lib/features/routing/edge-router.d.ts +30 -0
  80. package/lib/features/routing/edge-router.d.ts.map +1 -0
  81. package/lib/features/routing/edge-router.js +116 -0
  82. package/lib/features/routing/edge-router.js.map +1 -0
  83. package/lib/features/routing/index.d.ts +1 -1
  84. package/lib/features/routing/index.d.ts.map +1 -1
  85. package/lib/features/routing/index.js +1 -1
  86. package/lib/features/routing/index.js.map +1 -1
  87. package/lib/features/routing/routing-module.d.ts.map +1 -1
  88. package/lib/features/routing/routing-module.js +4 -4
  89. package/lib/features/routing/routing-module.js.map +1 -1
  90. package/lib/features/select/select-mouse-listener.d.ts +4 -3
  91. package/lib/features/select/select-mouse-listener.d.ts.map +1 -1
  92. package/lib/features/select/select-mouse-listener.js.map +1 -1
  93. package/lib/features/tools/base-tools.d.ts +23 -4
  94. package/lib/features/tools/base-tools.d.ts.map +1 -1
  95. package/lib/features/tools/base-tools.js +11 -6
  96. package/lib/features/tools/base-tools.js.map +1 -1
  97. package/lib/features/tools/change-bounds/change-bounds-tool-feedback.d.ts +1 -35
  98. package/lib/features/tools/change-bounds/change-bounds-tool-feedback.d.ts.map +1 -1
  99. package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js +5 -206
  100. package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js.map +1 -1
  101. package/lib/features/tools/change-bounds/change-bounds-tool-module.d.ts +1 -0
  102. package/lib/features/tools/change-bounds/change-bounds-tool-module.d.ts.map +1 -1
  103. package/lib/features/tools/change-bounds/change-bounds-tool-module.js +1 -0
  104. package/lib/features/tools/change-bounds/change-bounds-tool-module.js.map +1 -1
  105. package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.d.ts +67 -0
  106. package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.d.ts.map +1 -0
  107. package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js +227 -0
  108. package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js.map +1 -0
  109. package/lib/features/tools/change-bounds/change-bounds-tool.d.ts +34 -24
  110. package/lib/features/tools/change-bounds/change-bounds-tool.d.ts.map +1 -1
  111. package/lib/features/tools/change-bounds/change-bounds-tool.js +172 -180
  112. package/lib/features/tools/change-bounds/change-bounds-tool.js.map +1 -1
  113. package/lib/features/tools/change-bounds/index.d.ts +1 -0
  114. package/lib/features/tools/change-bounds/index.d.ts.map +1 -1
  115. package/lib/features/tools/change-bounds/index.js +1 -0
  116. package/lib/features/tools/change-bounds/index.js.map +1 -1
  117. package/lib/features/tools/change-bounds/view.d.ts +1 -1
  118. package/lib/features/tools/change-bounds/view.d.ts.map +1 -1
  119. package/lib/features/tools/change-bounds/view.js +3 -0
  120. package/lib/features/tools/change-bounds/view.js.map +1 -1
  121. package/lib/features/tools/deletion/delete-tool.d.ts +16 -1
  122. package/lib/features/tools/deletion/delete-tool.d.ts.map +1 -1
  123. package/lib/features/tools/deletion/delete-tool.js +5 -2
  124. package/lib/features/tools/deletion/delete-tool.js.map +1 -1
  125. package/lib/features/tools/edge-creation/dangling-edge-feedback.d.ts +17 -1
  126. package/lib/features/tools/edge-creation/dangling-edge-feedback.d.ts.map +1 -1
  127. package/lib/features/tools/edge-creation/dangling-edge-feedback.js +3 -1
  128. package/lib/features/tools/edge-creation/dangling-edge-feedback.js.map +1 -1
  129. package/lib/features/tools/edge-creation/edge-creation-tool-feedback.d.ts +3 -1
  130. package/lib/features/tools/edge-creation/edge-creation-tool-feedback.d.ts.map +1 -1
  131. package/lib/features/tools/edge-creation/edge-creation-tool-feedback.js +4 -7
  132. package/lib/features/tools/edge-creation/edge-creation-tool-feedback.js.map +1 -1
  133. package/lib/features/tools/edge-creation/edge-creation-tool.d.ts +20 -2
  134. package/lib/features/tools/edge-creation/edge-creation-tool.d.ts.map +1 -1
  135. package/lib/features/tools/edge-creation/edge-creation-tool.js +23 -18
  136. package/lib/features/tools/edge-creation/edge-creation-tool.js.map +1 -1
  137. package/lib/features/tools/edge-edit/edge-edit-tool-feedback.d.ts +3 -1
  138. package/lib/features/tools/edge-edit/edge-edit-tool-feedback.d.ts.map +1 -1
  139. package/lib/features/tools/edge-edit/edge-edit-tool-feedback.js +5 -8
  140. package/lib/features/tools/edge-edit/edge-edit-tool-feedback.js.map +1 -1
  141. package/lib/features/tools/edge-edit/edge-edit-tool.d.ts +4 -4
  142. package/lib/features/tools/edge-edit/edge-edit-tool.d.ts.map +1 -1
  143. package/lib/features/tools/edge-edit/edge-edit-tool.js +27 -44
  144. package/lib/features/tools/edge-edit/edge-edit-tool.js.map +1 -1
  145. package/lib/features/tools/marquee-selection/marquee-mouse-tool.d.ts +3 -2
  146. package/lib/features/tools/marquee-selection/marquee-mouse-tool.d.ts.map +1 -1
  147. package/lib/features/tools/marquee-selection/marquee-mouse-tool.js +4 -2
  148. package/lib/features/tools/marquee-selection/marquee-mouse-tool.js.map +1 -1
  149. package/lib/features/tools/node-creation/node-creation-tool.d.ts +14 -5
  150. package/lib/features/tools/node-creation/node-creation-tool.d.ts.map +1 -1
  151. package/lib/features/tools/node-creation/node-creation-tool.js +58 -24
  152. package/lib/features/tools/node-creation/node-creation-tool.js.map +1 -1
  153. package/lib/features/validation/marker-navigator.d.ts +7 -6
  154. package/lib/features/validation/marker-navigator.d.ts.map +1 -1
  155. package/lib/features/validation/marker-navigator.js.map +1 -1
  156. package/lib/features/validation/validate.d.ts +2 -5
  157. package/lib/features/validation/validate.d.ts.map +1 -1
  158. package/lib/features/validation/validate.js +4 -16
  159. package/lib/features/validation/validate.js.map +1 -1
  160. package/lib/utils/gmodel-util.d.ts +27 -2
  161. package/lib/utils/gmodel-util.d.ts.map +1 -1
  162. package/lib/utils/gmodel-util.js +30 -1
  163. package/lib/utils/gmodel-util.js.map +1 -1
  164. package/lib/utils/layout-utils.d.ts +8 -7
  165. package/lib/utils/layout-utils.d.ts.map +1 -1
  166. package/lib/utils/layout-utils.js +2 -4
  167. package/lib/utils/layout-utils.js.map +1 -1
  168. package/lib/utils/viewpoint-util.d.ts +4 -4
  169. package/lib/utils/viewpoint-util.d.ts.map +1 -1
  170. package/lib/utils/viewpoint-util.js.map +1 -1
  171. package/package.json +3 -3
  172. package/src/base/default.module.ts +1 -1
  173. package/src/base/drag-aware-mouse-listener.ts +16 -2
  174. package/src/base/feedback/css-feedback.ts +4 -0
  175. package/src/base/feedback/feeback-emitter.ts +112 -0
  176. package/src/base/feedback/feedback-action-dispatcher.ts +41 -6
  177. package/src/base/feedback/index.ts +1 -0
  178. package/src/base/index.ts +1 -1
  179. package/src/base/selection-service.spec.ts +5 -0
  180. package/src/base/selection-service.ts +2 -3
  181. package/src/base/ui-extension/index.ts +17 -0
  182. package/src/base/{ui-extension-registry.ts → ui-extension/ui-extension-registry.ts} +1 -1
  183. package/src/base/ui-extension/ui-extension.ts +119 -0
  184. package/src/features/accessibility/element-navigation/local-element-navigator.ts +4 -4
  185. package/src/features/accessibility/move-zoom/move-handler.ts +10 -5
  186. package/src/features/accessibility/resize-key-tool/resize-key-handler.ts +11 -7
  187. package/src/features/change-bounds/model.ts +25 -13
  188. package/src/features/change-bounds/movement-restrictor.ts +5 -4
  189. package/src/features/command-palette/command-palette.ts +2 -1
  190. package/src/features/element-template/mouse-tracking-element-position-listener.ts +44 -44
  191. package/src/features/helper-lines/helper-line-manager-default.ts +12 -21
  192. package/src/features/hints/type-hint-provider.spec.ts +4 -1
  193. package/src/features/hints/type-hint-provider.ts +9 -2
  194. package/src/features/label-edit-ui/label-edit-ui.ts +2 -1
  195. package/src/features/routing/{glsp-manhattan-edge-router.ts → edge-router.ts} +72 -2
  196. package/src/features/routing/index.ts +1 -1
  197. package/src/features/routing/routing-module.ts +3 -5
  198. package/src/features/select/select-mouse-listener.ts +4 -3
  199. package/src/features/tools/base-tools.ts +15 -8
  200. package/src/features/tools/change-bounds/change-bounds-tool-feedback.ts +6 -232
  201. package/src/features/tools/change-bounds/change-bounds-tool-module.ts +1 -0
  202. package/src/features/tools/change-bounds/change-bounds-tool-move-feedback.ts +254 -0
  203. package/src/features/tools/change-bounds/change-bounds-tool.ts +217 -226
  204. package/src/features/tools/change-bounds/index.ts +1 -0
  205. package/src/features/tools/change-bounds/view.tsx +4 -1
  206. package/src/features/tools/deletion/delete-tool.ts +6 -6
  207. package/src/features/tools/edge-creation/dangling-edge-feedback.ts +7 -4
  208. package/src/features/tools/edge-creation/edge-creation-tool-feedback.ts +9 -9
  209. package/src/features/tools/edge-creation/edge-creation-tool.ts +33 -23
  210. package/src/features/tools/edge-edit/edge-edit-tool-feedback.ts +8 -8
  211. package/src/features/tools/edge-edit/edge-edit-tool.ts +42 -49
  212. package/src/features/tools/marquee-selection/marquee-mouse-tool.ts +7 -6
  213. package/src/features/tools/node-creation/node-creation-tool.ts +69 -25
  214. package/src/features/validation/marker-navigator.ts +6 -8
  215. package/src/features/validation/validate.ts +5 -20
  216. package/src/utils/gmodel-util.ts +44 -1
  217. package/src/utils/layout-utils.ts +9 -20
  218. package/src/utils/viewpoint-util.ts +3 -4
  219. package/lib/base/ui-extension-registry.d.ts.map +0 -1
  220. package/lib/base/ui-extension-registry.js.map +0 -1
  221. package/lib/features/routing/glsp-manhattan-edge-router.d.ts.map +0 -1
  222. package/lib/features/routing/glsp-manhattan-edge-router.js +0 -68
  223. package/lib/features/routing/glsp-manhattan-edge-router.js.map +0 -1
  224. /package/lib/base/{ui-extension-registry.js → ui-extension/ui-extension-registry.js} +0 -0
@@ -1,8 +1,10 @@
1
- import { Action, Bounds, BoundsAware, Dimension, Disposable, EdgeRouterRegistry, ElementAndBounds, GModelElement, GModelRoot, GParentElement, MouseListener, Operation, Point } from '@eclipse-glsp/sprotty';
1
+ import { Action, BoundsAware, Dimension, Disposable, EdgeRouterRegistry, ElementAndBounds, GModelElement, GModelRoot, GParentElement, MouseListener, Operation, Point } from '@eclipse-glsp/sprotty';
2
2
  import { DragAwareMouseListener } from '../../../base/drag-aware-mouse-listener';
3
+ import { FeedbackEmitter } from '../../../base/feedback/feeback-emitter';
3
4
  import { ISelectionListener, SelectionService } from '../../../base/selection-service';
4
- import { PointPositionUpdater } from '../../../features/change-bounds/point-position-updater';
5
- import { Resizable, SResizeHandle } from '../../change-bounds/model';
5
+ import { BoundsAwareModelElement, ResizableModelElement } from '../../../utils/gmodel-util';
6
+ import { PointPositionUpdater } from '../../change-bounds';
7
+ import { SResizeHandle } from '../../change-bounds/model';
6
8
  import { IMovementRestrictor } from '../../change-bounds/movement-restrictor';
7
9
  import { PositionSnapper } from '../../change-bounds/position-snapper';
8
10
  import { BaseEditTool } from '../base-tools';
@@ -30,40 +32,48 @@ export declare class ChangeBoundsTool extends BaseEditTool {
30
32
  protected createMoveMouseListener(): MouseListener;
31
33
  protected createChangeBoundsListener(): MouseListener & ISelectionListener;
32
34
  }
35
+ export interface ValidatedElementAndBounds extends ElementAndBounds {
36
+ valid: boolean;
37
+ }
38
+ export declare namespace ValidatedElementAndBounds {
39
+ function isValid(move: ElementAndBounds): boolean;
40
+ }
33
41
  export declare class ChangeBoundsListener extends DragAwareMouseListener implements ISelectionListener, Disposable {
34
42
  protected tool: ChangeBoundsTool;
35
43
  static readonly CSS_CLASS_ACTIVE = "active";
36
- protected initialBounds: Bounds | undefined;
37
- protected pointPositionUpdater: PointPositionUpdater;
38
- protected activeResizeElement?: GModelElement;
44
+ protected initialBounds: ElementAndBounds | undefined;
45
+ protected positionUpdater: PointPositionUpdater;
46
+ protected activeResizeElement?: ResizableModelElement;
39
47
  protected activeResizeHandle?: SResizeHandle;
48
+ protected handleFeedback: FeedbackEmitter;
49
+ protected resizeFeedback: FeedbackEmitter;
40
50
  constructor(tool: ChangeBoundsTool);
41
51
  mouseDown(target: GModelElement, event: MouseEvent): Action[];
42
- mouseMove(target: GModelElement, event: MouseEvent): Action[];
52
+ protected updateResizeElement(target: GModelElement, event?: MouseEvent): boolean;
53
+ protected findResizeElement(target: GModelElement): ResizableModelElement | undefined;
54
+ protected draggingMouseMove(target: GModelElement, event: MouseEvent): Action[];
55
+ protected filterResizeOnClient(resize: ValidatedElementAndBounds, positionUpdate: Point): boolean;
56
+ protected addResizeFeedback(resizeActions: ValidatedElementAndBounds[], handle: SResizeHandle, target: GModelElement, event: MouseEvent): void;
57
+ protected resetBoundsAction(): Action[];
43
58
  draggingMouseUp(target: GModelElement, _event: MouseEvent): Action[];
59
+ nonDraggingMouseUp(element: GModelElement, event: MouseEvent): Action[];
44
60
  protected handleMoveOnServer(target: GModelElement): Action[];
45
61
  protected handleMoveElementsOnServer(target: GModelElement): Operation[];
62
+ protected isValidElement(element: BoundsAwareModelElement, selectedElements?: Set<BoundsAwareModelElement>): boolean;
46
63
  protected isChildOfSelected(selectedElements: Set<GModelElement>, element: GModelElement): boolean;
47
64
  protected handleMoveRoutingPointsOnServer(target: GModelElement): Operation[];
48
- protected handleResize(activeResizeHandle: SResizeHandle): Action[];
65
+ protected handleResizeOnServer(activeResizeHandle: SResizeHandle): Action[];
49
66
  selectionChanged(root: GModelRoot, selectedElements: string[]): void;
50
- protected setActiveResizeElement(target: GModelElement): boolean;
51
67
  protected isActiveResizeElement(element?: GModelElement): element is GParentElement & BoundsAware;
52
- protected initPosition(event: MouseEvent): void;
68
+ protected handleResizeOnClient(positionUpdate: Point): ValidatedElementAndBounds[];
69
+ protected handleTopLeftResize(resizeElement: ResizableModelElement, positionUpdate: Point): ValidatedElementAndBounds[];
70
+ protected handleTopRightResize(resizeElement: ResizableModelElement, positionUpdate: Point): ValidatedElementAndBounds[];
71
+ protected handleBottomLeftResize(resizeElement: ResizableModelElement, positionUpdate: Point): ValidatedElementAndBounds[];
72
+ protected handleBottomRightResize(resizeElement: ResizableModelElement, positionUpdate: Point): ValidatedElementAndBounds[];
73
+ protected createSetBoundsAction(element: BoundsAwareModelElement, newPosition: Point, newSize: Dimension): ValidatedElementAndBounds[];
74
+ protected isValidSize(element: BoundsAwareModelElement, size: Dimension): boolean;
75
+ protected isValidMove(element: BoundsAwareModelElement, newPosition: Point): boolean;
76
+ protected disposeAllButHandles(): void;
53
77
  dispose(): void;
54
- protected reset(resetBounds?: boolean): void;
55
- protected resetFeedback(resetBounds?: boolean): void;
56
- protected resetPosition(): void;
57
- protected handleResizeOnClient(positionUpdate: Point): Action[];
58
- protected handleTopLeftResize(resizeElement: GParentElement & Resizable, positionUpdate: Point): Action[];
59
- protected handleTopRightResize(resizeElement: GParentElement & Resizable, positionUpdate: Point): Action[];
60
- protected handleBottomLeftResize(resizeElement: GParentElement & Resizable, positionUpdate: Point): Action[];
61
- protected handleBottomRightResize(resizeElement: GParentElement & Resizable, positionUpdate: Point): Action[];
62
- protected createChangeBoundsAction(element: GModelElement & BoundsAware): Action[];
63
- protected createElementAndBounds(element: GModelElement & BoundsAware): ElementAndBounds[];
64
- protected createSetBoundsAction(element: GModelElement & BoundsAware, x: number, y: number, width: number, height: number): Action[];
65
- protected isValidBoundChange(element: GModelElement & BoundsAware, newPosition: Point, newSize: Dimension): boolean;
66
- protected isValidSize(element: GModelElement & BoundsAware, size: Dimension): boolean;
67
- protected isValidMove(element: GModelElement & BoundsAware, newPosition: Point): boolean;
68
78
  }
69
79
  //# sourceMappingURL=change-bounds-tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"change-bounds-tool.d.ts","sourceRoot":"","sources":["../../../../src/features/tools/change-bounds/change-bounds-tool.ts"],"names":[],"mappings":"AAiBA,OAAO,EACH,MAAM,EACN,MAAM,EACN,WAAW,EAIX,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAIhB,aAAa,EACb,UAAU,EACV,cAAc,EACd,aAAa,EACb,SAAS,EACT,KAAK,EAIR,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAEjF,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAS9F,OAAO,EAAE,SAAS,EAAwB,aAAa,EAAsC,MAAM,2BAA2B,CAAC;AAC/H,OAAO,EACH,mBAAmB,EAGtB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAO7C;;;;;;;;;;;;GAYG;AACH,qBACa,gBAAiB,SAAQ,YAAY;IAC9C,MAAM,CAAC,EAAE,SAA6B;IAEZ,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC/B,QAAQ,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IAC1C,QAAQ,CAAC,kBAAkB,CAAC,EAAE,mBAAmB,CAAC;IACxE,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAEnE,IAAI,EAAE,IAAI,MAAM,CAEf;IAED,MAAM,IAAI,IAAI;IAsBd,SAAS,CAAC,uBAAuB,IAAI,aAAa;IAIlD,SAAS,CAAC,0BAA0B,IAAI,aAAa,GAAG,kBAAkB;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AAE,KAAK,GAAG,yBAAyB,EAAE;IAQvH,SAAS,CAAC,oBAAoB,CAAC,aAAa,EAAE,qBAAqB,EAAE,cAAc,EAAE,KAAK,GAAG,yBAAyB,EAAE;IAQxH,SAAS,CAAC,sBAAsB,CAAC,aAAa,EAAE,qBAAqB,EAAE,cAAc,EAAE,KAAK,GAAG,yBAAyB,EAAE;IAQ1H,SAAS,CAAC,uBAAuB,CAAC,aAAa,EAAE,qBAAqB,EAAE,cAAc,EAAE,KAAK,GAAG,yBAAyB,EAAE;IAQ3H,SAAS,CAAC,qBAAqB,CAAC,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,GAAG,yBAAyB,EAAE;IAStI,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,uBAAuB,EAAE,IAAI,EAAE,SAAS,GAAG,OAAO;IAIjF,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,KAAK,GAAG,OAAO;IAIpF,SAAS,CAAC,oBAAoB,IAAI,IAAI;IAW7B,OAAO,IAAI,IAAI;CAI3B"}
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  var ChangeBoundsTool_1;
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.ChangeBoundsListener = exports.ChangeBoundsTool = void 0;
13
+ exports.ChangeBoundsListener = exports.ValidatedElementAndBounds = exports.ChangeBoundsTool = void 0;
14
14
  /********************************************************************************
15
15
  * Copyright (c) 2019-2023 EclipseSource and others.
16
16
  *
@@ -31,16 +31,17 @@ const sprotty_1 = require("@eclipse-glsp/sprotty");
31
31
  const drag_aware_mouse_listener_1 = require("../../../base/drag-aware-mouse-listener");
32
32
  const css_feedback_1 = require("../../../base/feedback/css-feedback");
33
33
  const selection_service_1 = require("../../../base/selection-service");
34
- const point_position_updater_1 = require("../../../features/change-bounds/point-position-updater");
34
+ const utils_1 = require("../../../utils");
35
35
  const gmodel_util_1 = require("../../../utils/gmodel-util");
36
- const layout_utils_1 = require("../../../utils/layout-utils");
37
- const set_bounds_feedback_command_1 = require("../../bounds/set-bounds-feedback-command");
36
+ const bounds_1 = require("../../bounds");
37
+ const change_bounds_1 = require("../../change-bounds");
38
38
  const model_1 = require("../../change-bounds/model");
39
39
  const movement_restrictor_1 = require("../../change-bounds/movement-restrictor");
40
40
  const position_snapper_1 = require("../../change-bounds/position-snapper");
41
- const model_2 = require("../../helper-lines/model");
41
+ const helper_lines_1 = require("../../helper-lines");
42
42
  const base_tools_1 = require("../base-tools");
43
43
  const change_bounds_tool_feedback_1 = require("./change-bounds-tool-feedback");
44
+ const change_bounds_tool_move_feedback_1 = require("./change-bounds-tool-move-feedback");
44
45
  /**
45
46
  * The change bounds tool has the license to move multiple elements or resize a single element by implementing the ChangeBounds operation.
46
47
  * In contrast to Sprotty's implementation this tool only sends a `ChangeBoundsOperationAction` when an operation has finished and does not
@@ -69,10 +70,10 @@ let ChangeBoundsTool = ChangeBoundsTool_1 = class ChangeBoundsTool extends base_
69
70
  if (sprotty_1.Disposable.is(changeBoundsListener)) {
70
71
  this.toDisposeOnDisable.push(changeBoundsListener);
71
72
  }
72
- this.toDisposeOnDisable.push(this.mouseTool.registerListener(feedbackMoveMouseListener), this.mouseTool.registerListener(changeBoundsListener), sprotty_1.Disposable.create(() => this.deregisterFeedback(feedbackMoveMouseListener)), sprotty_1.Disposable.create(() => this.deregisterFeedback(changeBoundsListener, [change_bounds_tool_feedback_1.HideChangeBoundsToolResizeFeedbackAction.create()])), this.selectionService.onSelectionChanged(change => changeBoundsListener.selectionChanged(change.root, change.selectedElements)));
73
+ this.toDisposeOnDisable.push(this.mouseTool.registerListener(feedbackMoveMouseListener), this.mouseTool.registerListener(changeBoundsListener), this.selectionService.onSelectionChanged(change => changeBoundsListener.selectionChanged(change.root, change.selectedElements)));
73
74
  }
74
75
  createMoveMouseListener() {
75
- return new change_bounds_tool_feedback_1.FeedbackMoveMouseListener(this);
76
+ return new change_bounds_tool_move_feedback_1.FeedbackMoveMouseListener(this);
76
77
  }
77
78
  createChangeBoundsListener() {
78
79
  return new ChangeBoundsListener(this);
@@ -101,11 +102,21 @@ __decorate([
101
102
  exports.ChangeBoundsTool = ChangeBoundsTool = ChangeBoundsTool_1 = __decorate([
102
103
  (0, inversify_1.injectable)()
103
104
  ], ChangeBoundsTool);
105
+ var ValidatedElementAndBounds;
106
+ (function (ValidatedElementAndBounds) {
107
+ function isValid(move) {
108
+ var _a;
109
+ return (_a = move.valid) !== null && _a !== void 0 ? _a : true;
110
+ }
111
+ ValidatedElementAndBounds.isValid = isValid;
112
+ })(ValidatedElementAndBounds || (exports.ValidatedElementAndBounds = ValidatedElementAndBounds = {}));
104
113
  class ChangeBoundsListener extends drag_aware_mouse_listener_1.DragAwareMouseListener {
105
114
  constructor(tool) {
106
115
  super();
107
116
  this.tool = tool;
108
- this.pointPositionUpdater = new point_position_updater_1.PointPositionUpdater(tool.positionSnapper);
117
+ this.positionUpdater = new change_bounds_1.PointPositionUpdater(tool.positionSnapper);
118
+ this.handleFeedback = tool.createFeedbackEmitter();
119
+ this.resizeFeedback = tool.createFeedbackEmitter();
109
120
  }
110
121
  mouseDown(target, event) {
111
122
  super.mouseDown(target, event);
@@ -115,83 +126,132 @@ class ChangeBoundsListener extends drag_aware_mouse_listener_1.DragAwareMouseLis
115
126
  return [];
116
127
  }
117
128
  // check if we have a resize handle (only single-selection)
118
- if (this.activeResizeElement && target instanceof model_1.SResizeHandle) {
119
- this.activeResizeHandle = target;
120
- }
121
- else {
122
- this.setActiveResizeElement(target);
123
- }
129
+ this.updateResizeElement(target, event);
130
+ return [];
131
+ }
132
+ updateResizeElement(target, event) {
133
+ var _a, _b;
134
+ this.activeResizeHandle = target instanceof model_1.SResizeHandle ? target : undefined;
135
+ this.activeResizeElement = (_b = (_a = this.activeResizeHandle) === null || _a === void 0 ? void 0 : _a.parent) !== null && _b !== void 0 ? _b : this.findResizeElement(target);
124
136
  if (this.activeResizeElement) {
125
- this.initPosition(event);
137
+ if (event) {
138
+ this.positionUpdater.updateLastDragPosition(event);
139
+ }
140
+ this.initialBounds = {
141
+ newSize: this.activeResizeElement.bounds,
142
+ newPosition: this.activeResizeElement.bounds,
143
+ elementId: this.activeResizeElement.id
144
+ };
145
+ this.handleFeedback.add(change_bounds_tool_feedback_1.ShowChangeBoundsToolResizeFeedbackAction.create(this.activeResizeElement.id), change_bounds_tool_feedback_1.HideChangeBoundsToolResizeFeedbackAction.create());
146
+ this.handleFeedback.submit();
147
+ return true;
126
148
  }
127
149
  else {
128
- this.reset();
150
+ this.positionUpdater.resetPosition();
151
+ this.handleFeedback.dispose();
152
+ return false;
129
153
  }
130
- return [];
131
154
  }
132
- mouseMove(target, event) {
133
- super.mouseMove(target, event);
134
- if (this.isMouseDrag && this.activeResizeHandle) {
135
- // rely on the FeedbackMoveMouseListener to update the element bounds of selected elements
136
- // consider resize handles ourselves
137
- const actions = [
138
- (0, css_feedback_1.cursorFeedbackAction)(this.activeResizeHandle.isNwSeResize() ? css_feedback_1.CursorCSS.RESIZE_NWSE : css_feedback_1.CursorCSS.RESIZE_NESW),
139
- (0, css_feedback_1.applyCssClasses)(this.activeResizeHandle, ChangeBoundsListener.CSS_CLASS_ACTIVE)
140
- ];
141
- const positionUpdate = this.pointPositionUpdater.updatePosition(target, event, (0, model_2.getDirectionFrom)(this.activeResizeHandle.location));
155
+ findResizeElement(target) {
156
+ // check if we have a selected, moveable element (multi-selection allowed)
157
+ // but only allow one element to have the element resize handles
158
+ return (0, sprotty_1.findParentByFeature)(target, model_1.isResizable);
159
+ }
160
+ draggingMouseMove(target, event) {
161
+ // rely on the FeedbackMoveMouseListener to update the element bounds of selected elements
162
+ // consider resize handles ourselves
163
+ if (this.activeResizeHandle && !this.positionUpdater.isLastDragPositionUndefined()) {
164
+ if (!this.initialBounds) {
165
+ const element = this.activeResizeHandle.parent;
166
+ this.initialBounds = { elementId: element.id, newSize: element.bounds, newPosition: element.bounds };
167
+ }
168
+ const positionUpdate = this.positionUpdater.updatePosition(target, event, (0, helper_lines_1.getDirectionFrom)(this.activeResizeHandle.location));
142
169
  if (positionUpdate) {
143
- const resizeActions = this.handleResizeOnClient(positionUpdate);
144
- actions.push(...resizeActions);
170
+ const resizeActions = this.handleResizeOnClient(positionUpdate).filter(action => action);
171
+ if (resizeActions.length > 0) {
172
+ this.resizeFeedback.add(bounds_1.SetBoundsFeedbackAction.create(resizeActions), () => this.resetBoundsAction());
173
+ this.addResizeFeedback(resizeActions, this.activeResizeHandle, target, event);
174
+ this.resizeFeedback.submit();
175
+ }
145
176
  }
146
- this.tool.registerFeedback(actions, this);
147
177
  }
148
- return [];
178
+ return super.draggingMouseMove(target, event);
179
+ }
180
+ filterResizeOnClient(resize, positionUpdate) {
181
+ return true;
182
+ }
183
+ addResizeFeedback(resizeActions, handle, target, event) {
184
+ // handle feedback
185
+ this.resizeFeedback.add((0, css_feedback_1.applyCssClasses)(handle, ChangeBoundsListener.CSS_CLASS_ACTIVE), (0, css_feedback_1.deleteCssClasses)(handle, ChangeBoundsListener.CSS_CLASS_ACTIVE));
186
+ // cursor feedback
187
+ const cursorClass = handle.isNeResize()
188
+ ? css_feedback_1.CursorCSS.RESIZE_NE
189
+ : handle.isNwResize()
190
+ ? css_feedback_1.CursorCSS.RESIZE_NW
191
+ : handle.isSeResize()
192
+ ? css_feedback_1.CursorCSS.RESIZE_SE
193
+ : css_feedback_1.CursorCSS.RESIZE_SW;
194
+ this.resizeFeedback.add((0, css_feedback_1.cursorFeedbackAction)(cursorClass), (0, css_feedback_1.cursorFeedbackAction)(css_feedback_1.CursorCSS.DEFAULT));
195
+ // restriction feedback
196
+ resizeActions.forEach(elementResize => {
197
+ const element = handle.root.index.getById(elementResize.elementId);
198
+ if (element && this.tool.movementRestrictor) {
199
+ if (!elementResize.valid) {
200
+ this.resizeFeedback.add((0, movement_restrictor_1.createMovementRestrictionFeedback)(element, this.tool.movementRestrictor), () => (0, movement_restrictor_1.removeMovementRestrictionFeedback)(element, this.tool.movementRestrictor));
201
+ }
202
+ else {
203
+ this.resizeFeedback.add((0, movement_restrictor_1.removeMovementRestrictionFeedback)(element, this.tool.movementRestrictor));
204
+ }
205
+ }
206
+ });
207
+ }
208
+ resetBoundsAction() {
209
+ // reset the bounds to the initial bounds and ensure that we do not show helper line feedback anymore (MoveFinishedEventAction)
210
+ return this.initialBounds
211
+ ? [bounds_1.SetBoundsFeedbackAction.create([this.initialBounds]), change_bounds_tool_feedback_1.MoveFinishedEventAction.create()]
212
+ : [change_bounds_tool_feedback_1.MoveFinishedEventAction.create()];
149
213
  }
150
214
  draggingMouseUp(target, _event) {
151
- if (this.pointPositionUpdater.isLastDragPositionUndefined()) {
152
- this.resetPosition();
215
+ if (this.positionUpdater.isLastDragPositionUndefined()) {
153
216
  return [];
154
217
  }
155
218
  const actions = [];
156
219
  if (this.activeResizeHandle) {
157
- // Resize
158
- actions.push(...this.handleResize(this.activeResizeHandle));
220
+ actions.push(...this.handleResizeOnServer(this.activeResizeHandle));
159
221
  }
160
222
  else {
161
- // Move
162
223
  actions.push(...this.handleMoveOnServer(target));
163
224
  }
164
- this.resetPosition();
165
- this.tool.deregisterFeedback(this, [(0, css_feedback_1.cursorFeedbackAction)(css_feedback_1.CursorCSS.DEFAULT)]);
225
+ this.disposeAllButHandles();
166
226
  return actions;
167
227
  }
228
+ nonDraggingMouseUp(element, event) {
229
+ this.disposeAllButHandles();
230
+ return super.nonDraggingMouseUp(element, event);
231
+ }
168
232
  handleMoveOnServer(target) {
169
233
  const operations = [];
170
234
  operations.push(...this.handleMoveElementsOnServer(target));
171
235
  operations.push(...this.handleMoveRoutingPointsOnServer(target));
172
- if (operations.length > 0) {
173
- return [sprotty_1.CompoundOperation.create(operations)];
174
- }
175
- return operations;
236
+ return operations.length > 0 ? [sprotty_1.CompoundOperation.create(operations)] : [];
176
237
  }
177
238
  handleMoveElementsOnServer(target) {
178
- const result = [];
179
- const newBounds = [];
180
- const selectedElements = [];
181
- (0, gmodel_util_1.forEachElement)(target.index, gmodel_util_1.isNonRoutableSelectedMovableBoundsAware, element => {
182
- selectedElements.push(element);
183
- });
239
+ const selectedElements = (0, gmodel_util_1.getMatchingElements)(target.index, gmodel_util_1.isNonRoutableSelectedMovableBoundsAware);
184
240
  const selectionSet = new Set(selectedElements);
185
- selectedElements
186
- .filter(element => !this.isChildOfSelected(selectionSet, element))
187
- .map(element => this.createElementAndBounds(element))
188
- .forEach(bounds => newBounds.push(...bounds));
189
- if (newBounds.length > 0) {
190
- result.push(sprotty_1.ChangeBoundsOperation.create(newBounds));
191
- }
192
- return result;
241
+ const newBounds = selectedElements
242
+ .filter(element => this.isValidElement(element, selectionSet))
243
+ .map(gmodel_util_1.toElementAndBounds);
244
+ return newBounds.length > 0 ? [sprotty_1.ChangeBoundsOperation.create(newBounds)] : [];
245
+ }
246
+ isValidElement(element, selectedElements = new Set()) {
247
+ return (this.isValidMove(element, element.bounds) &&
248
+ this.isValidSize(element, element.bounds) &&
249
+ !this.isChildOfSelected(selectedElements, element));
193
250
  }
194
251
  isChildOfSelected(selectedElements, element) {
252
+ if (selectedElements.size === 0) {
253
+ return false;
254
+ }
195
255
  while (element instanceof sprotty_1.GChildElement) {
196
256
  element = element.parent;
197
257
  if (selectedElements.has(element)) {
@@ -218,166 +278,98 @@ class ChangeBoundsListener extends drag_aware_mouse_listener_1.DragAwareMouseLis
218
278
  }
219
279
  return newRoutingPoints.length > 0 ? [sprotty_1.ChangeRoutingPointsOperation.create(newRoutingPoints)] : [];
220
280
  }
221
- handleResize(activeResizeHandle) {
222
- const actions = [];
223
- actions.push((0, css_feedback_1.cursorFeedbackAction)(css_feedback_1.CursorCSS.DEFAULT));
224
- actions.push((0, css_feedback_1.deleteCssClasses)(activeResizeHandle, ChangeBoundsListener.CSS_CLASS_ACTIVE));
225
- const resizeElement = (0, sprotty_1.findParentByFeature)(activeResizeHandle, model_1.isResizable);
226
- if (this.isActiveResizeElement(resizeElement)) {
227
- this.createChangeBoundsAction(resizeElement).forEach(action => actions.push(action));
228
- }
229
- return actions;
230
- }
231
- selectionChanged(root, selectedElements) {
232
- if (this.activeResizeElement) {
233
- if (selectedElements.includes(this.activeResizeElement.id)) {
234
- // our active element is still selected, nothing to do
235
- return;
281
+ handleResizeOnServer(activeResizeHandle) {
282
+ if (this.isValidElement(activeResizeHandle.parent) && this.initialBounds) {
283
+ const elementAndBounds = (0, gmodel_util_1.toElementAndBounds)(activeResizeHandle.parent);
284
+ if (!this.initialBounds.newPosition || !elementAndBounds.newPosition) {
285
+ return [];
236
286
  }
237
- // try to find some other selected element and mark that active
238
- for (const elementId of selectedElements.reverse()) {
239
- const element = root.index.getById(elementId);
240
- if (element && this.setActiveResizeElement(element)) {
241
- return;
242
- }
287
+ if (!sprotty_1.Point.equals(this.initialBounds.newPosition, elementAndBounds.newPosition) ||
288
+ !sprotty_1.Dimension.equals(this.initialBounds.newSize, elementAndBounds.newSize)) {
289
+ // UX: we do not want the element positions to be reset to their start as they will be moved to their start and
290
+ // only afterwards moved by the move action again, leading to a ping-pong movement.
291
+ // We therefore clear our element map so that they cannot be reset.
292
+ this.initialBounds = undefined;
293
+ return [sprotty_1.ChangeBoundsOperation.create([elementAndBounds])];
243
294
  }
244
- this.reset();
245
295
  }
296
+ return [];
246
297
  }
247
- setActiveResizeElement(target) {
248
- // check if we have a selected, moveable element (multi-selection allowed)
249
- const moveableElement = (0, sprotty_1.findParentByFeature)(target, model_1.isBoundsAwareMoveable);
250
- if ((0, sprotty_1.isSelected)(moveableElement)) {
251
- // only allow one element to have the element resize handles
252
- this.activeResizeElement = moveableElement;
253
- if ((0, model_1.isResizable)(this.activeResizeElement)) {
254
- this.tool.registerFeedback([change_bounds_tool_feedback_1.ShowChangeBoundsToolResizeFeedbackAction.create(this.activeResizeElement.id)], this.activeResizeElement);
298
+ selectionChanged(root, selectedElements) {
299
+ if (this.activeResizeElement && selectedElements.includes(this.activeResizeElement.id)) {
300
+ // our active element is still selected, nothing to do
301
+ return;
302
+ }
303
+ // try to find some other selected element and mark that active
304
+ for (const elementId of selectedElements.reverse()) {
305
+ const element = root.index.getById(elementId);
306
+ if (element && this.updateResizeElement(element)) {
307
+ return;
255
308
  }
256
- return true;
257
309
  }
258
- return false;
310
+ this.updateResizeElement(root);
311
+ this.disposeAllButHandles();
259
312
  }
260
313
  isActiveResizeElement(element) {
261
314
  return element !== undefined && this.activeResizeElement !== undefined && element.id === this.activeResizeElement.id;
262
315
  }
263
- initPosition(event) {
264
- this.pointPositionUpdater.updateLastDragPosition(event);
265
- if (this.activeResizeHandle) {
266
- const resizeElement = (0, sprotty_1.findParentByFeature)(this.activeResizeHandle, model_1.isResizable);
267
- this.initialBounds = {
268
- x: resizeElement.bounds.x,
269
- y: resizeElement.bounds.y,
270
- width: resizeElement.bounds.width,
271
- height: resizeElement.bounds.height
272
- };
273
- }
274
- }
275
- dispose() {
276
- this.reset(true);
277
- }
278
- reset(resetBounds = false) {
279
- this.resetFeedback(resetBounds);
280
- this.resetPosition();
281
- }
282
- resetFeedback(resetBounds = false) {
283
- const resetFeedback = [];
284
- if (this.activeResizeElement && (0, model_1.isResizable)(this.activeResizeElement)) {
285
- if (this.initialBounds && this.activeResizeHandle && resetBounds) {
286
- // we only reset the bounds if an active resize operation was cancelled due to the tool being disabled
287
- resetFeedback.push(set_bounds_feedback_command_1.SetBoundsFeedbackAction.create([
288
- {
289
- elementId: this.activeResizeElement.id,
290
- newPosition: this.initialBounds,
291
- newSize: this.initialBounds
292
- }
293
- ]));
294
- }
295
- this.tool.deregisterFeedback(this.activeResizeElement, [change_bounds_tool_feedback_1.HideChangeBoundsToolResizeFeedbackAction.create()]);
296
- }
297
- resetFeedback.push((0, css_feedback_1.cursorFeedbackAction)(css_feedback_1.CursorCSS.DEFAULT));
298
- this.tool.deregisterFeedback(this, resetFeedback);
299
- }
300
- resetPosition() {
301
- this.activeResizeHandle = undefined;
302
- this.pointPositionUpdater.resetPosition();
303
- }
304
316
  handleResizeOnClient(positionUpdate) {
305
317
  if (!this.activeResizeHandle) {
306
318
  return [];
307
319
  }
308
- const resizeElement = (0, sprotty_1.findParentByFeature)(this.activeResizeHandle, model_1.isResizable);
309
- if (this.isActiveResizeElement(resizeElement)) {
320
+ if (this.isActiveResizeElement(this.activeResizeHandle.parent)) {
310
321
  switch (this.activeResizeHandle.location) {
311
322
  case model_1.ResizeHandleLocation.TopLeft:
312
- return this.handleTopLeftResize(resizeElement, positionUpdate);
323
+ return this.handleTopLeftResize(this.activeResizeHandle.parent, positionUpdate);
313
324
  case model_1.ResizeHandleLocation.TopRight:
314
- return this.handleTopRightResize(resizeElement, positionUpdate);
325
+ return this.handleTopRightResize(this.activeResizeHandle.parent, positionUpdate);
315
326
  case model_1.ResizeHandleLocation.BottomLeft:
316
- return this.handleBottomLeftResize(resizeElement, positionUpdate);
327
+ return this.handleBottomLeftResize(this.activeResizeHandle.parent, positionUpdate);
317
328
  case model_1.ResizeHandleLocation.BottomRight:
318
- return this.handleBottomRightResize(resizeElement, positionUpdate);
329
+ return this.handleBottomRightResize(this.activeResizeHandle.parent, positionUpdate);
319
330
  }
320
331
  }
321
332
  return [];
322
333
  }
323
334
  handleTopLeftResize(resizeElement, positionUpdate) {
324
- return this.createSetBoundsAction(resizeElement, resizeElement.bounds.x + positionUpdate.x, resizeElement.bounds.y + positionUpdate.y, resizeElement.bounds.width - positionUpdate.x, resizeElement.bounds.height - positionUpdate.y);
335
+ return this.createSetBoundsAction(resizeElement, { x: resizeElement.bounds.x + positionUpdate.x, y: resizeElement.bounds.y + positionUpdate.y }, { width: resizeElement.bounds.width - positionUpdate.x, height: resizeElement.bounds.height - positionUpdate.y });
325
336
  }
326
337
  handleTopRightResize(resizeElement, positionUpdate) {
327
- return this.createSetBoundsAction(resizeElement, resizeElement.bounds.x, resizeElement.bounds.y + positionUpdate.y, resizeElement.bounds.width + positionUpdate.x, resizeElement.bounds.height - positionUpdate.y);
338
+ return this.createSetBoundsAction(resizeElement, { x: resizeElement.bounds.x, y: resizeElement.bounds.y + positionUpdate.y }, { width: resizeElement.bounds.width + positionUpdate.x, height: resizeElement.bounds.height - positionUpdate.y });
328
339
  }
329
340
  handleBottomLeftResize(resizeElement, positionUpdate) {
330
- return this.createSetBoundsAction(resizeElement, resizeElement.bounds.x + positionUpdate.x, resizeElement.bounds.y, resizeElement.bounds.width - positionUpdate.x, resizeElement.bounds.height + positionUpdate.y);
341
+ return this.createSetBoundsAction(resizeElement, { x: resizeElement.bounds.x + positionUpdate.x, y: resizeElement.bounds.y }, { width: resizeElement.bounds.width - positionUpdate.x, height: resizeElement.bounds.height + positionUpdate.y });
331
342
  }
332
343
  handleBottomRightResize(resizeElement, positionUpdate) {
333
- return this.createSetBoundsAction(resizeElement, resizeElement.bounds.x, resizeElement.bounds.y, resizeElement.bounds.width + positionUpdate.x, resizeElement.bounds.height + positionUpdate.y);
344
+ return this.createSetBoundsAction(resizeElement, { x: resizeElement.bounds.x, y: resizeElement.bounds.y }, { width: resizeElement.bounds.width + positionUpdate.x, height: resizeElement.bounds.height + positionUpdate.y });
334
345
  }
335
- createChangeBoundsAction(element) {
336
- if (this.isValidBoundChange(element, element.bounds, element.bounds)) {
337
- return [sprotty_1.ChangeBoundsOperation.create([(0, gmodel_util_1.toElementAndBounds)(element)])];
338
- }
339
- else if (this.initialBounds) {
340
- const actions = [];
341
- if (this.tool.movementRestrictor) {
342
- actions.push((0, movement_restrictor_1.removeMovementRestrictionFeedback)(element, this.tool.movementRestrictor));
343
- }
344
- actions.push(set_bounds_feedback_command_1.SetBoundsFeedbackAction.create([{ elementId: element.id, newPosition: this.initialBounds, newSize: this.initialBounds }]));
345
- return actions;
346
- }
347
- return [];
348
- }
349
- createElementAndBounds(element) {
350
- if (this.isValidBoundChange(element, element.bounds, element.bounds)) {
351
- return [(0, gmodel_util_1.toElementAndBounds)(element)];
352
- }
353
- return [];
354
- }
355
- createSetBoundsAction(element, x, y, width, height) {
356
- const newPosition = { x, y };
357
- const newSize = { width, height };
358
- const result = [];
359
- if (this.isValidBoundChange(element, newPosition, newSize)) {
360
- if (this.tool.movementRestrictor) {
361
- result.push((0, movement_restrictor_1.removeMovementRestrictionFeedback)(element, this.tool.movementRestrictor));
362
- }
363
- result.push(set_bounds_feedback_command_1.SetBoundsFeedbackAction.create([{ elementId: element.id, newPosition, newSize }]));
364
- }
365
- else if (this.isValidSize(element, newSize)) {
366
- if (this.tool.movementRestrictor) {
367
- result.push((0, movement_restrictor_1.createMovementRestrictionFeedback)(element, this.tool.movementRestrictor));
368
- }
369
- result.push(set_bounds_feedback_command_1.SetBoundsFeedbackAction.create([{ elementId: element.id, newPosition, newSize }]));
346
+ createSetBoundsAction(element, newPosition, newSize) {
347
+ if (!(0, utils_1.isValidSize)(element, newSize)) {
348
+ // we are not allowing any invalid sizes (breaking min size), not even during client feedback
349
+ return [];
370
350
  }
371
- return result;
372
- }
373
- isValidBoundChange(element, newPosition, newSize) {
374
- return this.isValidSize(element, newSize) && this.isValidMove(element, newPosition);
351
+ const valid = this.isValidMove(element, newPosition);
352
+ return [{ elementId: element.id, newPosition, newSize, valid }];
375
353
  }
376
354
  isValidSize(element, size) {
377
- return (0, layout_utils_1.isValidSize)(element, size);
355
+ return (0, utils_1.isValidSize)(element, size);
378
356
  }
379
357
  isValidMove(element, newPosition) {
380
- return (0, layout_utils_1.isValidMove)(element, newPosition, this.tool.movementRestrictor);
358
+ return (0, utils_1.isValidMove)(element, newPosition, this.tool.movementRestrictor);
359
+ }
360
+ disposeAllButHandles() {
361
+ // We do not dispose the handle feedback as we want to keep showing the handles on selected elements
362
+ // this.handleFeedback.dispose();
363
+ this.resizeFeedback.dispose();
364
+ this.positionUpdater.resetPosition();
365
+ this.activeResizeElement = undefined;
366
+ this.activeResizeHandle = undefined;
367
+ this.initialBounds = undefined;
368
+ super.dispose();
369
+ }
370
+ dispose() {
371
+ this.handleFeedback.dispose();
372
+ this.disposeAllButHandles();
381
373
  }
382
374
  }
383
375
  exports.ChangeBoundsListener = ChangeBoundsListener;