@finos/legend-extension-dsl-diagram 1.0.27 → 1.0.30

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 +63 -63
  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 +10 -9
  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 +1 -10
  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 +4 -4
  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 +13 -10
  79. package/lib/stores/studio/DiagramEditorState.js.map +1 -1
  80. package/package.json +11 -11
  81. package/src/DiagramRenderer.ts +136 -72
  82. package/src/components/studio/ClassDiagramPreview.tsx +3 -1
  83. package/src/components/studio/DiagramEditor.tsx +17 -11
  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 -13
  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 +28 -9
  102. package/tsconfig.json +2 -0
@@ -36,8 +36,6 @@ import {
36
36
  GenericType,
37
37
  Property,
38
38
  Multiplicity,
39
- addClassProperty,
40
- addClassSuperType,
41
39
  } from '@finos/legend-graph';
42
40
  import { action, makeObservable, observable } from 'mobx';
43
41
  import type { Diagram } from './models/metamodels/pure/packageableElements/diagram/DSLDiagram_Diagram';
@@ -47,13 +45,36 @@ import { PositionedRectangle } from './models/metamodels/pure/packageableElement
47
45
  import { ClassView } from './models/metamodels/pure/packageableElements/diagram/DSLDiagram_ClassView';
48
46
  import type { PropertyHolderView } from './models/metamodels/pure/packageableElements/diagram/DSLDiagram_PropertyHolderView';
49
47
  import { GeneralizationView } from './models/metamodels/pure/packageableElements/diagram/DSLDiagram_GeneralizationView';
50
- import {
51
- type RelationshipView,
52
- manageInsidePointsDynamically,
53
- } from './models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipView';
48
+ import { RelationshipView } from './models/metamodels/pure/packageableElements/diagram/DSLDiagram_RelationshipView';
54
49
  import { PropertyView } from './models/metamodels/pure/packageableElements/diagram/DSLDiagram_PropertyView';
55
50
  import { getElementPosition } from './helpers/DiagramHelper';
56
51
  import { AssociationView } from './models/metamodels/pure/packageableElements/diagram/DSLDiagram_AssociationView';
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';
57
78
 
