@finos/legend-extension-dsl-diagram 1.0.26 → 1.0.29
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/DiagramRenderer.d.ts +1 -1
- package/lib/DiagramRenderer.d.ts.map +1 -1
- package/lib/DiagramRenderer.js +56 -54
- package/lib/DiagramRenderer.js.map +1 -1
- package/lib/components/studio/ClassDiagramPreview.d.ts +1 -0
- package/lib/components/studio/ClassDiagramPreview.d.ts.map +1 -1
- package/lib/components/studio/DiagramEditor.d.ts +1 -0
- package/lib/components/studio/DiagramEditor.d.ts.map +1 -1
- package/lib/components/studio/DiagramEditor.js +10 -9
- package/lib/components/studio/DiagramEditor.js.map +1 -1
- package/lib/helpers/DiagramHelper.d.ts.map +1 -1
- package/lib/helpers/DiagramHelper.js +4 -3
- package/lib/helpers/DiagramHelper.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassView.d.ts +0 -3
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassView.d.ts.map +1 -1
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassView.js +1 -13
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassView.js.map +1 -1
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassViewReference.d.ts +0 -1
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassViewReference.d.ts.map +1 -1
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassViewReference.js +2 -7
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassViewReference.js.map +1 -1
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_Diagram.d.ts +0 -11
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_Diagram.d.ts.map +1 -1
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_Diagram.js +2 -46
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_Diagram.js.map +1 -1
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_GraphModifierHelper.d.ts +35 -0
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_GraphModifierHelper.d.ts.map +1 -0
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_GraphModifierHelper.js +118 -0
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_GraphModifierHelper.js.map +1 -0
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipEdgeView.d.ts +0 -2
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipEdgeView.d.ts.map +1 -1
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipEdgeView.js +1 -9
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipEdgeView.js.map +1 -1
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipView.d.ts +0 -17
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipView.d.ts.map +1 -1
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipView.js +6 -109
- package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipView.js.map +1 -1
- package/lib/models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_PositionedRectangle.d.ts +0 -8
- package/lib/models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_PositionedRectangle.d.ts.map +1 -1
- package/lib/models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_PositionedRectangle.js +1 -16
- package/lib/models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_PositionedRectangle.js.map +1 -1
- package/lib/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDiagram_GraphBuilderHelper.d.ts.map +1 -1
- package/lib/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDiagram_GraphBuilderHelper.js +3 -2
- package/lib/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDiagram_GraphBuilderHelper.js.map +1 -1
- package/lib/package.json +4 -4
- package/lib/stores/studio/DSLDiagram_ModifierHelper.d.ts +54 -0
- package/lib/stores/studio/DSLDiagram_ModifierHelper.d.ts.map +1 -0
- package/lib/stores/studio/DSLDiagram_ModifierHelper.js +87 -0
- package/lib/stores/studio/DSLDiagram_ModifierHelper.js.map +1 -0
- package/lib/stores/studio/DiagramEditorState.d.ts.map +1 -1
- package/lib/stores/studio/DiagramEditorState.js +3 -3
- package/lib/stores/studio/DiagramEditorState.js.map +1 -1
- package/package.json +10 -10
- package/src/DiagramRenderer.ts +125 -58
- package/src/components/studio/DiagramEditor.tsx +16 -11
- package/src/helpers/DiagramHelper.ts +4 -3
- package/src/index.ts +2 -4
- package/src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassView.ts +1 -14
- package/src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassViewReference.ts +1 -8
- package/src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_Diagram.ts +2 -52
- package/src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_GraphModifierHelper.ts +165 -0
- package/src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipEdgeView.ts +1 -10
- package/src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipView.ts +6 -147
- package/src/models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_PositionedRectangle.ts +1 -17
- package/src/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDiagram_GraphBuilderHelper.ts +3 -2
- package/src/stores/studio/DSLDiagram_ModifierHelper.ts +148 -0
- package/src/stores/studio/DiagramEditorState.ts +2 -2
- package/tsconfig.json +2 -0
@@ -14,7 +14,7 @@
|
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
16
|
|
17
|
-
import { observable,
|
17
|
+
import { observable, makeObservable } from 'mobx';
|
18
18
|
import { hashArray, type Hashable } from '@finos/legend-shared';
|
19
19
|
import { Point } from './DSLDiagram_Point';
|
20
20
|
import { Rectangle } from './DSLDiagram_Rectangle';
|
@@ -28,28 +28,12 @@ export class PositionedRectangle implements Hashable {
|
|
28
28
|
constructor(position: Point, rectangle: Rectangle) {
|
29
29
|
makeObservable(this, {
|
30
30
|
dummyObservable: observable,
|
31
|
-
forceRefreshHash: action,
|
32
31
|
});
|
33
32
|
|
34
33
|
this.position = position;
|
35
34
|
this.rectangle = rectangle;
|
36
35
|
}
|
37
36
|
|
38
|
-
setRectangle(value: Rectangle): void {
|
39
|
-
this.rectangle = value;
|
40
|
-
}
|
41
|
-
setPosition(value: Point): void {
|
42
|
-
this.position = value;
|
43
|
-
}
|
44
|
-
/**
|
45
|
-
* NOTE: Having `position` and `rectangle` as observables compromises the performance of diagram
|
46
|
-
* so we want to have a way to refresh the hash for change detection to pick up new hash when we resize
|
47
|
-
* the class view box or move it.
|
48
|
-
*/
|
49
|
-
forceRefreshHash(): void {
|
50
|
-
this.dummyObservable = {};
|
51
|
-
}
|
52
|
-
|
53
37
|
edgePoint = (): Point =>
|
54
38
|
new Point(
|
55
39
|
this.position.x + this.rectangle.width,
|
package/src/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDiagram_GraphBuilderHelper.ts
CHANGED
@@ -36,6 +36,7 @@ import type { V1_Rectangle } from '../../model/packageableElements/diagram/geome
|
|
36
36
|
import type { V1_PropertyView } from '../../model/packageableElements/diagram/V1_DSLDiagram_PropertyView';
|
37
37
|
import type { V1_GeneralizationView } from '../../model/packageableElements/diagram/V1_DSLDiagram_GeneralizationView';
|
38
38
|
import { getClassView } from '../../../../../../helpers/DiagramHelper';
|
39
|
+
import { _relationView_possiblyFlattenPath } from '../../../../../metamodels/pure/packageableElements/diagram/DSLDiagram_GraphModifierHelper';
|
39
40
|
|
40
41
|
const buildPoint = (point: V1_Point): Point => {
|
41
42
|
const x = guaranteeNonNullable(point.x, `Point 'x' coordinate is missing`);
|
@@ -115,7 +116,7 @@ export const V1_buildPropertyView = (
|
|
115
116
|
targetClassView,
|
116
117
|
);
|
117
118
|
view.path = propertyView.line.points.map((point) => buildPoint(point));
|
118
|
-
view
|
119
|
+
_relationView_possiblyFlattenPath(view); // transform the line because we store only 2 end points that are inside points and we will calculate the offset
|
119
120
|
return view;
|
120
121
|
};
|
121
122
|
|
@@ -141,7 +142,7 @@ export const V1_buildGeneralizationView = (
|
|
141
142
|
targetClassView,
|
142
143
|
);
|
143
144
|
view.path = generalizationView.line.points.map((point) => buildPoint(point));
|
144
|
-
view
|
145
|
+
_relationView_possiblyFlattenPath(view); // transform the line because we store only 2 end points that are inside points and we will calculate the offset
|
145
146
|
return view;
|
146
147
|
};
|
147
148
|
|
@@ -0,0 +1,148 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
import { addUniqueEntry, changeEntry, deleteEntry } from '@finos/legend-shared';
|
18
|
+
import { action } from 'mobx';
|
19
|
+
import type { AssociationView } from '../../models/metamodels/pure/packageableElements/diagram/DSLDiagram_AssociationView';
|
20
|
+
import type { ClassView } from '../../models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassView';
|
21
|
+
import type { Diagram } from '../../models/metamodels/pure/packageableElements/diagram/DSLDiagram_Diagram';
|
22
|
+
import type { GeneralizationView } from '../../models/metamodels/pure/packageableElements/diagram/DSLDiagram_GeneralizationView';
|
23
|
+
import {
|
24
|
+
_findOrBuildPoint,
|
25
|
+
_relationView_possiblyFlattenPath,
|
26
|
+
_relationView_setPath,
|
27
|
+
} from '../../models/metamodels/pure/packageableElements/diagram/DSLDiagram_GraphModifierHelper';
|
28
|
+
import type { PropertyView } from '../../models/metamodels/pure/packageableElements/diagram/DSLDiagram_PropertyView';
|
29
|
+
import type { RelationShipEdgeView } from '../../models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipEdgeView';
|
30
|
+
import type { RelationshipView } from '../../models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipView';
|
31
|
+
import type { Point } from '../../models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_Point';
|
32
|
+
import type { PositionedRectangle } from '../../models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_PositionedRectangle';
|
33
|
+
import type { Rectangle } from '../../models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_Rectangle';
|
34
|
+
|
35
|
+
export const diagram_setClassViews = action(
|
36
|
+
(diagram: Diagram, val: ClassView[]): void => {
|
37
|
+
diagram.classViews = val;
|
38
|
+
},
|
39
|
+
);
|
40
|
+
export const diagram_addClassView = action(
|
41
|
+
(diagram: Diagram, val: ClassView): void => {
|
42
|
+
addUniqueEntry(diagram.classViews, val);
|
43
|
+
},
|
44
|
+
);
|
45
|
+
export const diagram_deleteClassView = action(
|
46
|
+
(diagram: Diagram, val: ClassView): void => {
|
47
|
+
deleteEntry(diagram.classViews, val);
|
48
|
+
},
|
49
|
+
);
|
50
|
+
export const diagram_setAssociationViews = action(
|
51
|
+
(diagram: Diagram, val: AssociationView[]): void => {
|
52
|
+
diagram.associationViews = val;
|
53
|
+
},
|
54
|
+
);
|
55
|
+
export const diagram_deleteAssociationView = action(
|
56
|
+
(diagram: Diagram, val: AssociationView): void => {
|
57
|
+
deleteEntry(diagram.associationViews, val);
|
58
|
+
},
|
59
|
+
);
|
60
|
+
export const diagram_setGeneralizationViews = action(
|
61
|
+
(diagram: Diagram, val: GeneralizationView[]): void => {
|
62
|
+
diagram.generalizationViews = val;
|
63
|
+
},
|
64
|
+
);
|
65
|
+
export const diagram_addGeneralizationView = action(
|
66
|
+
(diagram: Diagram, val: GeneralizationView): void => {
|
67
|
+
addUniqueEntry(diagram.generalizationViews, val);
|
68
|
+
},
|
69
|
+
);
|
70
|
+
export const diagram_deleteGeneralizationView = action(
|
71
|
+
(diagram: Diagram, val: GeneralizationView): void => {
|
72
|
+
deleteEntry(diagram.generalizationViews, val);
|
73
|
+
},
|
74
|
+
);
|
75
|
+
export const diagram_setPropertyViews = action(
|
76
|
+
(diagram: Diagram, val: PropertyView[]): void => {
|
77
|
+
diagram.propertyViews = val;
|
78
|
+
},
|
79
|
+
);
|
80
|
+
export const diagram_addPropertyView = action(
|
81
|
+
(diagram: Diagram, val: PropertyView): void => {
|
82
|
+
addUniqueEntry(diagram.propertyViews, val);
|
83
|
+
},
|
84
|
+
);
|
85
|
+
export const diagram_deletePropertyView = action(
|
86
|
+
(diagram: Diagram, val: PropertyView): void => {
|
87
|
+
deleteEntry(diagram.propertyViews, val);
|
88
|
+
},
|
89
|
+
);
|
90
|
+
|
91
|
+
export const classView_setHideProperties = action(
|
92
|
+
(cv: ClassView, val: boolean): void => {
|
93
|
+
cv.hideProperties = val;
|
94
|
+
},
|
95
|
+
);
|
96
|
+
export const classView_setHideStereotypes = action(
|
97
|
+
(cv: ClassView, val: boolean): void => {
|
98
|
+
cv.hideStereotypes = val;
|
99
|
+
},
|
100
|
+
);
|
101
|
+
export const classView_setHideTaggedValues = action(
|
102
|
+
(cv: ClassView, val: boolean): void => {
|
103
|
+
cv.hideTaggedValues = val;
|
104
|
+
},
|
105
|
+
);
|
106
|
+
export const relationShipEdgeView_setOffsetX = action(
|
107
|
+
(r: RelationShipEdgeView, val: number): void => {
|
108
|
+
r.offsetX = val;
|
109
|
+
},
|
110
|
+
);
|
111
|
+
export const relationShipEdgeView_setOffsetY = action(
|
112
|
+
(r: RelationShipEdgeView, val: number): void => {
|
113
|
+
r.offsetY = val;
|
114
|
+
},
|
115
|
+
);
|
116
|
+
|
117
|
+
export const relationshipView_changePoint = action(
|
118
|
+
(v: RelationshipView, val: Point, newVal: Point): void => {
|
119
|
+
changeEntry(v.path, val, newVal);
|
120
|
+
},
|
121
|
+
);
|
122
|
+
export const relationView_possiblyFlattenPath = action(
|
123
|
+
_relationView_possiblyFlattenPath,
|
124
|
+
);
|
125
|
+
|
126
|
+
export const findOrBuildPoint = action(_findOrBuildPoint);
|
127
|
+
export const relationView_setPath = action(_relationView_setPath);
|
128
|
+
|
129
|
+
export const positionedRectangle_setRectangle = action(
|
130
|
+
(pR: PositionedRectangle, value: Rectangle): void => {
|
131
|
+
pR.rectangle = value;
|
132
|
+
},
|
133
|
+
);
|
134
|
+
export const positionedRectangle_setPosition = action(
|
135
|
+
(pR: PositionedRectangle, value: Point): void => {
|
136
|
+
pR.position = value;
|
137
|
+
},
|
138
|
+
);
|
139
|
+
/**
|
140
|
+
* NOTE: Having `position` and `rectangle` as observables compromises the performance of diagram
|
141
|
+
* so we want to have a way to refresh the hash for change detection to pick up new hash when we resize
|
142
|
+
* the class view box or move it.
|
143
|
+
*/
|
144
|
+
export const positionedRectangle_forceRefreshHash = action(
|
145
|
+
(pR: PositionedRectangle): void => {
|
146
|
+
pR.dummyObservable = {};
|
147
|
+
},
|
148
|
+
);
|
@@ -35,12 +35,12 @@ import {
|
|
35
35
|
Property,
|
36
36
|
GenericType,
|
37
37
|
PropertyExplicitReference,
|
38
|
-
addClassProperty,
|
39
38
|
} from '@finos/legend-graph';
|
40
39
|
import {
|
41
40
|
type EditorStore,
|
42
41
|
ClassEditorState,
|
43
42
|
ElementEditorState,
|
43
|
+
class_addProperty,
|
44
44
|
} from '@finos/legend-studio';
|
45
45
|
import type { ClassView } from '../../models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassView';
|
46
46
|
import type { Point } from '../../models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_Point';
|
@@ -402,7 +402,7 @@ export class DiagramEditorState extends ElementEditorState {
|
|
402
402
|
this.renderer.handleAddSimpleProperty = (classView: ClassView): void => {
|
403
403
|
if (!this.isReadOnly && !classView.class.value.isReadOnly) {
|
404
404
|
const _class = classView.class.value;
|
405
|
-
|
405
|
+
class_addProperty(
|
406
406
|
_class,
|
407
407
|
new Property(
|
408
408
|
`property_${_class.properties.length + 1}`,
|
package/tsconfig.json
CHANGED
@@ -51,6 +51,7 @@
|
|
51
51
|
"./src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassViewReference.ts",
|
52
52
|
"./src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_Diagram.ts",
|
53
53
|
"./src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_GeneralizationView.ts",
|
54
|
+
"./src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_GraphModifierHelper.ts",
|
54
55
|
"./src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_PropertyHolderView.ts",
|
55
56
|
"./src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_PropertyView.ts",
|
56
57
|
"./src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipEdgeView.ts",
|
@@ -73,6 +74,7 @@
|
|
73
74
|
"./src/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDiagram_GraphBuilderHelper.ts",
|
74
75
|
"./src/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDiagram_TransformerHelper.ts",
|
75
76
|
"./src/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDiagram_ProtocolHelper.ts",
|
77
|
+
"./src/stores/studio/DSLDiagram_ModifierHelper.ts",
|
76
78
|
"./src/stores/studio/DiagramEditorState.ts",
|
77
79
|
"./src/components/studio/ClassDiagramPreview.tsx",
|
78
80
|
"./src/components/studio/DSLDiagram_LegendStudioPlugin.tsx",
|