@eclipse-glsp/client 2.3.0-next.317 → 2.3.0-next.319

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 (80) hide show
  1. package/css/ghost-element.css +3 -1
  2. package/css/glsp-sprotty.css +0 -5
  3. package/lib/base/action-handler-registry.d.ts +10 -1
  4. package/lib/base/action-handler-registry.d.ts.map +1 -1
  5. package/lib/base/action-handler-registry.js +40 -2
  6. package/lib/base/action-handler-registry.js.map +1 -1
  7. package/lib/base/default.module.d.ts.map +1 -1
  8. package/lib/base/default.module.js +5 -0
  9. package/lib/base/default.module.js.map +1 -1
  10. package/lib/base/feedback/feedback-action-dispatcher.d.ts +28 -1
  11. package/lib/base/feedback/feedback-action-dispatcher.d.ts.map +1 -1
  12. package/lib/base/feedback/feedback-action-dispatcher.js +23 -1
  13. package/lib/base/feedback/feedback-action-dispatcher.js.map +1 -1
  14. package/lib/base/feedback/feedback-command.d.ts +8 -3
  15. package/lib/base/feedback/feedback-command.d.ts.map +1 -1
  16. package/lib/base/feedback/feedback-command.js +13 -2
  17. package/lib/base/feedback/feedback-command.js.map +1 -1
  18. package/lib/base/feedback/index.d.ts +1 -0
  19. package/lib/base/feedback/index.d.ts.map +1 -1
  20. package/lib/base/feedback/index.js +1 -0
  21. package/lib/base/feedback/index.js.map +1 -1
  22. package/lib/base/feedback/set-model-command.d.ts +25 -0
  23. package/lib/base/feedback/set-model-command.d.ts.map +1 -0
  24. package/lib/base/feedback/set-model-command.js +65 -0
  25. package/lib/base/feedback/set-model-command.js.map +1 -0
  26. package/lib/base/feedback/update-model-command.d.ts +17 -6
  27. package/lib/base/feedback/update-model-command.d.ts.map +1 -1
  28. package/lib/base/feedback/update-model-command.js +8 -28
  29. package/lib/base/feedback/update-model-command.js.map +1 -1
  30. package/lib/base/ranked.d.ts +10 -0
  31. package/lib/base/ranked.d.ts.map +1 -1
  32. package/lib/base/ranked.js +6 -0
  33. package/lib/base/ranked.js.map +1 -1
  34. package/lib/base/selection-service.spec.js +4 -0
  35. package/lib/base/selection-service.spec.js.map +1 -1
  36. package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts +5 -3
  37. package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts.map +1 -1
  38. package/lib/features/bounds/glsp-hidden-bounds-updater.js +19 -2
  39. package/lib/features/bounds/glsp-hidden-bounds-updater.js.map +1 -1
  40. package/lib/features/bounds/local-bounds.d.ts +7 -3
  41. package/lib/features/bounds/local-bounds.d.ts.map +1 -1
  42. package/lib/features/bounds/local-bounds.js +8 -4
  43. package/lib/features/bounds/local-bounds.js.map +1 -1
  44. package/lib/features/bounds/set-bounds-feedback-command.d.ts +1 -1
  45. package/lib/features/bounds/set-bounds-feedback-command.d.ts.map +1 -1
  46. package/lib/features/bounds/set-bounds-feedback-command.js +4 -2
  47. package/lib/features/bounds/set-bounds-feedback-command.js.map +1 -1
  48. package/lib/features/element-template/add-template-element.d.ts.map +1 -1
  49. package/lib/features/element-template/add-template-element.js +5 -4
  50. package/lib/features/element-template/add-template-element.js.map +1 -1
  51. package/lib/features/hints/type-hint-provider.d.ts +17 -2
  52. package/lib/features/hints/type-hint-provider.d.ts.map +1 -1
  53. package/lib/features/hints/type-hint-provider.js +12 -12
  54. package/lib/features/hints/type-hint-provider.js.map +1 -1
  55. package/lib/tsconfig.tsbuildinfo +1 -1
  56. package/lib/utils/contribution-provider.d.ts +27 -0
  57. package/lib/utils/contribution-provider.d.ts.map +1 -0
  58. package/lib/utils/contribution-provider.js +56 -0
  59. package/lib/utils/contribution-provider.js.map +1 -0
  60. package/lib/utils/gmodel-util.d.ts +1 -0
  61. package/lib/utils/gmodel-util.d.ts.map +1 -1
  62. package/lib/utils/gmodel-util.js +14 -4
  63. package/lib/utils/gmodel-util.js.map +1 -1
  64. package/package.json +3 -3
  65. package/src/base/action-handler-registry.ts +41 -2
  66. package/src/base/default.module.ts +7 -0
  67. package/src/base/feedback/feedback-action-dispatcher.ts +49 -1
  68. package/src/base/feedback/feedback-command.ts +15 -4
  69. package/src/base/feedback/index.ts +2 -0
  70. package/src/base/feedback/set-model-command.ts +45 -0
  71. package/src/base/feedback/update-model-command.ts +8 -45
  72. package/src/base/ranked.ts +14 -0
  73. package/src/base/selection-service.spec.ts +7 -1
  74. package/src/features/bounds/glsp-hidden-bounds-updater.ts +26 -4
  75. package/src/features/bounds/local-bounds.ts +23 -6
  76. package/src/features/bounds/set-bounds-feedback-command.ts +4 -2
  77. package/src/features/element-template/add-template-element.ts +5 -4
  78. package/src/features/hints/type-hint-provider.ts +5 -5
  79. package/src/utils/contribution-provider.ts +65 -0
  80. package/src/utils/gmodel-util.ts +15 -4
