@finos/legend-extension-dsl-diagram 0.0.13 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +18 -0
- package/lib/DSLDiagram_Extension.d.ts +0 -5
- package/lib/DSLDiagram_Extension.d.ts.map +1 -1
- package/lib/DSLDiagram_Extension.js +0 -12
- package/lib/DSLDiagram_Extension.js.map +1 -1
- package/lib/DiagramRenderer.d.ts +9 -7
- package/lib/DiagramRenderer.d.ts.map +1 -1
- package/lib/DiagramRenderer.js +119 -90
- package/lib/DiagramRenderer.js.map +1 -1
- package/lib/components/studio/ClassDiagramPreview.js +1 -1
- package/lib/components/studio/ClassDiagramPreview.js.map +1 -1
- package/lib/components/studio/{DSLDiagram_StudioPlugin.d.ts → DSLDiagram_LegendStudioPlugin.d.ts} +5 -5
- package/lib/components/studio/DSLDiagram_LegendStudioPlugin.d.ts.map +1 -0
- package/lib/components/studio/{DSLDiagram_StudioPlugin.js → DSLDiagram_LegendStudioPlugin.js} +4 -4
- package/lib/components/studio/DSLDiagram_LegendStudioPlugin.js.map +1 -0
- package/lib/components/studio/DSLDiagram_LegendStudioPlugin_Extension.d.ts +30 -0
- package/lib/components/studio/DSLDiagram_LegendStudioPlugin_Extension.d.ts.map +1 -0
- package/lib/components/studio/DSLDiagram_LegendStudioPlugin_Extension.js +17 -0
- package/lib/components/studio/DSLDiagram_LegendStudioPlugin_Extension.js.map +1 -0
- package/lib/components/studio/DiagramEditor.d.ts.map +1 -1
- package/lib/components/studio/DiagramEditor.js +53 -39
- package/lib/components/studio/DiagramEditor.js.map +1 -1
- package/lib/graph/DSLDiagram_PureGraphPlugin.js +1 -1
- package/lib/graph/DSLDiagram_PureGraphPlugin.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/index.css.map +1 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/models/metamodels/pure/packageableElements/diagram/RelationshipView.d.ts.map +1 -1
- package/lib/models/metamodels/pure/packageableElements/diagram/RelationshipView.js +3 -0
- package/lib/models/metamodels/pure/packageableElements/diagram/RelationshipView.js.map +1 -1
- package/lib/models/protocols/pure/DSLDiagram_PureProtocolProcessorPlugin.d.ts.map +1 -1
- package/lib/models/protocols/pure/DSLDiagram_PureProtocolProcessorPlugin.js +2 -2
- package/lib/models/protocols/pure/DSLDiagram_PureProtocolProcessorPlugin.js.map +1 -1
- package/lib/stores/studio/DiagramEditorState.d.ts +5 -0
- package/lib/stores/studio/DiagramEditorState.d.ts.map +1 -1
- package/lib/stores/studio/DiagramEditorState.js +28 -7
- package/lib/stores/studio/DiagramEditorState.js.map +1 -1
- package/package.json +17 -18
- package/src/DSLDiagram_Extension.ts +0 -15
- package/src/DiagramRenderer.ts +166 -134
- package/src/components/studio/{DSLDiagram_StudioPlugin.tsx → DSLDiagram_LegendStudioPlugin.tsx} +7 -7
- package/src/components/studio/DSLDiagram_LegendStudioPlugin_Extension.tsx +35 -0
- package/src/components/studio/DiagramEditor.tsx +54 -4
- package/src/graph/DSLDiagram_PureGraphPlugin.ts +1 -1
- package/src/index.ts +5 -1
- package/src/models/metamodels/pure/packageableElements/diagram/RelationshipView.ts +24 -14
- package/src/models/protocols/pure/DSLDiagram_PureProtocolProcessorPlugin.ts +2 -0
- package/src/stores/studio/DiagramEditorState.ts +34 -11
- package/tsconfig.json +3 -1
- package/tsconfig.package.json +1 -0
- package/lib/components/studio/DSLDiagram_StudioPlugin.d.ts.map +0 -1
- package/lib/components/studio/DSLDiagram_StudioPlugin.js.map +0 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# @finos/legend-extension-dsl-diagram
|
2
2
|
|
3
|
+
## 1.0.1
|
4
|
+
|
5
|
+
## 1.0.0
|
6
|
+
|
7
|
+
### Major Changes
|
8
|
+
|
9
|
+
- [#692](https://github.com/finos/legend-studio/pull/692) [`caab0e67`](https://github.com/finos/legend-studio/commit/caab0e6772181e514b246fe6030a02e7169952cc) ([@akphi](https://github.com/akphi)) - **BREAKING CHANGE:** Remove `LegendStudioPreset` and `LegendQueryPreset` and expose `LegendStudioPlugin` and `LegendQueryPlugin` respectively as we now prefer the usage of `@finos/legend-graph-extension-collection` to better manage graph presets.
|
10
|
+
|
11
|
+
## 0.1.2
|
12
|
+
|
13
|
+
## 0.1.1
|
14
|
+
|
15
|
+
## 0.1.0
|
16
|
+
|
17
|
+
### Minor Changes
|
18
|
+
|
19
|
+
- [#584](https://github.com/finos/legend-studio/pull/584) [`b32e834b`](https://github.com/finos/legend-studio/commit/b32e834ba037658de53632403c79aa0f0f651971) ([@akphi](https://github.com/akphi)) - Support context menu for class views. Cleanup diagram renderer event handlers: they now align with the events that trigger them, not their purpose, e.g. we changed `handleEditClassView` to `onClassViewDoubleClick`.
|
20
|
+
|
3
21
|
## 0.0.13
|
4
22
|
|
5
23
|
## 0.0.12
|
@@ -15,13 +15,8 @@
|
|
15
15
|
*/
|
16
16
|
import { AbstractPreset } from '@finos/legend-shared';
|
17
17
|
import type { GraphPluginManager } from '@finos/legend-graph';
|
18
|
-
import type { StudioPluginManager } from '@finos/legend-studio';
|
19
18
|
export declare class DSLDiagram_GraphPreset extends AbstractPreset {
|
20
19
|
constructor();
|
21
20
|
install(pluginManager: GraphPluginManager): void;
|
22
21
|
}
|
23
|
-
export declare class DSLDiagram_StudioPreset extends AbstractPreset {
|
24
|
-
constructor();
|
25
|
-
install(pluginManager: StudioPluginManager): void;
|
26
|
-
}
|
27
22
|
//# sourceMappingURL=DSLDiagram_Extension.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DSLDiagram_Extension.d.ts","sourceRoot":"","sources":["../src/DSLDiagram_Extension.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;
|
1
|
+
{"version":3,"file":"DSLDiagram_Extension.d.ts","sourceRoot":"","sources":["../src/DSLDiagram_Extension.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG9D,qBAAa,sBAAuB,SAAQ,cAAc;;IAKxD,OAAO,CAAC,aAAa,EAAE,kBAAkB,GAAG,IAAI;CAKjD"}
|
@@ -17,7 +17,6 @@ import packageJson from '../package.json';
|
|
17
17
|
import { AbstractPreset } from '@finos/legend-shared';
|
18
18
|
import { DSLDiagram_PureGraphManagerPlugin } from './graphManager/DSLDiagram_PureGraphManagerPlugin';
|
19
19
|
import { DSLDiagram_PureProtocolProcessorPlugin } from './models/protocols/pure/DSLDiagram_PureProtocolProcessorPlugin';
|
20
|
-
import { DSLDiagram_StudioPlugin } from './components/studio/DSLDiagram_StudioPlugin';
|
21
20
|
import { DSLDiagram_PureGraphPlugin } from './graph/DSLDiagram_PureGraphPlugin';
|
22
21
|
export class DSLDiagram_GraphPreset extends AbstractPreset {
|
23
22
|
constructor() {
|
@@ -29,15 +28,4 @@ export class DSLDiagram_GraphPreset extends AbstractPreset {
|
|
29
28
|
new DSLDiagram_PureProtocolProcessorPlugin().install(pluginManager);
|
30
29
|
}
|
31
30
|
}
|
32
|
-
export class DSLDiagram_StudioPreset extends AbstractPreset {
|
33
|
-
constructor() {
|
34
|
-
super(packageJson.extensions.studioPreset, packageJson.version);
|
35
|
-
}
|
36
|
-
install(pluginManager) {
|
37
|
-
new DSLDiagram_StudioPlugin().install(pluginManager);
|
38
|
-
new DSLDiagram_PureGraphPlugin().install(pluginManager);
|
39
|
-
new DSLDiagram_PureGraphManagerPlugin().install(pluginManager);
|
40
|
-
new DSLDiagram_PureProtocolProcessorPlugin().install(pluginManager);
|
41
|
-
}
|
42
|
-
}
|
43
31
|
//# sourceMappingURL=DSLDiagram_Extension.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DSLDiagram_Extension.js","sourceRoot":"","sources":["../src/DSLDiagram_Extension.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iCAAiC,EAAE,MAAM,kDAAkD,CAAC;AACrG,OAAO,EAAE,sCAAsC,EAAE,MAAM,gEAAgE,CAAC;
|
1
|
+
{"version":3,"file":"DSLDiagram_Extension.js","sourceRoot":"","sources":["../src/DSLDiagram_Extension.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iCAAiC,EAAE,MAAM,kDAAkD,CAAC;AACrG,OAAO,EAAE,sCAAsC,EAAE,MAAM,gEAAgE,CAAC;AAExH,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAEhF,MAAM,OAAO,sBAAuB,SAAQ,cAAc;IACxD;QACE,KAAK,CAAC,WAAW,CAAC,UAAU,CAAC,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,CAAC,aAAiC;QACvC,IAAI,0BAA0B,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QACxD,IAAI,iCAAiC,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAC/D,IAAI,sCAAsC,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACtE,CAAC;CACF"}
|
package/lib/DiagramRenderer.d.ts
CHANGED
@@ -130,7 +130,7 @@ export declare class DiagramRenderer {
|
|
130
130
|
selectedPoint?: Point | undefined;
|
131
131
|
private _selectedClassesInitialPositions;
|
132
132
|
startClassView?: ClassView | undefined;
|
133
|
-
|
133
|
+
handleAddRelationship?: ((start: ClassView, target: ClassView) => RelationshipView | undefined) | undefined;
|
134
134
|
mouseOverClassCorner?: ClassView | undefined;
|
135
135
|
mouseOverClassName?: ClassView | undefined;
|
136
136
|
mouseOverClassView?: ClassView | undefined;
|
@@ -144,11 +144,13 @@ export declare class DiagramRenderer {
|
|
144
144
|
clickY: number;
|
145
145
|
positionBeforeLastMove: Point;
|
146
146
|
onAddClassViewClick: (point: Point) => void;
|
147
|
+
onClassViewRightClick: (classView: ClassView, point: Point) => void;
|
147
148
|
onBackgroundDoubleClick: (point: Point) => void;
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
149
|
+
onClassViewDoubleClick: (classView: ClassView, point: Point) => void;
|
150
|
+
onClassNameDoubleClick: (classView: ClassView, point: Point) => void;
|
151
|
+
handleEditClassView: (classView: ClassView) => void;
|
152
|
+
handleEditProperty: (property: AbstractProperty, point: Point, propertyHolderView: PropertyHolderView | undefined) => void;
|
153
|
+
handleAddSimpleProperty: (classView: ClassView) => void;
|
152
154
|
constructor(div: HTMLDivElement, diagram: Diagram);
|
153
155
|
setIsReadOnly(val: boolean): void;
|
154
156
|
setMouseOverClassView(val: ClassView | undefined): void;
|
@@ -212,14 +214,14 @@ export declare class DiagramRenderer {
|
|
212
214
|
private drawLinePropertyText;
|
213
215
|
private drawPropertyOrAssociation;
|
214
216
|
private drawInheritance;
|
215
|
-
keydown(e: KeyboardEvent): void;
|
216
|
-
mouseup(e: MouseEvent): void;
|
217
217
|
/**
|
218
218
|
* Reorder will move the class view to the top of the class view array of the diagram,
|
219
219
|
* This will bring it to front.
|
220
220
|
*/
|
221
221
|
private reorderDiagramDomain;
|
222
222
|
private potentiallyShiftRelationships;
|
223
|
+
keydown(e: KeyboardEvent): void;
|
224
|
+
mouseup(e: MouseEvent): void;
|
223
225
|
mousedblclick(e: MouseEvent): void;
|
224
226
|
mousedown(e: MouseEvent): void;
|
225
227
|
mousewheel(e: WheelEvent): void;
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AE,OAAO,EAChB,oBAAoB,EAAE,OAAO,EAC7B,SAAS,EAAE,OAAO,GACjB,CAAC,SAAS,EAAE,EAAE,kBAAkB,EAAE,CAAC;CA+FvC"}
|
package/lib/DiagramRenderer.js
CHANGED
@@ -152,7 +152,7 @@ export class DiagramRenderer {
|
|
152
152
|
_selectedClassesInitialPositions;
|
153
153
|
// Relationship
|
154
154
|
startClassView;
|
155
|
-
|
155
|
+
handleAddRelationship;
|
156
156
|
mouseOverClassCorner;
|
157
157
|
mouseOverClassName;
|
158
158
|
mouseOverClassView;
|
@@ -167,11 +167,13 @@ export class DiagramRenderer {
|
|
167
167
|
positionBeforeLastMove;
|
168
168
|
// interactions
|
169
169
|
onAddClassViewClick = noop();
|
170
|
+
onClassViewRightClick = noop();
|
170
171
|
onBackgroundDoubleClick = noop();
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
172
|
+
onClassViewDoubleClick = noop();
|
173
|
+
onClassNameDoubleClick = noop();
|
174
|
+
handleEditClassView = noop();
|
175
|
+
handleEditProperty = noop();
|
176
|
+
handleAddSimpleProperty = noop();
|
175
177
|
constructor(div, diagram) {
|
176
178
|
makeObservable(this, {
|
177
179
|
isReadOnly: observable,
|
@@ -413,7 +415,7 @@ export class DiagramRenderer {
|
|
413
415
|
if (editMode === DIAGRAM_INTERACTION_MODE.ADD_RELATIONSHIP) {
|
414
416
|
switch (relationshipMode) {
|
415
417
|
case DIAGRAM_RELATIONSHIP_EDIT_MODE.INHERITANCE: {
|
416
|
-
this.
|
418
|
+
this.handleAddRelationship = (startClassView, targetClassView) => {
|
417
419
|
if (
|
418
420
|
// Do not allow creating self-inheritance
|
419
421
|
startClassView.class.value !== targetClassView.class.value &&
|
@@ -435,7 +437,7 @@ export class DiagramRenderer {
|
|
435
437
|
break;
|
436
438
|
}
|
437
439
|
case DIAGRAM_RELATIONSHIP_EDIT_MODE.PROPERTY: {
|
438
|
-
this.
|
440
|
+
this.handleAddRelationship = (startClassView, targetClassView) => {
|
439
441
|
const property = new Property(`property_${startClassView.class.value.properties.length + 1}`, new Multiplicity(1, 1), GenericTypeExplicitReference.create(new GenericType(targetClassView.class.value)), startClassView.class.value);
|
440
442
|
startClassView.class.value.addProperty(property);
|
441
443
|
// only create property view if the classviews are different
|
@@ -487,12 +489,11 @@ export class DiagramRenderer {
|
|
487
489
|
}
|
488
490
|
manageVirtualScreen() {
|
489
491
|
if (this.diagram.classViews.length) {
|
490
|
-
|
491
|
-
let
|
492
|
-
let
|
493
|
-
|
494
|
-
let maxY =
|
495
|
-
this.diagram.classViews[0].rectangle.height;
|
492
|
+
const firstClassView = guaranteeNonNullable(this.diagram.classViews[0]);
|
493
|
+
let minX = firstClassView.position.x;
|
494
|
+
let minY = firstClassView.position.y;
|
495
|
+
let maxX = firstClassView.position.x + firstClassView.rectangle.width;
|
496
|
+
let maxY = firstClassView.position.y + firstClassView.rectangle.height;
|
496
497
|
for (const classView of this.diagram.classViews) {
|
497
498
|
minX = Math.min(minX, classView.position.x);
|
498
499
|
minY = Math.min(minY, classView.position.y);
|
@@ -506,7 +507,10 @@ export class DiagramRenderer {
|
|
506
507
|
let fullPath = relationshipView.buildFullPath();
|
507
508
|
fullPath = manageInsidePointsDynamically(fullPath, relationshipView.from.classView.value, relationshipView.to.classView.value);
|
508
509
|
if (relationshipView instanceof PropertyView) {
|
509
|
-
const box = this.drawLinePropertyText(
|
510
|
+
const box = this.drawLinePropertyText(
|
511
|
+
// NOTE: by the way we compute the full path, it would guarantee
|
512
|
+
// to always have at least 2 points
|
513
|
+
fullPath[fullPath.length - 2], fullPath[fullPath.length - 1], relationshipView.to.classView.value, relationshipView.property.value, false);
|
510
514
|
minX = Math.min(minX, box.position.x);
|
511
515
|
minY = Math.min(minY, box.position.y);
|
512
516
|
maxX = Math.max(maxX, box.edgePoint().x);
|
@@ -1155,7 +1159,10 @@ export class DiagramRenderer {
|
|
1155
1159
|
fullPath = manageInsidePointsDynamically(fullPath, propertyView.from.classView.value, propertyView.to.classView.value);
|
1156
1160
|
// const toProperty = asso instanceof.property ? asso.property : asso.association.properties[1];
|
1157
1161
|
const toProperty = propertyView.property.value;
|
1158
|
-
this.drawLinePropertyText(
|
1162
|
+
this.drawLinePropertyText(
|
1163
|
+
// NOTE: by the way we compute the full path, it would guarantee
|
1164
|
+
// to always have at least 2 points
|
1165
|
+
fullPath[fullPath.length - 2], fullPath[fullPath.length - 1], propertyView.to.classView.value, toProperty, false);
|
1159
1166
|
// if (asso.association) {
|
1160
1167
|
// this.displayText(fullPath[1], fullPath[0], asso.from.classView, asso.association.properties[0], this.ctx);
|
1161
1168
|
// }
|
@@ -1232,6 +1239,8 @@ export class DiagramRenderer {
|
|
1232
1239
|
const rect = inheritance.to.classView.value.rectangle;
|
1233
1240
|
let fullPath = inheritance.buildFullPath();
|
1234
1241
|
fullPath = manageInsidePointsDynamically(fullPath, inheritance.from.classView.value, inheritance.to.classView.value);
|
1242
|
+
// NOTE: by the way we compute the full path, it would guarantee
|
1243
|
+
// to always have at least 2 points
|
1235
1244
|
const startX = fullPath[fullPath.length - 2].x;
|
1236
1245
|
const startY = fullPath[fullPath.length - 2].y;
|
1237
1246
|
const endX = fullPath[fullPath.length - 1].x;
|
@@ -1310,22 +1319,48 @@ export class DiagramRenderer {
|
|
1310
1319
|
angle = endX >= startX ? angle : angle + Math.PI;
|
1311
1320
|
this.ctx.beginPath();
|
1312
1321
|
this.ctx.moveTo(resultX +
|
1313
|
-
(this.screenOffset.x + this.triangle[0].rotateX(angle)) *
|
1314
|
-
|
1322
|
+
(this.screenOffset.x + this.triangle[0].rotateX(angle)) *
|
1323
|
+
this.zoom, resultY +
|
1324
|
+
(this.screenOffset.y + this.triangle[0].rotateY(angle)) *
|
1325
|
+
this.zoom);
|
1315
1326
|
this.ctx.lineTo(resultX +
|
1316
|
-
(this.screenOffset.x + this.triangle[1].rotateX(angle)) *
|
1317
|
-
|
1327
|
+
(this.screenOffset.x + this.triangle[1].rotateX(angle)) *
|
1328
|
+
this.zoom, resultY +
|
1329
|
+
(this.screenOffset.y + this.triangle[1].rotateY(angle)) *
|
1330
|
+
this.zoom);
|
1318
1331
|
this.ctx.lineTo(resultX +
|
1319
|
-
(this.screenOffset.x + this.triangle[2].rotateX(angle)) *
|
1320
|
-
|
1332
|
+
(this.screenOffset.x + this.triangle[2].rotateX(angle)) *
|
1333
|
+
this.zoom, resultY +
|
1334
|
+
(this.screenOffset.y + this.triangle[2].rotateY(angle)) *
|
1335
|
+
this.zoom);
|
1321
1336
|
this.ctx.lineTo(resultX +
|
1322
|
-
(this.screenOffset.x + this.triangle[0].rotateX(angle)) *
|
1323
|
-
|
1337
|
+
(this.screenOffset.x + this.triangle[0].rotateX(angle)) *
|
1338
|
+
this.zoom, resultY +
|
1339
|
+
(this.screenOffset.y + this.triangle[0].rotateY(angle)) *
|
1340
|
+
this.zoom);
|
1324
1341
|
this.ctx.fillStyle = this.generalizationViewInheritanceTriangeFillColor;
|
1325
1342
|
this.ctx.fill();
|
1326
1343
|
this.ctx.stroke();
|
1327
1344
|
this.ctx.lineWidth = 1;
|
1328
1345
|
}
|
1346
|
+
/**
|
1347
|
+
* Reorder will move the class view to the top of the class view array of the diagram,
|
1348
|
+
* This will bring it to front.
|
1349
|
+
*/
|
1350
|
+
reorderDiagramDomain(firstClass, diagram) {
|
1351
|
+
const newClasses = diagram.classViews.filter((classView) => classView !== firstClass);
|
1352
|
+
newClasses.push(firstClass);
|
1353
|
+
return newClasses;
|
1354
|
+
}
|
1355
|
+
// TODO: add doc
|
1356
|
+
potentiallyShiftRelationships(assoViews, selectedClasses, newMovingDeltaX, newMovingDeltaY) {
|
1357
|
+
assoViews.forEach((assoView) => {
|
1358
|
+
if (selectedClasses.indexOf(assoView.from.classView.value) !== -1 &&
|
1359
|
+
selectedClasses.indexOf(assoView.to.classView.value) !== -1) {
|
1360
|
+
assoView.setPath(assoView.path.map((point) => new Point(point.x - newMovingDeltaX, point.y - newMovingDeltaY)));
|
1361
|
+
}
|
1362
|
+
});
|
1363
|
+
}
|
1329
1364
|
keydown(e) {
|
1330
1365
|
// Remove selected view(s)
|
1331
1366
|
if ('Delete' === e.key) {
|
@@ -1360,20 +1395,20 @@ export class DiagramRenderer {
|
|
1360
1395
|
// we need to call `preventDefault` to avoid typing `e` in the property name input
|
1361
1396
|
else if ('e' === e.key) {
|
1362
1397
|
if (this.selectedClassProperty) {
|
1363
|
-
this.
|
1398
|
+
this.handleEditProperty(this.selectedClassProperty.property, this.selectedClassProperty.selectionPoint, undefined);
|
1364
1399
|
e.preventDefault();
|
1365
1400
|
}
|
1366
1401
|
else if (this.selectedPropertyOrAssociation) {
|
1367
1402
|
// TODO: we might want to revise this to allow edit property holder view
|
1368
1403
|
// on the side panel instead of showing the inline property editor
|
1369
|
-
this.
|
1404
|
+
this.handleEditProperty(this.selectedPropertyOrAssociation.property.value, this.selectedPoint ??
|
1370
1405
|
(this.selectedPropertyOrAssociation.path.length
|
1371
1406
|
? this.selectedPropertyOrAssociation.path[0]
|
1372
1407
|
: this.selectedPropertyOrAssociation.from.classView.value.center()), this.selectedPropertyOrAssociation);
|
1373
1408
|
e.preventDefault();
|
1374
1409
|
}
|
1375
1410
|
else if (this.selectedClasses.length === 1) {
|
1376
|
-
this.
|
1411
|
+
this.handleEditClassView(this.selectedClasses[0]);
|
1377
1412
|
}
|
1378
1413
|
}
|
1379
1414
|
// Recenter
|
@@ -1456,7 +1491,7 @@ export class DiagramRenderer {
|
|
1456
1491
|
// Add a new simple property to selected class
|
1457
1492
|
else if (e.altKey && 'ArrowDown' === e.code) {
|
1458
1493
|
if (!this.isReadOnly && this.selectedClasses.length === 1) {
|
1459
|
-
this.
|
1494
|
+
this.handleAddSimpleProperty(this.selectedClasses[0]);
|
1460
1495
|
}
|
1461
1496
|
}
|
1462
1497
|
// Eject the property
|
@@ -1540,7 +1575,8 @@ export class DiagramRenderer {
|
|
1540
1575
|
nextZoomLevel = Math.ceil(currentZoomLevel / 10) * 10 - 10;
|
1541
1576
|
}
|
1542
1577
|
else if (currentZoomLevel >=
|
1543
|
-
DIAGRAM_ZOOM_LEVELS[DIAGRAM_ZOOM_LEVELS.length - 1] +
|
1578
|
+
DIAGRAM_ZOOM_LEVELS[DIAGRAM_ZOOM_LEVELS.length - 1] +
|
1579
|
+
100) {
|
1544
1580
|
nextZoomLevel = Math.ceil(currentZoomLevel / 100) * 100 - 100;
|
1545
1581
|
}
|
1546
1582
|
else {
|
@@ -1552,12 +1588,12 @@ export class DiagramRenderer {
|
|
1552
1588
|
case DIAGRAM_INTERACTION_MODE.ADD_RELATIONSHIP: {
|
1553
1589
|
if (this.startClassView &&
|
1554
1590
|
this.selectionStart &&
|
1555
|
-
this.
|
1591
|
+
this.handleAddRelationship) {
|
1556
1592
|
const eventPointInModelCoordinate = this.canvasCoordinateToModelCoordinate(this.eventCoordinateToCanvasCoordinate(new Point(e.x, e.y)));
|
1557
1593
|
for (let i = this.diagram.classViews.length - 1; i >= 0; i--) {
|
1558
|
-
|
1559
|
-
|
1560
|
-
const gview = this.
|
1594
|
+
const targetClassView = this.diagram.classViews[i];
|
1595
|
+
if (targetClassView.contains(eventPointInModelCoordinate.x, eventPointInModelCoordinate.y)) {
|
1596
|
+
const gview = this.handleAddRelationship(this.startClassView, targetClassView);
|
1561
1597
|
if (gview) {
|
1562
1598
|
gview.from.setOffsetX(-(this.startClassView.position.x +
|
1563
1599
|
this.startClassView.rectangle.width / 2 -
|
@@ -1589,24 +1625,6 @@ export class DiagramRenderer {
|
|
1589
1625
|
this.setSelectionStart(undefined);
|
1590
1626
|
this.drawScreen();
|
1591
1627
|
}
|
1592
|
-
/**
|
1593
|
-
* Reorder will move the class view to the top of the class view array of the diagram,
|
1594
|
-
* This will bring it to front.
|
1595
|
-
*/
|
1596
|
-
reorderDiagramDomain(firstClass, diagram) {
|
1597
|
-
const newClasses = diagram.classViews.filter((classView) => classView !== firstClass);
|
1598
|
-
newClasses.push(firstClass);
|
1599
|
-
return newClasses;
|
1600
|
-
}
|
1601
|
-
// TODO: add doc
|
1602
|
-
potentiallyShiftRelationships(assoViews, selectedClasses, newMovingDeltaX, newMovingDeltaY) {
|
1603
|
-
assoViews.forEach((assoView) => {
|
1604
|
-
if (selectedClasses.indexOf(assoView.from.classView.value) !== -1 &&
|
1605
|
-
selectedClasses.indexOf(assoView.to.classView.value) !== -1) {
|
1606
|
-
assoView.setPath(assoView.path.map((point) => new Point(point.x - newMovingDeltaX, point.y - newMovingDeltaY)));
|
1607
|
-
}
|
1608
|
-
});
|
1609
|
-
}
|
1610
1628
|
mousedblclick(e) {
|
1611
1629
|
if ([
|
1612
1630
|
DIAGRAM_INTERACTION_MODE.ADD_RELATIONSHIP,
|
@@ -1619,23 +1637,23 @@ export class DiagramRenderer {
|
|
1619
1637
|
const eventPointInModelCoordinate = this.canvasCoordinateToModelCoordinate(this.eventCoordinateToCanvasCoordinate(new Point(e.x, e.y)));
|
1620
1638
|
// Check double click on class property
|
1621
1639
|
if (this.mouseOverClassProperty) {
|
1622
|
-
this.
|
1640
|
+
this.handleEditProperty(this.mouseOverClassProperty, eventPointInModelCoordinate, undefined);
|
1623
1641
|
return;
|
1624
1642
|
}
|
1625
1643
|
// Check double click on class name
|
1626
1644
|
if (this.mouseOverClassName) {
|
1627
|
-
this.
|
1645
|
+
this.onClassNameDoubleClick(this.mouseOverClassName, eventPointInModelCoordinate);
|
1628
1646
|
return;
|
1629
1647
|
}
|
1630
1648
|
// Check double click on class view
|
1631
1649
|
const selectedClass = this.diagram.classViews.find((classView) => classView.contains(eventPointInModelCoordinate.x, eventPointInModelCoordinate.y));
|
1632
1650
|
if (selectedClass) {
|
1633
|
-
this.
|
1651
|
+
this.onClassViewDoubleClick(selectedClass, eventPointInModelCoordinate);
|
1634
1652
|
return;
|
1635
1653
|
}
|
1636
1654
|
// Check double click on line property label
|
1637
1655
|
if (this.mouseOverPropertyHolderViewLabel) {
|
1638
|
-
this.
|
1656
|
+
this.handleEditProperty(this.mouseOverPropertyHolderViewLabel.property.value, eventPointInModelCoordinate, this.mouseOverPropertyHolderViewLabel);
|
1639
1657
|
return;
|
1640
1658
|
}
|
1641
1659
|
// Check double click on background
|
@@ -1651,11 +1669,11 @@ export class DiagramRenderer {
|
|
1651
1669
|
this.selectedClassProperty = undefined;
|
1652
1670
|
this.selectedPoint = undefined;
|
1653
1671
|
this.startClassView = undefined;
|
1672
|
+
const eventPointInCanvasCoordinate = this.eventCoordinateToCanvasCoordinate(new Point(e.x, e.y));
|
1673
|
+
const eventPointInModelCoordinate = this.canvasCoordinateToModelCoordinate(eventPointInCanvasCoordinate);
|
1654
1674
|
// left click
|
1655
1675
|
if (e.button === 0) {
|
1656
1676
|
this.setLeftClick(true);
|
1657
|
-
const eventPointInCanvasCoordinate = this.eventCoordinateToCanvasCoordinate(new Point(e.x, e.y));
|
1658
|
-
const eventPointInModelCoordinate = this.canvasCoordinateToModelCoordinate(eventPointInCanvasCoordinate);
|
1659
1677
|
switch (this.interactionMode) {
|
1660
1678
|
case DIAGRAM_INTERACTION_MODE.PAN: {
|
1661
1679
|
e.returnValue = false;
|
@@ -1666,7 +1684,8 @@ export class DiagramRenderer {
|
|
1666
1684
|
// Check if the selection lies within the bottom right corner box of a box (so we can do resize of box here)
|
1667
1685
|
// NOTE: Traverse backwards the class views to preserve z-index buffer
|
1668
1686
|
for (let i = this.diagram.classViews.length - 1; i >= 0; i--) {
|
1669
|
-
|
1687
|
+
const targetClassView = this.diagram.classViews[i];
|
1688
|
+
if (targetClassView
|
1670
1689
|
.buildBottomRightCornerBox()
|
1671
1690
|
.contains(eventPointInModelCoordinate.x, eventPointInModelCoordinate.y)) {
|
1672
1691
|
this.setSelectedClasses([]);
|
@@ -1692,11 +1711,11 @@ export class DiagramRenderer {
|
|
1692
1711
|
let anyClassesSelected = false;
|
1693
1712
|
// Traverse backwards the class views to preserve z-index buffer
|
1694
1713
|
for (let i = this.diagram.classViews.length - 1; i >= 0; i--) {
|
1695
|
-
|
1714
|
+
const targetClassView = this.diagram.classViews[i];
|
1715
|
+
if (targetClassView.contains(eventPointInModelCoordinate.x, eventPointInModelCoordinate.y)) {
|
1696
1716
|
if (this.selectedClasses.length === 0 ||
|
1697
|
-
this.selectedClasses.indexOf(
|
1698
|
-
|
1699
|
-
this.setSelectedClasses([this.diagram.classViews[i]]);
|
1717
|
+
this.selectedClasses.indexOf(targetClassView) === -1) {
|
1718
|
+
this.setSelectedClasses([targetClassView]);
|
1700
1719
|
}
|
1701
1720
|
if (!this.isReadOnly) {
|
1702
1721
|
// Bring the class view to front
|
@@ -1773,8 +1792,9 @@ export class DiagramRenderer {
|
|
1773
1792
|
this.setSelectionStart(eventPointInModelCoordinate);
|
1774
1793
|
this.startClassView = undefined;
|
1775
1794
|
for (let i = this.diagram.classViews.length - 1; i >= 0; i--) {
|
1776
|
-
|
1777
|
-
|
1795
|
+
const targetClassView = this.diagram.classViews[i];
|
1796
|
+
if (targetClassView.contains(eventPointInModelCoordinate.x, eventPointInModelCoordinate.y)) {
|
1797
|
+
this.startClassView = targetClassView;
|
1778
1798
|
}
|
1779
1799
|
}
|
1780
1800
|
if (!this.startClassView) {
|
@@ -1786,10 +1806,7 @@ export class DiagramRenderer {
|
|
1786
1806
|
break;
|
1787
1807
|
}
|
1788
1808
|
}
|
1789
|
-
//
|
1790
|
-
// right click to move the diagram. However, if we support context menu
|
1791
|
-
// using right click in the future, we need to adjust to only allow
|
1792
|
-
// middle click to move here.
|
1809
|
+
// middle click
|
1793
1810
|
else if (e.button === 1) {
|
1794
1811
|
e.returnValue = false;
|
1795
1812
|
this.setMiddleClick(true);
|
@@ -1801,6 +1818,10 @@ export class DiagramRenderer {
|
|
1801
1818
|
e.returnValue = false;
|
1802
1819
|
this.setRightClick(true);
|
1803
1820
|
this.positionBeforeLastMove = new Point(e.x, e.y);
|
1821
|
+
if (this.mouseOverClassView) {
|
1822
|
+
this.onClassViewRightClick(this.mouseOverClassView, eventPointInModelCoordinate);
|
1823
|
+
this.setRightClick(false);
|
1824
|
+
}
|
1804
1825
|
return;
|
1805
1826
|
}
|
1806
1827
|
this.clearScreen();
|
@@ -1998,7 +2019,10 @@ export class DiagramRenderer {
|
|
1998
2019
|
for (const propertyHolderView of propertyHolderViews) {
|
1999
2020
|
let fullPath = propertyHolderView.buildFullPath();
|
2000
2021
|
fullPath = manageInsidePointsDynamically(fullPath, propertyHolderView.from.classView.value, propertyHolderView.to.classView.value);
|
2001
|
-
const propertyInfoBox = this.drawLinePropertyText(
|
2022
|
+
const propertyInfoBox = this.drawLinePropertyText(
|
2023
|
+
// NOTE: by the way we compute the full path, it would guarantee
|
2024
|
+
// to always have at least 2 points
|
2025
|
+
fullPath[fullPath.length - 2], fullPath[fullPath.length - 1], propertyHolderView.to.classView.value, propertyHolderView.property.value, false);
|
2002
2026
|
if (propertyInfoBox.contains(eventPointInModelCoordinate.x, eventPointInModelCoordinate.y)) {
|
2003
2027
|
this.setMouseOverPropertyHolderViewLabel(propertyHolderView);
|
2004
2028
|
break;
|
@@ -2025,33 +2049,38 @@ export class DiagramRenderer {
|
|
2025
2049
|
return [];
|
2026
2050
|
}
|
2027
2051
|
layoutTaxonomy(classViewLevels, diagram, positionInitialClass, superType) {
|
2028
|
-
//Offsets
|
2052
|
+
// Offsets
|
2029
2053
|
const spaceY = 30;
|
2030
2054
|
const spaceX = 10;
|
2031
2055
|
classViewLevels.reverse();
|
2032
|
-
const classViews = classViewLevels.flatMap((
|
2056
|
+
const classViews = classViewLevels.flatMap((levels, currentLevelIndex) => {
|
2033
2057
|
// Get the bounding box of the precedent level
|
2034
2058
|
let precedentTotalWidth = 0;
|
2035
2059
|
let precedentTotalHeight = 0;
|
2036
2060
|
let precedentX = 0;
|
2037
2061
|
let precedentY = 0;
|
2038
2062
|
if (currentLevelIndex > 0) {
|
2039
|
-
const
|
2040
|
-
|
2041
|
-
|
2042
|
-
precedentByX[
|
2043
|
-
|
2044
|
-
precedentByX[
|
2045
|
-
|
2046
|
-
|
2047
|
-
|
2048
|
-
precedentByY[
|
2049
|
-
|
2050
|
-
|
2063
|
+
const precedent = classViewLevels[currentLevelIndex - 1];
|
2064
|
+
if (precedent.length) {
|
2065
|
+
const precedentByX = [...precedent].sort((a, b) => a.position.x - b.position.x);
|
2066
|
+
precedentX = precedentByX[0].position.x;
|
2067
|
+
precedentTotalWidth =
|
2068
|
+
precedentByX[precedentByX.length - 1].position.x +
|
2069
|
+
precedentByX[precedentByX.length - 1].rectangle
|
2070
|
+
.width -
|
2071
|
+
precedentByX[0].position.x;
|
2072
|
+
const precedentByY = [...precedent].sort((a, b) => a.position.y - b.position.y);
|
2073
|
+
precedentY = precedentByY[0].position.y;
|
2074
|
+
precedentTotalHeight =
|
2075
|
+
precedentByY[precedentByY.length - 1].position.y +
|
2076
|
+
precedentByY[precedentByY.length - 1].rectangle
|
2077
|
+
.height -
|
2078
|
+
precedentByY[0].position.y;
|
2079
|
+
}
|
2051
2080
|
}
|
2052
2081
|
// Get the bounding box of current Level
|
2053
|
-
const maxHeight = Math.max(...
|
2054
|
-
const totalWidth =
|
2082
|
+
const maxHeight = Math.max(...levels.map((classView) => classView.rectangle.height));
|
2083
|
+
const totalWidth = levels
|
2055
2084
|
.map((classView) => classView.rectangle.width)
|
2056
2085
|
.reduce((a, b) => a + b + spaceX);
|
2057
2086
|
// Get the starting position
|
@@ -2061,19 +2090,19 @@ export class DiagramRenderer {
|
|
2061
2090
|
: precedentY + precedentTotalHeight + spaceY;
|
2062
2091
|
// Set layout of current level
|
2063
2092
|
if (positionInitialClass || currentLevelIndex > 0) {
|
2064
|
-
|
2065
|
-
|
2066
|
-
if (
|
2067
|
-
const precedent =
|
2093
|
+
levels[0].setPosition(new Point(startX, currentLevelY));
|
2094
|
+
levels.forEach((view, idx) => {
|
2095
|
+
if (idx > 0) {
|
2096
|
+
const precedent = levels[idx - 1];
|
2068
2097
|
view.setPosition(new Point(precedent.position.x + precedent.rectangle.width + spaceX, currentLevelY));
|
2069
2098
|
}
|
2070
2099
|
});
|
2071
2100
|
}
|
2072
|
-
return
|
2101
|
+
return levels;
|
2073
2102
|
});
|
2074
2103
|
const generalizationViews = (superType ? classViewLevels : classViewLevels.reverse())
|
2075
2104
|
.slice(0, classViewLevels.length - 1)
|
2076
|
-
.flatMap((level,
|
2105
|
+
.flatMap((level, idx) => level.flatMap((fromClassView) => classViewLevels[idx + 1].flatMap((toClassView) => {
|
2077
2106
|
if (fromClassView.class.value.generalizations
|
2078
2107
|
.map((g) => g.value.rawType)
|
2079
2108
|
.includes(toClassView.class.value)) {
|