@eclipse-glsp/client 2.8.0-next.8 → 2.9.0-next.1
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/glsp-hidden-bounds-updater.d.ts +31 -1
- package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts.map +1 -1
- package/lib/features/bounds/glsp-hidden-bounds-updater.js +119 -58
- package/lib/features/bounds/glsp-hidden-bounds-updater.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.d.ts +1 -1
- package/lib/features/copy-paste/copy-paste-handler.d.ts.map +1 -1
- package/lib/features/copy-paste/copy-paste-handler.js +3 -5
- 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.d.ts +6 -1
- package/lib/features/element-template/add-template-element.d.ts.map +1 -1
- package/lib/features/element-template/add-template-element.js +17 -5
- 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.d.ts.map +1 -1
- package/lib/features/export/glsp-svg-exporter.js +5 -6
- 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/helper-lines/model.d.ts +1 -1
- package/lib/features/helper-lines/model.d.ts.map +1 -1
- package/lib/features/helper-lines/model.js +3 -4
- package/lib/features/helper-lines/model.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.d.ts.map +1 -1
- package/lib/features/tool-palette/tool-palette.js +16 -23
- 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.d.ts +1 -1
- package/lib/features/tools/edge-creation/dangling-edge-feedback.d.ts.map +1 -1
- package/lib/features/tools/edge-creation/dangling-edge-feedback.js +7 -5
- 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.d.ts +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool-feedback.d.ts.map +1 -1
- package/lib/features/tools/edge-edit/edge-edit-tool-feedback.js +8 -5
- 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.d.ts +1 -1
- package/lib/features/tools/marquee-selection/model.d.ts.map +1 -1
- package/lib/features/tools/marquee-selection/model.js +3 -2
- 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.d.ts +1 -1
- package/lib/features/tools/node-creation/insert-indicator.d.ts.map +1 -1
- package/lib/features/tools/node-creation/insert-indicator.js +5 -5
- 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/issue-marker.d.ts +2 -2
- package/lib/features/validation/issue-marker.d.ts.map +1 -1
- package/lib/features/validation/issue-marker.js +7 -2
- package/lib/features/validation/issue-marker.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.d.ts +13 -1
- package/lib/utils/gmodel-util.d.ts.map +1 -1
- package/lib/utils/gmodel-util.js +15 -7
- 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/features/bounds/glsp-hidden-bounds-updater.ts +133 -60
- package/src/features/copy-paste/copy-paste-handler.ts +3 -3
- package/src/features/element-template/add-template-element.ts +17 -2
- package/src/features/export/glsp-svg-exporter.ts +2 -2
- package/src/features/helper-lines/model.ts +4 -5
- package/src/features/tool-palette/tool-palette.ts +2 -4
- package/src/features/tools/edge-creation/dangling-edge-feedback.ts +4 -2
- package/src/features/tools/edge-edit/edge-edit-tool-feedback.ts +5 -3
- package/src/features/tools/marquee-selection/model.ts +3 -2
- package/src/features/tools/node-creation/insert-indicator.ts +5 -5
- package/src/features/validation/issue-marker.ts +7 -2
- package/src/utils/gmodel-util.ts +23 -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,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
|
-
});
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022-2026 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
|
-
/* eslint-disable import-x/no-deprecated */
|
|
17
|
-
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
18
|
-
|
|
19
|
-
import { GModelElement } from '@eclipse-glsp/sprotty';
|
|
20
|
-
import { expect } from 'chai';
|
|
21
|
-
import { GridSnapper } from './../grid/grid-snapper';
|
|
22
|
-
import { PointPositionUpdater } from './point-position-updater';
|
|
23
|
-
|
|
24
|
-
describe('PointPositionUpdater', () => {
|
|
25
|
-
it('updatePosition with no last drag position', () => {
|
|
26
|
-
const element = new GModelElement();
|
|
27
|
-
const updater = new PointPositionUpdater();
|
|
28
|
-
expect(updater.updatePosition(element, { x: 0, y: 0 }, false)).to.be.undefined;
|
|
29
|
-
expect(updater.updatePosition(element, { x: 0, y: 0 }, true)).to.be.undefined;
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('update last position and reset', () => {
|
|
33
|
-
const updater = new PointPositionUpdater();
|
|
34
|
-
expect(updater.isLastDragPositionUndefined()).to.be.true;
|
|
35
|
-
updater.updateLastDragPosition({ x: 0, y: 0 });
|
|
36
|
-
expect(updater.isLastDragPositionUndefined()).to.be.false;
|
|
37
|
-
updater.resetPosition();
|
|
38
|
-
expect(updater.isLastDragPositionUndefined()).to.be.true;
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('updatePosition with no snapper', () => {
|
|
42
|
-
const element = new GModelElement();
|
|
43
|
-
const updater = new PointPositionUpdater();
|
|
44
|
-
resetUpdater(updater);
|
|
45
|
-
expect(updater.updatePosition(element, { x: 0, y: 0 }, false)).to.be.undefined;
|
|
46
|
-
expect(updater.updatePosition(element, { x: 0, y: 0 }, true)).to.be.undefined;
|
|
47
|
-
|
|
48
|
-
resetUpdater(updater);
|
|
49
|
-
expect(updater.updatePosition(element, { x: 5, y: 3 }, false)).to.be.deep.equals({ x: 5, y: 3 });
|
|
50
|
-
expect(updater.updatePosition(element, { x: 5, y: 3 }, true)).to.be.undefined;
|
|
51
|
-
expect(updater.updatePosition(element, { x: 11, y: 6 }, false)).to.be.deep.equals({ x: 6, y: 3 });
|
|
52
|
-
expect(updater.updatePosition(element, { x: -3, y: 2 }, true)).to.be.deep.equals({ x: -14, y: -4 });
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('updatePosition with snapper', () => {
|
|
56
|
-
const element = new GModelElement();
|
|
57
|
-
const snapper = new GridSnapper();
|
|
58
|
-
const updater = new PointPositionUpdater(snapper);
|
|
59
|
-
resetUpdater(updater);
|
|
60
|
-
expect(updater.updatePosition(element, { x: 0, y: 0 }, false)).to.be.undefined;
|
|
61
|
-
expect(updater.updatePosition(element, { x: 0, y: 0 }, true)).to.be.undefined;
|
|
62
|
-
|
|
63
|
-
resetUpdater(updater);
|
|
64
|
-
expect(updater.updatePosition(element, { x: 5, y: 3 }, true)).to.be.deep.equals({ x: 10, y: 0 });
|
|
65
|
-
expect(updater.updatePosition(element, { x: 5, y: 3 }, true)).to.be.undefined;
|
|
66
|
-
expect(updater.updatePosition(element, { x: 11, y: 6 }, true)).to.be.deep.equals({ x: 0, y: 10 });
|
|
67
|
-
expect(updater.updatePosition(element, { x: -3, y: 2 }, true)).to.be.deep.equals({ x: -10, y: -10 });
|
|
68
|
-
|
|
69
|
-
// disable snapping (alt key)
|
|
70
|
-
resetUpdater(updater);
|
|
71
|
-
expect(updater.updatePosition(element, { x: 5, y: 3 }, false)).to.be.deep.equals({ x: 5, y: 3 });
|
|
72
|
-
expect(updater.updatePosition(element, { x: 5, y: 3 }, false)).to.be.undefined;
|
|
73
|
-
expect(updater.updatePosition(element, { x: 11, y: 6 }, false)).to.be.deep.equals({ x: 6, y: 3 });
|
|
74
|
-
expect(updater.updatePosition(element, { x: -3, y: 2 }, false)).to.be.deep.equals({ x: -14, y: -4 });
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
function resetUpdater(updater: PointPositionUpdater): void {
|
|
78
|
-
updater.resetPosition();
|
|
79
|
-
updater.updateLastDragPosition({ x: 0, y: 0 });
|
|
80
|
-
}
|
|
81
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022-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
|
-
|
|
17
|
-
import { GModelElement } from '@eclipse-glsp/sprotty';
|
|
18
|
-
import { expect } from 'chai';
|
|
19
|
-
import { GridSnapper } from './grid-snapper';
|
|
20
|
-
|
|
21
|
-
describe('GridSnapper', () => {
|
|
22
|
-
it('snap', () => {
|
|
23
|
-
const element = new GModelElement();
|
|
24
|
-
const snapper = new GridSnapper();
|
|
25
|
-
expect(snapper.snap({ x: 0, y: 0 }, element)).to.be.deep.equals({ x: 0, y: 0 });
|
|
26
|
-
expect(snapper.snap({ x: 4, y: 5 }, element)).to.be.deep.equals({ x: 0, y: 10 });
|
|
27
|
-
expect(snapper.snap({ x: 8, y: 11 }, element)).to.be.deep.equals({ x: 10, y: 10 });
|
|
28
|
-
expect(snapper.snap({ x: -7, y: -4 }, element)).to.be.deep.equals({ x: -10, y: -0 });
|
|
29
|
-
});
|
|
30
|
-
});
|