@finos/legend-extension-dsl-diagram 1.0.28 → 1.0.31

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. package/lib/DiagramRenderer.d.ts +4 -1
  2. package/lib/DiagramRenderer.d.ts.map +1 -1
  3. package/lib/DiagramRenderer.js +59 -60
  4. package/lib/DiagramRenderer.js.map +1 -1
  5. package/lib/components/studio/ClassDiagramPreview.d.ts.map +1 -1
  6. package/lib/components/studio/ClassDiagramPreview.js +3 -1
  7. package/lib/components/studio/ClassDiagramPreview.js.map +1 -1
  8. package/lib/components/studio/DiagramEditor.d.ts.map +1 -1
  9. package/lib/components/studio/DiagramEditor.js +11 -7
  10. package/lib/components/studio/DiagramEditor.js.map +1 -1
  11. package/lib/graphManager/DSLDiagram_PureGraphManagerPlugin.d.ts +2 -1
  12. package/lib/graphManager/DSLDiagram_PureGraphManagerPlugin.d.ts.map +1 -1
  13. package/lib/graphManager/DSLDiagram_PureGraphManagerPlugin.js +11 -0
  14. package/lib/graphManager/DSLDiagram_PureGraphManagerPlugin.js.map +1 -1
  15. package/lib/graphManager/action/changeDetection/DSLDiagram_ObserverHelper.d.ts +34 -0
  16. package/lib/graphManager/action/changeDetection/DSLDiagram_ObserverHelper.d.ts.map +1 -0
  17. package/lib/graphManager/action/changeDetection/DSLDiagram_ObserverHelper.js +94 -0
  18. package/lib/graphManager/action/changeDetection/DSLDiagram_ObserverHelper.js.map +1 -0
  19. package/lib/helpers/DiagramHelper.d.ts +16 -1
  20. package/lib/helpers/DiagramHelper.d.ts.map +1 -1
  21. package/lib/helpers/DiagramHelper.js +90 -3
  22. package/lib/helpers/DiagramHelper.js.map +1 -1
  23. package/lib/index.css +1 -1
  24. package/lib/index.d.ts +1 -1
  25. package/lib/index.d.ts.map +1 -1
  26. package/lib/index.js +1 -1
  27. package/lib/index.js.map +1 -1
  28. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_AssociationView.d.ts.map +1 -1
  29. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_AssociationView.js +0 -4
  30. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_AssociationView.js.map +1 -1
  31. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassView.d.ts +0 -3
  32. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassView.d.ts.map +1 -1
  33. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassView.js +0 -20
  34. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassView.js.map +1 -1
  35. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassViewReference.d.ts +0 -1
  36. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassViewReference.d.ts.map +1 -1
  37. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassViewReference.js +0 -9
  38. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassViewReference.js.map +1 -1
  39. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_Diagram.d.ts +0 -12
  40. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_Diagram.d.ts.map +1 -1
  41. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_Diagram.js +1 -56
  42. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_Diagram.js.map +1 -1
  43. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_GeneralizationView.d.ts +0 -3
  44. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_GeneralizationView.d.ts.map +1 -1
  45. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_GeneralizationView.js +0 -7
  46. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_GeneralizationView.js.map +1 -1
  47. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_PropertyView.d.ts +0 -4
  48. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_PropertyView.d.ts.map +1 -1
  49. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_PropertyView.js +0 -7
  50. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_PropertyView.js.map +1 -1
  51. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipEdgeView.d.ts +6 -3
  52. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipEdgeView.d.ts.map +1 -1
  53. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipEdgeView.js +6 -14
  54. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipEdgeView.js.map +1 -1
  55. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipView.d.ts +24 -23
  56. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipView.d.ts.map +1 -1
  57. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipView.js +57 -129
  58. package/lib/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipView.js.map +1 -1
  59. package/lib/models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_PositionedRectangle.d.ts +0 -8
  60. package/lib/models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_PositionedRectangle.d.ts.map +1 -1
  61. package/lib/models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_PositionedRectangle.js +0 -19
  62. package/lib/models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_PositionedRectangle.js.map +1 -1
  63. package/lib/models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_Vector.d.ts +3 -3
  64. package/lib/models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_Vector.d.ts.map +1 -1
  65. package/lib/models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_Vector.js +1 -1
  66. package/lib/models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_Vector.js.map +1 -1
  67. package/lib/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDiagram_GraphBuilderHelper.d.ts.map +1 -1
  68. package/lib/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDiagram_GraphBuilderHelper.js +3 -3
  69. package/lib/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDiagram_GraphBuilderHelper.js.map +1 -1
  70. package/lib/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDiagram_TransformerHelper.js +2 -2
  71. package/lib/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDiagram_TransformerHelper.js.map +1 -1
  72. package/lib/package.json +5 -5
  73. package/lib/stores/studio/DSLDiagram_GraphModifierHelper.d.ts +57 -0
  74. package/lib/stores/studio/DSLDiagram_GraphModifierHelper.d.ts.map +1 -0
  75. package/lib/stores/studio/DSLDiagram_GraphModifierHelper.js +94 -0
  76. package/lib/stores/studio/DSLDiagram_GraphModifierHelper.js.map +1 -0
  77. package/lib/stores/studio/DiagramEditorState.d.ts.map +1 -1
  78. package/lib/stores/studio/DiagramEditorState.js +10 -7
  79. package/lib/stores/studio/DiagramEditorState.js.map +1 -1
  80. package/package.json +12 -12
  81. package/src/DiagramRenderer.ts +133 -68
  82. package/src/components/studio/ClassDiagramPreview.tsx +3 -1
  83. package/src/components/studio/DiagramEditor.tsx +17 -6
  84. package/src/graphManager/DSLDiagram_PureGraphManagerPlugin.ts +17 -0
  85. package/src/graphManager/action/changeDetection/DSLDiagram_ObserverHelper.ts +153 -0
  86. package/src/helpers/DiagramHelper.ts +126 -4
  87. package/src/index.ts +1 -4
  88. package/src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_AssociationView.ts +0 -6
  89. package/src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassView.ts +0 -23
  90. package/src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassViewReference.ts +0 -12
  91. package/src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_Diagram.ts +1 -64
  92. package/src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_GeneralizationView.ts +0 -11
  93. package/src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_PropertyView.ts +0 -17
  94. package/src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipEdgeView.ts +6 -16
  95. package/src/models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipView.ts +71 -169
  96. package/src/models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_PositionedRectangle.ts +0 -21
  97. package/src/models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_Vector.ts +3 -3
  98. package/src/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDiagram_GraphBuilderHelper.ts +6 -3
  99. package/src/models/protocols/pure/v1/transformation/pureGraph/V1_DSLDiagram_TransformerHelper.ts +4 -4
  100. package/src/stores/studio/DSLDiagram_GraphModifierHelper.ts +164 -0
  101. package/src/stores/studio/DiagramEditorState.ts +26 -7
  102. package/tsconfig.json +2 -0
