@finos/legend-extension-dsl-diagram 8.1.195 → 8.1.197
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/components/DiagramRenderer.d.ts +39 -2
- package/lib/components/DiagramRenderer.d.ts.map +1 -1
- package/lib/components/DiagramRenderer.js +83 -61
- package/lib/components/DiagramRenderer.js.map +1 -1
- package/lib/components/DiagramViewer.d.ts +39 -0
- package/lib/components/DiagramViewer.d.ts.map +1 -0
- package/lib/components/DiagramViewer.js +170 -0
- package/lib/components/DiagramViewer.js.map +1 -0
- package/lib/components/DiagramViewerState.d.ts +44 -0
- package/lib/components/DiagramViewerState.d.ts.map +1 -0
- package/lib/components/DiagramViewerState.js +136 -0
- package/lib/components/DiagramViewerState.js.map +1 -0
- package/lib/components/index.d.ts +4 -1
- package/lib/components/index.d.ts.map +1 -1
- package/lib/components/index.js +4 -1
- package/lib/components/index.js.map +1 -1
- package/lib/graph-manager/index.d.ts +3 -0
- package/lib/graph-manager/index.d.ts.map +1 -1
- package/lib/graph-manager/index.js +3 -0
- package/lib/graph-manager/index.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/package.json +4 -5
- package/package.json +8 -9
- package/src/components/DiagramRenderer.ts +221 -103
- package/src/components/DiagramViewer.tsx +650 -0
- package/src/components/DiagramViewerState.ts +171 -0
- package/src/components/index.ts +4 -0
- package/src/graph-manager/index.ts +3 -0
- package/src/index.ts +0 -1
- package/tsconfig.json +2 -12
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioApplicationNavigationContext.d.ts +0 -19
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioApplicationNavigationContext.d.ts.map +0 -1
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioApplicationNavigationContext.js +0 -20
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioApplicationNavigationContext.js.map +0 -1
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioCodeSnippet.d.ts +0 -20
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioCodeSnippet.d.ts.map +0 -1
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioCodeSnippet.js +0 -81
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioCodeSnippet.js.map +0 -1
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioCommand.d.ts +0 -28
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioCommand.d.ts.map +0 -1
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioCommand.js +0 -62
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioCommand.js.map +0 -1
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioDocumentation.d.ts +0 -20
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioDocumentation.d.ts.map +0 -1
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioDocumentation.js +0 -21
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioDocumentation.js.map +0 -1
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioTesting.d.ts +0 -20
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioTesting.d.ts.map +0 -1
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioTesting.js +0 -21
- package/lib/__lib__/studio/DSL_Diagram_LegendStudioTesting.js.map +0 -1
- package/lib/components/studio/ClassDiagramPreview.d.ts +0 -22
- package/lib/components/studio/ClassDiagramPreview.d.ts.map +0 -1
- package/lib/components/studio/ClassDiagramPreview.js +0 -64
- package/lib/components/studio/ClassDiagramPreview.js.map +0 -1
- package/lib/components/studio/DSL_Diagram_LegendStudioApplicationPlugin.d.ts +0 -42
- package/lib/components/studio/DSL_Diagram_LegendStudioApplicationPlugin.d.ts.map +0 -1
- package/lib/components/studio/DSL_Diagram_LegendStudioApplicationPlugin.js +0 -216
- package/lib/components/studio/DSL_Diagram_LegendStudioApplicationPlugin.js.map +0 -1
- package/lib/components/studio/DiagramEditor.d.ts +0 -19
- package/lib/components/studio/DiagramEditor.d.ts.map +0 -1
- package/lib/components/studio/DiagramEditor.js +0 -436
- package/lib/components/studio/DiagramEditor.js.map +0 -1
- package/lib/components/studio/InheritanceDiagramRenderer.d.ts +0 -22
- package/lib/components/studio/InheritanceDiagramRenderer.d.ts.map +0 -1
- package/lib/components/studio/InheritanceDiagramRenderer.js +0 -34
- package/lib/components/studio/InheritanceDiagramRenderer.js.map +0 -1
- package/lib/components/studio/index.d.ts +0 -18
- package/lib/components/studio/index.d.ts.map +0 -1
- package/lib/components/studio/index.js +0 -18
- package/lib/components/studio/index.js.map +0 -1
- package/lib/stores/studio/DSL_Diagram_GraphModifierHelper.d.ts +0 -57
- package/lib/stores/studio/DSL_Diagram_GraphModifierHelper.d.ts.map +0 -1
- package/lib/stores/studio/DSL_Diagram_GraphModifierHelper.js +0 -94
- package/lib/stores/studio/DSL_Diagram_GraphModifierHelper.js.map +0 -1
- package/lib/stores/studio/DiagramEditorState.d.ts +0 -88
- package/lib/stores/studio/DiagramEditorState.d.ts.map +0 -1
- package/lib/stores/studio/DiagramEditorState.js +0 -341
- package/lib/stores/studio/DiagramEditorState.js.map +0 -1
- package/src/__lib__/studio/DSL_Diagram_LegendStudioApplicationNavigationContext.ts +0 -19
- package/src/__lib__/studio/DSL_Diagram_LegendStudioCodeSnippet.ts +0 -88
- package/src/__lib__/studio/DSL_Diagram_LegendStudioCommand.ts +0 -64
- package/src/__lib__/studio/DSL_Diagram_LegendStudioDocumentation.ts +0 -20
- package/src/__lib__/studio/DSL_Diagram_LegendStudioTesting.ts +0 -20
- package/src/components/studio/ClassDiagramPreview.tsx +0 -83
- package/src/components/studio/DSL_Diagram_LegendStudioApplicationPlugin.tsx +0 -313
- package/src/components/studio/DiagramEditor.tsx +0 -1514
- package/src/components/studio/InheritanceDiagramRenderer.ts +0 -50
- package/src/components/studio/index.ts +0 -19
- package/src/stores/studio/DSL_Diagram_GraphModifierHelper.ts +0 -166
- package/src/stores/studio/DiagramEditorState.ts +0 -487
|
@@ -1,487 +0,0 @@
|
|
|
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 { computed, action, makeObservable, observable } from 'mobx';
|
|
18
|
-
import {
|
|
19
|
-
guaranteeNonNullable,
|
|
20
|
-
guaranteeType,
|
|
21
|
-
isType,
|
|
22
|
-
uuid,
|
|
23
|
-
} from '@finos/legend-shared';
|
|
24
|
-
import {
|
|
25
|
-
type DiagramRenderer,
|
|
26
|
-
DIAGRAM_INTERACTION_MODE,
|
|
27
|
-
} from '../../components/DiagramRenderer.js';
|
|
28
|
-
import { PanelDisplayState } from '@finos/legend-art';
|
|
29
|
-
import {
|
|
30
|
-
type PackageableElement,
|
|
31
|
-
type AbstractProperty,
|
|
32
|
-
type PropertyReference,
|
|
33
|
-
GenericTypeExplicitReference,
|
|
34
|
-
Property,
|
|
35
|
-
GenericType,
|
|
36
|
-
PropertyExplicitReference,
|
|
37
|
-
isElementReadOnly,
|
|
38
|
-
Multiplicity,
|
|
39
|
-
PrimitiveType,
|
|
40
|
-
} from '@finos/legend-graph';
|
|
41
|
-
import {
|
|
42
|
-
type EditorStore,
|
|
43
|
-
ClassEditorState,
|
|
44
|
-
ElementEditorState,
|
|
45
|
-
class_addProperty,
|
|
46
|
-
} from '@finos/legend-application-studio';
|
|
47
|
-
import type { ClassView } from '../../graph/metamodel/pure/packageableElements/diagram/DSL_Diagram_ClassView.js';
|
|
48
|
-
import type { Point } from '../../graph/metamodel/pure/packageableElements/diagram/geometry/DSL_Diagram_Point.js';
|
|
49
|
-
import { Diagram } from '../../graph/metamodel/pure/packageableElements/diagram/DSL_Diagram_Diagram.js';
|
|
50
|
-
import type { PropertyHolderView } from '../../graph/metamodel/pure/packageableElements/diagram/DSL_Diagram_PropertyHolderView.js';
|
|
51
|
-
import { DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY } from '../../__lib__/studio/DSL_Diagram_LegendStudioCommand.js';
|
|
52
|
-
import type { CommandRegistrar } from '@finos/legend-application';
|
|
53
|
-
|
|
54
|
-
export abstract class DiagramEditorSidePanelState {
|
|
55
|
-
readonly uuid = uuid();
|
|
56
|
-
editorStore: EditorStore;
|
|
57
|
-
diagramEditorState: DiagramEditorState;
|
|
58
|
-
|
|
59
|
-
constructor(
|
|
60
|
-
editorStore: EditorStore,
|
|
61
|
-
diagramEditorState: DiagramEditorState,
|
|
62
|
-
) {
|
|
63
|
-
this.editorStore = editorStore;
|
|
64
|
-
this.diagramEditorState = diagramEditorState;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export enum DIAGRAM_EDITOR_SIDE_PANEL_TAB {
|
|
69
|
-
ELEMENT = 'ELEMENT',
|
|
70
|
-
VIEW = 'VIEW',
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export class DiagramEditorClassViewEditorSidePanelState extends DiagramEditorSidePanelState {
|
|
74
|
-
classEditorState: ClassEditorState;
|
|
75
|
-
classView: ClassView;
|
|
76
|
-
selectedTab = DIAGRAM_EDITOR_SIDE_PANEL_TAB.ELEMENT;
|
|
77
|
-
|
|
78
|
-
constructor(
|
|
79
|
-
editorStore: EditorStore,
|
|
80
|
-
diagramEditorState: DiagramEditorState,
|
|
81
|
-
classView: ClassView,
|
|
82
|
-
) {
|
|
83
|
-
super(editorStore, diagramEditorState);
|
|
84
|
-
|
|
85
|
-
makeObservable(this, {
|
|
86
|
-
selectedTab: observable,
|
|
87
|
-
setSelectedTab: action,
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
this.classView = classView;
|
|
91
|
-
this.classEditorState = guaranteeType(
|
|
92
|
-
this.editorStore.tabManagerState.tabs.find(
|
|
93
|
-
(elementState) =>
|
|
94
|
-
isType(elementState, ClassEditorState) &&
|
|
95
|
-
elementState.element === classView.class.value,
|
|
96
|
-
) ?? new ClassEditorState(this.editorStore, classView.class.value),
|
|
97
|
-
ClassEditorState,
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
setSelectedTab(val: DIAGRAM_EDITOR_SIDE_PANEL_TAB): void {
|
|
102
|
-
this.selectedTab = val;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export class DiagramEditorInlineClassCreatorState {
|
|
107
|
-
diagramEditorState: DiagramEditorState;
|
|
108
|
-
point: Point;
|
|
109
|
-
|
|
110
|
-
constructor(diagramEditorState: DiagramEditorState, point: Point) {
|
|
111
|
-
this.diagramEditorState = diagramEditorState;
|
|
112
|
-
this.point = point;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export class DiagramEditorInlineClassRenamerState {
|
|
117
|
-
diagramEditorState: DiagramEditorState;
|
|
118
|
-
classView: ClassView;
|
|
119
|
-
point: Point;
|
|
120
|
-
|
|
121
|
-
constructor(
|
|
122
|
-
diagramEditorState: DiagramEditorState,
|
|
123
|
-
classView: ClassView,
|
|
124
|
-
point: Point,
|
|
125
|
-
) {
|
|
126
|
-
this.diagramEditorState = diagramEditorState;
|
|
127
|
-
this.classView = classView;
|
|
128
|
-
this.point = point;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export class DiagramEditorInlinePropertyEditorState {
|
|
133
|
-
diagramEditorState: DiagramEditorState;
|
|
134
|
-
property: PropertyReference;
|
|
135
|
-
point: Point;
|
|
136
|
-
isEditingPropertyView: boolean;
|
|
137
|
-
|
|
138
|
-
constructor(
|
|
139
|
-
diagramEditorState: DiagramEditorState,
|
|
140
|
-
property: AbstractProperty,
|
|
141
|
-
point: Point,
|
|
142
|
-
isEditingPropertyView: boolean,
|
|
143
|
-
) {
|
|
144
|
-
this.diagramEditorState = diagramEditorState;
|
|
145
|
-
this.property = PropertyExplicitReference.create(property);
|
|
146
|
-
this.point = point;
|
|
147
|
-
this.isEditingPropertyView = isEditingPropertyView;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export class DiagramEditorState
|
|
152
|
-
extends ElementEditorState
|
|
153
|
-
implements CommandRegistrar
|
|
154
|
-
{
|
|
155
|
-
_renderer?: DiagramRenderer | undefined;
|
|
156
|
-
showHotkeyInfosModal = false;
|
|
157
|
-
sidePanelDisplayState = new PanelDisplayState({
|
|
158
|
-
initial: 0,
|
|
159
|
-
default: 500,
|
|
160
|
-
snap: 100,
|
|
161
|
-
});
|
|
162
|
-
sidePanelState?: DiagramEditorSidePanelState | undefined;
|
|
163
|
-
inlinePropertyEditorState?:
|
|
164
|
-
| DiagramEditorInlinePropertyEditorState
|
|
165
|
-
| undefined;
|
|
166
|
-
inlineClassCreatorState?: DiagramEditorInlineClassCreatorState | undefined;
|
|
167
|
-
inlineClassRenamerState?: DiagramEditorInlineClassRenamerState | undefined;
|
|
168
|
-
showContextMenu = false;
|
|
169
|
-
contextMenuClassView?: ClassView | undefined;
|
|
170
|
-
|
|
171
|
-
constructor(editorStore: EditorStore, element: PackageableElement) {
|
|
172
|
-
super(editorStore, element);
|
|
173
|
-
|
|
174
|
-
makeObservable(this, {
|
|
175
|
-
_renderer: observable,
|
|
176
|
-
showHotkeyInfosModal: observable,
|
|
177
|
-
sidePanelDisplayState: observable,
|
|
178
|
-
sidePanelState: observable,
|
|
179
|
-
inlinePropertyEditorState: observable,
|
|
180
|
-
inlineClassCreatorState: observable,
|
|
181
|
-
inlineClassRenamerState: observable,
|
|
182
|
-
showContextMenu: observable,
|
|
183
|
-
contextMenuClassView: observable,
|
|
184
|
-
renderer: computed,
|
|
185
|
-
diagram: computed,
|
|
186
|
-
isDiagramRendererInitialized: computed,
|
|
187
|
-
setShowHotkeyInfosModal: action,
|
|
188
|
-
setRenderer: action,
|
|
189
|
-
setSidePanelState: action,
|
|
190
|
-
setInlinePropertyEditorState: action,
|
|
191
|
-
setInlineClassCreatorState: action,
|
|
192
|
-
setInlineClassRenamerState: action,
|
|
193
|
-
setShowContextMenu: action,
|
|
194
|
-
setContextMenuClassView: action,
|
|
195
|
-
reprocess: action,
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
get diagram(): Diagram {
|
|
200
|
-
return guaranteeType(
|
|
201
|
-
this.element,
|
|
202
|
-
Diagram,
|
|
203
|
-
'Element inside diagram editor state must be a diagram',
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
get renderer(): DiagramRenderer {
|
|
208
|
-
return guaranteeNonNullable(
|
|
209
|
-
this._renderer,
|
|
210
|
-
`Diagram renderer must be initialized (this is likely caused by calling this method at the wrong place)`,
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
get isDiagramRendererInitialized(): boolean {
|
|
215
|
-
return Boolean(this._renderer);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// NOTE: we have tried to use React to control the cursor and
|
|
219
|
-
// could not overcome the jank/lag problem, so we settle with CSS-based approach
|
|
220
|
-
// See https://css-tricks.com/using-css-cursors/
|
|
221
|
-
// See https://developer.mozilla.org/en-US/docs/Web/CSS/cursor
|
|
222
|
-
get diagramCursorClass(): string {
|
|
223
|
-
if (!this.isDiagramRendererInitialized) {
|
|
224
|
-
return '';
|
|
225
|
-
}
|
|
226
|
-
if (this.renderer.middleClick || this.renderer.rightClick) {
|
|
227
|
-
return 'diagram-editor__cursor--grabbing';
|
|
228
|
-
}
|
|
229
|
-
switch (this.renderer.interactionMode) {
|
|
230
|
-
case DIAGRAM_INTERACTION_MODE.ADD_CLASS: {
|
|
231
|
-
return !this.isReadOnly ? 'diagram-editor__cursor--add' : '';
|
|
232
|
-
}
|
|
233
|
-
case DIAGRAM_INTERACTION_MODE.PAN: {
|
|
234
|
-
return this.renderer.leftClick
|
|
235
|
-
? 'diagram-editor__cursor--grabbing'
|
|
236
|
-
: 'diagram-editor__cursor--grab';
|
|
237
|
-
}
|
|
238
|
-
case DIAGRAM_INTERACTION_MODE.ZOOM_IN: {
|
|
239
|
-
return 'diagram-editor__cursor--zoom-in';
|
|
240
|
-
}
|
|
241
|
-
case DIAGRAM_INTERACTION_MODE.ZOOM_OUT: {
|
|
242
|
-
return 'diagram-editor__cursor--zoom-out';
|
|
243
|
-
}
|
|
244
|
-
case DIAGRAM_INTERACTION_MODE.ADD_RELATIONSHIP: {
|
|
245
|
-
if (this.isReadOnly) {
|
|
246
|
-
return '';
|
|
247
|
-
}
|
|
248
|
-
if (this.renderer.mouseOverClassView && this.renderer.selectionStart) {
|
|
249
|
-
return 'diagram-editor__cursor--add';
|
|
250
|
-
}
|
|
251
|
-
return 'diagram-editor__cursor--crosshair';
|
|
252
|
-
}
|
|
253
|
-
case DIAGRAM_INTERACTION_MODE.LAYOUT: {
|
|
254
|
-
if (this.renderer.selectionStart) {
|
|
255
|
-
return 'diagram-editor__cursor--crosshair';
|
|
256
|
-
} else if (
|
|
257
|
-
this.renderer.mouseOverClassCorner ||
|
|
258
|
-
this.renderer.selectedClassCorner
|
|
259
|
-
) {
|
|
260
|
-
return 'diagram-editor__cursor--resize';
|
|
261
|
-
} else if (this.renderer.mouseOverClassProperty) {
|
|
262
|
-
return this.isReadOnly ||
|
|
263
|
-
isElementReadOnly(this.renderer.mouseOverClassProperty._OWNER)
|
|
264
|
-
? 'diagram-editor__cursor--not-allowed'
|
|
265
|
-
: 'diagram-editor__cursor--text';
|
|
266
|
-
} else if (this.renderer.mouseOverPropertyHolderViewLabel) {
|
|
267
|
-
return this.isReadOnly ||
|
|
268
|
-
isElementReadOnly(
|
|
269
|
-
this.renderer.mouseOverPropertyHolderViewLabel.property.value
|
|
270
|
-
._OWNER,
|
|
271
|
-
)
|
|
272
|
-
? 'diagram-editor__cursor--not-allowed'
|
|
273
|
-
: 'diagram-editor__cursor--text';
|
|
274
|
-
} else if (this.renderer.mouseOverClassName) {
|
|
275
|
-
return this.isReadOnly ||
|
|
276
|
-
isElementReadOnly(this.renderer.mouseOverClassName.class.value)
|
|
277
|
-
? 'diagram-editor__cursor--not-allowed'
|
|
278
|
-
: 'diagram-editor__cursor--text';
|
|
279
|
-
} else if (this.renderer.mouseOverClassView) {
|
|
280
|
-
return 'diagram-editor__cursor--pointer';
|
|
281
|
-
}
|
|
282
|
-
return '';
|
|
283
|
-
}
|
|
284
|
-
default:
|
|
285
|
-
return '';
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
setRenderer(val: DiagramRenderer): void {
|
|
290
|
-
this._renderer = val;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
setShowHotkeyInfosModal(val: boolean): void {
|
|
294
|
-
this.showHotkeyInfosModal = val;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
setSidePanelState(val: DiagramEditorSidePanelState | undefined): void {
|
|
298
|
-
this.sidePanelState = val;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
setInlinePropertyEditorState(
|
|
302
|
-
val: DiagramEditorInlinePropertyEditorState | undefined,
|
|
303
|
-
): void {
|
|
304
|
-
this.inlinePropertyEditorState = val;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
setInlineClassRenamerState(
|
|
308
|
-
val: DiagramEditorInlineClassRenamerState | undefined,
|
|
309
|
-
): void {
|
|
310
|
-
this.inlineClassRenamerState = val;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
setInlineClassCreatorState(
|
|
314
|
-
val: DiagramEditorInlineClassCreatorState | undefined,
|
|
315
|
-
): void {
|
|
316
|
-
this.inlineClassCreatorState = val;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
setShowContextMenu(val: boolean): void {
|
|
320
|
-
this.showContextMenu = val;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
setContextMenuClassView(val: ClassView | undefined): void {
|
|
324
|
-
this.contextMenuClassView = val;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
closeContextMenu(): void {
|
|
328
|
-
this.setShowContextMenu(false);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
setupRenderer(): void {
|
|
332
|
-
this.renderer.setIsReadOnly(this.isReadOnly);
|
|
333
|
-
const handleEditClassView = (classView: ClassView): void => {
|
|
334
|
-
this.setSidePanelState(
|
|
335
|
-
new DiagramEditorClassViewEditorSidePanelState(
|
|
336
|
-
this.editorStore,
|
|
337
|
-
this,
|
|
338
|
-
classView,
|
|
339
|
-
),
|
|
340
|
-
);
|
|
341
|
-
this.sidePanelDisplayState.open();
|
|
342
|
-
};
|
|
343
|
-
this.renderer.onClassViewDoubleClick = handleEditClassView;
|
|
344
|
-
this.renderer.handleEditClassView = handleEditClassView;
|
|
345
|
-
const createNewClassView = (point: Point): void => {
|
|
346
|
-
if (!this.isReadOnly) {
|
|
347
|
-
this.setInlineClassCreatorState(
|
|
348
|
-
new DiagramEditorInlineClassCreatorState(this, point),
|
|
349
|
-
);
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
this.renderer.onBackgroundDoubleClick = createNewClassView;
|
|
353
|
-
this.renderer.onAddClassViewClick = createNewClassView;
|
|
354
|
-
this.renderer.onClassViewRightClick = (
|
|
355
|
-
classView: ClassView,
|
|
356
|
-
point: Point,
|
|
357
|
-
): void => {
|
|
358
|
-
this.setShowContextMenu(true);
|
|
359
|
-
this.setContextMenuClassView(classView);
|
|
360
|
-
};
|
|
361
|
-
this.renderer.onClassNameDoubleClick = (
|
|
362
|
-
classView: ClassView,
|
|
363
|
-
point: Point,
|
|
364
|
-
): void => {
|
|
365
|
-
if (!this.isReadOnly && !isElementReadOnly(classView.class.value)) {
|
|
366
|
-
this.setInlineClassRenamerState(
|
|
367
|
-
new DiagramEditorInlineClassRenamerState(this, classView, point),
|
|
368
|
-
);
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
const editProperty = (
|
|
372
|
-
property: AbstractProperty,
|
|
373
|
-
point: Point,
|
|
374
|
-
propertyHolderView: PropertyHolderView | undefined,
|
|
375
|
-
): void => {
|
|
376
|
-
if (!this.isReadOnly && !isElementReadOnly(property._OWNER)) {
|
|
377
|
-
this.setInlinePropertyEditorState(
|
|
378
|
-
new DiagramEditorInlinePropertyEditorState(
|
|
379
|
-
this,
|
|
380
|
-
property,
|
|
381
|
-
point,
|
|
382
|
-
Boolean(propertyHolderView),
|
|
383
|
-
),
|
|
384
|
-
);
|
|
385
|
-
}
|
|
386
|
-
};
|
|
387
|
-
this.renderer.onClassPropertyDoubleClick = editProperty;
|
|
388
|
-
this.renderer.handleEditProperty = editProperty;
|
|
389
|
-
this.renderer.handleAddSimpleProperty = (classView: ClassView): void => {
|
|
390
|
-
if (!this.isReadOnly && !isElementReadOnly(classView.class.value)) {
|
|
391
|
-
const _class = classView.class.value;
|
|
392
|
-
class_addProperty(
|
|
393
|
-
_class,
|
|
394
|
-
new Property(
|
|
395
|
-
`property_${_class.properties.length + 1}`,
|
|
396
|
-
Multiplicity.ONE,
|
|
397
|
-
GenericTypeExplicitReference.create(
|
|
398
|
-
new GenericType(PrimitiveType.STRING),
|
|
399
|
-
),
|
|
400
|
-
_class,
|
|
401
|
-
),
|
|
402
|
-
);
|
|
403
|
-
this.renderer.render();
|
|
404
|
-
}
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
registerCommands(): void {
|
|
409
|
-
const DEFAULT_TRIGGER = (): boolean =>
|
|
410
|
-
// make sure the current active editor is this diagram editor
|
|
411
|
-
this.editorStore.tabManagerState.currentTab === this &&
|
|
412
|
-
// make sure the renderer is initialized
|
|
413
|
-
this.isDiagramRendererInitialized &&
|
|
414
|
-
// since we use hotkeys that can be easily in text input
|
|
415
|
-
// we would need to do this check to make sure we don't accidentally
|
|
416
|
-
// trigger hotkeys when the user is typing
|
|
417
|
-
(!document.activeElement ||
|
|
418
|
-
!['input', 'textarea', 'select'].includes(
|
|
419
|
-
document.activeElement.tagName.toLowerCase(),
|
|
420
|
-
));
|
|
421
|
-
this.editorStore.applicationStore.commandService.registerCommand({
|
|
422
|
-
key: DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.RECENTER,
|
|
423
|
-
trigger: this.editorStore.createEditorCommandTrigger(DEFAULT_TRIGGER),
|
|
424
|
-
action: () => this.renderer.recenter(),
|
|
425
|
-
});
|
|
426
|
-
this.editorStore.applicationStore.commandService.registerCommand({
|
|
427
|
-
key: DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.USE_ZOOM_TOOL,
|
|
428
|
-
trigger: this.editorStore.createEditorCommandTrigger(DEFAULT_TRIGGER),
|
|
429
|
-
action: () => this.renderer.switchToZoomMode(),
|
|
430
|
-
});
|
|
431
|
-
this.editorStore.applicationStore.commandService.registerCommand({
|
|
432
|
-
key: DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.USE_VIEW_TOOL,
|
|
433
|
-
trigger: this.editorStore.createEditorCommandTrigger(DEFAULT_TRIGGER),
|
|
434
|
-
action: () => this.renderer.switchToViewMode(),
|
|
435
|
-
});
|
|
436
|
-
this.editorStore.applicationStore.commandService.registerCommand({
|
|
437
|
-
key: DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.USE_PAN_TOOL,
|
|
438
|
-
trigger: this.editorStore.createEditorCommandTrigger(DEFAULT_TRIGGER),
|
|
439
|
-
action: () => this.renderer.switchToPanMode(),
|
|
440
|
-
});
|
|
441
|
-
this.editorStore.applicationStore.commandService.registerCommand({
|
|
442
|
-
key: DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.USE_PROPERTY_TOOL,
|
|
443
|
-
trigger: this.editorStore.createEditorCommandTrigger(DEFAULT_TRIGGER),
|
|
444
|
-
action: () => this.renderer.switchToAddPropertyMode(),
|
|
445
|
-
});
|
|
446
|
-
this.editorStore.applicationStore.commandService.registerCommand({
|
|
447
|
-
key: DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.USE_INHERITANCE_TOOL,
|
|
448
|
-
trigger: this.editorStore.createEditorCommandTrigger(DEFAULT_TRIGGER),
|
|
449
|
-
action: () => this.renderer.switchToAddInheritanceMode(),
|
|
450
|
-
});
|
|
451
|
-
this.editorStore.applicationStore.commandService.registerCommand({
|
|
452
|
-
key: DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.ADD_CLASS,
|
|
453
|
-
trigger: this.editorStore.createEditorCommandTrigger(DEFAULT_TRIGGER),
|
|
454
|
-
action: () => this.renderer.switchToAddClassMode(),
|
|
455
|
-
});
|
|
456
|
-
this.editorStore.applicationStore.commandService.registerCommand({
|
|
457
|
-
key: DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.EJECT_PROPERTY,
|
|
458
|
-
trigger: this.editorStore.createEditorCommandTrigger(DEFAULT_TRIGGER),
|
|
459
|
-
action: () => this.renderer.ejectProperty(),
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
deregisterCommands(): void {
|
|
464
|
-
[
|
|
465
|
-
DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.RECENTER,
|
|
466
|
-
DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.USE_ZOOM_TOOL,
|
|
467
|
-
DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.USE_VIEW_TOOL,
|
|
468
|
-
DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.USE_PAN_TOOL,
|
|
469
|
-
DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.USE_PROPERTY_TOOL,
|
|
470
|
-
DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.USE_INHERITANCE_TOOL,
|
|
471
|
-
DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.ADD_CLASS,
|
|
472
|
-
DSL_DIAGRAM_LEGEND_STUDIO_COMMAND_KEY.EJECT_PROPERTY,
|
|
473
|
-
].forEach((commandKey) =>
|
|
474
|
-
this.editorStore.applicationStore.commandService.deregisterCommand(
|
|
475
|
-
commandKey,
|
|
476
|
-
),
|
|
477
|
-
);
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
reprocess(
|
|
481
|
-
newElement: PackageableElement,
|
|
482
|
-
editorStore: EditorStore,
|
|
483
|
-
): ElementEditorState {
|
|
484
|
-
const diagramEditorState = new DiagramEditorState(editorStore, newElement);
|
|
485
|
-
return diagramEditorState;
|
|
486
|
-
}
|
|
487
|
-
}
|