@@ -0,0 +1,27 @@
1
+ /*******************************************************************************
2
+ * Copyright (C) 2017 TypeFox and others.
3
+ * Modifications: (c) 2024 EclipseSource and others.
4
+ *
5
+ * This program and the accompanying materials are made available under the
6
+ * terms of the Eclipse Public License v. 2.0 which is available at
7
+ * http://www.eclipse.org/legal/epl-2.0.
8
+ *
9
+ * This Source Code may also be made available under the following Secondary
10
+ * Licenses when the conditions for such availability set forth in the Eclipse
11
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ * with the GNU Classpath Exception which is available at
13
+ * https://www.gnu.org/software/classpath/license.html.
14
+ *
15
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ *******************************************************************************/
17
+ import { BindingContext } from '@eclipse-glsp/sprotty';
18
+ import { interfaces } from 'inversify';
19
+ export interface IContributionProvider<T extends object> {
20
+ /**
21
+ * @param recursive `true` if the contributions should be collected from the parent containers as well. Otherwise, `false`.
22
+ * It is `false` by default.
23
+ */
24
+ getContributions(recursive?: boolean): T[];
25
+ }
26
+ export declare function bindContributionProvider(context: Pick<BindingContext, 'bind'> | interfaces.Bind, id: symbol): void;
27
+ //# sourceMappingURL=contribution-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contribution-provider.d.ts","sourceRoot":"","sources":["../../src/utils/contribution-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;iFAeiF;AAIjF,OAAO,EAAE,cAAc,EAAS,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,WAAW,qBAAqB,CAAC,CAAC,SAAS,MAAM;IACnD;;;OAGG;IACH,gBAAgB,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,CAAC,EAAE,CAAC;CAC9C;AA8BD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,GAAG,UAAU,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAMlH"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ /*******************************************************************************
3
+ * Copyright (C) 2017 TypeFox and others.
4
+ * Modifications: (c) 2024 EclipseSource and others.
5
+ *
6
+ * This program and the accompanying materials are made available under the
7
+ * terms of the Eclipse Public License v. 2.0 which is available at
8
+ * http://www.eclipse.org/legal/epl-2.0.
9
+ *
10
+ * This Source Code may also be made available under the following Secondary
11
+ * Licenses when the conditions for such availability set forth in the Eclipse
12
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
13
+ * with the GNU Classpath Exception which is available at
14
+ * https://www.gnu.org/software/classpath/license.html.
15
+ *
16
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
17
+ *******************************************************************************/
18
+ // eslint-disable-next-line max-len
19
+ // based on https://github.com/eclipse-theia/theia/blob/9ff0cedff1d591b0eb4be97a05f6d992789d0a24/packages/core/src/common/contribution-provider.ts
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.bindContributionProvider = void 0;
22
+ const sprotty_1 = require("@eclipse-glsp/sprotty");
23
+ class ContainerBasedContributionProvider {
24
+ constructor(serviceIdentifier, container) {
25
+ this.serviceIdentifier = serviceIdentifier;
26
+ this.container = container;
27
+ }
28
+ getContributions(recursive) {
29
+ if (this.services === undefined) {
30
+ const currentServices = [];
31
+ let currentContainer = this.container;
32
+ while (currentContainer !== undefined) {
33
+ if (currentContainer.isBound(this.serviceIdentifier)) {
34
+ try {
35
+ currentServices.push(...currentContainer.getAll(this.serviceIdentifier));
36
+ }
37
+ catch (error) {
38
+ console.error(error);
39
+ }
40
+ }
41
+ currentContainer = recursive === true && currentContainer.parent ? currentContainer.parent : undefined;
42
+ }
43
+ this.services = currentServices;
44
+ }
45
+ return this.services;
46
+ }
47
+ }
48
+ function bindContributionProvider(context, id) {
49
+ const bind = typeof context === 'object' ? context.bind.bind(context) : context;
50
+ bind(sprotty_1.TYPES.IContributionProvider)
51
+ .toDynamicValue(ctx => new ContainerBasedContributionProvider(id, ctx.container))
52
+ .inSingletonScope()
53
+ .whenTargetNamed(id);
54
+ }
55
+ exports.bindContributionProvider = bindContributionProvider;
56
+ //# sourceMappingURL=contribution-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contribution-provider.js","sourceRoot":"","sources":["../../src/utils/contribution-provider.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;iFAeiF;AACjF,mCAAmC;AACnC,kJAAkJ;;;AAElJ,mDAA8D;AAW9D,MAAM,kCAAkC;IAGpC,YACuB,iBAAkD,EAClD,SAA+B;QAD/B,sBAAiB,GAAjB,iBAAiB,CAAiC;QAClD,cAAS,GAAT,SAAS,CAAsB;IACnD,CAAC;IAEJ,gBAAgB,CAAC,SAAmB;QAChC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC7B,MAAM,eAAe,GAAQ,EAAE,CAAC;YAChC,IAAI,gBAAgB,GAAqC,IAAI,CAAC,SAAS,CAAC;YACxE,OAAO,gBAAgB,KAAK,SAAS,EAAE;gBACnC,IAAI,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE;oBAClD,IAAI;wBACA,eAAe,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;qBAC5E;oBAAC,OAAO,KAAK,EAAE;wBACZ,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;qBACxB;iBACJ;gBACD,gBAAgB,GAAG,SAAS,KAAK,IAAI,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;aAC1G;YACD,IAAI,CAAC,QAAQ,GAAG,eAAe,CAAC;SACnC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CACJ;AAED,SAAgB,wBAAwB,CAAC,OAAuD,EAAE,EAAU;IACxG,MAAM,IAAI,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAChF,IAAI,CAAC,eAAK,CAAC,qBAAqB,CAAC;SAC5B,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,kCAAkC,CAAC,EAAE,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;SAChF,gBAAgB,EAAE;SAClB,eAAe,CAAC,EAAE,CAAC,CAAC;AAC7B,CAAC;AAND,4DAMC"}
@@ -173,4 +173,5 @@ export declare function getElementTypeId(input: GModelElement | GModelElementSch
173
173
  export declare function findTopLevelElementByFeature<T>(element: GModelElement, predicate: (t: GModelElement) => t is GModelElement & T, skip?: (t: GModelElement) => boolean): (GModelElement & T) | undefined;
174
174
  export declare function calculateDeltaBetweenPoints(target: Point, source: Point, element: GModelElement): Point;
175
175
  export declare function isVisibleOnCanvas(model: BoundsAwareModelElement): boolean;
176
+ export declare function getDescendantIds(element?: GModelElement, skip?: (t: GModelElement) => boolean): string[];
176
177
  //# sourceMappingURL=gmodel-util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gmodel-util.d.ts","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ule", { value: true });
3
- exports.isVisibleOnCanvas = exports.calculateDeltaBetweenPoints = exports.findTopLevelElementByFeature = exports.getElementTypeId = exports.calcRoute = exports.calcElementAndRoute = exports.calcElementAndRoutingPoints = exports.ROUTE_KINDS = exports.ROUTING_POINT_KINDS = exports.ALL_ROUTING_POINTS = exports.toElementAndRoutingPoints = exports.toElementAndBounds = exports.isSelectableAndBoundsAware = exports.isRoutingHandle = exports.isRoutable = exports.isNonRoutableSelectedBoundsAware = exports.isNonRoutableSelectedMovableBoundsAware = exports.removeCssClasses = exports.addCssClasses = exports.isNotUndefined = exports.hasSelectedElements = exports.getSelectedElementCount = exports.getElements = exports.getMatchingElements = exports.forEachElement = exports.filter = void 0;
3
+ exports.getDescendantIds = exports.isVisibleOnCanvas = exports.calculateDeltaBetweenPoints = exports.findTopLevelElementByFeature = exports.getElementTypeId = exports.calcRoute = exports.calcElementAndRoute = exports.calcElementAndRoutingPoints = exports.ROUTE_KINDS = exports.ROUTING_POINT_KINDS = exports.ALL_ROUTING_POINTS = exports.toElementAndRoutingPoints = exports.toElementAndBounds = exports.isSelectableAndBoundsAware = exports.isRoutingHandle = exports.isRoutable = exports.isNonRoutableSelectedBoundsAware = exports.isNonRoutableSelectedMovableBoundsAware = exports.removeCssClasses = exports.addCssClasses = exports.isNotUndefined = exports.hasSelectedElements = exports.getSelectedElementCount = exports.getElements = exports.getMatchingElements = exports.forEachElement = exports.filter = void 0;
4
4
  /********************************************************************************
5
5
  * Copyright (c) 2019-2023 EclipseSource and others.
6
6
  *
@@ -293,10 +293,8 @@ function findTopLevelElementByFeature(element, predicate, skip = _t => false) {
293
293
  }
294
294
  exports.findTopLevelElementByFeature = findTopLevelElementByFeature;
295
295
  function calculateDeltaBetweenPoints(target, source, element) {
296
- var _a;
297
296
  const delta = sprotty_1.Point.subtract(target, source);
298
- const viewport = (0, sprotty_1.findParentByFeature)(element, sprotty_1.isViewport);
299
- const zoom = (_a = viewport === null || viewport === void 0 ? void 0 : viewport.zoom) !== null && _a !== void 0 ? _a : 1;
297
+ const zoom = (0, sprotty_1.getZoom)(element);
300
298
  const adaptedDelta = { x: delta.x / zoom, y: delta.y / zoom };
301
299
  return adaptedDelta;
302
300
  }
@@ -310,4 +308,16 @@ function isVisibleOnCanvas(model) {
310
308
  modelBounds.y + modelBounds.height >= 0);
311
309
  }
312
310
  exports.isVisibleOnCanvas = isVisibleOnCanvas;
311
+ function getDescendantIds(element, skip) {
312
+ if (!element || (skip === null || skip === void 0 ? void 0 : skip(element))) {
313
+ return [];
314
+ }
315
+ const parent = element;
316
+ const ids = [parent.id];
317
+ if (parent instanceof sprotty_1.GParentElement) {
318
+ ids.push(...parent.children.flatMap(child => getDescendantIds(child, skip)));
319
+ }
320
+ return ids;
321
+ }
322
+ exports.getDescendantIds = getDescendantIds;
313
323
  //# sourceMappingURL=gmodel-util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gmodel-util.js","sourceRoot":"","sources":["../../src/utils/gmodel-util.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,mDAyB+B;AAS/B;;;;;;GAMG;AACH,SAAgB,MAAM,CAAI,KAAqB,EAAE,SAAkC;IAC/E,OAAO,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAsC,CAAC;AAC9E,CAAC;AAFD,wBAEC;AAED;;;;;;GAMG;AACH,SAAgB,cAAc,CAC1B,KAAqB,EACrB,SAAkC,EAClC,QAAmD;IAEnD,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC/C,CAAC;AAND,wCAMC;AAED;;;;;;GAMG;AACH,SAAgB,mBAAmB,CAAI,KAAqB,EAAE,SAAkC;IAC5F,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC;AAChD,CAAC;AAFD,kDAEC;AAED;;;;;;;GAOG;AACH,SAAgB,WAAW,CAA0B,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AAI,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;KAChF;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AAVD,4CAUC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclipse-glsp/client",
3
- "version": "2.3.0-next.317+c4764a5",
3
+ "version": "2.3.0-next.319+5e43503",
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.3.0-next.317+c4764a5",
50
+ "@eclipse-glsp/sprotty": "2.3.0-next.319+5e43503",
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": "c4764a57efbca4ab081804a28b0d2ebef46ea141"
62
+ "gitHead": "5e435038399d7acf5408a64348e212b8393ea205"
63
63
  }
@@ -14,17 +14,56 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
- import { injectable } from 'inversify';
18
- import { ActionHandlerRegistry } from '@eclipse-glsp/sprotty';
17
+ import { ActionHandlerRegistration, ActionHandlerRegistry, IActionHandler, IActionHandlerInitializer, TYPES } from '@eclipse-glsp/sprotty';
18
+ import { inject, injectable, named } from 'inversify';
19
+ import { IContributionProvider } from '../utils/contribution-provider';
19
20
 
20
21
  @injectable()
21
22
  export class GLSPActionHandlerRegistry extends ActionHandlerRegistry {
23
+ @inject(TYPES.IContributionProvider)
24
+ @named(TYPES.ActionHandlerRegistration)
25
+ protected readonly registrations: IContributionProvider<ActionHandlerRegistration>;
26
+
27
+ @inject(TYPES.IContributionProvider)
28
+ @named(TYPES.IActionHandlerInitializer)
29
+ protected readonly initializers: IContributionProvider<IActionHandlerInitializer>;
30
+
31
+ protected initialized = false;
32
+
33
+ constructor() {
34
+ super([], []);
35
+ }
36
+
37
+ protected init(): void {
38
+ if (!this.initialized) {
39
+ this.initialized = true;
40
+ this.registrations.getContributions().forEach(registration => this.register(registration.actionKind, registration.factory()));
41
+ this.initializers.getContributions().forEach(initializer => this.initializeActionHandler(initializer));
42
+ }
43
+ }
44
+
45
+ override register(key: string, instance: IActionHandler): void {
46
+ this.init();
47
+ super.register(key, instance);
48
+ }
49
+
50
+ override get(key: string): IActionHandler[] {
51
+ this.init();
52
+ return super.get(key);
53
+ }
54
+
55
+ override initializeActionHandler(initializer: IActionHandlerInitializer): void {
56
+ this.init();
57
+ super.initializeActionHandler(initializer);
58
+ }
59
+
22
60
  /**
23
61
  * Retrieve a set of all action kinds for which (at least) one
24
62
  * handler is registered
25
63
  * @returns the set of handled action kinds
26
64
  */
27
65
  getHandledActionKinds(): string[] {
66
+ this.init();
28
67
  return Array.from(this.elements.keys());
29
68
  }
30
69
  }