@@ -45,14 +45,36 @@ import { PositionedRectangle } from './models/metamodels/pure/packageableElement
45
45
  import { ClassView } from './models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassView';
46
46
  import type { PropertyHolderView } from './models/metamodels/pure/packageableElements/diagram/DSLDiagram_PropertyHolderView';
47
47
  import { GeneralizationView } from './models/metamodels/pure/packageableElements/diagram/DSLDiagram_GeneralizationView';
48
- import {
49
- type RelationshipView,
50
- manageInsidePointsDynamically,
51
- } from './models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipView';
48
+ import { RelationshipView } from './models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipView';
52
49
  import { PropertyView } from './models/metamodels/pure/packageableElements/diagram/DSLDiagram_PropertyView';
53
50
  import { getElementPosition } from './helpers/DiagramHelper';
54
51
  import { AssociationView } from './models/metamodels/pure/packageableElements/diagram/DSLDiagram_AssociationView';
55
52
  import { class_addProperty, class_addSuperType } from '@finos/legend-studio';
53
+ import {
54
+ classView_setHideProperties,
55
+ classView_setHideStereotypes,
56
+ classView_setHideTaggedValues,
57
+ diagram_addClassView,
58
+ diagram_addGeneralizationView,
59
+ diagram_addPropertyView,
60
+ diagram_deleteAssociationView,
61
+ diagram_deleteClassView,
62
+ diagram_deleteGeneralizationView,
63
+ diagram_deletePropertyView,
64
+ diagram_setAssociationViews,
65
+ diagram_setClassViews,
66
+ diagram_setGeneralizationViews,
67
+ diagram_setPropertyViews,
68
+ findOrBuildPoint,
69
+ positionedRectangle_forceRefreshHash,
70
+ positionedRectangle_setPosition,
71
+ positionedRectangle_setRectangle,
72
+ relationshipEdgeView_setOffsetX,
73
+ relationshipEdgeView_setOffsetY,
74
+ relationshipView_changePoint,
75
+ relationshipView_simplifyPath,
76
+ relationshipView_setPath,
77
+ } from './stores/studio/DSLDiagram_GraphModifierHelper';
56
78
 
57
79
  export enum DIAGRAM_INTERACTION_MODE {
58
80
  LAYOUT,
@@ -601,7 +623,7 @@ export class DiagramRenderer {
601
623
  startClassView,
602
624
  targetClassView,
603
625
  );
604
- this.diagram.addGeneralizationView(gview);
626
+ diagram_addGeneralizationView(this.diagram, gview);
605
627
  return gview;
606
628
  }