58
79
  export enum DIAGRAM_INTERACTION_MODE {
59
80
  LAYOUT,
@@ -582,7 +603,7 @@ export class DiagramRenderer {
582
603
  startClassView.class.value,
583
604
  )
584
605
  ) {
585
- addClassSuperType(
606
+ class_addSuperType(
586
607
  startClassView.class.value,
587
608
  GenericTypeExplicitReference.create(
588
609
  new GenericType(targetClassView.class.value),
@@ -602,7 +623,7 @@ export class DiagramRenderer {
602
623
  startClassView,
603
624
  targetClassView,
604
625
  );
605
- this.diagram.addGeneralizationView(gview);
626
+ diagram_addGeneralizationView(this.diagram, gview);
606
627
  return gview;
607
628
  }
608
629
  return undefined;
@@ -622,7 +643,7 @@ export class DiagramRenderer {
622
643
  ),
623
644
  startClassView.class.value,
624
645
  );
625
- addClassProperty(startClassView.class.value, property);
646
+ class_addProperty(startClassView.class.value, property);
626
647
  // only create property view if the classviews are different
627
648
  // else we end up with a weird rendering where the property view
628
649
  // is not targetable
@@ -633,7 +654,7 @@ export class DiagramRenderer {
633
654
  startClassView,
634
655
  targetClassView,
635
656
  );
636
- this.diagram.addPropertyView(pView);
657
+ diagram_addPropertyView(this.diagram, pView);
637
658
  return pView;
638
659
  }
639
660
  return undefined;
@@ -724,9 +745,8 @@ export class DiagramRenderer {
724
745
  .concat(this.diagram.generalizationViews)
725
746
  .concat(this.diagram.propertyViews);
726
747
  for (const relationshipView of relationshipViews) {
727
- let fullPath = relationshipView.buildFullPath();
728
- fullPath = manageInsidePointsDynamically(
729
- fullPath,
748
+ const fullPath = RelationshipView.pruneUnnecessaryInsidePoints(
749
+ relationshipView.buildFullPath(),
730
750
  relationshipView.from.classView.value,
731
751
  relationshipView.to.classView.value,
732
752
  );
@@ -861,7 +881,8 @@ export class DiagramRenderer {
861
881
  id,
862
882
  PackageableElementExplicitReference.create(addedClass),
863
883
  );
864
- newClassView.setPosition(
884
+ positionedRectangle_setPosition(
885
+ newClassView,
865
886
  classViewModelCoordinate ??
866
887
  this.canvasCoordinateToModelCoordinate(
867
888
  new Point(
@@ -872,10 +893,10 @@ export class DiagramRenderer {
872
893
  ),
873
894
  ),
874
895
  );
875
- this.diagram.addClassView(newClassView);
896
+ diagram_addClassView(this.diagram, newClassView);
876
897
  // Refresh hash since ClassView position is not observable
877
898
  // NOTE: here we refresh after adding the class view to the diagram, that way the diagram hash is refreshed
878
- newClassView.forceRefreshHash();
899
+ positionedRectangle_forceRefreshHash(newClassView);
879
900
  this.diagram.classViews
880
901
  .filter((classView) => classView.class.value !== addedClass)
881
902
  .forEach((classView) => {
@@ -886,7 +907,8 @@ export class DiagramRenderer {
886
907
  .map((generalization) => generalization.value.rawType)
887
908
  .includes(_class)
888
909
  ) {
889
- this.diagram.addGeneralizationView(
910
+ diagram_addGeneralizationView(
911
+ this.diagram,
890
912
  new GeneralizationView(this.diagram, newClassView, classView),
891
913
  );
892
914
  }
@@ -895,14 +917,18 @@ export class DiagramRenderer {
895
917
  .map((generalization) => generalization.value.rawType)
896
918
  .includes(addedClass)
897
919
  ) {
898
- this.diagram.addGeneralizationView(
920
+ diagram_addGeneralizationView(
921
+ this.diagram,
922
+
899
923
  new GeneralizationView(this.diagram, classView, newClassView),
900
924
  );
901
925
  }
902
926
  // Add property view
903
927
  addedClass.getAllOwnedProperties().forEach((property) => {
904
928
  if (property.genericType.value.rawType === _class) {
905
- this.diagram.addPropertyView(
929
+ diagram_addPropertyView(
930
+ this.diagram,
931
+
906
932
  new PropertyView(
907
933
  this.diagram,
908
934
  PropertyExplicitReference.create(property),
@@ -914,7 +940,8 @@ export class DiagramRenderer {
914
940
  });
915
941
  _class.getAllOwnedProperties().forEach((property) => {
916
942
  if (property.genericType.value.rawType === addedClass) {
917
- this.diagram.addPropertyView(
943
+ diagram_addPropertyView(
944
+ this.diagram,
918
945
  new PropertyView(
919
946
  this.diagram,
920
947
  PropertyExplicitReference.create(property),
@@ -1453,7 +1480,7 @@ export class DiagramRenderer {
1453
1480
  classView.rectangle.height > classMinHeight
1454
1481
  ? classView.rectangle.height
1455
1482
  : classMinHeight;
1456
- classView.setRectangle(new Rectangle(width, height));
1483
+ positionedRectangle_setRectangle(classView, new Rectangle(width, height));
1457
1484
  }
1458
1485
  }
1459
1486
 
@@ -1631,7 +1658,7 @@ export class DiagramRenderer {
1631
1658
  // NOTE: force hash reload when we redraw class view; this would help with cases where
1632
1659
  // we auto add new properties to the class view, causing the box to expand, hence we need
1633
1660
  // to recompute hash
1634
- classView.forceRefreshHash();
1661
+ positionedRectangle_forceRefreshHash(classView);
1635
1662
  }
1636
1663
 
1637
1664
  private drawLinePropertyNameAndMultiplicity(
@@ -1794,9 +1821,8 @@ export class DiagramRenderer {
1794
1821
  }
1795
1822
 
1796
1823
  private drawPropertyOrAssociation(propertyView: PropertyView): void {
1797
- let fullPath = propertyView.buildFullPath();
1798
- fullPath = manageInsidePointsDynamically(
1799
- fullPath,
1824
+ const fullPath = RelationshipView.pruneUnnecessaryInsidePoints(
1825
+ propertyView.buildFullPath(),
1800
1826
  propertyView.from.classView.value,
1801
1827
  propertyView.to.classView.value,
1802
1828
  );
@@ -1885,9 +1911,8 @@ export class DiagramRenderer {
1885
1911
 
1886
1912
  private drawInheritance(inheritance: GeneralizationView): void {
1887
1913
  const rect = inheritance.to.classView.value.rectangle;
1888
- let fullPath = inheritance.buildFullPath();
1889
- fullPath = manageInsidePointsDynamically(
1890
- fullPath,
1914
+ const fullPath = RelationshipView.pruneUnnecessaryInsidePoints(
1915
+ inheritance.buildFullPath(),
1891
1916
  inheritance.from.classView.value,
1892
1917
  inheritance.to.classView.value,
1893
1918
  );
@@ -2032,20 +2057,23 @@ export class DiagramRenderer {
2032
2057
  return newClasses;
2033
2058
  }
2034
2059
 
2035
- // TODO: add doc
2060
+ /**
2061
+ * Shift relationship views if both ends' classviews are moved.
2062
+ */
2036
2063
  private potentiallyShiftRelationships(
2037
- assoViews: RelationshipView[],
2064
+ relationshipViews: RelationshipView[],
2038
2065
  selectedClasses: ClassView[],
2039
2066
  newMovingDeltaX: number,
2040
2067
  newMovingDeltaY: number,
2041
2068
  ): void {
2042
- assoViews.forEach((assoView) => {
2069
+ relationshipViews.forEach((view) => {
2043
2070
  if (
2044
- selectedClasses.indexOf(assoView.from.classView.value) !== -1 &&
2045
- selectedClasses.indexOf(assoView.to.classView.value) !== -1
2071
+ selectedClasses.indexOf(view.from.classView.value) !== -1 &&
2072
+ selectedClasses.indexOf(view.to.classView.value) !== -1
2046
2073
  ) {
2047
- assoView.setPath(
2048
- assoView.path.map(
2074
+ relationshipView_setPath(
2075
+ view,
2076
+ view.path.map(
2049
2077
  (point) =>
2050
2078
  new Point(point.x - newMovingDeltaX, point.y - newMovingDeltaY),
2051
2079
  ),
@@ -2059,8 +2087,10 @@ export class DiagramRenderer {
2059
2087
  if ('Delete' === e.key) {
2060
2088
  if (!this.isReadOnly) {
2061
2089
  this.selectedClasses.forEach((classView) => {
2062
- this.diagram.deleteClassView(classView);
2063
- this.diagram.setAssociationViews(
2090
+ diagram_deleteClassView(this.diagram, classView);
2091
+ diagram_setAssociationViews(
2092
+ this.diagram,
2093
+
2064
2094
  this.diagram.associationViews.filter(
2065
2095
  (associationView) =>
2066
2096
  !(
@@ -2069,7 +2099,9 @@ export class DiagramRenderer {
2069
2099
  ),
2070
2100
  ),
2071
2101
  );
2072
- this.diagram.setGeneralizationViews(
2102
+ diagram_setGeneralizationViews(
2103
+ this.diagram,
2104
+
2073
2105
  this.diagram.generalizationViews.filter(
2074
2106
  (generalizationView) =>
2075
2107
  !(
@@ -2078,7 +2110,9 @@ export class DiagramRenderer {
2078
2110
  ),
2079
2111
  ),
2080
2112
  );
2081
- this.diagram.setPropertyViews(
2113
+ diagram_setPropertyViews(
2114
+ this.diagram,
2115
+
2082
2116
  this.diagram.propertyViews.filter(
2083
2117
  (propertyView) =>
2084
2118
  !(
@@ -2089,11 +2123,16 @@ export class DiagramRenderer {
2089
2123
  );
2090
2124
  });
2091
2125
  if (this.selectedPropertyOrAssociation instanceof AssociationView) {
2092
- this.diagram.deleteAssociationView(
2126
+ diagram_deleteAssociationView(
2127
+ this.diagram,
2128
+
2093
2129
  this.selectedPropertyOrAssociation,
2094
2130
  );
2095
2131
  } else if (this.selectedPropertyOrAssociation instanceof PropertyView) {
2096
- this.diagram.deletePropertyView(this.selectedPropertyOrAssociation);
2132
+ diagram_deletePropertyView(
2133
+ this.diagram,
2134
+ this.selectedPropertyOrAssociation,
2135
+ );
2097
2136
  }
2098
2137
  if (this.selectedInheritance) {
2099
2138
  if (
@@ -2102,7 +2141,10 @@ export class DiagramRenderer {
2102
2141
  generalizationView === this.selectedInheritance,
2103
2142
  )
2104
2143
  ) {
2105
- this.diagram.deleteGeneralizationView(this.selectedInheritance);
2144
+ diagram_deleteGeneralizationView(
2145
+ this.diagram,
2146
+ this.selectedInheritance,
2147
+ );
2106
2148
  }
2107
2149
  }
2108
2150
  this.selectedClasses = [];
@@ -2209,7 +2251,7 @@ export class DiagramRenderer {
2209
2251
  if (!this.isReadOnly) {
2210
2252
  if (this.selectedClasses.length !== 0) {
2211
2253
  this.selectedClasses.forEach((classView) => {
2212
- classView.setHideProperties(!classView.hideProperties);
2254
+ classView_setHideProperties(classView, !classView.hideProperties);
2213
2255
  });
2214
2256
  this.drawScreen();
2215
2257
  }
@@ -2220,7 +2262,7 @@ export class DiagramRenderer {
2220
2262
  if (!this.isReadOnly) {
2221
2263
  if (this.selectedClasses.length !== 0) {
2222
2264
  this.selectedClasses.forEach((classView) => {
2223
- classView.setHideStereotypes(!classView.hideStereotypes);
2265
+ classView_setHideStereotypes(classView, !classView.hideStereotypes);
2224
2266
  });
2225
2267
  this.drawScreen();
2226
2268
  }
@@ -2231,7 +2273,10 @@ export class DiagramRenderer {
2231
2273
  if (!this.isReadOnly) {
2232
2274
  if (this.selectedClasses.length !== 0) {
2233
2275
  this.selectedClasses.forEach((classView) => {
2234
- classView.setHideTaggedValues(!classView.hideTaggedValues);
2276
+ classView_setHideTaggedValues(
2277
+ classView,
2278
+ !classView.hideTaggedValues,
2279
+ );
2235
2280
  });
2236
2281
  this.drawScreen();
2237
2282
  }
@@ -2286,8 +2331,8 @@ export class DiagramRenderer {
2286
2331
  1,
2287
2332
  );
2288
2333
  const res = this.layoutTaxonomy(views, this.diagram, false, true);
2289
- res[0].forEach((cv) => this.diagram.addClassView(cv));
2290
- 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));
2291
2336
 
2292
2337
  this.drawScreen();
2293
2338
  }
@@ -2319,8 +2364,8 @@ export class DiagramRenderer {
2319
2364
  false,
2320
2365
  false,
2321
2366
  );
2322
- res[0].forEach((cv) => this.diagram.addClassView(cv));
2323
- 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));
2324
2369
  }
2325
2370
 
2326
2371
  this.drawScreen();
@@ -2332,13 +2377,13 @@ export class DiagramRenderer {
2332
2377
  switch (this.interactionMode) {
2333
2378
  case DIAGRAM_INTERACTION_MODE.LAYOUT: {
2334
2379
  this.diagram.generalizationViews.forEach((generalizationView) =>
2335
- generalizationView.possiblyFlattenPath(),
2380
+ relationshipView_simplifyPath(generalizationView),
2336
2381
  );
2337
2382
  this.diagram.associationViews.forEach((associationView) =>
2338
- associationView.possiblyFlattenPath(),
2383
+ relationshipView_simplifyPath(associationView),
2339
2384
  );
2340
2385
  this.diagram.propertyViews.forEach((propertyView) =>
2341
- propertyView.possiblyFlattenPath(),
2386
+ relationshipView_simplifyPath(propertyView),
2342
2387
  );
2343
2388
  break;
2344
2389
  }
@@ -2426,28 +2471,32 @@ export class DiagramRenderer {
2426
2471
  );
2427
2472
 
2428
2473
  if (gview) {
2429
- gview.from.setOffsetX(
2474
+ relationshipEdgeView_setOffsetX(
2475
+ gview.from,
2430
2476
  -(
2431
2477
  this.startClassView.position.x +
2432
2478
  this.startClassView.rectangle.width / 2 -
2433
2479
  this.selectionStart.x
2434
2480
  ),
2435
2481
  );
2436
- gview.from.setOffsetY(
2482
+ relationshipEdgeView_setOffsetY(
2483
+ gview.from,
2437
2484
  -(
2438
2485
  this.startClassView.position.y +
2439
2486
  this.startClassView.rectangle.height / 2 -
2440
2487
  this.selectionStart.y
2441
2488
  ),
2442
2489
  );
2443
- gview.to.setOffsetX(
2490
+ relationshipEdgeView_setOffsetX(
2491
+ gview.to,
2444
2492
  -(
2445
2493
  targetClassView.position.x +
2446
2494
  targetClassView.rectangle.width / 2 -
2447
2495
  eventPointInModelCoordinate.x
2448
2496
  ),
2449
2497
  );
2450
- gview.to.setOffsetY(
2498
+ relationshipEdgeView_setOffsetY(
2499
+ gview.to,
2451
2500
  -(
2452
2501
  targetClassView.position.y +
2453
2502
  targetClassView.rectangle.height / 2 -
@@ -2592,7 +2641,8 @@ export class DiagramRenderer {
2592
2641
  this.setSelectedClassCorner(this.diagram.classViews[i]);
2593
2642
  if (!this.isReadOnly) {
2594
2643
  // Bring the class view to front
2595
- this.diagram.setClassViews(
2644
+ diagram_setClassViews(
2645
+ this.diagram,
2596
2646
  this.reorderDiagramDomain(
2597
2647
  guaranteeNonNullable(this.selectedClassCorner),
2598
2648
  this.diagram,
@@ -2632,7 +2682,9 @@ export class DiagramRenderer {
2632
2682
  }
2633
2683
  if (!this.isReadOnly) {
2634
2684
  // Bring the class view to front
2635
- this.diagram.setClassViews(
2685
+ diagram_setClassViews(
2686
+ this.diagram,
2687
+
2636
2688
  this.reorderDiagramDomain(
2637
2689
  this.selectedClasses[0] as ClassView,
2638
2690
  this.diagram,
@@ -2670,7 +2722,8 @@ export class DiagramRenderer {
2670
2722
  // check for selection of inheritance view
2671
2723
  for (const generalizationView of this.diagram
2672
2724
  .generalizationViews) {
2673
- const val = generalizationView.findOrBuildPoint(
2725
+ const val = findOrBuildPoint(
2726
+ generalizationView,
2674
2727
  eventPointInModelCoordinate.x,
2675
2728
  eventPointInModelCoordinate.y,
2676
2729
  this.zoom,
@@ -2686,7 +2739,8 @@ export class DiagramRenderer {
2686
2739
  // check for selection of association view
2687
2740
  if (!this.selectedPoint) {
2688
2741
  for (const associationView of this.diagram.associationViews) {
2689
- const val = associationView.findOrBuildPoint(
2742
+ const val = findOrBuildPoint(
2743
+ associationView,
2690
2744
  eventPointInModelCoordinate.x,
2691
2745
  eventPointInModelCoordinate.y,
2692
2746
  this.zoom,
@@ -2703,7 +2757,8 @@ export class DiagramRenderer {
2703
2757
  // check for selection of property view
2704
2758
  if (!this.selectedPoint) {
2705
2759
  for (const propertyView of this.diagram.propertyViews) {
2706
- const val = propertyView.findOrBuildPoint(
2760
+ const val = findOrBuildPoint(
2761
+ propertyView,
2707
2762
  eventPointInModelCoordinate.x,
2708
2763
  eventPointInModelCoordinate.y,
2709
2764
  this.zoom,
@@ -2811,7 +2866,8 @@ export class DiagramRenderer {
2811
2866
  // Resize class view
2812
2867
  if (this.selectedClassCorner) {
2813
2868
  // Make sure width and height are in range!
2814
- this.selectedClassCorner.setRectangle(
2869
+ positionedRectangle_setRectangle(
2870
+ this.selectedClassCorner,
2815
2871
  new Rectangle(
2816
2872
  eventPointInModelCoordinate.x -
2817
2873
  this.selectedClassCorner.position.x,
@@ -2820,7 +2876,7 @@ export class DiagramRenderer {
2820
2876
  ),
2821
2877
  );
2822
2878
  // Refresh hash since ClassView rectangle is not observable
2823
- this.selectedClassCorner.forceRefreshHash();
2879
+ positionedRectangle_forceRefreshHash(this.selectedClassCorner);
2824
2880
  this.drawClassView(this.selectedClassCorner);
2825
2881
  this.drawScreen();
2826
2882
  }
@@ -2847,9 +2903,12 @@ export class DiagramRenderer {
2847
2903
  (this.clickY - selectedClassOldPosition.oldPos.y);
2848
2904
  newMovingDeltaX = selectedClass.position.x - newMovingX;
2849
2905
  newMovingDeltaY = selectedClass.position.y - newMovingY;
2850
- selectedClass.setPosition(new Point(newMovingX, newMovingY));
2906
+ positionedRectangle_setPosition(
2907
+ selectedClass,
2908
+ new Point(newMovingX, newMovingY),
2909
+ );
2851
2910
  // Refresh hash since ClassView position is not observable
2852
- selectedClass.forceRefreshHash();
2911
+ positionedRectangle_forceRefreshHash(selectedClass);
2853
2912
  }
2854
2913
  });
2855
2914
  this.potentiallyShiftRelationships(
@@ -2877,12 +2936,14 @@ export class DiagramRenderer {
2877
2936
  // Change line (add a new point to the line)
2878
2937
  if (this.selectedPoint) {
2879
2938
  if (this.selectedPropertyOrAssociation) {
2880
- this.selectedPropertyOrAssociation.changePoint(
2939
+ relationshipView_changePoint(
2940
+ this.selectedPropertyOrAssociation,
2881
2941
  this.selectedPoint,
2882
2942
  eventPointInModelCoordinate,
2883
2943
  );
2884
2944
  } else if (this.selectedInheritance) {
2885
- this.selectedInheritance.changePoint(
2945
+ relationshipView_changePoint(
2946
+ this.selectedInheritance,
2886
2947
  this.selectedPoint,
2887
2948
  eventPointInModelCoordinate,
2888
2949
  );
@@ -3101,9 +3162,8 @@ export class DiagramRenderer {
3101
3162
  ...this.diagram.associationViews,
3102
3163
  ];
3103
3164
  for (const propertyHolderView of propertyHolderViews) {
3104
- let fullPath = propertyHolderView.buildFullPath();
3105
- fullPath = manageInsidePointsDynamically(
3106
- fullPath,
3165
+ const fullPath = RelationshipView.pruneUnnecessaryInsidePoints(
3166
+ propertyHolderView.buildFullPath(),
3107
3167
  propertyHolderView.from.classView.value,
3108
3168
  propertyHolderView.to.classView.value,
3109
3169
  );
@@ -3234,11 +3294,15 @@ export class DiagramRenderer {
3234
3294
 
3235
3295
  // Set layout of current level
3236
3296
  if (positionInitialClass || currentLevelIndex > 0) {
3237
- (levels[0] as ClassView).setPosition(new Point(startX, currentLevelY));
3297
+ positionedRectangle_setPosition(
3298
+ levels[0] as ClassView,
3299
+ new Point(startX, currentLevelY),
3300
+ );
3238
3301
  levels.forEach((view, idx) => {
3239
3302
  if (idx > 0) {
3240
3303
  const precedent = levels[idx - 1] as ClassView;
3241
- view.setPosition(
3304
+ positionedRectangle_setPosition(
3305
+ view,
3242
3306
  new Point(
3243
3307
  precedent.position.x + precedent.rectangle.width + spaceX,
3244
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,
@@ -84,10 +84,6 @@ import {
84
84
  isValidFullPath,
85
85
  isValidPathIdentifier,
86
86
  resolvePackagePathAndElementName,
87
- setPropertyName,
88
- setPropertyGenericType,
89
- setPropertyMultiplicity,
90
- addPackageElement,
91
87
  } from '@finos/legend-graph';
92
88
  import {
93
89
  guaranteeNonNullable,
@@ -104,10 +100,19 @@ import {
104
100
  CORE_DND_TYPE,
105
101
  ElementDragSource,
106
102
  useEditorStore,
103
+ property_setName,
104
+ property_setGenericType,
105
+ property_setMultiplicity,
106
+ package_addElement,
107
107
  } from '@finos/legend-studio';
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
 
@@ -857,9 +862,10 @@ const DiagramEditorInlineClassCreatorInner = observer(
857
862
  diagramEditorState.setInlineClassCreatorState(undefined);
858
863
  const [packagePath, name] = resolvePackagePathAndElementName(path);
859
864
  const _class = new Class(name);
860
- addPackageElement(
865
+ package_addElement(
861
866
  editorStore.graphManagerState.graph.getOrCreatePackage(packagePath),
862
867
  _class,
868
+ editorStore.changeDetectionState.observerContext,
863
869
  );
864
870
  editorStore.graphManagerState.graph.addElement(_class);
865
871
  editorStore.explorerTreeState.reprocess();
@@ -1032,14 +1038,14 @@ const DiagramEditorInlinePropertyEditorInner = observer(
1032
1038
  event,
1033
1039
  ) => {
1034
1040
  if (property instanceof DerivedProperty || property instanceof Property) {
1035
- setPropertyName(property, event.target.value);
1041
+ property_setName(property, event.target.value);
1036
1042
  diagramEditorState.renderer.render();
1037
1043
  }
1038
1044
  };
1039
1045
 
1040
1046
  const changeMultiplicity = (val: Multiplicity): void => {
1041
1047
  if (property instanceof DerivedProperty || property instanceof Property) {
1042
- setPropertyMultiplicity(property, val);
1048
+ property_setMultiplicity(property, val);
1043
1049
  diagramEditorState.renderer.render();
1044
1050
  }
1045
1051
  };
@@ -1059,7 +1065,7 @@ const DiagramEditorInlinePropertyEditorInner = observer(
1059
1065
  };
1060
1066
  const changePropertyType = (val: PackageableElementOption<Type>): void => {
1061
1067
  if (property instanceof Property || property instanceof DerivedProperty) {
1062
- setPropertyGenericType(property, new GenericType(val.value));
1068
+ property_setGenericType(property, new GenericType(val.value));
1063
1069
  }
1064
1070
  };
1065
1071
 
@@ -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
  }