@eclipse-glsp/client 1.1.0-next.cb7168a.239 → 1.1.0-next.d3b810d.243

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 (41) hide show
  1. package/package.json +3 -3
  2. package/lib/features/bounds/freeform-layout.spec.d.ts +0 -3
  3. package/lib/features/bounds/freeform-layout.spec.d.ts.map +0 -1
  4. package/lib/features/bounds/freeform-layout.spec.js +0 -201
  5. package/lib/features/bounds/freeform-layout.spec.js.map +0 -1
  6. package/lib/features/bounds/hbox-layout.spec.d.ts +0 -3
  7. package/lib/features/bounds/hbox-layout.spec.d.ts.map +0 -1
  8. package/lib/features/bounds/hbox-layout.spec.js +0 -161
  9. package/lib/features/bounds/hbox-layout.spec.js.map +0 -1
  10. package/lib/features/bounds/layouter-test-util.spec.d.ts +0 -33
  11. package/lib/features/bounds/layouter-test-util.spec.d.ts.map +0 -1
  12. package/lib/features/bounds/layouter-test-util.spec.js +0 -96
  13. package/lib/features/bounds/layouter-test-util.spec.js.map +0 -1
  14. package/lib/features/bounds/vbox-layout.spec.d.ts +0 -3
  15. package/lib/features/bounds/vbox-layout.spec.d.ts.map +0 -1
  16. package/lib/features/bounds/vbox-layout.spec.js +0 -161
  17. package/lib/features/bounds/vbox-layout.spec.js.map +0 -1
  18. package/lib/features/change-bounds/snap.spec.d.ts +0 -17
  19. package/lib/features/change-bounds/snap.spec.d.ts.map +0 -1
  20. package/lib/features/change-bounds/snap.spec.js +0 -82
  21. package/lib/features/change-bounds/snap.spec.js.map +0 -1
  22. package/lib/features/layout/layout-elements-action.spec.d.ts +0 -3
  23. package/lib/features/layout/layout-elements-action.spec.d.ts.map +0 -1
  24. package/lib/features/layout/layout-elements-action.spec.js +0 -325
  25. package/lib/features/layout/layout-elements-action.spec.js.map +0 -1
  26. package/lib/features/navigation/navigation-target-resolver.spec.d.ts +0 -3
  27. package/lib/features/navigation/navigation-target-resolver.spec.d.ts.map +0 -1
  28. package/lib/features/navigation/navigation-target-resolver.spec.js +0 -54
  29. package/lib/features/navigation/navigation-target-resolver.spec.js.map +0 -1
  30. package/lib/features/select/selection-service.spec.d.ts +0 -2
  31. package/lib/features/select/selection-service.spec.d.ts.map +0 -1
  32. package/lib/features/select/selection-service.spec.js +0 -363
  33. package/lib/features/select/selection-service.spec.js.map +0 -1
  34. package/lib/features/tools/marquee-behavior.spec.d.ts +0 -17
  35. package/lib/features/tools/marquee-behavior.spec.d.ts.map +0 -1
  36. package/lib/features/tools/marquee-behavior.spec.js +0 -165
  37. package/lib/features/tools/marquee-behavior.spec.js.map +0 -1
  38. package/lib/features/validation/marker-navigator.spec.d.ts +0 -3
  39. package/lib/features/validation/marker-navigator.spec.d.ts.map +0 -1
  40. package/lib/features/validation/marker-navigator.spec.js +0 -169
  41. package/lib/features/validation/marker-navigator.spec.js.map +0 -1