607
629
  return undefined;
@@ -632,7 +654,7 @@ export class DiagramRenderer {
632
654
  startClassView,
633
655
  targetClassView,
634
656
  );
635
- this.diagram.addPropertyView(pView);
657
+ diagram_addPropertyView(this.diagram, pView);
636
658
  return pView;
637
659
  }
638
660
  return undefined;
@@ -723,9 +745,8 @@ export class DiagramRenderer {
723
745
  .concat(this.diagram.generalizationViews)
724
746
  .concat(this.diagram.propertyViews);
725
747
  for (const relationshipView of relationshipViews) {
726
- let fullPath = relationshipView.buildFullPath();
727
- fullPath = manageInsidePointsDynamically(
728
- fullPath,
748
+ const fullPath = RelationshipView.pruneUnnecessaryInsidePoints(
749
+ relationshipView.buildFullPath(),
729
750
  relationshipView.from.classView.value,
730
751
  relationshipView.to.classView.value,
731
752
  );
@@ -860,7 +881,8 @@ export class DiagramRenderer {
860
881
  id,
861
882
  PackageableElementExplicitReference.create(addedClass),
862
883
  );
863
- newClassView.setPosition(
884
+ positionedRectangle_setPosition(
885
+ newClassView,
864
886
  classViewModelCoordinate ??
865
887
  this.canvasCoordinateToModelCoordinate(
866
888
  new Point(
@@ -871,10 +893,10 @@ export class DiagramRenderer {
871
893
  ),
872
894
  ),
873
895
  );
874
- this.diagram.addClassView(newClassView);
896
+ diagram_addClassView(this.diagram, newClassView);
875
897
  // Refresh hash since ClassView position is not observable
876
898
  // NOTE: here we refresh after adding the class view to the diagram, that way the diagram hash is refreshed
877
- newClassView.forceRefreshHash();
899
+ positionedRectangle_forceRefreshHash(newClassView);
878
900
  this.diagram.classViews
879
901
  .filter((classView) => classView.class.value !== addedClass)
880
902
  .forEach((classView) => {
@@ -885,7 +907,8 @@ export class DiagramRenderer {
885
907
  .map((generalization) => generalization.value.rawType)
886
908
  .includes(_class)
887
909
  ) {
888
- this.diagram.addGeneralizationView(
910
+ diagram_addGeneralizationView(
911
+ this.diagram,
889
912
  new GeneralizationView(this.diagram, newClassView, classView),
890
913
  );
891
914
  }
@@ -894,14 +917,18 @@ export class DiagramRenderer {
894
917
  .map((generalization) => generalization.value.rawType)
895
918
  .includes(addedClass)
896
919
  ) {
897
- this.diagram.addGeneralizationView(
920
+ diagram_addGeneralizationView(
921
+ this.diagram,
922
+
898
923
  new GeneralizationView(this.diagram, classView, newClassView),
899
924
  );
900
925
  }
901
926
  // Add property view
902
927
  addedClass.getAllOwnedProperties().forEach((property) => {
903
928
  if (property.genericType.value.rawType === _class) {
904
- this.diagram.addPropertyView(
929
+ diagram_addPropertyView(
930
+ this.diagram,
931
+
905
932
  new PropertyView(
906
933
  this.diagram,
907
934
  PropertyExplicitReference.create(property),
@@ -913,7 +940,8 @@ export class DiagramRenderer {
913
940
  });
914
941
  _class.getAllOwnedProperties().forEach((property) => {
915
942
  if (property.genericType.value.rawType === addedClass) {
916
- this.diagram.addPropertyView(
943
+ diagram_addPropertyView(
944
+ this.diagram,
917
945
  new PropertyView(
918
946
  this.diagram,
919
947
  PropertyExplicitReference.create(property),
@@ -1452,7 +1480,7 @@ export class DiagramRenderer {
1452
1480
  classView.rectangle.height > classMinHeight
1453
1481
  ? classView.rectangle.height
1454
1482
  : classMinHeight;
1455
- classView.setRectangle(new Rectangle(width, height));
1483
+ positionedRectangle_setRectangle(classView, new Rectangle(width, height));
1456
1484
  }
1457
1485
  }
1458
1486
 
@@ -1630,7 +1658,7 @@ export class DiagramRenderer {
1630
1658
  // NOTE: force hash reload when we redraw class view; this would help with cases where
1631
1659
  // we auto add new properties to the class view, causing the box to expand, hence we need
1632
1660
  // to recompute hash
1633
- classView.forceRefreshHash();
1661
+ positionedRectangle_forceRefreshHash(classView);
1634
1662
  }
1635
1663
 
1636
1664
  private drawLinePropertyNameAndMultiplicity(
@@ -1793,9 +1821,8 @@ export class DiagramRenderer {
1793
1821
  }
1794
1822
 
1795
1823
  private drawPropertyOrAssociation(propertyView: PropertyView): void {
1796
- let fullPath = propertyView.buildFullPath();
1797
- fullPath = manageInsidePointsDynamically(
1798
- fullPath,
1824
+ const fullPath = RelationshipView.pruneUnnecessaryInsidePoints(
1825
+ propertyView.buildFullPath(),
1799
1826
  propertyView.from.classView.value,
1800
1827
  propertyView.to.classView.value,
1801
1828
  );
@@ -1884,9 +1911,8 @@ export class DiagramRenderer {
1884
1911
 
1885
1912
  private drawInheritance(inheritance: GeneralizationView): void {
1886
1913
  const rect = inheritance.to.classView.value.rectangle;
1887
- let fullPath = inheritance.buildFullPath();
1888
- fullPath = manageInsidePointsDynamically(
1889
- fullPath,
1914
+ const fullPath = RelationshipView.pruneUnnecessaryInsidePoints(
1915
+ inheritance.buildFullPath(),
1890
1916
  inheritance.from.classView.value,
1891
1917
  inheritance.to.classView.value,
1892
1918
  );
@@ -2031,20 +2057,23 @@ export class DiagramRenderer {
2031
2057
  return newClasses;
2032
2058
  }
2033
2059
 
2034
- // TODO: add doc
2060
+ /**
2061
+ * Shift relationship views if both ends' classviews are moved.
2062
+ */
2035
2063
  private potentiallyShiftRelationships(
2036
- assoViews: RelationshipView[],
2064
+ relationshipViews: RelationshipView[],
2037
2065
  selectedClasses: ClassView[],
2038
2066
  newMovingDeltaX: number,
2039
2067
  newMovingDeltaY: number,
2040
2068
  ): void {
2041
- assoViews.forEach((assoView) => {
2069
+ relationshipViews.forEach((view) => {
2042
2070
  if (
2043
- selectedClasses.indexOf(assoView.from.classView.value) !== -1 &&
2044
- selectedClasses.indexOf(assoView.to.classView.value) !== -1
2071
+ selectedClasses.indexOf(view.from.classView.value) !== -1 &&
2072
+ selectedClasses.indexOf(view.to.classView.value) !== -1
2045
2073
  ) {
2046
- assoView.setPath(
2047
- assoView.path.map(
2074
+ relationshipView_setPath(
2075
+ view,
2076
+ view.path.map(
2048
2077
  (point) =>
2049
2078
  new Point(point.x - newMovingDeltaX, point.y - newMovingDeltaY),
2050
2079
  ),
@@ -2058,8 +2087,10 @@ export class DiagramRenderer {
2058
2087
  if ('Delete' === e.key) {
2059
2088
  if (!this.isReadOnly) {
2060
2089
  this.selectedClasses.forEach((classView) => {
2061
- this.diagram.deleteClassView(classView);
2062
- this.diagram.setAssociationViews(
2090
+ diagram_deleteClassView(this.diagram, classView);
2091
+ diagram_setAssociationViews(
2092
+ this.diagram,
2093
+
2063
2094
  this.diagram.associationViews.filter(
2064
2095
  (associationView) =>
2065
2096
  !(
@@ -2068,7 +2099,9 @@ export class DiagramRenderer {
2068
2099
  ),
2069
2100
  ),
2070
2101
  );
2071
- this.diagram.setGeneralizationViews(
2102
+ diagram_setGeneralizationViews(
2103
+ this.diagram,
2104
+
2072
2105
  this.diagram.generalizationViews.filter(
2073
2106
  (generalizationView) =>
2074
2107
  !(
@@ -2077,7 +2110,9 @@ export class DiagramRenderer {
2077
2110
  ),
2078
2111
  ),
2079
2112
  );
2080
- this.diagram.setPropertyViews(
2113
+ diagram_setPropertyViews(
2114
+ this.diagram,
2115
+
2081
2116
  this.diagram.propertyViews.filter(
2082
2117
  (propertyView) =>
2083
2118
  !(
@@ -2088,11 +2123,16 @@ export class DiagramRenderer {
2088
2123
  );
2089
2124
  });
2090
2125
  if (this.selectedPropertyOrAssociation instanceof AssociationView) {
2091
- this.diagram.deleteAssociationView(
2126
+ diagram_deleteAssociationView(
2127
+ this.diagram,
2128
+
2092
2129
  this.selectedPropertyOrAssociation,
2093
2130
  );
2094
2131
  } else if (this.selectedPropertyOrAssociation instanceof PropertyView) {
2095
- this.diagram.deletePropertyView(this.selectedPropertyOrAssociation);
2132
+ diagram_deletePropertyView(
2133
+ this.diagram,
2134
+ this.selectedPropertyOrAssociation,
2135
+ );
2096
2136
  }
2097
2137
  if (this.selectedInheritance) {
2098
2138
  if (
@@ -2101,7 +2141,10 @@ export class DiagramRenderer {
2101
2141
  generalizationView === this.selectedInheritance,
2102
2142
  )
2103
2143
  ) {
2104
- this.diagram.deleteGeneralizationView(this.selectedInheritance);
2144
+ diagram_deleteGeneralizationView(
2145
+ this.diagram,
2146
+ this.selectedInheritance,
2147
+ );
2105
2148
  }
2106
2149
  }
2107
2150
  this.selectedClasses = [];
@@ -2208,7 +2251,7 @@ export class DiagramRenderer {
2208
2251
  if (!this.isReadOnly) {
2209
2252
  if (this.selectedClasses.length !== 0) {
2210
2253
  this.selectedClasses.forEach((classView) => {
2211
- classView.setHideProperties(!classView.hideProperties);
2254
+ classView_setHideProperties(classView, !classView.hideProperties);
2212
2255
  });
2213
2256
  this.drawScreen();
2214
2257
  }
@@ -2219,7 +2262,7 @@ export class DiagramRenderer {
2219
2262
  if (!this.isReadOnly) {
2220
2263
  if (this.selectedClasses.length !== 0) {
2221
2264
  this.selectedClasses.forEach((classView) => {
2222
- classView.setHideStereotypes(!classView.hideStereotypes);
2265
+ classView_setHideStereotypes(classView, !classView.hideStereotypes);
2223
2266
  });
2224
2267
  this.drawScreen();
2225
2268
  }
@@ -2230,7 +2273,10 @@ export class DiagramRenderer {
2230
2273
  if (!this.isReadOnly) {
2231
2274
  if (this.selectedClasses.length !== 0) {
2232
2275
  this.selectedClasses.forEach((classView) => {
2233
- classView.setHideTaggedValues(!classView.hideTaggedValues);
2276
+ classView_setHideTaggedValues(
2277
+ classView,
2278
+ !classView.hideTaggedValues,
2279
+ );
2234
2280
  });
2235
2281
  this.drawScreen();
2236
2282
  }
@@ -2285,8 +2331,8 @@ export class DiagramRenderer {
2285
2331
  1,
2286
2332
  );
2287
2333
  const res = this.layoutTaxonomy(views, this.diagram, false, true);
2288
- res[0].forEach((cv) => this.diagram.addClassView(cv));
2289
- res[1].forEach((gv) => this.diagram.addGeneralizationView(gv));
2334
+ res[0].forEach((cv) => diagram_addClassView(this.diagram, cv));
2335
+ res[1].forEach((gv) => diagram_addGeneralizationView(this.diagram, gv));
2290
2336
 
2291
2337
  this.drawScreen();
2292
2338
  }
@@ -2318,8 +2364,8 @@ export class DiagramRenderer {
2318
2364
  false,
2319
2365
  false,
2320
2366
  );
2321
- res[0].forEach((cv) => this.diagram.addClassView(cv));
2322
- res[1].forEach((gv) => this.diagram.addGeneralizationView(gv));
2367
+ res[0].forEach((cv) => diagram_addClassView(this.diagram, cv));
2368
+ res[1].forEach((gv) => diagram_addGeneralizationView(this.diagram, gv));
2323
2369
  }
2324
2370
 
2325
2371
  this.drawScreen();
@@ -2331,13 +2377,13 @@ export class DiagramRenderer {
2331
2377
  switch (this.interactionMode) {
2332
2378
  case DIAGRAM_INTERACTION_MODE.LAYOUT: {
2333
2379
  this.diagram.generalizationViews.forEach((generalizationView) =>
2334
- generalizationView.possiblyFlattenPath(),
2380
+ relationshipView_simplifyPath(generalizationView),
2335
2381
  );
2336
2382
  this.diagram.associationViews.forEach((associationView) =>
2337
- associationView.possiblyFlattenPath(),
2383
+ relationshipView_simplifyPath(associationView),
2338
2384
  );
2339
2385
  this.diagram.propertyViews.forEach((propertyView) =>
2340
- propertyView.possiblyFlattenPath(),
2386
+ relationshipView_simplifyPath(propertyView),
2341
2387
  );
2342
2388
  break;
2343
2389
  }
@@ -2425,28 +2471,32 @@ export class DiagramRenderer {
2425
2471
  );
2426
2472
 
2427
2473
  if (gview) {
2428
- gview.from.setOffsetX(
2474
+ relationshipEdgeView_setOffsetX(
2475
+ gview.from,
2429
2476
  -(
2430
2477
  this.startClassView.position.x +
2431
2478
  this.startClassView.rectangle.width / 2 -
2432
2479
  this.selectionStart.x
2433
2480
  ),
2434
2481
  );
2435
- gview.from.setOffsetY(
2482
+ relationshipEdgeView_setOffsetY(
2483
+ gview.from,
2436
2484
  -(
2437
2485
  this.startClassView.position.y +
2438
2486
  this.startClassView.rectangle.height / 2 -
2439
2487
  this.selectionStart.y
2440
2488
  ),
2441
2489
  );
2442
- gview.to.setOffsetX(
2490
+ relationshipEdgeView_setOffsetX(
2491
+ gview.to,
2443
2492
  -(
2444
2493
  targetClassView.position.x +
2445
2494
  targetClassView.rectangle.width / 2 -
2446
2495
  eventPointInModelCoordinate.x
2447
2496
  ),
2448
2497
  );
2449
- gview.to.setOffsetY(
2498
+ relationshipEdgeView_setOffsetY(
2499
+ gview.to,
2450
2500
  -(
2451
2501
  targetClassView.position.y +
2452
2502
  targetClassView.rectangle.height / 2 -
@@ -2591,7 +2641,8 @@ export class DiagramRenderer {
2591
2641
  this.setSelectedClassCorner(this.diagram.classViews[i]);
2592
2642
  if (!this.isReadOnly) {
2593
2643
  // Bring the class view to front
2594
- this.diagram.setClassViews(
2644
+ diagram_setClassViews(
2645
+ this.diagram,
2595
2646
  this.reorderDiagramDomain(
2596
2647
  guaranteeNonNullable(this.selectedClassCorner),
2597
2648
  this.diagram,
@@ -2631,7 +2682,9 @@ export class DiagramRenderer {
2631
2682
  }
2632
2683
  if (!this.isReadOnly) {
2633
2684
  // Bring the class view to front
2634
- this.diagram.setClassViews(
2685
+ diagram_setClassViews(
2686
+ this.diagram,
2687
+
2635
2688
  this.reorderDiagramDomain(
2636
2689
  this.selectedClasses[0] as ClassView,
2637
2690
  this.diagram,
@@ -2669,7 +2722,8 @@ export class DiagramRenderer {
2669
2722
  // check for selection of inheritance view
2670
2723
  for (const generalizationView of this.diagram
2671
2724
  .generalizationViews) {
2672
- const val = generalizationView.findOrBuildPoint(
2725
+ const val = findOrBuildPoint(
2726
+ generalizationView,
2673
2727
  eventPointInModelCoordinate.x,
2674
2728
  eventPointInModelCoordinate.y,
2675
2729
  this.zoom,
@@ -2685,7 +2739,8 @@ export class DiagramRenderer {
2685
2739
  // check for selection of association view
2686
2740
  if (!this.selectedPoint) {
2687
2741
  for (const associationView of this.diagram.associationViews) {
2688
- const val = associationView.findOrBuildPoint(
2742
+ const val = findOrBuildPoint(
2743
+ associationView,
2689
2744
  eventPointInModelCoordinate.x,
2690
2745
  eventPointInModelCoordinate.y,
2691
2746
  this.zoom,
@@ -2702,7 +2757,8 @@ export class DiagramRenderer {
2702
2757
  // check for selection of property view
2703
2758
  if (!this.selectedPoint) {
2704
2759
  for (const propertyView of this.diagram.propertyViews) {
2705
- const val = propertyView.findOrBuildPoint(
2760
+ const val = findOrBuildPoint(
2761
+ propertyView,
2706
2762
  eventPointInModelCoordinate.x,
2707
2763
  eventPointInModelCoordinate.y,
2708
2764
  this.zoom,
@@ -2810,7 +2866,8 @@ export class DiagramRenderer {
2810
2866
  // Resize class view
2811
2867
  if (this.selectedClassCorner) {
2812
2868
  // Make sure width and height are in range!
2813
- this.selectedClassCorner.setRectangle(
2869
+ positionedRectangle_setRectangle(
2870
+ this.selectedClassCorner,
2814
2871
  new Rectangle(
2815
2872
  eventPointInModelCoordinate.x -
2816
2873
  this.selectedClassCorner.position.x,
@@ -2819,7 +2876,7 @@ export class DiagramRenderer {
2819
2876
  ),
2820
2877
  );
2821
2878
  // Refresh hash since ClassView rectangle is not observable
2822
- this.selectedClassCorner.forceRefreshHash();
2879
+ positionedRectangle_forceRefreshHash(this.selectedClassCorner);
2823
2880
  this.drawClassView(this.selectedClassCorner);
2824
2881
  this.drawScreen();
2825
2882
  }
@@ -2846,9 +2903,12 @@ export class DiagramRenderer {
2846
2903
  (this.clickY - selectedClassOldPosition.oldPos.y);
2847
2904
  newMovingDeltaX = selectedClass.position.x - newMovingX;
2848
2905
  newMovingDeltaY = selectedClass.position.y - newMovingY;
2849
- selectedClass.setPosition(new Point(newMovingX, newMovingY));
2906
+ positionedRectangle_setPosition(
2907
+ selectedClass,
2908
+ new Point(newMovingX, newMovingY),
2909
+ );
2850
2910
  // Refresh hash since ClassView position is not observable
2851
- selectedClass.forceRefreshHash();
2911
+ positionedRectangle_forceRefreshHash(selectedClass);
2852
2912
  }
2853
2913
  });
2854
2914
  this.potentiallyShiftRelationships(
@@ -2876,12 +2936,14 @@ export class DiagramRenderer {
2876
2936
  // Change line (add a new point to the line)
2877
2937
  if (this.selectedPoint) {
2878
2938
  if (this.selectedPropertyOrAssociation) {
2879
- this.selectedPropertyOrAssociation.changePoint(
2939
+ relationshipView_changePoint(
2940
+ this.selectedPropertyOrAssociation,
2880
2941
  this.selectedPoint,
2881
2942
  eventPointInModelCoordinate,
2882
2943
  );
2883
2944
  } else if (this.selectedInheritance) {
2884
- this.selectedInheritance.changePoint(
2945
+ relationshipView_changePoint(
2946
+ this.selectedInheritance,
2885
2947
  this.selectedPoint,
2886
2948
  eventPointInModelCoordinate,
2887
2949
  );
@@ -3100,9 +3162,8 @@ export class DiagramRenderer {
3100
3162
  ...this.diagram.associationViews,
3101
3163
  ];
3102
3164
  for (const propertyHolderView of propertyHolderViews) {
3103
- let fullPath = propertyHolderView.buildFullPath();
3104
- fullPath = manageInsidePointsDynamically(
3105
- fullPath,
3165
+ const fullPath = RelationshipView.pruneUnnecessaryInsidePoints(
3166
+ propertyHolderView.buildFullPath(),
3106
3167
  propertyHolderView.from.classView.value,
3107
3168
  propertyHolderView.to.classView.value,
3108
3169
  );
@@ -3233,11 +3294,15 @@ export class DiagramRenderer {
3233
3294
 
3234
3295
  // Set layout of current level
3235
3296
  if (positionInitialClass || currentLevelIndex > 0) {
3236
- (levels[0] as ClassView).setPosition(new Point(startX, currentLevelY));
3297
+ positionedRectangle_setPosition(
3298
+ levels[0] as ClassView,
3299
+ new Point(startX, currentLevelY),
3300
+ );
3237
3301
  levels.forEach((view, idx) => {
3238
3302
  if (idx > 0) {
3239
3303
  const precedent = levels[idx - 1] as ClassView;
3240
- view.setPosition(
3304
+ positionedRectangle_setPosition(
3305
+ view,
3241
3306
  new Point(
3242
3307
  precedent.position.x + precedent.rectangle.width + spaceX,
3243
3308
  currentLevelY,
@@ -21,11 +21,13 @@ import { useApplicationStore } from '@finos/legend-application';
21
21
  import type { Class } from '@finos/legend-graph';
22
22
  import { InheritanceDiagramRenderer } from './InheritanceDiagramRenderer';
23
23
  import { DSL_DIAGRAM_TEST_ID } from './DSLDiagram_TestID';
24
+ import { useEditorStore } from '@finos/legend-studio';
24
25
 
25
26
  export const ClassDiagramPreview = observer((props: { _class: Class }) => {
26
27
  const { _class } = props;
27
28
  const applicationStore = useApplicationStore();
28
- const classHash = _class.isReadOnly
29
+ const editorStore = useEditorStore();
30
+ const classHash = editorStore.graphManagerState.isElementReadOnly(_class)
29
31
  ? undefined
30
32
  : applicationStore.notifyAndReturnAlternativeOnError(
31
33
  () => _class.hashCode,
@@ -108,6 +108,11 @@ import {
108
108
  import { cleanUpDeadReferencesInDiagram } from '../../helpers/DiagramHelper';
109
109
  import { Point } from '../../models/metamodels/pure/packageableElements/diagram/geometry/DSLDiagram_Point';
110
110
  import type { DSLDiagram_LegendStudioPlugin_Extension } from './DSLDiagram_LegendStudioPlugin_Extension';
111
+ import {
112
+ classView_setHideProperties,
113
+ classView_setHideStereotypes,
114
+ classView_setHideTaggedValues,
115
+ } from '../../stores/studio/DSLDiagram_GraphModifierHelper';
111
116
 
112
117
  const DiagramEditorContextMenu = observer(
113
118
  forwardRef<
@@ -519,21 +524,21 @@ const DiagramEditorClassViewEditor = observer(
519
524
  if (isReadOnly) {
520
525
  return;
521
526
  }
522
- classView.setHideProperties(!classView.hideProperties);
527
+ classView_setHideProperties(classView, !classView.hideProperties);
523
528
  diagramEditorState.renderer.render();
524
529
  };
525
530
  const toggleHideTaggedValues = (): void => {
526
531
  if (isReadOnly) {
527
532
  return;
528
533
  }
529
- classView.setHideTaggedValues(!classView.hideTaggedValues);
534
+ classView_setHideTaggedValues(classView, !classView.hideTaggedValues);
530
535
  diagramEditorState.renderer.render();
531
536
  };
532
537
  const toggleHideStereotypes = (): void => {
533
538
  if (isReadOnly) {
534
539
  return;
535
540
  }
536
- classView.setHideStereotypes(!classView.hideStereotypes);
541
+ classView_setHideStereotypes(classView, !classView.hideStereotypes);
537
542
  diagramEditorState.renderer.render();
538
543
  };
539
544
 
@@ -825,6 +830,7 @@ const DiagramEditorInlineClassCreatorInner = observer(
825
830
  }) => {
826
831
  const { inlineClassCreatorState } = props;
827
832
  const editorStore = useEditorStore();
833
+ const applicationStore = useApplicationStore();
828
834
  const diagramEditorState = inlineClassCreatorState.diagramEditorState;
829
835
  const isReadOnly = diagramEditorState.isReadOnly;
830
836
  const [path, setPath] = useState(
@@ -851,7 +857,9 @@ const DiagramEditorInlineClassCreatorInner = observer(
851
857
  const canCreateClass =
852
858
  isClassPathNonEmpty && isNotTopLevelClass && isValidPath && isClassUnique;
853
859
 
854
- const close = (event: React.MouseEvent<HTMLButtonElement>): void => {
860
+ const createClass = async (
861
+ event: React.MouseEvent<HTMLButtonElement>,
862
+ ): Promise<void> => {
855
863
  event.preventDefault();
856
864
  if (canCreateClass) {
857
865
  diagramEditorState.setInlineClassCreatorState(undefined);
@@ -860,15 +868,18 @@ const DiagramEditorInlineClassCreatorInner = observer(
860
868
  package_addElement(
861
869
  editorStore.graphManagerState.graph.getOrCreatePackage(packagePath),
862
870
  _class,
871
+ editorStore.changeDetectionState.observerContext,
863
872
  );
864
- editorStore.graphManagerState.graph.addElement(_class);
865
- editorStore.explorerTreeState.reprocess();
873
+ await flowResult(editorStore.addElement(_class, false));
866
874
  diagramEditorState.renderer.addClassView(
867
875
  _class,
868
876
  inlineClassCreatorState.point,
869
877
  );
870
878
  }
871
879
  };
880
+ const close = (event: React.MouseEvent<HTMLButtonElement>): void => {
881
+ createClass(event).catch(applicationStore.alertUnhandledError);
882
+ };
872
883
  const pathInputRef = useRef<HTMLInputElement>(null);
873
884
 
874
885
  const changePath: React.ChangeEventHandler<HTMLInputElement> = (event) =>
@@ -17,10 +17,13 @@
17
17
  import packageJson from '../../package.json';
18
18
  import {
19
19
  PureGraphManagerPlugin,
20
+ type ObserverContext,
21
+ type ElementObserver,
20
22
  type PackageableElement,
21
23
  type PureGrammarElementLabeler,
22
24
  } from '@finos/legend-graph';
23
25
  import { Diagram } from '../models/metamodels/pure/packageableElements/diagram/DSLDiagram_Diagram';
26
+ import { observe_Diagram } from './action/changeDetection/DSLDiagram_ObserverHelper';
24
27
 
25
28
  const PURE_GRAMMAR_DIAGRAM_PARSER_NAME = 'Diagram';
26
29
  const PURE_GRAMMAR_DIAGRAM_ELEMENT_TYPE_LABEL = 'Diagram';
@@ -48,4 +51,18 @@ export class DSLDiagram_PureGraphManagerPlugin extends PureGraphManagerPlugin {
48
51
  },
49
52
  ];
50
53
  }
54
+
55
+ override getExtraElementObservers(): ElementObserver[] {
56
+ return [
57
+ (
58
+ element: PackageableElement,
59
+ context: ObserverContext,
60
+ ): PackageableElement | undefined => {
61
+ if (element instanceof Diagram) {
62
+ return observe_Diagram(element);
63
+ }
64
+ return undefined;
65
+ },
66
+ ];
67
+ }
51
68
  }