@finos/legend-extension-dsl-diagram 8.1.194 → 8.1.196

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.
Files changed (95) hide show
  1. package/lib/components/DiagramRenderer.d.ts +39 -2
  2. package/lib/components/DiagramRenderer.d.ts.map +1 -1
  3. package/lib/components/DiagramRenderer.js +83 -61
  4. package/lib/components/DiagramRenderer.js.map +1 -1
  5. package/lib/components/DiagramViewer.d.ts +39 -0
  6. package/lib/components/DiagramViewer.d.ts.map +1 -0
  7. package/lib/components/DiagramViewer.js +170 -0
  8. package/lib/components/DiagramViewer.js.map +1 -0
  9. package/lib/components/DiagramViewerState.d.ts +44 -0
  10. package/lib/components/DiagramViewerState.d.ts.map +1 -0
  11. package/lib/components/DiagramViewerState.js +136 -0
  12. package/lib/components/DiagramViewerState.js.map +1 -0
  13. package/lib/components/index.d.ts +4 -1
  14. package/lib/components/index.d.ts.map +1 -1
  15. package/lib/components/index.js +4 -1
  16. package/lib/components/index.js.map +1 -1
  17. package/lib/graph-manager/index.d.ts +3 -0
  18. package/lib/graph-manager/index.d.ts.map +1 -1
  19. package/lib/graph-manager/index.js +3 -0
  20. package/lib/graph-manager/index.js.map +1 -1
  21. package/lib/index.css +2 -2
  22. package/lib/index.css.map +1 -1
  23. package/lib/index.d.ts +0 -1
  24. package/lib/index.d.ts.map +1 -1
  25. package/lib/index.js +0 -1
  26. package/lib/index.js.map +1 -1
  27. package/lib/package.json +1 -2
  28. package/package.json +3 -4
  29. package/src/components/DiagramRenderer.ts +221 -103
  30. package/src/components/DiagramViewer.tsx +650 -0
  31. package/src/components/DiagramViewerState.ts +171 -0
  32. package/src/components/index.ts +4 -0
  33. package/src/graph-manager/index.ts +3 -0
  34. package/src/index.ts +0 -1
  35. package/tsconfig.json +2 -12
  36. package/lib/__lib__/studio/DSL_Diagram_LegendStudioApplicationNavigationContext.d.ts +0 -19
  37. package/lib/__lib__/studio/DSL_Diagram_LegendStudioApplicationNavigationContext.d.ts.map +0 -1
  38. package/lib/__lib__/studio/DSL_Diagram_LegendStudioApplicationNavigationContext.js +0 -20
  39. package/lib/__lib__/studio/DSL_Diagram_LegendStudioApplicationNavigationContext.js.map +0 -1
  40. package/lib/__lib__/studio/DSL_Diagram_LegendStudioCodeSnippet.d.ts +0 -20
  41. package/lib/__lib__/studio/DSL_Diagram_LegendStudioCodeSnippet.d.ts.map +0 -1
  42. package/lib/__lib__/studio/DSL_Diagram_LegendStudioCodeSnippet.js +0 -81
  43. package/lib/__lib__/studio/DSL_Diagram_LegendStudioCodeSnippet.js.map +0 -1
  44. package/lib/__lib__/studio/DSL_Diagram_LegendStudioCommand.d.ts +0 -28
  45. package/lib/__lib__/studio/DSL_Diagram_LegendStudioCommand.d.ts.map +0 -1
  46. package/lib/__lib__/studio/DSL_Diagram_LegendStudioCommand.js +0 -62
  47. package/lib/__lib__/studio/DSL_Diagram_LegendStudioCommand.js.map +0 -1
  48. package/lib/__lib__/studio/DSL_Diagram_LegendStudioDocumentation.d.ts +0 -20
  49. package/lib/__lib__/studio/DSL_Diagram_LegendStudioDocumentation.d.ts.map +0 -1
  50. package/lib/__lib__/studio/DSL_Diagram_LegendStudioDocumentation.js +0 -21
  51. package/lib/__lib__/studio/DSL_Diagram_LegendStudioDocumentation.js.map +0 -1
  52. package/lib/__lib__/studio/DSL_Diagram_LegendStudioTesting.d.ts +0 -20
  53. package/lib/__lib__/studio/DSL_Diagram_LegendStudioTesting.d.ts.map +0 -1
  54. package/lib/__lib__/studio/DSL_Diagram_LegendStudioTesting.js +0 -21
  55. package/lib/__lib__/studio/DSL_Diagram_LegendStudioTesting.js.map +0 -1
  56. package/lib/components/studio/ClassDiagramPreview.d.ts +0 -22
  57. package/lib/components/studio/ClassDiagramPreview.d.ts.map +0 -1
  58. package/lib/components/studio/ClassDiagramPreview.js +0 -64
  59. package/lib/components/studio/ClassDiagramPreview.js.map +0 -1
  60. package/lib/components/studio/DSL_Diagram_LegendStudioApplicationPlugin.d.ts +0 -42
  61. package/lib/components/studio/DSL_Diagram_LegendStudioApplicationPlugin.d.ts.map +0 -1
  62. package/lib/components/studio/DSL_Diagram_LegendStudioApplicationPlugin.js +0 -216
  63. package/lib/components/studio/DSL_Diagram_LegendStudioApplicationPlugin.js.map +0 -1
  64. package/lib/components/studio/DiagramEditor.d.ts +0 -19
  65. package/lib/components/studio/DiagramEditor.d.ts.map +0 -1
  66. package/lib/components/studio/DiagramEditor.js +0 -436
  67. package/lib/components/studio/DiagramEditor.js.map +0 -1
  68. package/lib/components/studio/InheritanceDiagramRenderer.d.ts +0 -22
  69. package/lib/components/studio/InheritanceDiagramRenderer.d.ts.map +0 -1
  70. package/lib/components/studio/InheritanceDiagramRenderer.js +0 -34
  71. package/lib/components/studio/InheritanceDiagramRenderer.js.map +0 -1
  72. package/lib/components/studio/index.d.ts +0 -18
  73. package/lib/components/studio/index.d.ts.map +0 -1
  74. package/lib/components/studio/index.js +0 -18
  75. package/lib/components/studio/index.js.map +0 -1
  76. package/lib/stores/studio/DSL_Diagram_GraphModifierHelper.d.ts +0 -57
  77. package/lib/stores/studio/DSL_Diagram_GraphModifierHelper.d.ts.map +0 -1
  78. package/lib/stores/studio/DSL_Diagram_GraphModifierHelper.js +0 -94
  79. package/lib/stores/studio/DSL_Diagram_GraphModifierHelper.js.map +0 -1
  80. package/lib/stores/studio/DiagramEditorState.d.ts +0 -88
  81. package/lib/stores/studio/DiagramEditorState.d.ts.map +0 -1
  82. package/lib/stores/studio/DiagramEditorState.js +0 -341
  83. package/lib/stores/studio/DiagramEditorState.js.map +0 -1
  84. package/src/__lib__/studio/DSL_Diagram_LegendStudioApplicationNavigationContext.ts +0 -19
  85. package/src/__lib__/studio/DSL_Diagram_LegendStudioCodeSnippet.ts +0 -88
  86. package/src/__lib__/studio/DSL_Diagram_LegendStudioCommand.ts +0 -64
  87. package/src/__lib__/studio/DSL_Diagram_LegendStudioDocumentation.ts +0 -20
  88. package/src/__lib__/studio/DSL_Diagram_LegendStudioTesting.ts +0 -20
  89. package/src/components/studio/ClassDiagramPreview.tsx +0 -83
  90. package/src/components/studio/DSL_Diagram_LegendStudioApplicationPlugin.tsx +0 -313
  91. package/src/components/studio/DiagramEditor.tsx +0 -1514
  92. package/src/components/studio/InheritanceDiagramRenderer.ts +0 -50
  93. package/src/components/studio/index.ts +0 -19
  94. package/src/stores/studio/DSL_Diagram_GraphModifierHelper.ts +0 -166
  95. package/src/stores/studio/DiagramEditorState.ts +0 -487