@@ -22,6 +22,7 @@ import {
22
22
  MoveCommand,
23
23
  SetDirtyStateAction,
24
24
  SetEditModeAction,
25
+ SetModelCommand,
25
26
  TYPES,
26
27
  bindAsService,
27
28
  bindOrRebind,
@@ -31,10 +32,12 @@ import {
31
32
  } from '@eclipse-glsp/sprotty';
32
33
  import '@vscode/codicons/dist/codicon.css';
33
34
  import '../../css/glsp-sprotty.css';
35
+ import { bindContributionProvider } from '../utils/contribution-provider';
34
36
  import { GLSPActionDispatcher } from './action-dispatcher';
35
37
  import { GLSPActionHandlerRegistry } from './action-handler-registry';
36
38
  import { GLSPCommandStack } from './command-stack';
37
39
  import { EditorContextService } from './editor-context-service';
40
+ import { FeedbackAwareSetModelCommand } from './feedback';
38
41
  import { ModifyCssFeedbackCommand } from './feedback/css-feedback';
39
42
  import { FeedbackActionDispatcher } from './feedback/feedback-action-dispatcher';
40
43
  import { FeedbackAwareUpdateModelCommand } from './feedback/update-model-command';
@@ -73,6 +76,7 @@ export const defaultModule = new FeatureModule((bind, unbind, isBound, rebind, .
73
76
  // Model update initialization ------------------------------------
74
77
  bind(TYPES.IFeedbackActionDispatcher).to(FeedbackActionDispatcher).inSingletonScope();
75
78
  configureCommand(context, FeedbackAwareUpdateModelCommand);
79
+ rebind(SetModelCommand).to(FeedbackAwareSetModelCommand);
76
80
 
77
81
  bind(GLSPMouseTool).toSelf().inSingletonScope();
78
82
  bindOrRebind(context, MouseTool).toService(GLSPMouseTool);
@@ -84,6 +88,9 @@ export const defaultModule = new FeatureModule((bind, unbind, isBound, rebind, .
84
88
  bindOrRebind(context, TYPES.ICommandStack).to(GLSPCommandStack).inSingletonScope();
85
89
  bind(GLSPActionDispatcher).toSelf().inSingletonScope();
86
90
  bindOrRebind(context, TYPES.IActionDispatcher).toService(GLSPActionDispatcher);
91
+
92
+ bindContributionProvider(bind, TYPES.ActionHandlerRegistration);
93
+ bindContributionProvider(bind, TYPES.IActionHandlerInitializer);
87
94
  bind(GLSPActionHandlerRegistry).toSelf().inSingletonScope();
88
95
  bindOrRebind(context, ActionHandlerRegistry).toService(GLSPActionHandlerRegistry);
89
96
 
@@ -13,8 +13,21 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
+ import {
17
+ Action,
18
+ ActionHandlerRegistry,
19
+ Command,
20
+ CommandActionHandler,
21
+ CommandExecutionContext,
22
+ Disposable,
23
+ IActionDispatcher,
24
+ ICommand,
25
+ ILogger,
26
+ TYPES,
27
+ toTypeGuard
28
+ } from '@eclipse-glsp/sprotty';
16
29
  import { inject, injectable } from 'inversify';
17
- import { Action, Disposable, IActionDispatcher, ILogger, TYPES } from '@eclipse-glsp/sprotty';
30
+ import { getFeedbackRank } from './feedback-command';
18
31
 
19
32
  export interface IFeedbackEmitter {}
20
33
 
@@ -57,6 +70,16 @@ export interface IFeedbackActionDispatcher {
57
70
  * Retrieve all `actions` sent out by currently registered `feedbackEmitter`.
58
71
  */
59
72
  getRegisteredFeedback(): Action[];
73
+
74
+ /**
75
+ * Retrieves all commands based on the registered feedback actions, ordered by their rank (lowest rank first).
76
+ */
77
+ getFeedbackCommands(): Command[];
78
+
79
+ /**
80
+ * Applies all current feedback commands to the given command execution context.
81
+ */
82
+ applyFeedbackCommands(context: CommandExecutionContext): Promise<void>;
60
83
  }
61
84
 
62
85
  @injectable()
@@ -66,6 +89,8 @@ export class FeedbackActionDispatcher implements IFeedbackActionDispatcher {
66
89
  @inject(TYPES.IActionDispatcherProvider) protected actionDispatcher: () => Promise<IActionDispatcher>;
67
90
  @inject(TYPES.ILogger) protected logger: ILogger;
68
91
 
92
+ @inject(ActionHandlerRegistry) protected actionHandlerRegistry: ActionHandlerRegistry;
93
+
69
94
  registerFeedback(feedbackEmitter: IFeedbackEmitter, feedbackActions: Action[], cleanupActions?: Action[] | undefined): Disposable {
70
95
  if (feedbackActions.length > 0) {
71
96
  this.registeredFeedback.set(feedbackEmitter, feedbackActions);
@@ -97,6 +122,29 @@ export class FeedbackActionDispatcher implements IFeedbackActionDispatcher {
97
122
  return result;
98
123
  }
99
124
 
125
+ getFeedbackCommands(): Command[] {
126
+ return this.getRegisteredFeedback()
127
+ .flatMap(action => this.actionToCommands(action))
128
+ .sort((left, right) => getFeedbackRank(left) - getFeedbackRank(right));
129
+ }
130
+
131
+ async applyFeedbackCommands(context: CommandExecutionContext): Promise<void> {
132
+ const feedbackCommands = this.getFeedbackCommands() ?? [];
133
+ if (feedbackCommands?.length > 0) {
134
+ const results = feedbackCommands.map(command => command.execute(context));
135
+ await Promise.all(results);
136
+ }
137
+ }
138
+
139
+ protected actionToCommands(action: Action): ICommand[] {
140
+ return (
141
+ this.actionHandlerRegistry
142
+ ?.get(action.kind)
143
+ .filter(toTypeGuard(CommandActionHandler))
144
+ .map(handler => handler.handle(action)) ?? []
145
+ );
146
+ }
147
+
100
148
  protected async dispatchFeedback(actions: Action[], feedbackEmitter: IFeedbackEmitter): Promise<void> {
101
149
  try {
102
150
  const actionDispatcher = await this.actionDispatcher();
@@ -13,11 +13,16 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { Command, CommandExecutionContext, CommandReturn } from '@eclipse-glsp/sprotty';
16
+ /* eslint-disable deprecation/deprecation */
17
+ import { Command, CommandExecutionContext, CommandReturn, ICommand } from '@eclipse-glsp/sprotty';
18
+ import { Ranked } from '../ranked';
17
19
 
18
- export abstract class FeedbackCommand extends Command {
19
- // used by the `FeedbackAwareUpdateModelCommand`
20
- readonly priority: number = 0;
20
+ export abstract class FeedbackCommand extends Command implements Ranked {
21
+ /** @deprecated Use rank instead. Please note that a lower rank implies higher priority, so the order is reversed. */
22
+ readonly priority?: number = 0;
23
+
24
+ // backwards compatibility: convert any existing priority to an equivalent rank
25
+ readonly rank: number = this.priority ? -this.priority : Ranked.DEFAULT_RANK;
21
26
 
22
27
  undo(context: CommandExecutionContext): CommandReturn {
23
28
  return context.root;
@@ -27,3 +32,9 @@ export abstract class FeedbackCommand extends Command {
27
32
  return context.root;
28
33
  }
29
34
  }
35
+
36
+ /** Used for backwards compatibility, otherwise use Ranked.getRank or Ranked sort functions. */
37
+ export function getFeedbackRank(command: ICommand): number {
38
+ const feedbackCommand = command as Partial<FeedbackCommand>;
39
+ return feedbackCommand?.priority ? -feedbackCommand.priority : feedbackCommand.rank ?? Ranked.DEFAULT_RANK;
40
+ }
@@ -16,4 +16,6 @@
16
16
  export * from './css-feedback';
17
17
  export * from './feedback-action-dispatcher';
18
18
  export * from './feedback-command';
19
+ export * from './set-model-command';
19
20
  export * from './update-model-command';
21
+
@@ -0,0 +1,45 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2024 EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+ import { CommandExecutionContext, GModelRoot, ILogger, SetModelAction, SetModelCommand, TYPES } from '@eclipse-glsp/sprotty';
17
+ import { inject, injectable, optional } from 'inversify';
18
+ import { IFeedbackActionDispatcher } from './feedback-action-dispatcher';
19
+
20
+ @injectable()
21
+ export class FeedbackAwareSetModelCommand extends SetModelCommand {
22
+ @inject(TYPES.ILogger)
23
+ protected logger: ILogger;
24
+
25
+ @inject(TYPES.IFeedbackActionDispatcher)
26
+ @optional()
27
+ protected feedbackActionDispatcher?: IFeedbackActionDispatcher;
28
+
29
+ constructor(@inject(TYPES.Action) action: SetModelAction) {
30
+ super(action);
31
+ }
32
+
33
+ override execute(context: CommandExecutionContext): GModelRoot {
34
+ const root = super.execute(context);
35
+ this.applyFeedback(root, context);
36
+ return root;
37
+ }
38
+
39
+ protected applyFeedback(newRoot: GModelRoot, context: CommandExecutionContext): void {
40
+ // Create a temporary context which defines the `newRoot` as `root`
41
+ // This way we do not corrupt the redo/undo behavior of the super class
42
+ const tempContext: CommandExecutionContext = { ...context, root: newRoot };
43
+ this.feedbackActionDispatcher?.applyFeedbackCommands(tempContext);
44
+ }
45
+ }
@@ -13,25 +13,20 @@
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, optional } from 'inversify';
17
16
  import {
18
- ActionHandlerRegistry,
19
17
  Animation,
20
- Command,
21
- CommandActionHandler,
22
18
  CommandExecutionContext,
23
19
  CommandReturn,
20
+ GModelRoot,
24
21
  ILogger,
25
22
  MorphEdgesAnimation,
26
- GModelRoot,
27
23
  TYPES,
28
24
  UpdateAnimationData,
29
25
  UpdateModelAction,
30
- UpdateModelCommand,
31
- toTypeGuard
26
+ UpdateModelCommand
32
27
  } from '@eclipse-glsp/sprotty';
28
+ import { inject, injectable, optional } from 'inversify';
33
29
  import { IFeedbackActionDispatcher } from './feedback-action-dispatcher';
34
- import { FeedbackCommand } from './feedback-command';
35
30
 
36
31
  /**
37
32
  * A special {@link UpdateModelCommand} that retrieves all registered {@link Action}s from the {@link IFeedbackActionDispatcher}
@@ -47,50 +42,18 @@ export class FeedbackAwareUpdateModelCommand extends UpdateModelCommand {
47
42
  @optional()
48
43
  protected feedbackActionDispatcher: IFeedbackActionDispatcher;
49
44
 
50
- protected actionHandlerRegistry?: ActionHandlerRegistry;
51
-
52
- constructor(
53
- @inject(TYPES.Action) action: UpdateModelAction,
54
- @inject(TYPES.ActionHandlerRegistryProvider)
55
- actionHandlerRegistryProvider: () => Promise<ActionHandlerRegistry>
56
- ) {
45
+ constructor(@inject(TYPES.Action) action: UpdateModelAction) {
57
46
  super({ animate: true, ...action });
58
- actionHandlerRegistryProvider().then(registry => (this.actionHandlerRegistry = registry));
59
47
  }
60
48
 
61
49
  protected override performUpdate(oldRoot: GModelRoot, newRoot: GModelRoot, context: CommandExecutionContext): CommandReturn {
62
- if (this.feedbackActionDispatcher && this.actionHandlerRegistry) {
63
- // Create a temporary context which defines the `newRoot` as `root`
64
- // This way we do not corrupt the redo/undo behavior of the super class
65
- const tempContext: CommandExecutionContext = {
66
- ...context,
67
- root: newRoot
68
- };
69
-
70
- const feedbackCommands = this.getFeedbackCommands(this.actionHandlerRegistry);
71
- feedbackCommands.forEach(command => command.execute(tempContext));
72
- }
73
-
50
+ // Create a temporary context which defines the `newRoot` as `root`
51
+ // This way we do not corrupt the redo/undo behavior of the super class
52
+ const tempContext: CommandExecutionContext = { ...context, root: newRoot };
53
+ this.feedbackActionDispatcher?.applyFeedbackCommands(tempContext);
74
54
  return super.performUpdate(oldRoot, newRoot, context);
75
55
  }
76
56
 
77
- protected getFeedbackCommands(registry: ActionHandlerRegistry): Command[] {
78
- const result: Command[] = [];
79
- this.feedbackActionDispatcher.getRegisteredFeedback().forEach(action => {
80
- const commands = registry
81
- .get(action.kind)
82
- .filter<CommandActionHandler>(toTypeGuard(CommandActionHandler))
83
- .map(handler => handler.handle(action));
84
- result.push(...commands);
85
- });
86
- // sort commands descanting by priority
87
- return result.sort((a, b) => this.getPriority(b) - this.getPriority(a));
88
- }
89
-
90
- protected getPriority(command: Partial<FeedbackCommand>): number {
91
- return command.priority ?? 0;
92
- }
93
-
94
57
  // Override the `createAnimations` implementation and remove the animation for edge morphing. Otherwise routing & reconnect
95
58
  // handles flicker after each server update.
96
59
  protected override createAnimations(data: UpdateAnimationData, root: GModelRoot, context: CommandExecutionContext): Animation[] {
@@ -21,11 +21,16 @@ import { AnyObject, hasNumberProp } from '@eclipse-glsp/sprotty';
21
21
  * orderable by a type or rank/priority.
22
22
  */
23
23
  export interface Ranked {
24
+ /**
25
+ * A rank implies the position of this element within a sequence of other ranked elements.
26
+ * A lower rank implies a position earlier in the list.
27
+ */
24
28
  rank: number;
25
29
  }
26
30
 
27
31
  export namespace Ranked {
28
32
  export const DEFAULT_RANK = 0;
33
+
29
34
  export function is(object: unknown): object is Ranked {
30
35
  return AnyObject.is(object) && hasNumberProp(object, 'rank');
31
36
  }
@@ -39,4 +44,13 @@ export namespace Ranked {
39
44
  export function getRank(object: unknown): number {
40
45
  return is(object) ? object.rank : DEFAULT_RANK;
41
46
  }
47
+
48
+ /** Sort function for lowest rank first. */
49
+ export const sortAsc = (left: unknown, right: unknown): number => getRank(left) - getRank(right);
50
+
51
+ /** Sort function for highest rank first. */
52
+ export const sortDesc = (left: unknown, right: unknown): number => getRank(right) - getRank(left);
53
+
54
+ /** Default sort function for rank: Lowest rank first */
55
+ export const sort = sortAsc;
42
56
  }
@@ -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, Disposable, GModelRoot, GNode, TYPES, initializeContainer } from '@eclipse-glsp/sprotty';
16
+ import { Action, Command, CommandExecutionContext, Disposable, GModelRoot, GNode, TYPES, initializeContainer } from '@eclipse-glsp/sprotty';
17
17
  import { AssertionError, expect } from 'chai';
18
18
  import { Container, injectable } from 'inversify';
19
19
  import * as sinon from 'sinon';
@@ -44,6 +44,12 @@ class MockFeedbackActionDispatcher implements IFeedbackActionDispatcher {
44
44
  const actions = this.getRegisteredFeedback();
45
45
  return actions.length === 1 ? (actions[0] as SelectFeedbackAction) : undefined;
46
46
  }
47
+
48
+ getFeedbackCommands(): Command[] {
49
+ return [];
50
+ }
51
+
52
+ async applyFeedbackCommands(context: CommandExecutionContext): Promise<void> {}
47
53
  }
48
54
 
49
55
  class MockSelectionListener implements ISelectionListener {