@@ -1,161 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /********************************************************************************
4
- * Copyright (c) 2022-2023 TypeFox, STMicroelectronics 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 WITH Classpath-exception-2.0
17
- ********************************************************************************/
18
- /* eslint-disable deprecation/deprecation */
19
- const protocol_1 = require("@eclipse-glsp/protocol");
20
- const chai_1 = require("chai");
21
- require("mocha");
22
- require("reflect-metadata");
23
- const sprotty_1 = require("sprotty");
24
- const layouter_test_util_spec_1 = require("./layouter-test-util.spec");
25
- describe('VBoxLayouter', () => {
26
- const layoutRegistry = (0, layouter_test_util_spec_1.setupLayoutRegistry)();
27
- const log = new sprotty_1.ConsoleLogger();
28
- const map = new Map();
29
- function createModel() {
30
- const model = (0, layouter_test_util_spec_1.sNode)('node', undefined, protocol_1.Dimension.EMPTY);
31
- model.children = [
32
- (0, layouter_test_util_spec_1.sLabel)('label1', undefined, undefined, { width: 1, height: 2 }),
33
- (0, layouter_test_util_spec_1.sLabel)('label2', undefined, undefined, { width: 2, height: 1 }),
34
- (0, layouter_test_util_spec_1.sLabel)('label3', undefined, undefined, { width: 3, height: 3 })
35
- ];
36
- model.layout = 'vbox';
37
- return model;
38
- }
39
- it('defaultParams', () => {
40
- const model = createModel();
41
- (0, layouter_test_util_spec_1.layout)(layoutRegistry, log, map, model);
42
- (0, chai_1.expect)(map.get(model).bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 18 });
43
- (0, chai_1.expect)(map.get(model.children[0]).bounds).to.deep.equal({ x: 6, y: 5, width: 1, height: 2 });
44
- (0, chai_1.expect)(map.get(model.children[1]).bounds).to.deep.equal({ x: 5.5, y: 8, width: 2, height: 1 });
45
- (0, chai_1.expect)(map.get(model.children[2]).bounds).to.deep.equal({ x: 5, y: 10, width: 3, height: 3 });
46
- });
47
- it('alignLeft', () => {
48
- const model = createModel();
49
- model.layoutOptions = {
50
- hAlign: 'left'
51
- };
52
- (0, layouter_test_util_spec_1.layout)(layoutRegistry, log, map, model);
53
- (0, chai_1.expect)(map.get(model).bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 18 });
54
- (0, chai_1.expect)(map.get(model.children[0]).bounds).to.deep.equal({ x: 5, y: 5, width: 1, height: 2 });
55
- (0, chai_1.expect)(map.get(model.children[1]).bounds).to.deep.equal({ x: 5, y: 8, width: 2, height: 1 });
56
- (0, chai_1.expect)(map.get(model.children[2]).bounds).to.deep.equal({ x: 5, y: 10, width: 3, height: 3 });
57
- });
58
- it('alignCenter', () => {
59
- const model = createModel();
60
- model.layoutOptions = {
61
- hAlign: 'center'
62
- };
63
- (0, layouter_test_util_spec_1.layout)(layoutRegistry, log, map, model);
64
- (0, chai_1.expect)(map.get(model).bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 18 });
65
- (0, chai_1.expect)(map.get(model.children[0]).bounds).to.deep.equal({ x: 6, y: 5, width: 1, height: 2 });
66
- (0, chai_1.expect)(map.get(model.children[1]).bounds).to.deep.equal({ x: 5.5, y: 8, width: 2, height: 1 });
67
- (0, chai_1.expect)(map.get(model.children[2]).bounds).to.deep.equal({ x: 5, y: 10, width: 3, height: 3 });
68
- });
69
- it('alignRight', () => {
70
- const model = createModel();
71
- model.layoutOptions = {
72
- hAlign: 'right'
73
- };
74
- (0, layouter_test_util_spec_1.layout)(layoutRegistry, log, map, model);
75
- (0, chai_1.expect)(map.get(model).bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 18 });
76
- (0, chai_1.expect)(map.get(model.children[0]).bounds).to.deep.equal({ x: 7, y: 5, width: 1, height: 2 });
77
- (0, chai_1.expect)(map.get(model.children[1]).bounds).to.deep.equal({ x: 6, y: 8, width: 2, height: 1 });
78
- (0, chai_1.expect)(map.get(model.children[2]).bounds).to.deep.equal({ x: 5, y: 10, width: 3, height: 3 });
79
- });
80
- it('padding', () => {
81
- const model = createModel();
82
- model.layoutOptions = {
83
- paddingTop: 7,
84
- paddingBottom: 8,
85
- paddingLeft: 9,
86
- paddingRight: 10
87
- };
88
- (0, layouter_test_util_spec_1.layout)(layoutRegistry, log, map, model);
89
- (0, chai_1.expect)(map.get(model).bounds).to.deep.equal({ x: 0, y: 0, width: 22, height: 23 });
90
- (0, chai_1.expect)(map.get(model.children[0]).bounds).to.deep.equal({ x: 10, y: 7, width: 1, height: 2 });
91
- (0, chai_1.expect)(map.get(model.children[1]).bounds).to.deep.equal({ x: 9.5, y: 10, width: 2, height: 1 });
92
- (0, chai_1.expect)(map.get(model.children[2]).bounds).to.deep.equal({ x: 9, y: 12, width: 3, height: 3 });
93
- });
94
- it('vGap', () => {
95
- const model = createModel();
96
- model.layoutOptions = {
97
- vGap: 4
98
- };
99
- (0, layouter_test_util_spec_1.layout)(layoutRegistry, log, map, model);
100
- (0, chai_1.expect)(map.get(model).bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 24 });
101
- (0, chai_1.expect)(map.get(model.children[0]).bounds).to.deep.equal({ x: 6, y: 5, width: 1, height: 2 });
102
- (0, chai_1.expect)(map.get(model.children[1]).bounds).to.deep.equal({ x: 5.5, y: 11, width: 2, height: 1 });
103
- (0, chai_1.expect)(map.get(model.children[2]).bounds).to.deep.equal({ x: 5, y: 16, width: 3, height: 3 });
104
- });
105
- it('paddingFactor', () => {
106
- const model = createModel();
107
- model.layoutOptions = {
108
- paddingFactor: 2
109
- };
110
- (0, layouter_test_util_spec_1.layout)(layoutRegistry, log, map, model);
111
- (0, chai_1.expect)(map.get(model).bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 18 });
112
- (0, chai_1.expect)(map.get(model.children[0]).bounds).to.deep.equal({ x: 9, y: 9, width: 1, height: 2 });
113
- (0, chai_1.expect)(map.get(model.children[1]).bounds).to.deep.equal({ x: 8.5, y: 12, width: 2, height: 1 });
114
- (0, chai_1.expect)(map.get(model.children[2]).bounds).to.deep.equal({ x: 8, y: 14, width: 3, height: 3 });
115
- });
116
- it('minWidth', () => {
117
- const model = createModel();
118
- model.layoutOptions = {
119
- minWidth: 25
120
- };
121
- (0, layouter_test_util_spec_1.layout)(layoutRegistry, log, map, model);
122
- (0, chai_1.expect)(map.get(model).bounds).to.deep.equal({ x: 0, y: 0, width: 25, height: 18 });
123
- (0, chai_1.expect)(map.get(model.children[0]).bounds).to.deep.equal({ x: 12, y: 5, width: 1, height: 2 });
124
- (0, chai_1.expect)(map.get(model.children[1]).bounds).to.deep.equal({ x: 11.5, y: 8, width: 2, height: 1 });
125
- (0, chai_1.expect)(map.get(model.children[2]).bounds).to.deep.equal({ x: 11, y: 10, width: 3, height: 3 });
126
- });
127
- it('minHeight', () => {
128
- const model = createModel();
129
- model.layoutOptions = {
130
- minHeight: 25
131
- };
132
- (0, layouter_test_util_spec_1.layout)(layoutRegistry, log, map, model);
133
- (0, chai_1.expect)(map.get(model).bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 25 });
134
- (0, chai_1.expect)(map.get(model.children[0]).bounds).to.deep.equal({ x: 6, y: 5, width: 1, height: 2 });
135
- (0, chai_1.expect)(map.get(model.children[1]).bounds).to.deep.equal({ x: 5.5, y: 8, width: 2, height: 1 });
136
- (0, chai_1.expect)(map.get(model.children[2]).bounds).to.deep.equal({ x: 5, y: 10, width: 3, height: 3 });
137
- });
138
- it('prefWidth', () => {
139
- const model = createModel();
140
- model.layoutOptions = {
141
- prefWidth: 20
142
- };
143
- (0, layouter_test_util_spec_1.layout)(layoutRegistry, log, map, model);
144
- (0, chai_1.expect)(map.get(model).bounds).to.deep.equal({ x: 0, y: 0, width: 20, height: 18 });
145
- (0, chai_1.expect)(map.get(model.children[0]).bounds).to.deep.equal({ x: 9.5, y: 5, width: 1, height: 2 });
146
- (0, chai_1.expect)(map.get(model.children[1]).bounds).to.deep.equal({ x: 9, y: 8, width: 2, height: 1 });
147
- (0, chai_1.expect)(map.get(model.children[2]).bounds).to.deep.equal({ x: 8.5, y: 10, width: 3, height: 3 });
148
- });
149
- it('prefHeight', () => {
150
- const model = createModel();
151
- model.layoutOptions = {
152
- prefHeight: 20
153
- };
154
- (0, layouter_test_util_spec_1.layout)(layoutRegistry, log, map, model);
155
- (0, chai_1.expect)(map.get(model).bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 20 });
156
- (0, chai_1.expect)(map.get(model.children[0]).bounds).to.deep.equal({ x: 6, y: 5, width: 1, height: 2 });
157
- (0, chai_1.expect)(map.get(model.children[1]).bounds).to.deep.equal({ x: 5.5, y: 8, width: 2, height: 1 });
158
- (0, chai_1.expect)(map.get(model.children[2]).bounds).to.deep.equal({ x: 5, y: 10, width: 3, height: 3 });
159
- });
160
- });
161
- //# sourceMappingURL=vbox-layout.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3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CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;QAChG,IAAA,aAAM,EAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IACnG,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,17 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2022 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
- export {};
17
- //# sourceMappingURL=snap.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"snap.spec.d.ts","sourceRoot":"","sources":["../../../src/features/change-bounds/snap.spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF"}
@@ -1,82 +0,0 @@
1
- "use strict";
2
- /********************************************************************************
3
- * Copyright (c) 2022 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 WITH Classpath-exception-2.0
16
- ********************************************************************************/
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- const chai_1 = require("chai");
19
- const sprotty_1 = require("sprotty");
20
- const snap_1 = require("./snap");
21
- describe('GridSnapper', () => {
22
- it('snap', () => {
23
- const element = new sprotty_1.SModelElement();
24
- const snapper = new snap_1.GridSnapper();
25
- (0, chai_1.expect)(snapper.snap({ x: 0, y: 0 }, element)).to.be.deep.equals({ x: 0, y: 0 });
26
- (0, chai_1.expect)(snapper.snap({ x: 4, y: 5 }, element)).to.be.deep.equals({ x: 0, y: 10 });
27
- (0, chai_1.expect)(snapper.snap({ x: 8, y: 11 }, element)).to.be.deep.equals({ x: 10, y: 10 });
28
- (0, chai_1.expect)(snapper.snap({ x: -7, y: -4 }, element)).to.be.deep.equals({ x: -10, y: -0 });
29
- });
30
- });
31
- describe('PointPositionUpdater', () => {
32
- it('updatePosition with no last drag position', () => {
33
- const element = new sprotty_1.SModelElement();
34
- const updater = new snap_1.PointPositionUpdater();
35
- (0, chai_1.expect)(updater.updatePosition(element, { x: 0, y: 0 }, false)).to.be.undefined;
36
- (0, chai_1.expect)(updater.updatePosition(element, { x: 0, y: 0 }, true)).to.be.undefined;
37
- });
38
- it('update last position and reset', () => {
39
- const updater = new snap_1.PointPositionUpdater();
40
- (0, chai_1.expect)(updater.isLastDragPositionUndefined()).to.be.true;
41
- updater.updateLastDragPosition({ x: 0, y: 0 });
42
- (0, chai_1.expect)(updater.isLastDragPositionUndefined()).to.be.false;
43
- updater.resetPosition();
44
- (0, chai_1.expect)(updater.isLastDragPositionUndefined()).to.be.true;
45
- });
46
- it('updatePosition with no snapper', () => {
47
- const element = new sprotty_1.SModelElement();
48
- const updater = new snap_1.PointPositionUpdater();
49
- resetUpdater(updater);
50
- (0, chai_1.expect)(updater.updatePosition(element, { x: 0, y: 0 }, false)).to.be.undefined;
51
- (0, chai_1.expect)(updater.updatePosition(element, { x: 0, y: 0 }, true)).to.be.undefined;
52
- resetUpdater(updater);
53
- (0, chai_1.expect)(updater.updatePosition(element, { x: 5, y: 3 }, false)).to.be.deep.equals({ x: 5, y: 3 });
54
- (0, chai_1.expect)(updater.updatePosition(element, { x: 5, y: 3 }, true)).to.be.undefined;
55
- (0, chai_1.expect)(updater.updatePosition(element, { x: 11, y: 6 }, false)).to.be.deep.equals({ x: 6, y: 3 });
56
- (0, chai_1.expect)(updater.updatePosition(element, { x: -3, y: 2 }, true)).to.be.deep.equals({ x: -14, y: -4 });
57
- });
58
- it('updatePosition with snapper', () => {
59
- const element = new sprotty_1.SModelElement();
60
- const snapper = new snap_1.GridSnapper();
61
- const updater = new snap_1.PointPositionUpdater(snapper);
62
- resetUpdater(updater);
63
- (0, chai_1.expect)(updater.updatePosition(element, { x: 0, y: 0 }, false)).to.be.undefined;
64
- (0, chai_1.expect)(updater.updatePosition(element, { x: 0, y: 0 }, true)).to.be.undefined;
65
- resetUpdater(updater);
66
- (0, chai_1.expect)(updater.updatePosition(element, { x: 5, y: 3 }, true)).to.be.deep.equals({ x: 10, y: 0 });
67
- (0, chai_1.expect)(updater.updatePosition(element, { x: 5, y: 3 }, true)).to.be.undefined;
68
- (0, chai_1.expect)(updater.updatePosition(element, { x: 11, y: 6 }, true)).to.be.deep.equals({ x: 0, y: 10 });
69
- (0, chai_1.expect)(updater.updatePosition(element, { x: -3, y: 2 }, true)).to.be.deep.equals({ x: -10, y: -10 });
70
- // disable snapping (alt key)
71
- resetUpdater(updater);
72
- (0, chai_1.expect)(updater.updatePosition(element, { x: 5, y: 3 }, false)).to.be.deep.equals({ x: 5, y: 3 });
73
- (0, chai_1.expect)(updater.updatePosition(element, { x: 5, y: 3 }, false)).to.be.undefined;
74
- (0, chai_1.expect)(updater.updatePosition(element, { x: 11, y: 6 }, false)).to.be.deep.equals({ x: 6, y: 3 });
75
- (0, chai_1.expect)(updater.updatePosition(element, { x: -3, y: 2 }, false)).to.be.deep.equals({ x: -14, y: -4 });
76
- });
77
- function resetUpdater(updater) {
78
- updater.resetPosition();
79
- updater.updateLastDragPosition({ x: 0, y: 0 });
80
- }
81
- });
82
- //# sourceMappingURL=snap.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"snap.spec.js","sourceRoot":"","sources":["../../../src/features/change-bounds/snap.spec.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;AAElF,+BAA8B;AAC9B,qCAAwC;AACxC,iCAA2D;AAE3D,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACZ,MAAM,OAAO,GAAG,IAAI,uBAAa,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,kBAAW,EAAE,CAAC;QAClC,IAAA,aAAM,EAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAChF,IAAA,aAAM,EAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACjF,IAAA,aAAM,EAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,I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AAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACjG,IAAA,aAAM,EAAC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;QAC/E,IAAA,aAAM,EAAC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAClG,IAAA,aAAM,EAAC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACzG,CAAC,CAAC,CAAC;IAEH,SAAS,YAAY,CAAC,OAA6B;QAC/C,OAAO,CAAC,aAAa,EAAE,CAAC;QACxB,OAAO,CAAC,sBAAsB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import 'mocha';
2
- import 'reflect-metadata';
3
- //# sourceMappingURL=layout-elements-action.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"layout-elements-action.spec.d.ts","sourceRoot":"","sources":["../../../src/features/layout/layout-elements-action.spec.ts"],"names":[],"mappings":"AA2BA,OAAO,OAAO,CAAC;AACf,OAAO,kBAAkB,CAAC"}
@@ -1,325 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /********************************************************************************
4
- * Copyright (c) 2019-2022 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 WITH Classpath-exception-2.0
17
- ********************************************************************************/
18
- /* eslint-disable deprecation/deprecation */
19
- const protocol_1 = require("@eclipse-glsp/protocol");
20
- const chai_1 = require("chai");
21
- const inversify_1 = require("inversify");
22
- require("mocha");
23
- require("reflect-metadata");
24
- const sprotty_1 = require("sprotty");
25
- const types_1 = require("../../base/types");
26
- const model_1 = require("../change-bounds/model");
27
- const selection_service_1 = require("../select/selection-service");
28
- const feedback_action_dispatcher_1 = require("../tool-feedback/feedback-action-dispatcher");
29
- const layout_elements_action_1 = require("./layout-elements-action");
30
- class MockActionDispatcher {
31
- constructor(dispatchedActions = []) {
32
- this.dispatchedActions = dispatchedActions;
33
- }
34
- dispatch(action) {
35
- this.dispatchedActions.push(action);
36
- return Promise.resolve();
37
- }
38
- dispatchAll(actions) {
39
- actions.forEach(action => this.dispatchedActions.push(action));
40
- return Promise.resolve();
41
- }
42
- request(action) {
43
- throw new Error('Method not implemented.');
44
- }
45
- }
46
- class MockSelectionService extends selection_service_1.SelectionService {
47
- constructor(modelRoot) {
48
- super();
49
- this.modelRoot = modelRoot;
50
- }
51
- getModelRoot() {
52
- return this.modelRoot;
53
- }
54
- }
55
- // Generic Test setup
56
- const container = new inversify_1.Container();
57
- container.load(sprotty_1.defaultModule);
58
- container.bind(types_1.TYPES.IFeedbackActionDispatcher).to(feedback_action_dispatcher_1.FeedbackActionDispatcher).inSingletonScope();
59
- container.rebind(types_1.TYPES.IModelFactory).to(sprotty_1.SGraphFactory).inSingletonScope();
60
- const graphFactory = container.get(types_1.TYPES.IModelFactory);
61
- const actionDispatcher = new MockActionDispatcher();
62
- const node1 = {
63
- id: 'node1',
64
- type: 'node:circle',
65
- selected: true
66
- };
67
- const node2 = {
68
- id: 'node2',
69
- type: 'node:circle',
70
- selected: true
71
- };
72
- const node3 = {
73
- id: 'node3',
74
- type: 'node:circle',
75
- selected: true
76
- };
77
- const model = createModel();
78
- function createModel() {
79
- const root = graphFactory.createRoot({
80
- id: 'model1',
81
- type: 'graph',
82
- children: [node1, node2, node3]
83
- });
84
- root.children.forEach(child => applyFeature(child, model_1.resizeFeature));
85
- return root;
86
- }
87
- function applyFeature(element, feature) {
88
- element.features.add(feature);
89
- }
90
- const context = {
91
- root: model,
92
- modelFactory: graphFactory,
93
- duration: 0,
94
- modelChanged: undefined,
95
- logger: new sprotty_1.ConsoleLogger(),
96
- syncer: new sprotty_1.AnimationFrameSyncer()
97
- };
98
- const defaultSize = { height: 10, width: 10 };
99
- describe('AlignElementsCommand', () => {
100
- let handler;
101
- const setModel = (newModel) => {
102
- handler['selectionService'] = new MockSelectionService(newModel);
103
- };
104
- beforeEach(() => {
105
- actionDispatcher.dispatchedActions = [];
106
- handler = new layout_elements_action_1.AlignElementsActionHandler();
107
- handler['actionDispatcher'] = actionDispatcher;
108
- });
109
- it('should align all elements left', () => {
110
- const newModel = initModel([
111
- { elementId: 'node1', newPosition: { x: 111, y: 111 }, newSize: defaultSize },
112
- { elementId: 'node2', newPosition: { x: 222, y: 222 }, newSize: defaultSize },
113
- { elementId: 'node3', newPosition: { x: 333, y: 333 }, newSize: defaultSize }
114
- ]);
115
- const action = layout_elements_action_1.AlignElementsAction.create({ elementIds: ['node1', 'node2', 'node3'], alignment: layout_elements_action_1.Alignment.Left });
116
- setModel(newModel);
117
- handler.handle(action);
118
- assertAllBounds(new Map([
119
- ['node1', { x: 111, y: 111, width: defaultSize.width, height: defaultSize.height }],
120
- ['node2', { x: 111, y: 222, width: defaultSize.width, height: defaultSize.height }],
121
- ['node3', { x: 111, y: 333, width: defaultSize.width, height: defaultSize.height }]
122
- ]));
123
- });
124
- it('should align all elements right', () => {
125
- const newModel = initModel([
126
- { elementId: 'node1', newPosition: { x: 111, y: 111 }, newSize: defaultSize },
127
- { elementId: 'node2', newPosition: { x: 222, y: 222 }, newSize: defaultSize },
128
- { elementId: 'node3', newPosition: { x: 333, y: 333 }, newSize: defaultSize }
129
- ]);
130
- const action = layout_elements_action_1.AlignElementsAction.create({ elementIds: ['node1', 'node2', 'node3'], alignment: layout_elements_action_1.Alignment.Right });
131
- setModel(newModel);
132
- handler.handle(action);
133
- assertAllBounds(new Map([
134
- ['node1', { x: 333, y: 111, width: defaultSize.width, height: defaultSize.height }],
135
- ['node2', { x: 333, y: 222, width: defaultSize.width, height: defaultSize.height }],
136
- ['node3', { x: 333, y: 333, width: defaultSize.width, height: defaultSize.height }]
137
- ]));
138
- });
139
- it('should align all elements center', () => {
140
- actionDispatcher.dispatchedActions = [];
141
- const newModel = initModel([
142
- { elementId: 'node1', newPosition: { x: 111, y: 111 }, newSize: defaultSize },
143
- { elementId: 'node2', newPosition: { x: 222, y: 222 }, newSize: defaultSize },
144
- { elementId: 'node3', newPosition: { x: 333, y: 333 }, newSize: defaultSize }
145
- ]);
146
- const action = layout_elements_action_1.AlignElementsAction.create({ elementIds: ['node1', 'node2', 'node3'], alignment: layout_elements_action_1.Alignment.Center });
147
- setModel(newModel);
148
- handler.handle(action);
149
- assertAllBounds(new Map([
150
- ['node1', { x: 222, y: 111, width: defaultSize.width, height: defaultSize.height }],
151
- ['node2', { x: 222, y: 222, width: defaultSize.width, height: defaultSize.height }],
152
- ['node3', { x: 222, y: 333, width: defaultSize.width, height: defaultSize.height }]
153
- ]));
154
- });
155
- it('should align all elements top', () => {
156
- const newModel = initModel([
157
- { elementId: 'node1', newPosition: { x: 111, y: 111 }, newSize: defaultSize },
158
- { elementId: 'node2', newPosition: { x: 222, y: 222 }, newSize: defaultSize },
159
- { elementId: 'node3', newPosition: { x: 333, y: 333 }, newSize: defaultSize }
160
- ]);
161
- const action = layout_elements_action_1.AlignElementsAction.create({ elementIds: ['node1', 'node2', 'node3'], alignment: layout_elements_action_1.Alignment.Top });
162
- setModel(newModel);
163
- handler.handle(action);
164
- assertAllBounds(new Map([
165
- ['node1', { x: 111, y: 111, width: defaultSize.width, height: defaultSize.height }],
166
- ['node2', { x: 222, y: 111, width: defaultSize.width, height: defaultSize.height }],
167
- ['node3', { x: 333, y: 111, width: defaultSize.width, height: defaultSize.height }]
168
- ]));
169
- });
170
- it('should align all elements bottom', () => {
171
- const newModel = initModel([
172
- { elementId: 'node1', newPosition: { x: 111, y: 111 }, newSize: defaultSize },
173
- { elementId: 'node2', newPosition: { x: 222, y: 222 }, newSize: defaultSize },
174
- { elementId: 'node3', newPosition: { x: 333, y: 333 }, newSize: defaultSize }
175
- ]);
176
- const action = layout_elements_action_1.AlignElementsAction.create({ elementIds: ['node1', 'node2', 'node3'], alignment: layout_elements_action_1.Alignment.Bottom });
177
- setModel(newModel);
178
- handler.handle(action);
179
- assertAllBounds(new Map([
180
- ['node1', { x: 111, y: 333, width: defaultSize.width, height: defaultSize.height }],
181
- ['node2', { x: 222, y: 333, width: defaultSize.width, height: defaultSize.height }],
182
- ['node3', { x: 333, y: 333, width: defaultSize.width, height: defaultSize.height }]
183
- ]));
184
- });
185
- it('should align all elements middle', () => {
186
- const newModel = initModel([
187
- { elementId: 'node1', newPosition: { x: 111, y: 111 }, newSize: defaultSize },
188
- { elementId: 'node2', newPosition: { x: 222, y: 222 }, newSize: defaultSize },
189
- { elementId: 'node3', newPosition: { x: 333, y: 333 }, newSize: defaultSize }
190
- ]);
191
- const action = layout_elements_action_1.AlignElementsAction.create({ elementIds: ['node1', 'node2', 'node3'], alignment: layout_elements_action_1.Alignment.Middle });
192
- setModel(newModel);
193
- handler.handle(action);
194
- assertAllBounds(new Map([
195
- ['node1', { x: 111, y: 222, width: defaultSize.width, height: defaultSize.height }],
196
- ['node2', { x: 222, y: 222, width: defaultSize.width, height: defaultSize.height }],
197
- ['node3', { x: 333, y: 222, width: defaultSize.width, height: defaultSize.height }]
198
- ]));
199
- });
200
- });
201
- describe('ResizeElementsCommand', () => {
202
- let handler;
203
- const setModel = (newModel) => {
204
- handler['selectionService'] = new MockSelectionService(newModel);
205
- };
206
- beforeEach(() => {
207
- actionDispatcher.dispatchedActions = [];
208
- handler = new layout_elements_action_1.ResizeElementsActionHandler();
209
- handler['actionDispatcher'] = actionDispatcher;
210
- });
211
- it('should make same width as last', () => {
212
- const newModel = initModel([
213
- { elementId: 'node1', newPosition: { x: 100, y: 100 }, newSize: { height: 10, width: 10 } },
214
- { elementId: 'node2', newPosition: { x: 100, y: 200 }, newSize: { height: 20, width: 20 } },
215
- { elementId: 'node3', newPosition: { x: 100, y: 300 }, newSize: { height: 30, width: 30 } }
216
- ]);
217
- const action = layout_elements_action_1.ResizeElementsAction.create({
218
- elementIds: ['node1', 'node2', 'node3'],
219
- dimension: layout_elements_action_1.ResizeDimension.Width,
220
- reduceFunction: 'last'
221
- });
222
- setModel(newModel);
223
- handler.handle(action);
224
- // resize is keeping the center, so the X moves by diff / 2
225
- assertAllBoundsInChangeBounds(new Map([
226
- ['node1', { x: 90, y: 100, height: 10, width: 30 }],
227
- ['node2', { x: 95, y: 200, height: 20, width: 30 }],
228
- ['node3', { x: 100, y: 300, height: 30, width: 30 }]
229
- ]));
230
- });
231
- it('should make same height as last', () => {
232
- const newModel = initModel([
233
- { elementId: 'node1', newPosition: { x: 100, y: 100 }, newSize: { height: 10, width: 10 } },
234
- { elementId: 'node2', newPosition: { x: 100, y: 200 }, newSize: { height: 20, width: 20 } },
235
- { elementId: 'node3', newPosition: { x: 100, y: 300 }, newSize: { height: 30, width: 30 } }
236
- ]);
237
- const action = layout_elements_action_1.ResizeElementsAction.create({
238
- elementIds: ['node1', 'node2', 'node3'],
239
- dimension: layout_elements_action_1.ResizeDimension.Height,
240
- reduceFunction: 'last'
241
- });
242
- setModel(newModel);
243
- handler.handle(action);
244
- // resize is keeping the center, so the Y moves by diff / 2
245
- assertAllBoundsInChangeBounds(new Map([
246
- ['node1', { x: 100, y: 90, height: 30, width: 10 }],
247
- ['node2', { x: 100, y: 195, height: 30, width: 20 }],
248
- ['node3', { x: 100, y: 300, height: 30, width: 30 }]
249
- ]));
250
- });
251
- it('should make same width and height as last', () => {
252
- const newModel = initModel([
253
- { elementId: 'node1', newPosition: { x: 100, y: 100 }, newSize: { height: 10, width: 10 } },
254
- { elementId: 'node2', newPosition: { x: 100, y: 200 }, newSize: { height: 20, width: 20 } },
255
- { elementId: 'node3', newPosition: { x: 100, y: 300 }, newSize: { height: 30, width: 30 } }
256
- ]);
257
- const action = layout_elements_action_1.ResizeElementsAction.create({
258
- elementIds: ['node1', 'node2', 'node3'],
259
- dimension: layout_elements_action_1.ResizeDimension.Width_And_Height,
260
- reduceFunction: 'last'
261
- });
262
- setModel(newModel);
263
- handler.handle(action);
264
- // resize is keeping the center, so the Y moves by diff / 2
265
- assertAllBoundsInChangeBounds(new Map([
266
- ['node1', { x: 90, y: 90, height: 30, width: 30 }],
267
- ['node2', { x: 95, y: 195, height: 30, width: 30 }],
268
- ['node3', { x: 100, y: 300, height: 30, width: 30 }]
269
- ]));
270
- });
271
- });
272
- function initModel(elementAndBounds) {
273
- const mySetBoundsAction = protocol_1.SetBoundsAction.create(elementAndBounds);
274
- const setBoundsCommand = new sprotty_1.SetBoundsCommand(mySetBoundsAction);
275
- return setBoundsCommand.execute(context);
276
- }
277
- function assertAllBounds(allBounds) {
278
- allBounds.forEach((bounds, nodeId) => assertBounds(nodeId, bounds));
279
- }
280
- function assertAllBoundsInChangeBounds(allBounds) {
281
- allBounds.forEach((bounds, nodeId) => assertBoundsInChangeBoundsActions(nodeId, bounds));
282
- }
283
- function assertBounds(nodeId, bounds) {
284
- assertBoundsInMoves(nodeId, bounds);
285
- assertBoundsInChangeBoundsActions(nodeId, bounds);
286
- }
287
- function assertBoundsInMoves(nodeId, bounds) {
288
- const moves = dispatchedElementMoves();
289
- const move = getMoveById(nodeId, moves);
290
- (0, chai_1.expect)(move.toPosition.x).to.be.equal(bounds.x);
291
- (0, chai_1.expect)(move.toPosition.y).to.be.equal(bounds.y);
292
- }
293
- function assertBoundsInChangeBoundsActions(nodeId, bounds) {
294
- const allChangeBounds = dispatchedChangeBounds();
295
- const changeBounds = getElementAndBoundsById(nodeId, allChangeBounds);
296
- (0, chai_1.expect)(changeBounds.newPosition.x).to.be.equal(bounds.x);
297
- (0, chai_1.expect)(changeBounds.newPosition.y).to.be.equal(bounds.y);
298
- (0, chai_1.expect)(changeBounds.newSize.height).to.be.equal(bounds.height);
299
- (0, chai_1.expect)(changeBounds.newSize.width).to.be.equal(bounds.width);
300
- }
301
- function getMoveById(id, moves) {
302
- return moves.filter(m => m.elementId === id)[0];
303
- }
304
- function getElementAndBoundsById(id, elementAndBounds) {
305
- return elementAndBounds.filter(m => m.elementId === id)[0];
306
- }
307
- function dispatchedElementMoves() {
308
- return actionDispatcher.dispatchedActions
309
- .filter(isMoveAction)
310
- .map(a => a.moves)
311
- .reduce((acc, val) => acc.concat(val), []);
312
- }
313
- function dispatchedChangeBounds() {
314
- return actionDispatcher.dispatchedActions
315
- .filter(isChangeBounds)
316
- .map(a => a.newBounds)
317
- .reduce((acc, val) => acc.concat(val), []);
318
- }
319
- function isMoveAction(action) {
320
- return action.kind === sprotty_1.MoveCommand.KIND;
321
- }
322
- function isChangeBounds(action) {
323
- return action.kind === protocol_1.ChangeBoundsOperation.KIND;
324
- }
325
- //# sourceMappingURL=layout-elements-action.spec.js.map