@@ -25,6 +25,7 @@ import {
25
25
  } from '@finos/legend-shared';
26
26
  import {
27
27
  type AbstractProperty,
28
+ type GenericTypeReference,
28
29
  Class,
29
30
  Enumeration,
30
31
  PrimitiveType,
@@ -60,35 +61,114 @@ import {
60
61
  rotatePointY,
61
62
  } from '../graph/helpers/DSL_Diagram_Helper.js';
62
63
  import { AssociationView } from '../graph/metamodel/pure/packageableElements/diagram/DSL_Diagram_AssociationView.js';
63
- import {
64
- class_addProperty,
65
- class_addSuperType,
66
- } from '@finos/legend-application-studio';
67
- import {
68
- classView_setHideProperties,
69
- classView_setHideStereotypes,
70
- classView_setHideTaggedValues,
71
- diagram_addClassView,
72
- diagram_addGeneralizationView,
73
- diagram_addPropertyView,
74
- diagram_deleteAssociationView,
75
- diagram_deleteClassView,
76
- diagram_deleteGeneralizationView,
77
- diagram_deletePropertyView,
78
- diagram_setAssociationViews,
79
- diagram_setClassViews,
80
- diagram_setGeneralizationViews,
81
- diagram_setPropertyViews,
82
- findOrBuildPoint,
83
- positionedRectangle_forceRefreshHash,
84
- positionedRectangle_setPosition,
85
- positionedRectangle_setRectangle,
86
- relationshipEdgeView_setOffsetX,
87
- relationshipEdgeView_setOffsetY,
88
- relationshipView_changePoint,
89
- relationshipView_simplifyPath,
90
- relationshipView_setPath,
91
- } from '../stores/studio/DSL_Diagram_GraphModifierHelper.js';
64
+ import type { RelationshipViewEnd } from '../graph-manager/index.js';
65
+
66
+ export class DiagramAnalysisResult {
67
+ readonly uuid = uuid();
68
+ title!: string;
69
+ description?: string | undefined;
70
+ diagram!: Diagram;
71
+ }
72
+
73
+ export interface DiagramRendererCallbacks {
74
+ // Domain mutations (from legend-application-studio)
75
+ onClass_addSuperType?: (
76
+ subclass: Class,
77
+ superType: GenericTypeReference,
78
+ ) => void;
79
+ onClass_addProperty?: (ownerClass: Class, property: Property) => void;
80
+
81
+ // Diagram mutations - ClassView
82
+ onDiagram_setClassViews?: (diagram: Diagram, classViews: ClassView[]) => void;
83
+ onDiagram_addClassView?: (diagram: Diagram, classView: ClassView) => void;
84
+ onDiagram_deleteClassView?: (diagram: Diagram, classView: ClassView) => void;
85
+
86
+ // Diagram mutations - AssociationView
87
+ onDiagram_setAssociationViews?: (
88
+ diagram: Diagram,
89
+ associationViews: AssociationView[],
90
+ ) => void;
91
+ onDiagram_deleteAssociationView?: (
92
+ diagram: Diagram,
93
+ associationView: AssociationView,
94
+ ) => void;
95
+
96
+ // Diagram mutations - GeneralizationView
97
+ onDiagram_setGeneralizationViews?: (
98
+ diagram: Diagram,
99
+ generalizationViews: GeneralizationView[],
100
+ ) => void;
101
+ onDiagram_addGeneralizationView?: (
102
+ diagram: Diagram,
103
+ view: GeneralizationView,
104
+ ) => void;
105
+ onDiagram_deleteGeneralizationView?: (
106
+ diagram: Diagram,
107
+ view: GeneralizationView,
108
+ ) => void;
109
+
110
+ // Diagram mutations - PropertyView
111
+ onDiagram_setPropertyViews?: (
112
+ diagram: Diagram,
113
+ propertyViews: PropertyView[],
114
+ ) => void;
115
+ onDiagram_addPropertyView?: (diagram: Diagram, view: PropertyView) => void;
116
+ onDiagram_deletePropertyView?: (diagram: Diagram, view: PropertyView) => void;
117
+
118
+ // ClassView display mutations
119
+ onClassView_setHideProperties?: (classView: ClassView, hide: boolean) => void;
120
+ onClassView_setHideStereotypes?: (
121
+ classView: ClassView,
122
+ hide: boolean,
123
+ ) => void;
124
+ onClassView_setHideTaggedValues?: (
125
+ classView: ClassView,
126
+ hide: boolean,
127
+ ) => void;
128
+
129
+ // RelationshipViewEnd mutations
130
+ onRelationshipEdgeView_setOffsetX?: (
131
+ edge: RelationshipViewEnd,
132
+ offsetX: number,
133
+ ) => void;
134
+ onRelationshipEdgeView_setOffsetY?: (
135
+ edge: RelationshipViewEnd,
136
+ offsetY: number,
137
+ ) => void;
138
+
139
+ // RelationshipView path mutations
140
+ onRelationshipView_changePoint?: (
141
+ relationship: RelationshipView,
142
+ oldPoint: Point,
143
+ newPoint: Point,
144
+ ) => void;
145
+ onRelationshipView_simplifyPath?: (relationship: RelationshipView) => void;
146
+ onRelationshipView_setPath?: (
147
+ relationship: RelationshipView,
148
+ path: Point[],
149
+ ) => void;
150
+
151
+ // PositionedRectangle mutations
152
+ onPositionedRectangle_setRectangle?: (
153
+ classView: ClassView,
154
+ rectangle: Rectangle,
155
+ ) => void;
156
+ onPositionedRectangle_setPosition?: (
157
+ classView: ClassView,
158
+ position: Point,
159
+ ) => void;
160
+ onPositionedRectangle_forceRefreshHash?: (
161
+ positionedRectangle: PositionedRectangle,
162
+ ) => void;
163
+
164
+ onFindOrBuildPoint?: (
165
+ relationship: RelationshipView,
166
+ x: number,
167
+ y: number,
168
+ zoom: number,
169
+ editable: boolean,
170
+ ) => Point | undefined;
171
+ }
92
172
 
93
173
  export enum DIAGRAM_INTERACTION_MODE {
94
174
  LAYOUT,
@@ -262,6 +342,7 @@ export class DiagramRenderer {
262
342
  mouseOverClassProperty?: AbstractProperty | undefined;
263
343
  mouseOverPropertyHolderViewLabel?: PropertyHolderView | undefined;
264
344
  cursorPosition: Point;
345
+ callbacks?: DiagramRendererCallbacks | undefined;
265
346
 
266
347
  leftClick: boolean;
267
348
  middleClick: boolean;
@@ -297,7 +378,11 @@ export class DiagramRenderer {
297
378
  ) => void = noop();
298
379
  handleAddSimpleProperty: (classView: ClassView) => void = noop();
299
380
 
300
- constructor(div: HTMLDivElement, diagram: Diagram) {
381
+ constructor(
382
+ div: HTMLDivElement,
383
+ diagram: Diagram,
384
+ callbacks?: DiagramRendererCallbacks,
385
+ ) {
301
386
  makeObservable(this, {
302
387
  isReadOnly: observable,
303
388
  enableLayoutAutoAdjustment: observable,
@@ -338,6 +423,7 @@ export class DiagramRenderer {
338
423
  });
339
424
 
340
425
  this.diagram = diagram;
426
+ this.callbacks = callbacks;
341
427
 
342
428
  // Container and canvas
343
429
  this.div = div;
@@ -655,7 +741,7 @@ export class DiagramRenderer {
655
741
  startClassView.class.value,
656
742
  )
657
743
  ) {
658
- class_addSuperType(
744
+ this.callbacks?.onClass_addSuperType?.(
659
745
  startClassView.class.value,
660
746
  GenericTypeExplicitReference.create(
661
747
  new GenericType(targetClassView.class.value),
@@ -675,7 +761,10 @@ export class DiagramRenderer {
675
761
  startClassView,
676
762
  targetClassView,
677
763
  );
678
- diagram_addGeneralizationView(this.diagram, gview);
764
+ this.callbacks?.onDiagram_addGeneralizationView?.(
765
+ this.diagram,
766
+ gview,
767
+ );
679
768
  return gview;
680
769
  }
681
770
  return undefined;
@@ -695,7 +784,10 @@ export class DiagramRenderer {
695
784
  ),
696
785
  startClassView.class.value,
697
786
  );
698
- class_addProperty(startClassView.class.value, property);
787
+ this.callbacks?.onClass_addProperty?.(
788
+ startClassView.class.value,
789
+ property,
790
+ );
699
791
  // only create property view if the classviews are different
700
792
  // else we end up with a weird rendering where the property view
701
793
  // is not targetable
@@ -706,7 +798,7 @@ export class DiagramRenderer {
706
798
  startClassView,
707
799
  targetClassView,
708
800
  );
709
- diagram_addPropertyView(this.diagram, pView);
801
+ this.callbacks?.onDiagram_addPropertyView?.(this.diagram, pView);
710
802
  return pView;
711
803
  }
712
804
  return undefined;
@@ -731,12 +823,12 @@ export class DiagramRenderer {
731
823
  (val, view) => Math.min(val, view.position.x),
732
824
  Number.MAX_SAFE_INTEGER,
733
825
  );
734
- this.selectedClasses.forEach((view) =>
735
- positionedRectangle_setPosition(
826
+ this.selectedClasses.forEach((view) => {
827
+ this.callbacks?.onPositionedRectangle_setPosition?.(
736
828
  view,
737
829
  new Point(leftBound, view.position.y),
738
- ),
739
- );
830
+ );
831
+ });
740
832
  break;
741
833
  }
742
834
  case DIAGRAM_ALIGNER_OPERATOR.ALIGN_CENTER: {
@@ -746,39 +838,42 @@ export class DiagramRenderer {
746
838
  0,
747
839
  ) / this.selectedClasses.length;
748
840
  this.selectedClasses.forEach((view) =>
749
- positionedRectangle_setPosition(
841
+ this.callbacks?.onPositionedRectangle_setPosition?.(
750
842
  view,
751
843
  new Point(center - view.rectangle.width / 2, view.position.y),
752
844
  ),
753
845
  );
754
846
  break;
755
847
  }
848
+
756
849
  case DIAGRAM_ALIGNER_OPERATOR.ALIGN_RIGHT: {
757
850
  const rightBound = this.selectedClasses.reduce(
758
851
  (val, view) => Math.max(val, view.position.x + view.rectangle.width),
759
852
  -Number.MAX_SAFE_INTEGER,
760
853
  );
761
854
  this.selectedClasses.forEach((view) =>
762
- positionedRectangle_setPosition(
855
+ this.callbacks?.onPositionedRectangle_setPosition?.(
763
856
  view,
764
857
  new Point(rightBound - view.rectangle.width, view.position.y),
765
858
  ),
766
859
  );
767
860
  break;
768
861
  }
862
+
769
863
  case DIAGRAM_ALIGNER_OPERATOR.ALIGN_TOP: {
770
864
  const topBound = this.selectedClasses.reduce(
771
865
  (val, view) => Math.min(val, view.position.y),
772
866
  Number.MAX_SAFE_INTEGER,
773
867
  );
774
868
  this.selectedClasses.forEach((view) =>
775
- positionedRectangle_setPosition(
869
+ this.callbacks?.onPositionedRectangle_setPosition?.(
776
870
  view,
777
871
  new Point(view.position.x, topBound),
778
872
  ),
779
873
  );
780
874
  break;
781
875
  }
876
+
782
877
  case DIAGRAM_ALIGNER_OPERATOR.ALIGN_MIDDLE: {
783
878
  const middle =
784
879
  this.selectedClasses.reduce(
@@ -786,26 +881,28 @@ export class DiagramRenderer {
786
881
  0,
787
882
  ) / this.selectedClasses.length;
788
883
  this.selectedClasses.forEach((view) =>
789
- positionedRectangle_setPosition(
884
+ this.callbacks?.onPositionedRectangle_setPosition?.(
790
885
  view,
791
886
  new Point(view.position.x, middle - view.rectangle.height / 2),
792
887
  ),
793
888
  );
794
889
  break;
795
890
  }
891
+
796
892
  case DIAGRAM_ALIGNER_OPERATOR.ALIGN_BOTTOM: {
797
893
  const bottomBound = this.selectedClasses.reduce(
798
894
  (val, view) => Math.max(val, view.position.y + view.rectangle.height),
799
895
  -Number.MAX_SAFE_INTEGER,
800
896
  );
801
897
  this.selectedClasses.forEach((view) =>
802
- positionedRectangle_setPosition(
898
+ this.callbacks?.onPositionedRectangle_setPosition?.(
803
899
  view,
804
900
  new Point(view.position.x, bottomBound - view.rectangle.height),
805
901
  ),
806
902
  );
807
903
  break;
808
904
  }
905
+
809
906
  case DIAGRAM_ALIGNER_OPERATOR.SPACE_HORIZONTALLY: {
810
907
  const sorted = this.selectedClasses.toSorted(
811
908
  (a, b) => a.position.x - b.position.x,
@@ -814,7 +911,7 @@ export class DiagramRenderer {
814
911
  if (sorted.length === 2) {
815
912
  const previousView = sorted[0] as ClassView;
816
913
  const currentView = sorted[1] as ClassView;
817
- positionedRectangle_setPosition(
914
+ this.callbacks?.onPositionedRectangle_setPosition?.(
818
915
  currentView,
819
916
  new Point(
820
917
  previousView.position.x + previousView.rectangle.width,
@@ -837,7 +934,7 @@ export class DiagramRenderer {
837
934
  for (let idx = 1; idx < sorted.length; idx++) {
838
935
  const previousView = sorted[idx - 1] as ClassView;
839
936
  const currentView = sorted[idx] as ClassView;
840
- positionedRectangle_setPosition(
937
+ this.callbacks?.onPositionedRectangle_setPosition?.(
841
938
  currentView,
842
939
  new Point(
843
940
  previousView.position.x +
@@ -858,7 +955,7 @@ export class DiagramRenderer {
858
955
  if (sorted.length === 2) {
859
956
  const previousView = sorted[0] as ClassView;
860
957
  const currentView = sorted[1] as ClassView;
861
- positionedRectangle_setPosition(
958
+ this.callbacks?.onPositionedRectangle_setPosition?.(
862
959
  currentView,
863
960
  new Point(
864
961
  currentView.position.x,
@@ -881,7 +978,7 @@ export class DiagramRenderer {
881
978
  for (let idx = 1; idx < sorted.length; idx++) {
882
979
  const previousView = sorted[idx - 1] as ClassView;
883
980
  const currentView = sorted[idx] as ClassView;
884
- positionedRectangle_setPosition(
981
+ this.callbacks?.onPositionedRectangle_setPosition?.(
885
982
  currentView,
886
983
  new Point(
887
984
  currentView.position.x,
@@ -1128,7 +1225,7 @@ export class DiagramRenderer {
1128
1225
  id,
1129
1226
  PackageableElementExplicitReference.create(addedClass),
1130
1227
  );
1131
- positionedRectangle_setPosition(
1228
+ this.callbacks?.onPositionedRectangle_setPosition?.(
1132
1229
  newClassView,
1133
1230
  classViewModelCoordinate ??
1134
1231
  this.canvasCoordinateToModelCoordinate(
@@ -1140,10 +1237,12 @@ export class DiagramRenderer {
1140
1237
  ),
1141
1238
  ),
1142
1239
  );
1143
- diagram_addClassView(this.diagram, newClassView);
1240
+
1241
+ this.callbacks?.onDiagram_addClassView?.(this.diagram, newClassView);
1144
1242
  // Refresh hash since ClassView position is not observable
1145
1243
  // NOTE: here we refresh after adding the class view to the diagram, that way the diagram hash is refreshed
1146
- positionedRectangle_forceRefreshHash(newClassView);
1244
+
1245
+ this.callbacks?.onPositionedRectangle_forceRefreshHash?.(newClassView);
1147
1246
  this.diagram.classViews
1148
1247
  .filter((classView) => classView.class.value !== addedClass)
1149
1248
  .forEach((classView) => {
@@ -1154,7 +1253,7 @@ export class DiagramRenderer {
1154
1253
  .map((generalization) => generalization.value.rawType)
1155
1254
  .includes(_class)
1156
1255
  ) {
1157
- diagram_addGeneralizationView(
1256
+ this.callbacks?.onDiagram_addGeneralizationView?.(
1158
1257
  this.diagram,
1159
1258
  new GeneralizationView(this.diagram, newClassView, classView),
1160
1259
  );
@@ -1164,16 +1263,15 @@ export class DiagramRenderer {
1164
1263
  .map((generalization) => generalization.value.rawType)
1165
1264
  .includes(addedClass)
1166
1265
  ) {
1167
- diagram_addGeneralizationView(
1266
+ this.callbacks?.onDiagram_addGeneralizationView?.(
1168
1267
  this.diagram,
1169
-
1170
1268
  new GeneralizationView(this.diagram, classView, newClassView),
1171
1269
  );
1172
1270
  }
1173
1271
  // Add property view
1174
1272
  getAllOwnClassProperties(addedClass).forEach((property) => {
1175
1273
  if (property.genericType.value.rawType === _class) {
1176
- diagram_addPropertyView(
1274
+ this.callbacks?.onDiagram_addPropertyView?.(
1177
1275
  this.diagram,
1178
1276
 
1179
1277
  new PropertyView(
@@ -1187,7 +1285,7 @@ export class DiagramRenderer {
1187
1285
  });
1188
1286
  getAllOwnClassProperties(_class).forEach((property) => {
1189
1287
  if (property.genericType.value.rawType === addedClass) {
1190
- diagram_addPropertyView(
1288
+ this.callbacks?.onDiagram_addPropertyView?.(
1191
1289
  this.diagram,
1192
1290
  new PropertyView(
1193
1291
  this.diagram,
@@ -1727,7 +1825,10 @@ export class DiagramRenderer {
1727
1825
  classView.rectangle.height > classMinHeight
1728
1826
  ? classView.rectangle.height
1729
1827
  : classMinHeight;
1730
- positionedRectangle_setRectangle(classView, new Rectangle(width, height));
1828
+ this.callbacks?.onPositionedRectangle_setRectangle?.(
1829
+ classView,
1830
+ new Rectangle(width, height),
1831
+ );
1731
1832
  }
1732
1833
  }
1733
1834
 
@@ -1905,7 +2006,7 @@ export class DiagramRenderer {
1905
2006
  // NOTE: force hash reload when we redraw class view; this would help with cases where
1906
2007
  // we auto add new properties to the class view, causing the box to expand, hence we need
1907
2008
  // to recompute hash
1908
- positionedRectangle_forceRefreshHash(classView);
2009
+ this.callbacks?.onPositionedRectangle_forceRefreshHash?.(classView);
1909
2010
  }
1910
2011
 
1911
2012
  private drawLinePropertyNameAndMultiplicity(
@@ -2425,7 +2526,7 @@ export class DiagramRenderer {
2425
2526
  selectedClasses.indexOf(view.from.classView.value) !== -1 &&
2426
2527
  selectedClasses.indexOf(view.to.classView.value) !== -1
2427
2528
  ) {
2428
- relationshipView_setPath(
2529
+ this.callbacks?.onRelationshipView_setPath?.(
2429
2530
  view,
2430
2531
  view.path.map(
2431
2532
  (point) =>
@@ -2633,14 +2734,14 @@ export class DiagramRenderer {
2633
2734
 
2634
2735
  // Set layout of current level
2635
2736
  if (positionInitialClass || currentLevelIndex > 0) {
2636
- positionedRectangle_setPosition(
2737
+ this.callbacks?.onPositionedRectangle_setPosition?.(
2637
2738
  levels[0] as ClassView,
2638
2739
  new Point(startX, currentLevelY),
2639
2740
  );
2640
2741
  levels.forEach((view, idx) => {
2641
2742
  if (idx > 0) {
2642
2743
  const precedent = levels[idx - 1] as ClassView;
2643
- positionedRectangle_setPosition(
2744
+ this.callbacks?.onPositionedRectangle_setPosition?.(
2644
2745
  view,
2645
2746
  new Point(
2646
2747
  precedent.position.x + precedent.rectangle.width + spaceX,
@@ -2652,7 +2753,6 @@ export class DiagramRenderer {
2652
2753
  }
2653
2754
  return levels;
2654
2755
  });
2655
-
2656
2756
  const generalizationViews = (
2657
2757
  superType ? classViewLevels : classViewLevels.slice().reverse()
2658
2758
  )
@@ -2685,10 +2785,9 @@ export class DiagramRenderer {
2685
2785
  if ('Delete' === e.code) {
2686
2786
  if (!this.isReadOnly) {
2687
2787
  this.selectedClasses.forEach((classView) => {
2688
- diagram_deleteClassView(this.diagram, classView);
2689
- diagram_setAssociationViews(
2788
+ this.callbacks?.onDiagram_deleteClassView?.(this.diagram, classView);
2789
+ this.callbacks?.onDiagram_setAssociationViews?.(
2690
2790
  this.diagram,
2691
-
2692
2791
  this.diagram.associationViews.filter(
2693
2792
  (associationView) =>
2694
2793
  !(
@@ -2697,9 +2796,8 @@ export class DiagramRenderer {
2697
2796
  ),
2698
2797
  ),
2699
2798
  );
2700
- diagram_setGeneralizationViews(
2799
+ this.callbacks?.onDiagram_setGeneralizationViews?.(
2701
2800
  this.diagram,
2702
-
2703
2801
  this.diagram.generalizationViews.filter(
2704
2802
  (generalizationView) =>
2705
2803
  !(
@@ -2708,9 +2806,8 @@ export class DiagramRenderer {
2708
2806
  ),
2709
2807
  ),
2710
2808
  );
2711
- diagram_setPropertyViews(
2809
+ this.callbacks?.onDiagram_setPropertyViews?.(
2712
2810
  this.diagram,
2713
-
2714
2811
  this.diagram.propertyViews.filter(
2715
2812
  (propertyView) =>
2716
2813
  !(
@@ -2721,13 +2818,12 @@ export class DiagramRenderer {
2721
2818
  );
2722
2819
  });
2723
2820
  if (this.selectedPropertyOrAssociation instanceof AssociationView) {
2724
- diagram_deleteAssociationView(
2821
+ this.callbacks?.onDiagram_deleteAssociationView?.(
2725
2822
  this.diagram,
2726
-
2727
2823
  this.selectedPropertyOrAssociation,
2728
2824
  );
2729
2825
  } else if (this.selectedPropertyOrAssociation instanceof PropertyView) {
2730
- diagram_deletePropertyView(
2826
+ this.callbacks?.onDiagram_deletePropertyView?.(
2731
2827
  this.diagram,
2732
2828
  this.selectedPropertyOrAssociation,
2733
2829
  );
@@ -2739,7 +2835,7 @@ export class DiagramRenderer {
2739
2835
  generalizationView === this.selectedInheritance,
2740
2836
  )
2741
2837
  ) {
2742
- diagram_deleteGeneralizationView(
2838
+ this.callbacks?.onDiagram_deleteGeneralizationView?.(
2743
2839
  this.diagram,
2744
2840
  this.selectedInheritance,
2745
2841
  );
@@ -2783,7 +2879,10 @@ export class DiagramRenderer {
2783
2879
  if (!this.isReadOnly) {
2784
2880
  if (this.selectedClasses.length !== 0) {
2785
2881
  this.selectedClasses.forEach((classView) => {
2786
- classView_setHideProperties(classView, !classView.hideProperties);
2882
+ this.callbacks?.onClassView_setHideProperties?.(
2883
+ classView,
2884
+ !classView.hideProperties,
2885
+ );
2787
2886
  });
2788
2887
  this.drawScreen();
2789
2888
  }
@@ -2794,7 +2893,10 @@ export class DiagramRenderer {
2794
2893
  if (!this.isReadOnly) {
2795
2894
  if (this.selectedClasses.length !== 0) {
2796
2895
  this.selectedClasses.forEach((classView) => {
2797
- classView_setHideStereotypes(classView, !classView.hideStereotypes);
2896
+ this.callbacks?.onClassView_setHideStereotypes?.(
2897
+ classView,
2898
+ !classView.hideStereotypes,
2899
+ );
2798
2900
  });
2799
2901
  this.drawScreen();
2800
2902
  }
@@ -2805,7 +2907,7 @@ export class DiagramRenderer {
2805
2907
  if (!this.isReadOnly) {
2806
2908
  if (this.selectedClasses.length !== 0) {
2807
2909
  this.selectedClasses.forEach((classView) => {
2808
- classView_setHideTaggedValues(
2910
+ this.callbacks?.onClassView_setHideTaggedValues?.(
2809
2911
  classView,
2810
2912
  !classView.hideTaggedValues,
2811
2913
  );
@@ -2831,8 +2933,13 @@ export class DiagramRenderer {
2831
2933
  1,
2832
2934
  );
2833
2935
  const res = this.layoutTaxonomy(views, this.diagram, false, true);
2834
- res[0].forEach((cv) => diagram_addClassView(this.diagram, cv));
2835
- res[1].forEach((gv) => diagram_addGeneralizationView(this.diagram, gv));
2936
+ res[0].forEach((cv) => {
2937
+ this.callbacks?.onDiagram_addClassView?.(this.diagram, cv);
2938
+ });
2939
+
2940
+ res[1].forEach((gv) => {
2941
+ this.callbacks?.onDiagram_addGeneralizationView?.(this.diagram, gv);
2942
+ });
2836
2943
 
2837
2944
  this.drawScreen();
2838
2945
  }
@@ -2864,8 +2971,12 @@ export class DiagramRenderer {
2864
2971
  false,
2865
2972
  false,
2866
2973
  );
2867
- res[0].forEach((cv) => diagram_addClassView(this.diagram, cv));
2868
- res[1].forEach((gv) => diagram_addGeneralizationView(this.diagram, gv));
2974
+ res[0].forEach((cv) => {
2975
+ this.callbacks?.onDiagram_addClassView?.(this.diagram, cv);
2976
+ });
2977
+ res[1].forEach((gv) => {
2978
+ this.callbacks?.onDiagram_addGeneralizationView?.(this.diagram, gv);
2979
+ });
2869
2980
  }
2870
2981
 
2871
2982
  this.drawScreen();
@@ -2939,15 +3050,17 @@ export class DiagramRenderer {
2939
3050
  if (!this.isReadOnly) {
2940
3051
  switch (this.interactionMode) {
2941
3052
  case DIAGRAM_INTERACTION_MODE.LAYOUT: {
2942
- this.diagram.generalizationViews.forEach((generalizationView) =>
2943
- relationshipView_simplifyPath(generalizationView),
2944
- );
2945
- this.diagram.associationViews.forEach((associationView) =>
2946
- relationshipView_simplifyPath(associationView),
2947
- );
2948
- this.diagram.propertyViews.forEach((propertyView) =>
2949
- relationshipView_simplifyPath(propertyView),
2950
- );
3053
+ this.diagram.generalizationViews.forEach((generalizationView) => {
3054
+ this.callbacks?.onRelationshipView_simplifyPath?.(
3055
+ generalizationView,
3056
+ );
3057
+ });
3058
+ this.diagram.associationViews.forEach((associationView) => {
3059
+ this.callbacks?.onRelationshipView_simplifyPath?.(associationView);
3060
+ });
3061
+ this.diagram.propertyViews.forEach((propertyView) => {
3062
+ this.callbacks?.onRelationshipView_simplifyPath?.(propertyView);
3063
+ });
2951
3064
  break;
2952
3065
  }
2953
3066
  case DIAGRAM_INTERACTION_MODE.ADD_CLASS: {
@@ -2987,7 +3100,7 @@ export class DiagramRenderer {
2987
3100
  );
2988
3101
 
2989
3102
  if (gview) {
2990
- relationshipEdgeView_setOffsetX(
3103
+ this.callbacks?.onRelationshipEdgeView_setOffsetX?.(
2991
3104
  gview.from,
2992
3105
  -(
2993
3106
  this.startClassView.position.x +
@@ -2995,7 +3108,8 @@ export class DiagramRenderer {
2995
3108
  this.selectionStart.x
2996
3109
  ),
2997
3110
  );
2998
- relationshipEdgeView_setOffsetY(
3111
+
3112
+ this.callbacks?.onRelationshipEdgeView_setOffsetY?.(
2999
3113
  gview.from,
3000
3114
  -(
3001
3115
  this.startClassView.position.y +
@@ -3003,7 +3117,7 @@ export class DiagramRenderer {
3003
3117
  this.selectionStart.y
3004
3118
  ),
3005
3119
  );
3006
- relationshipEdgeView_setOffsetX(
3120
+ this.callbacks?.onRelationshipEdgeView_setOffsetX?.(
3007
3121
  gview.to,
3008
3122
  -(
3009
3123
  targetClassView.position.x +
@@ -3011,7 +3125,7 @@ export class DiagramRenderer {
3011
3125
  eventPointInModelCoordinate.x
3012
3126
  ),
3013
3127
  );
3014
- relationshipEdgeView_setOffsetY(
3128
+ this.callbacks?.onRelationshipEdgeView_setOffsetY?.(
3015
3129
  gview.to,
3016
3130
  -(
3017
3131
  targetClassView.position.y +
@@ -3157,7 +3271,7 @@ export class DiagramRenderer {
3157
3271
  this.setSelectedClassCorner(this.diagram.classViews[i]);
3158
3272
  if (!this.isReadOnly) {
3159
3273
  // Bring the class view to front
3160
- diagram_setClassViews(
3274
+ this.callbacks?.onDiagram_setClassViews?.(
3161
3275
  this.diagram,
3162
3276
  this.reorderDiagramDomain(
3163
3277
  guaranteeNonNullable(this.selectedClassCorner),
@@ -3198,7 +3312,7 @@ export class DiagramRenderer {
3198
3312
  }
3199
3313
  if (!this.isReadOnly) {
3200
3314
  // Bring the class view to front
3201
- diagram_setClassViews(
3315
+ this.callbacks?.onDiagram_setClassViews?.(
3202
3316
  this.diagram,
3203
3317
 
3204
3318
  this.reorderDiagramDomain(
@@ -3238,7 +3352,7 @@ export class DiagramRenderer {
3238
3352
  // check for selection of inheritance view
3239
3353
  for (const generalizationView of this.diagram
3240
3354
  .generalizationViews) {
3241
- const val = findOrBuildPoint(
3355
+ const val = this.callbacks?.onFindOrBuildPoint?.(
3242
3356
  generalizationView,
3243
3357
  eventPointInModelCoordinate.x,
3244
3358
  eventPointInModelCoordinate.y,
@@ -3255,7 +3369,7 @@ export class DiagramRenderer {
3255
3369
  // check for selection of association view
3256
3370
  if (!this.selectedPoint) {
3257
3371
  for (const associationView of this.diagram.associationViews) {
3258
- const val = findOrBuildPoint(
3372
+ const val = this.callbacks?.onFindOrBuildPoint?.(
3259
3373
  associationView,
3260
3374
  eventPointInModelCoordinate.x,
3261
3375
  eventPointInModelCoordinate.y,
@@ -3273,7 +3387,7 @@ export class DiagramRenderer {
3273
3387
  // check for selection of property view
3274
3388
  if (!this.selectedPoint) {
3275
3389
  for (const propertyView of this.diagram.propertyViews) {
3276
- const val = findOrBuildPoint(
3390
+ const val = this.callbacks?.onFindOrBuildPoint?.(
3277
3391
  propertyView,
3278
3392
  eventPointInModelCoordinate.x,
3279
3393
  eventPointInModelCoordinate.y,
@@ -3397,7 +3511,7 @@ export class DiagramRenderer {
3397
3511
  // Resize class view
3398
3512
  if (this.selectedClassCorner) {
3399
3513
  // Make sure width and height are in range!
3400
- positionedRectangle_setRectangle(
3514
+ this.callbacks?.onPositionedRectangle_setRectangle?.(
3401
3515
  this.selectedClassCorner,
3402
3516
  new Rectangle(
3403
3517
  eventPointInModelCoordinate.x -
@@ -3407,7 +3521,9 @@ export class DiagramRenderer {
3407
3521
  ),
3408
3522
  );
3409
3523
  // Refresh hash since ClassView rectangle is not observable
3410
- positionedRectangle_forceRefreshHash(this.selectedClassCorner);
3524
+ this.callbacks?.onPositionedRectangle_forceRefreshHash?.(
3525
+ this.selectedClassCorner,
3526
+ );
3411
3527
  this.drawClassView(this.selectedClassCorner);
3412
3528
  this.drawScreen();
3413
3529
  }
@@ -3434,12 +3550,14 @@ export class DiagramRenderer {
3434
3550
  (this.clickY - selectedClassOldPosition.oldPos.y);
3435
3551
  newMovingDeltaX = selectedClass.position.x - newMovingX;
3436
3552
  newMovingDeltaY = selectedClass.position.y - newMovingY;
3437
- positionedRectangle_setPosition(
3553
+ this.callbacks?.onPositionedRectangle_setPosition?.(
3438
3554
  selectedClass,
3439
3555
  new Point(newMovingX, newMovingY),
3440
3556
  );
3441
3557
  // Refresh hash since ClassView position is not observable
3442
- positionedRectangle_forceRefreshHash(selectedClass);
3558
+ this.callbacks?.onPositionedRectangle_forceRefreshHash?.(
3559
+ selectedClass,
3560
+ );
3443
3561
  }
3444
3562
  });
3445
3563
  this.potentiallyShiftRelationships(
@@ -3467,13 +3585,13 @@ export class DiagramRenderer {
3467
3585
  // Change line (add a new point to the line)
3468
3586
  if (this.selectedPoint) {
3469
3587
  if (this.selectedPropertyOrAssociation) {
3470
- relationshipView_changePoint(
3588
+ this.callbacks?.onRelationshipView_changePoint?.(
3471
3589
  this.selectedPropertyOrAssociation,
3472
3590
  this.selectedPoint,
3473
3591
  eventPointInModelCoordinate,
3474
3592
  );
3475
3593
  } else if (this.selectedInheritance) {
3476
- relationshipView_changePoint(
3594
+ this.callbacks?.onRelationshipView_changePoint?.(
3477
3595
  this.selectedInheritance,
3478
3596
  this.selectedPoint,
3479
3597
  eventPointInModelCoordinate,