@eclipse-glsp/layout-elk 0.9.0-next.66aad6e.3 → 0.9.0-next.95961ba.7
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/lib/di.config.d.ts +7 -13
- package/lib/di.config.d.ts.map +1 -1
- package/lib/di.config.js +20 -32
- package/lib/di.config.js.map +1 -1
- package/lib/di.config.spec.js +13 -16
- package/lib/di.config.spec.js.map +1 -1
- package/lib/element-filter.d.ts +45 -0
- package/lib/element-filter.d.ts.map +1 -0
- package/lib/element-filter.js +84 -0
- package/lib/element-filter.js.map +1 -0
- package/lib/glsp-elk-layout-engine.d.ts +34 -20
- package/lib/glsp-elk-layout-engine.d.ts.map +1 -1
- package/lib/glsp-elk-layout-engine.js +265 -42
- package/lib/glsp-elk-layout-engine.js.map +1 -1
- package/lib/index.d.ts +4 -6
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -7
- package/lib/index.js.map +1 -1
- package/lib/{glsp-layout-configurator.d.ts → layout-configurator.d.ts} +29 -15
- package/lib/layout-configurator.d.ts.map +1 -0
- package/lib/layout-configurator.js +99 -0
- package/lib/layout-configurator.js.map +1 -0
- package/lib/{basic-type-mapper.d.ts → sprotty-elk.d.ts} +3 -11
- package/lib/sprotty-elk.d.ts.map +1 -0
- package/lib/sprotty-elk.js +5 -0
- package/lib/sprotty-elk.js.map +1 -0
- package/package.json +3 -3
- package/src/di.config.spec.ts +15 -18
- package/src/di.config.ts +29 -42
- package/src/element-filter.ts +84 -0
- package/src/glsp-elk-layout-engine.ts +305 -30
- package/src/index.ts +4 -6
- package/src/layout-configurator.ts +101 -0
- package/src/sprotty-elk.ts +18 -0
- package/lib/basic-type-mapper.d.ts.map +0 -1
- package/lib/basic-type-mapper.js +0 -97
- package/lib/basic-type-mapper.js.map +0 -1
- package/lib/glsp-element-filter.d.ts +0 -17
- package/lib/glsp-element-filter.d.ts.map +0 -1
- package/lib/glsp-element-filter.js +0 -53
- package/lib/glsp-element-filter.js.map +0 -1
- package/lib/glsp-layout-configurator.d.ts.map +0 -1
- package/lib/glsp-layout-configurator.js +0 -57
- package/lib/glsp-layout-configurator.js.map +0 -1
- package/src/basic-type-mapper.ts +0 -73
- package/src/glsp-element-filter.ts +0 -38
- package/src/glsp-layout-configurator.ts +0 -59
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022 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 { GEdge, GGraph, GLabel, GModelElement, GNode, GPort, ModelState } from '@eclipse-glsp/server-node';
|
|
17
|
+
import { inject, injectable } from 'inversify';
|
|
18
|
+
import { LayoutOptions } from './sprotty-elk';
|
|
19
|
+
|
|
20
|
+
export const LayoutConfigurator = Symbol('LayoutConfigurator');
|
|
21
|
+
/**
|
|
22
|
+
* Configurator for ELK layout algorithms; provides mappings of layout options for each model element.
|
|
23
|
+
* For a list of all available layout options checkout the official ELK documentation:
|
|
24
|
+
* {@link https://www.eclipse.org/elk/reference/options.html}
|
|
25
|
+
*/
|
|
26
|
+
export interface LayoutConfigurator {
|
|
27
|
+
/**
|
|
28
|
+
* Computes the {@link LayoutOptions} for the given {@link GModelElement}.
|
|
29
|
+
* @param element The element for which the layout options should be computed.
|
|
30
|
+
* @returns The set of layout options for the given element or `undefined`.
|
|
31
|
+
*/
|
|
32
|
+
apply(element: GModelElement): LayoutOptions | undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Abstract default implementation of {@link LayoutConfigurator}.
|
|
37
|
+
* A minimal configuration should at least specify the `elk.algorithm` option as
|
|
38
|
+
* return value of {@link DefaultLayoutConfigurator.graphOptions}.
|
|
39
|
+
*/
|
|
40
|
+
@injectable()
|
|
41
|
+
export abstract class AbstractLayoutConfigurator implements LayoutConfigurator {
|
|
42
|
+
@inject(ModelState)
|
|
43
|
+
protected modelState: ModelState;
|
|
44
|
+
|
|
45
|
+
apply(element: GModelElement): LayoutOptions | undefined {
|
|
46
|
+
if (element instanceof GGraph) {
|
|
47
|
+
return this.graphOptions(element);
|
|
48
|
+
} else if (element instanceof GNode) {
|
|
49
|
+
return this.nodeOptions(element);
|
|
50
|
+
} else if (element instanceof GEdge) {
|
|
51
|
+
return this.edgeOptions(element);
|
|
52
|
+
} else if (element instanceof GLabel) {
|
|
53
|
+
this.labelOptions(element);
|
|
54
|
+
} else if (element instanceof GPort) {
|
|
55
|
+
this.portOptions(element);
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
protected graphOptions(graph: GGraph): LayoutOptions | undefined {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
protected nodeOptions(node: GNode): LayoutOptions | undefined {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
protected edgeOptions(edge: GEdge): LayoutOptions | undefined {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
protected labelOptions(label: GLabel): LayoutOptions | undefined {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
protected portOptions(sport: GPort): LayoutOptions | undefined {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A fallback configurator that is used in the `configureELKLayoutModule` utility method.
|
|
83
|
+
* If no explicit layout configurator binding is provided a new instance of the fallback configurator is
|
|
84
|
+
* bound as replacement. Basic layout options for the root graph element are derived from the
|
|
85
|
+
* configuration parameters that haven been passed to the `configureELKLayoutModule` function.
|
|
86
|
+
*/
|
|
87
|
+
@injectable()
|
|
88
|
+
export class FallbackLayoutConfigurator extends AbstractLayoutConfigurator {
|
|
89
|
+
protected fallbackGraphOptions: LayoutOptions;
|
|
90
|
+
constructor(algorithms: string[], defaultLayoutOptions: LayoutOptions = {}) {
|
|
91
|
+
super();
|
|
92
|
+
this.fallbackGraphOptions = {
|
|
93
|
+
'elk.algorithm': algorithms[0],
|
|
94
|
+
...defaultLayoutOptions
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
protected graphOptions(sgraph: GGraph): LayoutOptions | undefined {
|
|
99
|
+
return this.fallbackGraphOptions;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022 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
|
+
// Reexport of the relevant sprotty-elk typings
|
|
17
|
+
export { LayoutOptions } from 'elkjs';
|
|
18
|
+
export { ElkFactory } from 'sprotty-elk/lib/inversify';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"basic-type-mapper.d.ts","sourceRoot":"","sources":["../src/basic-type-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,oBAAoB,EAAyB,wBAAwB,EAAgB,MAAM,2BAA2B,CAAC;AAEhI,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,oBAAY,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEvF,qBAMa,eAAe;IAExB,SAAS,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAErD,SAAS,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAGrD,SAAS,CAAC,aAAa,IAAI,IAAI;IAU/B,SAAS,CAAC,WAAW,CAAC,WAAW,EAAE,wBAAwB,GAAG,eAAe;IAgB7E,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,eAAe;CAY/D"}
|
package/lib/basic-type-mapper.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.BasicTypeMapper = void 0;
|
|
13
|
-
/********************************************************************************
|
|
14
|
-
* Copyright (c) 2022 STMicroelectronics and others.
|
|
15
|
-
*
|
|
16
|
-
* This program and the accompanying materials are made available under the
|
|
17
|
-
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
18
|
-
* http://www.eclipse.org/legal/epl-2.0.
|
|
19
|
-
*
|
|
20
|
-
* This Source Code may also be made available under the following Secondary
|
|
21
|
-
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
22
|
-
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
23
|
-
* with the GNU Classpath Exception which is available at
|
|
24
|
-
* https://www.gnu.org/software/classpath/license.html.
|
|
25
|
-
*
|
|
26
|
-
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
27
|
-
********************************************************************************/
|
|
28
|
-
const server_node_1 = require("@eclipse-glsp/server-node");
|
|
29
|
-
const inversify_1 = require("inversify");
|
|
30
|
-
let BasicTypeMapper =
|
|
31
|
-
/**
|
|
32
|
-
* The `BasicTypeMapper` provides the means to derive the basic type from a given graph model element.
|
|
33
|
-
* The basic type information is used by the `ElkLayoutEngine` to transform graphic model elements into their corresponding ELK object
|
|
34
|
-
* representation.
|
|
35
|
-
*/
|
|
36
|
-
class BasicTypeMapper {
|
|
37
|
-
postConstruct() {
|
|
38
|
-
this.basicTypeMap = new Map();
|
|
39
|
-
this.diagramConfiguration.typeMapping.forEach((constructor, type) => {
|
|
40
|
-
const basicType = this.toBasicType(constructor);
|
|
41
|
-
if (basicType) {
|
|
42
|
-
this.basicTypeMap.set(type, basicType);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
toBasicType(constructor) {
|
|
47
|
-
const element = new constructor();
|
|
48
|
-
if (element instanceof server_node_1.GNode) {
|
|
49
|
-
return 'node';
|
|
50
|
-
}
|
|
51
|
-
else if (element instanceof server_node_1.GEdge) {
|
|
52
|
-
return 'edge';
|
|
53
|
-
}
|
|
54
|
-
else if (element instanceof server_node_1.GGraph) {
|
|
55
|
-
return 'graph';
|
|
56
|
-
}
|
|
57
|
-
else if (element instanceof server_node_1.GLabel) {
|
|
58
|
-
return 'label';
|
|
59
|
-
}
|
|
60
|
-
else if (element instanceof server_node_1.GPort) {
|
|
61
|
-
return 'port';
|
|
62
|
-
}
|
|
63
|
-
return 'unknown';
|
|
64
|
-
}
|
|
65
|
-
getBasicType(input) {
|
|
66
|
-
const type = typeof input === 'string' ? input : input.type;
|
|
67
|
-
const basicType = this.basicTypeMap.get(type);
|
|
68
|
-
if (basicType) {
|
|
69
|
-
return basicType;
|
|
70
|
-
}
|
|
71
|
-
const subtypeSeparator = type.lastIndexOf(':');
|
|
72
|
-
if (subtypeSeparator > 0) {
|
|
73
|
-
return this.getBasicType(type.substring(0, subtypeSeparator));
|
|
74
|
-
}
|
|
75
|
-
return 'unknown';
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
__decorate([
|
|
79
|
-
inversify_1.inject(server_node_1.DiagramConfiguration),
|
|
80
|
-
__metadata("design:type", Object)
|
|
81
|
-
], BasicTypeMapper.prototype, "diagramConfiguration", void 0);
|
|
82
|
-
__decorate([
|
|
83
|
-
inversify_1.postConstruct(),
|
|
84
|
-
__metadata("design:type", Function),
|
|
85
|
-
__metadata("design:paramtypes", []),
|
|
86
|
-
__metadata("design:returntype", void 0)
|
|
87
|
-
], BasicTypeMapper.prototype, "postConstruct", null);
|
|
88
|
-
BasicTypeMapper = __decorate([
|
|
89
|
-
inversify_1.injectable()
|
|
90
|
-
/**
|
|
91
|
-
* The `BasicTypeMapper` provides the means to derive the basic type from a given graph model element.
|
|
92
|
-
* The basic type information is used by the `ElkLayoutEngine` to transform graphic model elements into their corresponding ELK object
|
|
93
|
-
* representation.
|
|
94
|
-
*/
|
|
95
|
-
], BasicTypeMapper);
|
|
96
|
-
exports.BasicTypeMapper = BasicTypeMapper;
|
|
97
|
-
//# sourceMappingURL=basic-type-mapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"basic-type-mapper.js","sourceRoot":"","sources":["../src/basic-type-mapper.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,2DAAgI;AAChI,yCAA8D;AAW9D,IAAa,eAAe;AAL5B;;;;GAIG;AACH,MAAa,eAAe;IAOd,aAAa;QACnB,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;QAC9B,IAAI,CAAC,oBAAoB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE;YAChE,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;YAChD,IAAI,SAAS,EAAE;gBACX,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;aAC1C;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAES,WAAW,CAAC,WAAqC;QACvD,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClC,IAAI,OAAO,YAAY,mBAAK,EAAE;YAC1B,OAAO,MAAM,CAAC;SACjB;aAAM,IAAI,OAAO,YAAY,mBAAK,EAAE;YACjC,OAAO,MAAM,CAAC;SACjB;aAAM,IAAI,OAAO,YAAY,oBAAM,EAAE;YAClC,OAAO,OAAO,CAAC;SAClB;aAAM,IAAI,OAAO,YAAY,oBAAM,EAAE;YAClC,OAAO,OAAO,CAAC;SAClB;aAAM,IAAI,OAAO,YAAY,mBAAK,EAAE;YACjC,OAAO,MAAM,CAAC;SACjB;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,YAAY,CAAC,KAA6B;QACtC,MAAM,IAAI,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;QAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,SAAS,EAAE;YACX,OAAO,SAAS,CAAC;SACpB;QACD,MAAM,gBAAgB,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC/C,IAAI,gBAAgB,GAAG,CAAC,EAAE;YACtB,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC;SACjE;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ,CAAA;AA3CG;IADC,kBAAM,CAAC,kCAAoB,CAAC;;6DACwB;AAKrD;IADC,yBAAa,EAAE;;;;oDASf;AAfQ,eAAe;IAN3B,sBAAU,EAAE;IACb;;;;OAIG;GACU,eAAe,CA6C3B;AA7CY,0CAAe"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { DefaultElementFilter } from 'sprotty-elk';
|
|
2
|
-
import { SModelElement } from 'sprotty-protocol';
|
|
3
|
-
import { BasicTypeMapper } from './basic-type-mapper';
|
|
4
|
-
/**
|
|
5
|
-
* The default `IElementFilter` used to determine which model elements should be included in the automatic layout.
|
|
6
|
-
* Without further configuration this filter includes all basic model elements (nodes,edges,labels,ports) that are
|
|
7
|
-
* part of the graphical model. For each a custom filter behavior is in place. Edges that have no source or target are filtered out.
|
|
8
|
-
* In addition, edges that are connected to a filtered element are filtered out as well.
|
|
9
|
-
* The filter behavior for each of the basic types can be customized by overriding the corresponding `filter` method.
|
|
10
|
-
* (e.g. {@link GlspElementFilter.filterNode})
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
export declare class GlspElementFilter extends DefaultElementFilter {
|
|
14
|
-
protected typeMapper: BasicTypeMapper;
|
|
15
|
-
protected getBasicType(smodel: SModelElement): string;
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=glsp-element-filter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"glsp-element-filter.d.ts","sourceRoot":"","sources":["../src/glsp-element-filter.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;;;;GAQG;AACH,qBACa,iBAAkB,SAAQ,oBAAoB;IAEvD,SAAS,CAAC,UAAU,EAAE,eAAe,CAAC;IAEtC,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM;CAGxD"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.GlspElementFilter = void 0;
|
|
13
|
-
/********************************************************************************
|
|
14
|
-
* Copyright (c) 2022 STMicroelectronics and others.
|
|
15
|
-
*
|
|
16
|
-
* This program and the accompanying materials are made available under the
|
|
17
|
-
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
18
|
-
* http://www.eclipse.org/legal/epl-2.0.
|
|
19
|
-
*
|
|
20
|
-
* This Source Code may also be made available under the following Secondary
|
|
21
|
-
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
22
|
-
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
23
|
-
* with the GNU Classpath Exception which is available at
|
|
24
|
-
* https://www.gnu.org/software/classpath/license.html.
|
|
25
|
-
*
|
|
26
|
-
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
27
|
-
********************************************************************************/
|
|
28
|
-
const inversify_1 = require("inversify");
|
|
29
|
-
const sprotty_elk_1 = require("sprotty-elk");
|
|
30
|
-
const basic_type_mapper_1 = require("./basic-type-mapper");
|
|
31
|
-
/**
|
|
32
|
-
* The default `IElementFilter` used to determine which model elements should be included in the automatic layout.
|
|
33
|
-
* Without further configuration this filter includes all basic model elements (nodes,edges,labels,ports) that are
|
|
34
|
-
* part of the graphical model. For each a custom filter behavior is in place. Edges that have no source or target are filtered out.
|
|
35
|
-
* In addition, edges that are connected to a filtered element are filtered out as well.
|
|
36
|
-
* The filter behavior for each of the basic types can be customized by overriding the corresponding `filter` method.
|
|
37
|
-
* (e.g. {@link GlspElementFilter.filterNode})
|
|
38
|
-
*
|
|
39
|
-
*/
|
|
40
|
-
let GlspElementFilter = class GlspElementFilter extends sprotty_elk_1.DefaultElementFilter {
|
|
41
|
-
getBasicType(smodel) {
|
|
42
|
-
return this.typeMapper.getBasicType(smodel);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
__decorate([
|
|
46
|
-
inversify_1.inject(basic_type_mapper_1.BasicTypeMapper),
|
|
47
|
-
__metadata("design:type", basic_type_mapper_1.BasicTypeMapper)
|
|
48
|
-
], GlspElementFilter.prototype, "typeMapper", void 0);
|
|
49
|
-
GlspElementFilter = __decorate([
|
|
50
|
-
inversify_1.injectable()
|
|
51
|
-
], GlspElementFilter);
|
|
52
|
-
exports.GlspElementFilter = GlspElementFilter;
|
|
53
|
-
//# sourceMappingURL=glsp-element-filter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"glsp-element-filter.js","sourceRoot":"","sources":["../src/glsp-element-filter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,yCAA+C;AAC/C,6CAAmD;AAEnD,2DAAsD;AAEtD;;;;;;;;GAQG;AAEH,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,kCAAoB;IAI7C,YAAY,CAAC,MAAqB;QACxC,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;CACJ,CAAA;AALG;IADC,kBAAM,CAAC,mCAAe,CAAC;8BACF,mCAAe;qDAAC;AAF7B,iBAAiB;IAD7B,sBAAU,EAAE;GACA,iBAAiB,CAO7B;AAPY,8CAAiB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"glsp-layout-configurator.d.ts","sourceRoot":"","sources":["../src/glsp-layout-configurator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;;GAMG;AACH,qBACa,sBAAuB,SAAQ,yBAAyB;IAEjE,SAAS,CAAC,UAAU,EAAE,eAAe,CAAC;IAEtC,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM;CAGxD;AAED;;;;;GAKG;AACH,qBACa,8BAA+B,SAAQ,sBAAsB;IAE1D,SAAS,CAAC,UAAU,EAAE,eAAe;IADjD,SAAS,CAAC,oBAAoB,EAAE,aAAa,CAAC;gBACxB,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,oBAAoB,GAAE,aAAkB;IAQjH,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,aAAa,GAAG,SAAS;CAGxF"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.FallbackGlspLayoutConfigurator = exports.GlspLayoutConfigurator = void 0;
|
|
13
|
-
const inversify_1 = require("inversify");
|
|
14
|
-
const sprotty_elk_1 = require("sprotty-elk");
|
|
15
|
-
const basic_type_mapper_1 = require("./basic-type-mapper");
|
|
16
|
-
/**
|
|
17
|
-
* Configurator for ELK layout algorithms; provides mappings of layout options for each model element.
|
|
18
|
-
* For a list of all available layout options checkout the official ELK documentation.
|
|
19
|
-
* A minimal configuration should at least specify the `elk.algorithm` option as
|
|
20
|
-
* return value of {@link GlspLayoutConfigurator.graphOptions}.
|
|
21
|
-
* {@link https://www.eclipse.org/elk/reference/options.html}
|
|
22
|
-
*/
|
|
23
|
-
let GlspLayoutConfigurator = class GlspLayoutConfigurator extends sprotty_elk_1.DefaultLayoutConfigurator {
|
|
24
|
-
getBasicType(smodel) {
|
|
25
|
-
return this.typeMapper.getBasicType(smodel);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
__decorate([
|
|
29
|
-
inversify_1.inject(basic_type_mapper_1.BasicTypeMapper),
|
|
30
|
-
__metadata("design:type", basic_type_mapper_1.BasicTypeMapper)
|
|
31
|
-
], GlspLayoutConfigurator.prototype, "typeMapper", void 0);
|
|
32
|
-
GlspLayoutConfigurator = __decorate([
|
|
33
|
-
inversify_1.injectable()
|
|
34
|
-
], GlspLayoutConfigurator);
|
|
35
|
-
exports.GlspLayoutConfigurator = GlspLayoutConfigurator;
|
|
36
|
-
/**
|
|
37
|
-
* A fallback configurator that is used in the `configureELKLayoutModule` utility method.
|
|
38
|
-
* If no explicit layout configurator binding is provided a new instance of the fallback configurator is
|
|
39
|
-
* bound as replacement. Basic layout options for the root graph element are derived from the
|
|
40
|
-
* configuration parameters that haven been passed to the `configureELKLayoutModule` function.
|
|
41
|
-
*/
|
|
42
|
-
let FallbackGlspLayoutConfigurator = class FallbackGlspLayoutConfigurator extends GlspLayoutConfigurator {
|
|
43
|
-
constructor(typeMapper, algorithms, defaultLayoutOptions = {}) {
|
|
44
|
-
super();
|
|
45
|
-
this.typeMapper = typeMapper;
|
|
46
|
-
this.fallbackGraphOptions = Object.assign({ 'elk.algorithm': algorithms[0] }, defaultLayoutOptions);
|
|
47
|
-
}
|
|
48
|
-
graphOptions(sgraph, index) {
|
|
49
|
-
return this.fallbackGraphOptions;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
FallbackGlspLayoutConfigurator = __decorate([
|
|
53
|
-
inversify_1.injectable(),
|
|
54
|
-
__metadata("design:paramtypes", [basic_type_mapper_1.BasicTypeMapper, Array, Object])
|
|
55
|
-
], FallbackGlspLayoutConfigurator);
|
|
56
|
-
exports.FallbackGlspLayoutConfigurator = FallbackGlspLayoutConfigurator;
|
|
57
|
-
//# sourceMappingURL=glsp-layout-configurator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"glsp-layout-configurator.js","sourceRoot":"","sources":["../src/glsp-layout-configurator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAgBA,yCAA+C;AAC/C,6CAAwD;AAExD,2DAAsD;AAEtD;;;;;;GAMG;AAEH,IAAa,sBAAsB,GAAnC,MAAa,sBAAuB,SAAQ,uCAAyB;IAIvD,YAAY,CAAC,MAAqB;QACxC,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;CACJ,CAAA;AALG;IADC,kBAAM,CAAC,mCAAe,CAAC;8BACF,mCAAe;0DAAC;AAF7B,sBAAsB;IADlC,sBAAU,EAAE;GACA,sBAAsB,CAOlC;AAPY,wDAAsB;AASnC;;;;;GAKG;AAEH,IAAa,8BAA8B,GAA3C,MAAa,8BAA+B,SAAQ,sBAAsB;IAEtE,YAAsB,UAA2B,EAAE,UAAoB,EAAE,uBAAsC,EAAE;QAC7G,KAAK,EAAE,CAAC;QADU,eAAU,GAAV,UAAU,CAAiB;QAE7C,IAAI,CAAC,oBAAoB,mBACrB,eAAe,EAAE,UAAU,CAAC,CAAC,CAAC,IAC3B,oBAAoB,CAC1B,CAAC;IACN,CAAC;IAES,YAAY,CAAC,MAAc,EAAE,KAAkB;QACrD,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;CACJ,CAAA;AAbY,8BAA8B;IAD1C,sBAAU,EAAE;qCAGyB,mCAAe;GAFxC,8BAA8B,CAa1C;AAbY,wEAA8B"}
|
package/src/basic-type-mapper.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022 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 { DiagramConfiguration, GEdge, GGraph, GLabel, GModelElementConstructor, GNode, GPort } from '@eclipse-glsp/server-node';
|
|
17
|
-
import { inject, injectable, postConstruct } from 'inversify';
|
|
18
|
-
import { SModelElement } from 'sprotty-protocol';
|
|
19
|
-
|
|
20
|
-
export type BasicGModelType = 'graph' | 'node' | 'edge' | 'label' | 'port' | 'unknown';
|
|
21
|
-
|
|
22
|
-
@injectable()
|
|
23
|
-
/**
|
|
24
|
-
* The `BasicTypeMapper` provides the means to derive the basic type from a given graph model element.
|
|
25
|
-
* The basic type information is used by the `ElkLayoutEngine` to transform graphic model elements into their corresponding ELK object
|
|
26
|
-
* representation.
|
|
27
|
-
*/
|
|
28
|
-
export class BasicTypeMapper {
|
|
29
|
-
@inject(DiagramConfiguration)
|
|
30
|
-
protected diagramConfiguration: DiagramConfiguration;
|
|
31
|
-
|
|
32
|
-
protected basicTypeMap: Map<string, BasicGModelType>;
|
|
33
|
-
|
|
34
|
-
@postConstruct()
|
|
35
|
-
protected postConstruct(): void {
|
|
36
|
-
this.basicTypeMap = new Map();
|
|
37
|
-
this.diagramConfiguration.typeMapping.forEach((constructor, type) => {
|
|
38
|
-
const basicType = this.toBasicType(constructor);
|
|
39
|
-
if (basicType) {
|
|
40
|
-
this.basicTypeMap.set(type, basicType);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
protected toBasicType(constructor: GModelElementConstructor): BasicGModelType {
|
|
46
|
-
const element = new constructor();
|
|
47
|
-
if (element instanceof GNode) {
|
|
48
|
-
return 'node';
|
|
49
|
-
} else if (element instanceof GEdge) {
|
|
50
|
-
return 'edge';
|
|
51
|
-
} else if (element instanceof GGraph) {
|
|
52
|
-
return 'graph';
|
|
53
|
-
} else if (element instanceof GLabel) {
|
|
54
|
-
return 'label';
|
|
55
|
-
} else if (element instanceof GPort) {
|
|
56
|
-
return 'port';
|
|
57
|
-
}
|
|
58
|
-
return 'unknown';
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
getBasicType(input: SModelElement | string): BasicGModelType {
|
|
62
|
-
const type = typeof input === 'string' ? input : input.type;
|
|
63
|
-
const basicType = this.basicTypeMap.get(type);
|
|
64
|
-
if (basicType) {
|
|
65
|
-
return basicType;
|
|
66
|
-
}
|
|
67
|
-
const subtypeSeparator = type.lastIndexOf(':');
|
|
68
|
-
if (subtypeSeparator > 0) {
|
|
69
|
-
return this.getBasicType(type.substring(0, subtypeSeparator));
|
|
70
|
-
}
|
|
71
|
-
return 'unknown';
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022 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 { inject, injectable } from 'inversify';
|
|
17
|
-
import { DefaultElementFilter } from 'sprotty-elk';
|
|
18
|
-
import { SModelElement } from 'sprotty-protocol';
|
|
19
|
-
import { BasicTypeMapper } from './basic-type-mapper';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The default `IElementFilter` used to determine which model elements should be included in the automatic layout.
|
|
23
|
-
* Without further configuration this filter includes all basic model elements (nodes,edges,labels,ports) that are
|
|
24
|
-
* part of the graphical model. For each a custom filter behavior is in place. Edges that have no source or target are filtered out.
|
|
25
|
-
* In addition, edges that are connected to a filtered element are filtered out as well.
|
|
26
|
-
* The filter behavior for each of the basic types can be customized by overriding the corresponding `filter` method.
|
|
27
|
-
* (e.g. {@link GlspElementFilter.filterNode})
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
@injectable()
|
|
31
|
-
export class GlspElementFilter extends DefaultElementFilter {
|
|
32
|
-
@inject(BasicTypeMapper)
|
|
33
|
-
protected typeMapper: BasicTypeMapper;
|
|
34
|
-
|
|
35
|
-
protected getBasicType(smodel: SModelElement): string {
|
|
36
|
-
return this.typeMapper.getBasicType(smodel);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022 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 { LayoutOptions } from 'elkjs';
|
|
17
|
-
import { inject, injectable } from 'inversify';
|
|
18
|
-
import { DefaultLayoutConfigurator } from 'sprotty-elk';
|
|
19
|
-
import { SGraph, SModelElement, SModelIndex } from 'sprotty-protocol';
|
|
20
|
-
import { BasicTypeMapper } from './basic-type-mapper';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Configurator for ELK layout algorithms; provides mappings of layout options for each model element.
|
|
24
|
-
* For a list of all available layout options checkout the official ELK documentation.
|
|
25
|
-
* A minimal configuration should at least specify the `elk.algorithm` option as
|
|
26
|
-
* return value of {@link GlspLayoutConfigurator.graphOptions}.
|
|
27
|
-
* {@link https://www.eclipse.org/elk/reference/options.html}
|
|
28
|
-
*/
|
|
29
|
-
@injectable()
|
|
30
|
-
export class GlspLayoutConfigurator extends DefaultLayoutConfigurator {
|
|
31
|
-
@inject(BasicTypeMapper)
|
|
32
|
-
protected typeMapper: BasicTypeMapper;
|
|
33
|
-
|
|
34
|
-
protected getBasicType(smodel: SModelElement): string {
|
|
35
|
-
return this.typeMapper.getBasicType(smodel);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* A fallback configurator that is used in the `configureELKLayoutModule` utility method.
|
|
41
|
-
* If no explicit layout configurator binding is provided a new instance of the fallback configurator is
|
|
42
|
-
* bound as replacement. Basic layout options for the root graph element are derived from the
|
|
43
|
-
* configuration parameters that haven been passed to the `configureELKLayoutModule` function.
|
|
44
|
-
*/
|
|
45
|
-
@injectable()
|
|
46
|
-
export class FallbackGlspLayoutConfigurator extends GlspLayoutConfigurator {
|
|
47
|
-
protected fallbackGraphOptions: LayoutOptions;
|
|
48
|
-
constructor(protected typeMapper: BasicTypeMapper, algorithms: string[], defaultLayoutOptions: LayoutOptions = {}) {
|
|
49
|
-
super();
|
|
50
|
-
this.fallbackGraphOptions = {
|
|
51
|
-
'elk.algorithm': algorithms[0],
|
|
52
|
-
...defaultLayoutOptions
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
protected graphOptions(sgraph: SGraph, index: SModelIndex): LayoutOptions | undefined {
|
|
57
|
-
return this.fallbackGraphOptions;
|
|
58
|
-
}
|
|
59
|
-
}
|