@eclipse-glsp/client 2.8.0-next.10 → 2.8.0-next.13
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.
- package/README.md +1 -1
- package/css/grid.css +2 -1
- package/lib/base/action-dispatcher.js +1 -4
- package/lib/base/action-dispatcher.js.map +1 -1
- package/lib/base/auto-complete/auto-complete-widget.js +4 -8
- package/lib/base/auto-complete/auto-complete-widget.js.map +1 -1
- package/lib/base/auto-complete/base-autocomplete-palette.js +1 -2
- package/lib/base/auto-complete/base-autocomplete-palette.js.map +1 -1
- package/lib/base/editor-context-service.js +4 -7
- package/lib/base/editor-context-service.js.map +1 -1
- package/lib/base/feedback/css-feedback.js +1 -1
- package/lib/base/feedback/css-feedback.js.map +1 -1
- package/lib/base/feedback/feedback-action-dispatcher.js +4 -6
- package/lib/base/feedback/feedback-action-dispatcher.js.map +1 -1
- package/lib/base/feedback/feedback-command.js +1 -2
- package/lib/base/feedback/feedback-command.js.map +1 -1
- package/lib/base/feedback/feedback-emitter.js +1 -2
- package/lib/base/feedback/feedback-emitter.js.map +1 -1
- package/lib/base/feedback/set-model-command.js +1 -2
- package/lib/base/feedback/set-model-command.js.map +1 -1
- package/lib/base/feedback/update-model-command.js +1 -2
- package/lib/base/feedback/update-model-command.js.map +1 -1
- package/lib/base/model/diagram-loader.js +4 -6
- package/lib/base/model/diagram-loader.js.map +1 -1
- package/lib/base/model/glsp-model-source.d.ts +1 -1
- package/lib/base/model/glsp-model-source.d.ts.map +1 -1
- package/lib/base/model/glsp-model-source.js +3 -5
- package/lib/base/model/glsp-model-source.js.map +1 -1
- package/lib/base/model/model-registry.js +1 -2
- package/lib/base/model/model-registry.js.map +1 -1
- package/lib/base/selection-service.js +3 -3
- package/lib/base/selection-service.js.map +1 -1
- package/lib/base/shortcuts/available-shortcuts-extension.js +3 -2
- package/lib/base/shortcuts/available-shortcuts-extension.js.map +1 -1
- package/lib/base/shortcuts/available-shortcuts-tool.js +3 -2
- package/lib/base/shortcuts/available-shortcuts-tool.js.map +1 -1
- package/lib/base/tool-manager/tool-manager.js +1 -1
- package/lib/base/tool-manager/tool-manager.js.map +1 -1
- package/lib/base/ui-extension/ui-extension.js +4 -6
- package/lib/base/ui-extension/ui-extension.js.map +1 -1
- package/lib/features/accessibility/edge-autocomplete/edge-autocomplete-palette.js +12 -17
- package/lib/features/accessibility/edge-autocomplete/edge-autocomplete-palette.js.map +1 -1
- package/lib/features/accessibility/edge-autocomplete/edge-autocomplete-tool.js +3 -2
- package/lib/features/accessibility/edge-autocomplete/edge-autocomplete-tool.js.map +1 -1
- package/lib/features/accessibility/element-navigation/diagram-navigation-tool.js +11 -15
- package/lib/features/accessibility/element-navigation/diagram-navigation-tool.js.map +1 -1
- package/lib/features/accessibility/element-navigation/left-right-top-bottom-navigator.js +2 -3
- package/lib/features/accessibility/element-navigation/left-right-top-bottom-navigator.js.map +1 -1
- package/lib/features/accessibility/element-navigation/local-element-navigator.js +2 -3
- package/lib/features/accessibility/element-navigation/local-element-navigator.js.map +1 -1
- package/lib/features/accessibility/focus-tracker/focus-tracker-tool.js +5 -4
- package/lib/features/accessibility/focus-tracker/focus-tracker-tool.js.map +1 -1
- package/lib/features/accessibility/global-keylistener-tool.js +4 -3
- package/lib/features/accessibility/global-keylistener-tool.js.map +1 -1
- package/lib/features/accessibility/keyboard-grid/keyboard-grid-search-palette.js +3 -2
- package/lib/features/accessibility/keyboard-grid/keyboard-grid-search-palette.js.map +1 -1
- package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.js +5 -7
- package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.js.map +1 -1
- package/lib/features/accessibility/toast/toast-handler.js +2 -4
- package/lib/features/accessibility/toast/toast-handler.js.map +1 -1
- package/lib/features/accessibility/toast/toast-tool.js +3 -2
- package/lib/features/accessibility/toast/toast-tool.js.map +1 -1
- package/lib/features/accessibility/view-key-tools/deselect-key-tool.js +3 -2
- package/lib/features/accessibility/view-key-tools/deselect-key-tool.js.map +1 -1
- package/lib/features/accessibility/view-key-tools/grid-cell-zoom-key-tool.js +4 -3
- package/lib/features/accessibility/view-key-tools/grid-cell-zoom-key-tool.js.map +1 -1
- package/lib/features/bounds/freeform-layout.js +1 -1
- package/lib/features/bounds/freeform-layout.js.map +1 -1
- package/lib/features/bounds/hbox-layout.js +7 -10
- package/lib/features/bounds/hbox-layout.js.map +1 -1
- package/lib/features/bounds/layout-data.js +2 -4
- package/lib/features/bounds/layout-data.js.map +1 -1
- package/lib/features/bounds/local-bounds.js +3 -4
- package/lib/features/bounds/local-bounds.js.map +1 -1
- package/lib/features/bounds/set-bounds-feedback-command.js +2 -3
- package/lib/features/bounds/set-bounds-feedback-command.js.map +1 -1
- package/lib/features/bounds/vbox-layout.js +7 -10
- package/lib/features/bounds/vbox-layout.js.map +1 -1
- package/lib/features/change-bounds/model.js +1 -1
- package/lib/features/change-bounds/model.js.map +1 -1
- package/lib/features/change-bounds/move-element-handler.js +1 -2
- package/lib/features/change-bounds/move-element-handler.js.map +1 -1
- package/lib/features/change-bounds/movement-restrictor.js +1 -2
- package/lib/features/change-bounds/movement-restrictor.js.map +1 -1
- package/lib/features/change-bounds/point-position-updater.js +1 -1
- package/lib/features/change-bounds/point-position-updater.js.map +1 -1
- package/lib/features/change-bounds/resize/resize-default-tool.js +4 -3
- package/lib/features/change-bounds/resize/resize-default-tool.js.map +1 -1
- package/lib/features/change-bounds/resize/resize-handler.js +1 -2
- package/lib/features/change-bounds/resize/resize-handler.js.map +1 -1
- package/lib/features/change-bounds/resize/resize-tool.js +4 -3
- package/lib/features/change-bounds/resize/resize-tool.js.map +1 -1
- package/lib/features/change-bounds/tracker.js +1 -2
- package/lib/features/change-bounds/tracker.js.map +1 -1
- package/lib/features/command-palette/command-palette-tool.js +3 -2
- package/lib/features/command-palette/command-palette-tool.js.map +1 -1
- package/lib/features/command-palette/command-palette.js +2 -3
- package/lib/features/command-palette/command-palette.js.map +1 -1
- package/lib/features/context-menu/glsp-context-menu-mouse-listener.js +2 -3
- package/lib/features/context-menu/glsp-context-menu-mouse-listener.js.map +1 -1
- package/lib/features/copy-paste/copy-paste-handler.js +1 -2
- package/lib/features/copy-paste/copy-paste-handler.js.map +1 -1
- package/lib/features/copy-paste/copy-paste-standalone.js +6 -9
- package/lib/features/copy-paste/copy-paste-standalone.js.map +1 -1
- package/lib/features/debug/debug-bounds-decorator.js +9 -12
- package/lib/features/debug/debug-bounds-decorator.js.map +1 -1
- package/lib/features/debug/debug-model.js +1 -1
- package/lib/features/debug/debug-model.js.map +1 -1
- package/lib/features/decoration/decoration-placer.js +3 -2
- package/lib/features/decoration/decoration-placer.js.map +1 -1
- package/lib/features/element-template/add-template-element.js +3 -4
- package/lib/features/element-template/add-template-element.js.map +1 -1
- package/lib/features/element-template/mouse-tracking-element-position-listener.js +1 -1
- package/lib/features/element-template/mouse-tracking-element-position-listener.js.map +1 -1
- package/lib/features/element-template/remove-template-element.js +1 -1
- package/lib/features/element-template/remove-template-element.js.map +1 -1
- package/lib/features/export/default-png-diagram-exporter.js +4 -7
- package/lib/features/export/default-png-diagram-exporter.js.map +1 -1
- package/lib/features/export/diagram-export-postprocessor.js +1 -2
- package/lib/features/export/diagram-export-postprocessor.js.map +1 -1
- package/lib/features/export/glsp-svg-exporter.js +4 -4
- package/lib/features/export/glsp-svg-exporter.js.map +1 -1
- package/lib/features/export/request-export-command.js +1 -1
- package/lib/features/export/request-export-command.js.map +1 -1
- package/lib/features/grid/grid-model.js +1 -1
- package/lib/features/grid/grid-model.js.map +1 -1
- package/lib/features/helper-lines/helper-line-feedback.js +7 -8
- package/lib/features/helper-lines/helper-line-feedback.js.map +1 -1
- package/lib/features/hints/type-hint-provider.js +3 -5
- package/lib/features/hints/type-hint-provider.js.map +1 -1
- package/lib/features/label-edit/edit-label-tool.js +3 -2
- package/lib/features/label-edit/edit-label-tool.js.map +1 -1
- package/lib/features/label-edit-ui/label-edit-ui.js +2 -3
- package/lib/features/label-edit-ui/label-edit-ui.js.map +1 -1
- package/lib/features/navigation/navigation-target-resolver.js +1 -1
- package/lib/features/navigation/navigation-target-resolver.js.map +1 -1
- package/lib/features/routing/sticky-manhattan-anchors.js +9 -6
- package/lib/features/routing/sticky-manhattan-anchors.js.map +1 -1
- package/lib/features/routing/sticky-manhattan-edge-router.js +10 -12
- package/lib/features/routing/sticky-manhattan-edge-router.js.map +1 -1
- package/lib/features/search-palette/search-palette.js +3 -2
- package/lib/features/search-palette/search-palette.js.map +1 -1
- package/lib/features/search-palette/suggestions/edge-element-suggestions.js +2 -3
- package/lib/features/search-palette/suggestions/edge-element-suggestions.js.map +1 -1
- package/lib/features/search-palette/suggestions/named-element-suggestions.js +8 -11
- package/lib/features/search-palette/suggestions/named-element-suggestions.js.map +1 -1
- package/lib/features/select/select-feedback-command.js +1 -1
- package/lib/features/select/select-feedback-command.js.map +1 -1
- package/lib/features/select/select-mouse-listener.js +1 -2
- package/lib/features/select/select-mouse-listener.js.map +1 -1
- package/lib/features/status/status-overlay.js +4 -4
- package/lib/features/status/status-overlay.js.map +1 -1
- package/lib/features/tool-palette/tool-palette.js +14 -19
- package/lib/features/tool-palette/tool-palette.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-manager.js +4 -6
- package/lib/features/tools/change-bounds/change-bounds-manager.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js +3 -4
- package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js +4 -8
- package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool.js +6 -6
- package/lib/features/tools/change-bounds/change-bounds-tool.js.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tracker.js +7 -10
- package/lib/features/tools/change-bounds/change-bounds-tracker.js.map +1 -1
- package/lib/features/tools/deletion/delete-tool.js +6 -4
- package/lib/features/tools/deletion/delete-tool.js.map +1 -1
- package/lib/features/tools/edge-creation/dangling-edge-feedback.js +4 -4
- package/lib/features/tools/edge-creation/dangling-edge-feedback.js.map +1 -1
- package/lib/features/tools/edge-creation/edge-creation-tool.js +5 -6
- package/lib/features/tools/edge-creation/edge-creation-tool.js.map +1 -1
- package/lib/features/tools/edge-creation/view.js +1 -2
- package/lib/features/tools/edge-creation/view.js.map +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool-feedback.js +4 -4
- package/lib/features/tools/edge-edit/edge-edit-tool-feedback.js.map +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool.js +3 -2
- package/lib/features/tools/edge-edit/edge-edit-tool.js.map +1 -1
- package/lib/features/tools/marquee-selection/marquee-mouse-tool.js +3 -2
- package/lib/features/tools/marquee-selection/marquee-mouse-tool.js.map +1 -1
- package/lib/features/tools/marquee-selection/marquee-tool-feedback.js +2 -2
- package/lib/features/tools/marquee-selection/marquee-tool-feedback.js.map +1 -1
- package/lib/features/tools/marquee-selection/marquee-tool.js +3 -2
- package/lib/features/tools/marquee-selection/marquee-tool.js.map +1 -1
- package/lib/features/tools/marquee-selection/model.js +1 -1
- package/lib/features/tools/marquee-selection/model.js.map +1 -1
- package/lib/features/tools/node-creation/container-manager.js +3 -4
- package/lib/features/tools/node-creation/container-manager.js.map +1 -1
- package/lib/features/tools/node-creation/insert-indicator.js +2 -2
- package/lib/features/tools/node-creation/insert-indicator.js.map +1 -1
- package/lib/features/tools/node-creation/node-creation-tool.js +5 -6
- package/lib/features/tools/node-creation/node-creation-tool.js.map +1 -1
- package/lib/features/tools/node-creation/node-creation-views.js +1 -2
- package/lib/features/tools/node-creation/node-creation-views.js.map +1 -1
- package/lib/features/validation/marker-navigator.js +1 -1
- package/lib/features/validation/marker-navigator.js.map +1 -1
- package/lib/features/validation/validate.js +4 -6
- package/lib/features/validation/validate.js.map +1 -1
- package/lib/features/viewport/origin-viewport.js +1 -1
- package/lib/features/viewport/origin-viewport.js.map +1 -1
- package/lib/features/viewport/reposition.js +2 -3
- package/lib/features/viewport/reposition.js.map +1 -1
- package/lib/features/viewport/viewport-handler.js +2 -3
- package/lib/features/viewport/viewport-handler.js.map +1 -1
- package/lib/features/viewport/viewport-tool.js +4 -3
- package/lib/features/viewport/viewport-tool.js.map +1 -1
- package/lib/features/zorder/bring-to-front-command.js +1 -2
- package/lib/features/zorder/bring-to-front-command.js.map +1 -1
- package/lib/model.js +2 -2
- package/lib/model.js.map +1 -1
- package/lib/utils/argument-utils.js +5 -5
- package/lib/utils/argument-utils.js.map +1 -1
- package/lib/utils/gmodel-util.js +4 -6
- package/lib/utils/gmodel-util.js.map +1 -1
- package/lib/utils/layout-utils.js +1 -2
- package/lib/utils/layout-utils.js.map +1 -1
- package/lib/views/glsp-projection-view.js +1 -2
- package/lib/views/glsp-projection-view.js.map +1 -1
- package/package.json +18 -17
- package/src/base/feedback/feedback-command.ts +1 -1
- package/src/base/model/glsp-model-source.ts +1 -1
- package/src/features/accessibility/README.md +5 -5
- package/src/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.ts +1 -1
- package/src/base/action-dispatcher.spec.ts +0 -366
- package/src/base/feedback/feedback-emitter.spec.ts +0 -176
- package/src/base/model/model-initialization-constraint.spec.ts +0 -95
- package/src/base/selection-service.spec.ts +0 -318
- package/src/default-modules.spec.ts +0 -56
- package/src/features/bounds/freeform-layout.spec.ts +0 -216
- package/src/features/bounds/hbox-layout.spec.ts +0 -170
- package/src/features/bounds/layouter-test-util.spec.ts +0 -127
- package/src/features/bounds/vbox-layout.spec.ts +0 -170
- package/src/features/change-bounds/point-position-updater.spec.ts +0 -81
- package/src/features/grid/grid-snapper.spec.ts +0 -30
- package/src/features/hints/type-hint-provider.spec.ts +0 -360
- package/src/features/layout/layout-elements-action.spec.ts +0 -426
- package/src/features/navigation/navigation-target-resolver.spec.ts +0 -56
- package/src/features/routing/sticky-manhattan-edge-router.spec.ts +0 -212
- package/src/features/tools/marquee-selection/marquee-behavior.spec.ts +0 -176
- package/src/features/validation/marker-navigator.spec.ts +0 -183
- package/src/utils/gmodel-util.spec.ts +0 -221
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022-2023 STMicroelectronics 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 { expect } from 'chai';
|
|
17
|
-
import 'mocha';
|
|
18
|
-
import 'reflect-metadata';
|
|
19
|
-
import { BoundsData, ConsoleLogger, GModelElement } from '@eclipse-glsp/sprotty';
|
|
20
|
-
import { createCompartment, createGraph, createLabel, createNode, layout, setupLayoutRegistry } from './layouter-test-util.spec';
|
|
21
|
-
|
|
22
|
-
describe('FreeFormLayouter', () => {
|
|
23
|
-
const layoutRegistry = setupLayoutRegistry();
|
|
24
|
-
const log = new ConsoleLogger();
|
|
25
|
-
const map = new Map<GModelElement, BoundsData>();
|
|
26
|
-
|
|
27
|
-
describe('issue-610', () => {
|
|
28
|
-
it('recursive hGrab/vGrab', () => {
|
|
29
|
-
/**
|
|
30
|
-
* _________________________
|
|
31
|
-
* | Category 1 |
|
|
32
|
-
* | _______________________ |
|
|
33
|
-
* || ||
|
|
34
|
-
* || ||
|
|
35
|
-
* || ||
|
|
36
|
-
* || ||
|
|
37
|
-
* ||_______________________||
|
|
38
|
-
* | _______________________ |
|
|
39
|
-
* ||_left____________right_||
|
|
40
|
-
* |_________________________|
|
|
41
|
-
*
|
|
42
|
-
* This test case checks recursive hGrab/vGrab functionality of nested compartments
|
|
43
|
-
* See also issue 610 for details and an example model https://github.com/eclipse-glsp/glsp/issues/610.
|
|
44
|
-
*/
|
|
45
|
-
const model = createGraph();
|
|
46
|
-
const category = createNode('category', 'vbox', { width: 410.0, height: 215.0 }, undefined, {
|
|
47
|
-
vGrab: false,
|
|
48
|
-
hGrab: false,
|
|
49
|
-
hAlign: 'center',
|
|
50
|
-
prefWidth: 410.0,
|
|
51
|
-
prefHeight: 215.0
|
|
52
|
-
});
|
|
53
|
-
const headerComp = createCompartment('comp:header', 'hbox');
|
|
54
|
-
headerComp.children = [createLabel('Category 1')];
|
|
55
|
-
const childContainer = createCompartment('struct', 'freeform', { hGrab: true, vGrab: true });
|
|
56
|
-
const labelContainer = createCompartment('struct', 'hbox', { hGrab: true });
|
|
57
|
-
labelContainer.children = [createLabel('left text', { hGrab: true }), createLabel('right text')];
|
|
58
|
-
category.children = [headerComp, childContainer, labelContainer];
|
|
59
|
-
|
|
60
|
-
model.add(category);
|
|
61
|
-
layout(layoutRegistry, log, map, model);
|
|
62
|
-
// check category
|
|
63
|
-
expect(map.get(category)!.bounds).to.deep.equal({ x: 0, y: 0, width: 410.0, height: 215.0 });
|
|
64
|
-
// check header compartment
|
|
65
|
-
expect(map.get(category.children[0])!.bounds).to.deep.equal({ x: 0, y: 0, width: -1, height: -1 });
|
|
66
|
-
// check child freeform compartment
|
|
67
|
-
expect(map.get(category.children[1])!.bounds).to.deep.equal({ x: 5, y: 5, width: 400.0, height: 205.0 });
|
|
68
|
-
// check label compartment
|
|
69
|
-
expect(map.get(category.children[2])!.bounds).to.deep.equal({ x: 0, y: 0, width: -1, height: -1 });
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
describe('issue-694', () => {
|
|
74
|
-
it('Structure compartment (hGrab=true, vGrab=true), Left-aligned label (hGrab=true), right-aligned label (hGrab=false)', () => {
|
|
75
|
-
/**
|
|
76
|
-
* _________________________
|
|
77
|
-
* | Category 2 |
|
|
78
|
-
* | _______________________ |
|
|
79
|
-
* || ||
|
|
80
|
-
* || ||
|
|
81
|
-
* || Task node ||
|
|
82
|
-
* || ||
|
|
83
|
-
* ||_______________________||
|
|
84
|
-
* | _______________________ |
|
|
85
|
-
* ||_left____________right_||
|
|
86
|
-
* |_________________________|
|
|
87
|
-
*/
|
|
88
|
-
const model = createGraph();
|
|
89
|
-
const category = createNode('category', 'vbox', { width: 500.0, height: 375.0 }, undefined, {
|
|
90
|
-
vGrab: false,
|
|
91
|
-
hGrab: false,
|
|
92
|
-
hAlign: 'center',
|
|
93
|
-
prefWidth: 500.0,
|
|
94
|
-
prefHeight: 375.0
|
|
95
|
-
});
|
|
96
|
-
const headerComp = createCompartment('comp:header', 'hbox');
|
|
97
|
-
headerComp.children = [createLabel('Category 2')];
|
|
98
|
-
const childContainer = createCompartment('struct', 'freeform', { hGrab: true, vGrab: true });
|
|
99
|
-
const childNode = createNode('task', 'hbox', undefined, { x: 170, y: 190 });
|
|
100
|
-
childNode.children = [createLabel('Task node', undefined, { x: 5.0, y: 5.0 }, { width: 25.0, height: 20.0 })];
|
|
101
|
-
childContainer.children = [childNode];
|
|
102
|
-
const labelContainer = createCompartment('struct', 'hbox', { hGrab: true });
|
|
103
|
-
labelContainer.children = [createLabel('left text', { hGrab: true }), createLabel('right text')];
|
|
104
|
-
category.children = [headerComp, childContainer, labelContainer];
|
|
105
|
-
|
|
106
|
-
model.add(category);
|
|
107
|
-
|
|
108
|
-
// layout graph
|
|
109
|
-
layout(layoutRegistry, log, map, model);
|
|
110
|
-
// check category
|
|
111
|
-
expect(map.get(category)!.bounds).to.deep.equal({ x: 0, y: 0, width: 500.0, height: 375.0 });
|
|
112
|
-
// check header compartment
|
|
113
|
-
expect(map.get(category.children[0])!.bounds).to.deep.equal({ x: 0, y: 0, width: -1, height: -1 });
|
|
114
|
-
// check child freeform compartment
|
|
115
|
-
expect(map.get(category.children[1])!.bounds).to.deep.equal({ x: 5.0, y: 5.0, width: 490.0, height: 365.0 });
|
|
116
|
-
// check child task node
|
|
117
|
-
expect(map.get(category.children[1].children[0])!.bounds).to.deep.equal({ x: 170.0, y: 190.0, width: 35.0, height: 30.0 });
|
|
118
|
-
// check label compartment
|
|
119
|
-
expect(map.get(category.children[2])!.bounds).to.deep.equal({ x: 0, y: 0, width: -1, height: -1 });
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('Structure compartment (hGrab=true, vGrab=true)', () => {
|
|
123
|
-
/**
|
|
124
|
-
* _________________________
|
|
125
|
-
* | Category 2 |
|
|
126
|
-
* | _______________________ |
|
|
127
|
-
* || ||
|
|
128
|
-
* || Task node ||
|
|
129
|
-
* || ||
|
|
130
|
-
* || ||
|
|
131
|
-
* ||_______________________||
|
|
132
|
-
* |_________________________|
|
|
133
|
-
*/
|
|
134
|
-
const model = createGraph();
|
|
135
|
-
const category = createNode('category', 'vbox', { width: 500.0, height: 375.0 }, undefined, {
|
|
136
|
-
vGrab: false,
|
|
137
|
-
hGrab: false,
|
|
138
|
-
hAlign: 'center',
|
|
139
|
-
prefWidth: 500.0,
|
|
140
|
-
prefHeight: 375.0
|
|
141
|
-
});
|
|
142
|
-
const headerComp = createCompartment('comp:header', 'hbox');
|
|
143
|
-
headerComp.children = [createLabel('Category 2')];
|
|
144
|
-
const childContainer = createCompartment('struct', 'freeform', { hGrab: true, vGrab: true });
|
|
145
|
-
const childNode = createNode('task', 'hbox', undefined, { x: 55, y: 15 });
|
|
146
|
-
childNode.children = [createLabel('Task node', undefined, undefined, { width: 50.0, height: 35.0 })];
|
|
147
|
-
childContainer.children = [childNode];
|
|
148
|
-
category.children = [headerComp, childContainer];
|
|
149
|
-
|
|
150
|
-
model.add(category);
|
|
151
|
-
|
|
152
|
-
// layout graph
|
|
153
|
-
layout(layoutRegistry, log, map, model);
|
|
154
|
-
// check category
|
|
155
|
-
expect(map.get(category)!.bounds).to.deep.equal({ x: 0, y: 0, width: 500.0, height: 375.0 });
|
|
156
|
-
// check header compartment
|
|
157
|
-
expect(map.get(category.children[0])!.bounds).to.deep.equal({ x: 0, y: 0, width: -1, height: -1 });
|
|
158
|
-
// check child freeform compartment
|
|
159
|
-
expect(map.get(category.children[1])!.bounds).to.deep.equal({ x: 5.0, y: 5.0, width: 490.0, height: 365.0 });
|
|
160
|
-
// check child task node
|
|
161
|
-
expect(map.get(category.children[1].children[0])!.bounds).to.deep.equal({ x: 55.0, y: 15.0, width: 60.0, height: 45.0 });
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('Structure compartment (hGrab=true, vGrab=true, padding*=10)', () => {
|
|
165
|
-
/**
|
|
166
|
-
* _________________________
|
|
167
|
-
* | Category 2 |
|
|
168
|
-
* | _______________________ |
|
|
169
|
-
* || ||
|
|
170
|
-
* || Task node ||
|
|
171
|
-
* || ||
|
|
172
|
-
* || ||
|
|
173
|
-
* ||_______________________||
|
|
174
|
-
* |_________________________|
|
|
175
|
-
*/
|
|
176
|
-
const model = createGraph();
|
|
177
|
-
const category = createNode('category', 'vbox', { width: 500.0, height: 375.0 }, undefined, {
|
|
178
|
-
vGrab: false,
|
|
179
|
-
hGrab: false,
|
|
180
|
-
hAlign: 'center',
|
|
181
|
-
prefWidth: 500.0,
|
|
182
|
-
prefHeight: 375.0,
|
|
183
|
-
paddingLeft: 10,
|
|
184
|
-
paddingRight: 10,
|
|
185
|
-
paddingTop: 10,
|
|
186
|
-
paddingBottom: 10
|
|
187
|
-
});
|
|
188
|
-
const headerComp = createCompartment('comp:header', 'hbox');
|
|
189
|
-
headerComp.children = [createLabel('Category 2')];
|
|
190
|
-
const childContainer = createCompartment('struct', 'freeform', { hGrab: true, vGrab: true });
|
|
191
|
-
const childNode = createNode(
|
|
192
|
-
'task',
|
|
193
|
-
'hbox',
|
|
194
|
-
undefined,
|
|
195
|
-
{ x: 55, y: 15 },
|
|
196
|
-
{ paddingLeft: 10, paddingRight: 10, paddingTop: 10, paddingBottom: 10 }
|
|
197
|
-
);
|
|
198
|
-
childNode.children = [createLabel('Task node', undefined, undefined, { width: 50.0, height: 35.0 })];
|
|
199
|
-
childContainer.children = [childNode];
|
|
200
|
-
category.children = [headerComp, childContainer];
|
|
201
|
-
|
|
202
|
-
model.add(category);
|
|
203
|
-
|
|
204
|
-
// layout graph
|
|
205
|
-
layout(layoutRegistry, log, map, model);
|
|
206
|
-
// check category
|
|
207
|
-
expect(map.get(category)!.bounds).to.deep.equal({ x: 0, y: 0, width: 500.0, height: 375.0 });
|
|
208
|
-
// check header compartment
|
|
209
|
-
expect(map.get(category.children[0])!.bounds).to.deep.equal({ x: 0, y: 0, width: -1, height: -1 });
|
|
210
|
-
// check child freeform compartment
|
|
211
|
-
expect(map.get(category.children[1])!.bounds).to.deep.equal({ x: 10.0, y: 10.0, width: 480.0, height: 355.0 });
|
|
212
|
-
// check child task node
|
|
213
|
-
expect(map.get(category.children[1].children[0])!.bounds).to.deep.equal({ x: 55.0, y: 15.0, width: 70.0, height: 55.0 });
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
});
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022-2026 TypeFox, STMicroelectronics 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
|
-
|
|
17
|
-
import { expect } from 'chai';
|
|
18
|
-
import 'mocha';
|
|
19
|
-
import 'reflect-metadata';
|
|
20
|
-
import { BoundsData, ConsoleLogger, Dimension, GModelElement, GNode } from '@eclipse-glsp/sprotty';
|
|
21
|
-
import { createLabel, createNode, layout, setupLayoutRegistry } from './layouter-test-util.spec';
|
|
22
|
-
|
|
23
|
-
describe('HBoxLayouter', () => {
|
|
24
|
-
const layoutRegistry = setupLayoutRegistry();
|
|
25
|
-
const log = new ConsoleLogger();
|
|
26
|
-
const map = new Map<GModelElement, BoundsData>();
|
|
27
|
-
|
|
28
|
-
function createModel(): GNode {
|
|
29
|
-
const model = createNode('node', undefined, Dimension.EMPTY);
|
|
30
|
-
model.children = [
|
|
31
|
-
createLabel('label1', undefined, undefined, { width: 1, height: 2 }),
|
|
32
|
-
createLabel('label2', undefined, undefined, { width: 2, height: 1 }),
|
|
33
|
-
createLabel('label3', undefined, undefined, { width: 3, height: 3 })
|
|
34
|
-
];
|
|
35
|
-
model.layout = 'hbox';
|
|
36
|
-
return model;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
it('defaultParams', () => {
|
|
40
|
-
const model = createModel();
|
|
41
|
-
layout(layoutRegistry, log, map, model);
|
|
42
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 18, height: 13 });
|
|
43
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 5.5, width: 1, height: 2 });
|
|
44
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 7, y: 6, width: 2, height: 1 });
|
|
45
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 10, y: 5, width: 3, height: 3 });
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('alignTop', () => {
|
|
49
|
-
const model = createModel();
|
|
50
|
-
model.layoutOptions = {
|
|
51
|
-
vAlign: 'top'
|
|
52
|
-
};
|
|
53
|
-
layout(layoutRegistry, log, map, model);
|
|
54
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 18, height: 13 });
|
|
55
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 5, width: 1, height: 2 });
|
|
56
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 7, y: 5, width: 2, height: 1 });
|
|
57
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 10, y: 5, width: 3, height: 3 });
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('alignCenter', () => {
|
|
61
|
-
const model = createModel();
|
|
62
|
-
model.layoutOptions = {
|
|
63
|
-
vAlign: 'center'
|
|
64
|
-
};
|
|
65
|
-
layout(layoutRegistry, log, map, model);
|
|
66
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 18, height: 13 });
|
|
67
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 5.5, width: 1, height: 2 });
|
|
68
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 7, y: 6, width: 2, height: 1 });
|
|
69
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 10, y: 5, width: 3, height: 3 });
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('alignBottom', () => {
|
|
73
|
-
const model = createModel();
|
|
74
|
-
model.layoutOptions = {
|
|
75
|
-
vAlign: 'bottom'
|
|
76
|
-
};
|
|
77
|
-
layout(layoutRegistry, log, map, model);
|
|
78
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 18, height: 13 });
|
|
79
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 6, width: 1, height: 2 });
|
|
80
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 7, y: 7, width: 2, height: 1 });
|
|
81
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 10, y: 5, width: 3, height: 3 });
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('padding', () => {
|
|
85
|
-
const model = createModel();
|
|
86
|
-
model.layoutOptions = {
|
|
87
|
-
paddingTop: 7,
|
|
88
|
-
paddingBottom: 8,
|
|
89
|
-
paddingLeft: 9,
|
|
90
|
-
paddingRight: 10
|
|
91
|
-
};
|
|
92
|
-
layout(layoutRegistry, log, map, model);
|
|
93
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 27, height: 18 });
|
|
94
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 9, y: 7.5, width: 1, height: 2 });
|
|
95
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 11, y: 8, width: 2, height: 1 });
|
|
96
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 14, y: 7, width: 3, height: 3 });
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('hGap', () => {
|
|
100
|
-
const model = createModel();
|
|
101
|
-
model.layoutOptions = {
|
|
102
|
-
hGap: 4
|
|
103
|
-
};
|
|
104
|
-
layout(layoutRegistry, log, map, model);
|
|
105
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 24, height: 13 });
|
|
106
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 5.5, width: 1, height: 2 });
|
|
107
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 10, y: 6, width: 2, height: 1 });
|
|
108
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 16, y: 5, width: 3, height: 3 });
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('paddingFactor', () => {
|
|
112
|
-
const model = createModel();
|
|
113
|
-
model.layoutOptions = {
|
|
114
|
-
paddingFactor: 2
|
|
115
|
-
};
|
|
116
|
-
layout(layoutRegistry, log, map, model);
|
|
117
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 18, height: 13 });
|
|
118
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 9, y: 8.5, width: 1, height: 2 });
|
|
119
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 11, y: 9, width: 2, height: 1 });
|
|
120
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 14, y: 8, width: 3, height: 3 });
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('minWidth', () => {
|
|
124
|
-
const model = createModel();
|
|
125
|
-
model.layoutOptions = {
|
|
126
|
-
minWidth: 25
|
|
127
|
-
};
|
|
128
|
-
layout(layoutRegistry, log, map, model);
|
|
129
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 25, height: 13 });
|
|
130
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 5.5, width: 1, height: 2 });
|
|
131
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 7, y: 6, width: 2, height: 1 });
|
|
132
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 10, y: 5, width: 3, height: 3 });
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('minHeight', () => {
|
|
136
|
-
const model = createModel();
|
|
137
|
-
model.layoutOptions = {
|
|
138
|
-
minHeight: 25
|
|
139
|
-
};
|
|
140
|
-
layout(layoutRegistry, log, map, model);
|
|
141
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 18, height: 25 });
|
|
142
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 11.5, width: 1, height: 2 });
|
|
143
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 7, y: 12, width: 2, height: 1 });
|
|
144
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 10, y: 11, width: 3, height: 3 });
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('prefWidth', () => {
|
|
148
|
-
const model = createModel();
|
|
149
|
-
model.layoutOptions = {
|
|
150
|
-
prefWidth: 20
|
|
151
|
-
};
|
|
152
|
-
layout(layoutRegistry, log, map, model);
|
|
153
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 20, height: 13 });
|
|
154
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 5.5, width: 1, height: 2 });
|
|
155
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 7, y: 6, width: 2, height: 1 });
|
|
156
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 10, y: 5, width: 3, height: 3 });
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it('prefHeight', () => {
|
|
160
|
-
const model = createModel();
|
|
161
|
-
model.layoutOptions = {
|
|
162
|
-
prefHeight: 20
|
|
163
|
-
};
|
|
164
|
-
layout(layoutRegistry, log, map, model);
|
|
165
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 18, height: 20 });
|
|
166
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 9, width: 1, height: 2 });
|
|
167
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 7, y: 9.5, width: 2, height: 1 });
|
|
168
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 10, y: 8.5, width: 3, height: 3 });
|
|
169
|
-
});
|
|
170
|
-
});
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022-2023 STMicroelectronics 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
|
-
|
|
17
|
-
import { Container } from 'inversify';
|
|
18
|
-
import 'mocha';
|
|
19
|
-
import {
|
|
20
|
-
BoundsData,
|
|
21
|
-
ConsoleLogger,
|
|
22
|
-
Dimension,
|
|
23
|
-
LayoutRegistry,
|
|
24
|
-
Point,
|
|
25
|
-
GCompartment,
|
|
26
|
-
GLabel,
|
|
27
|
-
GModelElement,
|
|
28
|
-
GNode,
|
|
29
|
-
GParentElement,
|
|
30
|
-
TYPES,
|
|
31
|
-
createFeatureSet,
|
|
32
|
-
layoutableChildFeature
|
|
33
|
-
} from '@eclipse-glsp/sprotty';
|
|
34
|
-
import { initializeDiagramContainer } from '../../default-modules';
|
|
35
|
-
import { StatefulLayouterExt } from './layouter';
|
|
36
|
-
import { GGraph } from '../../model';
|
|
37
|
-
|
|
38
|
-
export function createGraph(): GGraph {
|
|
39
|
-
return new GGraph();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function createNode(
|
|
43
|
-
type: string,
|
|
44
|
-
nodeLayout?: string,
|
|
45
|
-
size?: Dimension,
|
|
46
|
-
position?: Point,
|
|
47
|
-
layoutOptions?: { [key: string]: string | number | boolean }
|
|
48
|
-
): GNode {
|
|
49
|
-
const node = new GNode();
|
|
50
|
-
node.features = createFeatureSet(GNode.DEFAULT_FEATURES, { enable: [layoutableChildFeature] });
|
|
51
|
-
node.position = position || {
|
|
52
|
-
x: 0,
|
|
53
|
-
y: 0
|
|
54
|
-
};
|
|
55
|
-
if (size) {
|
|
56
|
-
node.size = size;
|
|
57
|
-
}
|
|
58
|
-
node.type = type;
|
|
59
|
-
if (nodeLayout) {
|
|
60
|
-
node.layout = nodeLayout;
|
|
61
|
-
}
|
|
62
|
-
node.layoutOptions = layoutOptions;
|
|
63
|
-
return node;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function createCompartment(
|
|
67
|
-
type: string,
|
|
68
|
-
compLayout: string,
|
|
69
|
-
layoutOptions?: { [key: string]: string | number | boolean }
|
|
70
|
-
): GCompartment {
|
|
71
|
-
const comp = new GCompartment();
|
|
72
|
-
comp.features = createFeatureSet(GCompartment.DEFAULT_FEATURES);
|
|
73
|
-
comp.type = type;
|
|
74
|
-
comp.layout = compLayout;
|
|
75
|
-
comp.layoutOptions = layoutOptions;
|
|
76
|
-
return comp;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function createLabel(
|
|
80
|
-
labelText: string,
|
|
81
|
-
layoutOptions?: { [key: string]: string | number | boolean },
|
|
82
|
-
position?: Point,
|
|
83
|
-
size?: Dimension
|
|
84
|
-
): GLabel {
|
|
85
|
-
const label = new GLabel();
|
|
86
|
-
label.features = createFeatureSet(GLabel.DEFAULT_FEATURES);
|
|
87
|
-
if (position) {
|
|
88
|
-
label.position = position;
|
|
89
|
-
}
|
|
90
|
-
if (size) {
|
|
91
|
-
label.size = size;
|
|
92
|
-
}
|
|
93
|
-
label.layoutOptions = layoutOptions;
|
|
94
|
-
label.text = labelText;
|
|
95
|
-
label.type = 'label';
|
|
96
|
-
return label;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function addToMap(map: Map<GModelElement, BoundsData>, element: GModelElement): void {
|
|
100
|
-
map.set(element, {
|
|
101
|
-
bounds: (element as any).bounds,
|
|
102
|
-
boundsChanged: true,
|
|
103
|
-
alignmentChanged: true
|
|
104
|
-
});
|
|
105
|
-
if (element instanceof GParentElement) {
|
|
106
|
-
element.children.forEach(c => addToMap(map, c));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export function layout(
|
|
111
|
-
layoutRegistry: LayoutRegistry,
|
|
112
|
-
log: ConsoleLogger,
|
|
113
|
-
map: Map<GModelElement, BoundsData>,
|
|
114
|
-
model: GNode | GGraph
|
|
115
|
-
): void {
|
|
116
|
-
map.clear();
|
|
117
|
-
addToMap(map, model);
|
|
118
|
-
const layouter = new StatefulLayouterExt(map, layoutRegistry, log);
|
|
119
|
-
layouter.layout();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export function setupLayoutRegistry(): LayoutRegistry {
|
|
123
|
-
// Generic Test setup
|
|
124
|
-
// create client container that registers all default modules including the layoutModule
|
|
125
|
-
const layoutContainer = initializeDiagramContainer(new Container());
|
|
126
|
-
return layoutContainer.get<LayoutRegistry>(TYPES.LayoutRegistry);
|
|
127
|
-
}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022-2026 TypeFox, STMicroelectronics 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
|
-
|
|
17
|
-
import { expect } from 'chai';
|
|
18
|
-
import 'mocha';
|
|
19
|
-
import 'reflect-metadata';
|
|
20
|
-
import { BoundsData, ConsoleLogger, Dimension, GModelElement, GNode } from '@eclipse-glsp/sprotty';
|
|
21
|
-
import { createLabel, createNode, layout, setupLayoutRegistry } from './layouter-test-util.spec';
|
|
22
|
-
|
|
23
|
-
describe('VBoxLayouter', () => {
|
|
24
|
-
const layoutRegistry = setupLayoutRegistry();
|
|
25
|
-
const log = new ConsoleLogger();
|
|
26
|
-
const map = new Map<GModelElement, BoundsData>();
|
|
27
|
-
|
|
28
|
-
function createModel(): GNode {
|
|
29
|
-
const model = createNode('node', undefined, Dimension.EMPTY);
|
|
30
|
-
model.children = [
|
|
31
|
-
createLabel('label1', undefined, undefined, { width: 1, height: 2 }),
|
|
32
|
-
createLabel('label2', undefined, undefined, { width: 2, height: 1 }),
|
|
33
|
-
createLabel('label3', undefined, undefined, { width: 3, height: 3 })
|
|
34
|
-
];
|
|
35
|
-
model.layout = 'vbox';
|
|
36
|
-
return model;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
it('defaultParams', () => {
|
|
40
|
-
const model = createModel();
|
|
41
|
-
layout(layoutRegistry, log, map, model);
|
|
42
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 18 });
|
|
43
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 6, y: 5, width: 1, height: 2 });
|
|
44
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 5.5, y: 8, width: 2, height: 1 });
|
|
45
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 5, y: 10, width: 3, height: 3 });
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('alignLeft', () => {
|
|
49
|
-
const model = createModel();
|
|
50
|
-
model.layoutOptions = {
|
|
51
|
-
hAlign: 'left'
|
|
52
|
-
};
|
|
53
|
-
layout(layoutRegistry, log, map, model);
|
|
54
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 18 });
|
|
55
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 5, width: 1, height: 2 });
|
|
56
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 5, y: 8, width: 2, height: 1 });
|
|
57
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 5, y: 10, width: 3, height: 3 });
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('alignCenter', () => {
|
|
61
|
-
const model = createModel();
|
|
62
|
-
model.layoutOptions = {
|
|
63
|
-
hAlign: 'center'
|
|
64
|
-
};
|
|
65
|
-
layout(layoutRegistry, log, map, model);
|
|
66
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 18 });
|
|
67
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 6, y: 5, width: 1, height: 2 });
|
|
68
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 5.5, y: 8, width: 2, height: 1 });
|
|
69
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 5, y: 10, width: 3, height: 3 });
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('alignRight', () => {
|
|
73
|
-
const model = createModel();
|
|
74
|
-
model.layoutOptions = {
|
|
75
|
-
hAlign: 'right'
|
|
76
|
-
};
|
|
77
|
-
layout(layoutRegistry, log, map, model);
|
|
78
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 18 });
|
|
79
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 7, y: 5, width: 1, height: 2 });
|
|
80
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 6, y: 8, width: 2, height: 1 });
|
|
81
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 5, y: 10, width: 3, height: 3 });
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('padding', () => {
|
|
85
|
-
const model = createModel();
|
|
86
|
-
model.layoutOptions = {
|
|
87
|
-
paddingTop: 7,
|
|
88
|
-
paddingBottom: 8,
|
|
89
|
-
paddingLeft: 9,
|
|
90
|
-
paddingRight: 10
|
|
91
|
-
};
|
|
92
|
-
layout(layoutRegistry, log, map, model);
|
|
93
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 22, height: 23 });
|
|
94
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 10, y: 7, width: 1, height: 2 });
|
|
95
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 9.5, y: 10, width: 2, height: 1 });
|
|
96
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 9, y: 12, width: 3, height: 3 });
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('vGap', () => {
|
|
100
|
-
const model = createModel();
|
|
101
|
-
model.layoutOptions = {
|
|
102
|
-
vGap: 4
|
|
103
|
-
};
|
|
104
|
-
layout(layoutRegistry, log, map, model);
|
|
105
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 24 });
|
|
106
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 6, y: 5, width: 1, height: 2 });
|
|
107
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 5.5, y: 11, width: 2, height: 1 });
|
|
108
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 5, y: 16, width: 3, height: 3 });
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('paddingFactor', () => {
|
|
112
|
-
const model = createModel();
|
|
113
|
-
model.layoutOptions = {
|
|
114
|
-
paddingFactor: 2
|
|
115
|
-
};
|
|
116
|
-
layout(layoutRegistry, log, map, model);
|
|
117
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 18 });
|
|
118
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 9, y: 9, width: 1, height: 2 });
|
|
119
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 8.5, y: 12, width: 2, height: 1 });
|
|
120
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 8, y: 14, width: 3, height: 3 });
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('minWidth', () => {
|
|
124
|
-
const model = createModel();
|
|
125
|
-
model.layoutOptions = {
|
|
126
|
-
minWidth: 25
|
|
127
|
-
};
|
|
128
|
-
layout(layoutRegistry, log, map, model);
|
|
129
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 25, height: 18 });
|
|
130
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 12, y: 5, width: 1, height: 2 });
|
|
131
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 11.5, y: 8, width: 2, height: 1 });
|
|
132
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 11, y: 10, width: 3, height: 3 });
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('minHeight', () => {
|
|
136
|
-
const model = createModel();
|
|
137
|
-
model.layoutOptions = {
|
|
138
|
-
minHeight: 25
|
|
139
|
-
};
|
|
140
|
-
layout(layoutRegistry, log, map, model);
|
|
141
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 25 });
|
|
142
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 6, y: 5, width: 1, height: 2 });
|
|
143
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 5.5, y: 8, width: 2, height: 1 });
|
|
144
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 5, y: 10, width: 3, height: 3 });
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('prefWidth', () => {
|
|
148
|
-
const model = createModel();
|
|
149
|
-
model.layoutOptions = {
|
|
150
|
-
prefWidth: 20
|
|
151
|
-
};
|
|
152
|
-
layout(layoutRegistry, log, map, model);
|
|
153
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 20, height: 18 });
|
|
154
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 9.5, y: 5, width: 1, height: 2 });
|
|
155
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 9, y: 8, width: 2, height: 1 });
|
|
156
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 8.5, y: 10, width: 3, height: 3 });
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it('prefHeight', () => {
|
|
160
|
-
const model = createModel();
|
|
161
|
-
model.layoutOptions = {
|
|
162
|
-
prefHeight: 20
|
|
163
|
-
};
|
|
164
|
-
layout(layoutRegistry, log, map, model);
|
|
165
|
-
expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 20 });
|
|
166
|
-
expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 6, y: 5, width: 1, height: 2 });
|
|
167
|
-
expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 5.5, y: 8, width: 2, height: 1 });
|
|
168
|
-
expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 5, y: 10, width: 3, height: 3 });
|
|
169
|
-
});
|
|
170
|
-
});
|