Author Topic: How use JavaScript to filter Compartments as part of Diagram Properties?  (Read 3909 times)

ea0522

  • EA User
  • **
  • Posts: 134
  • Karma: +5/-0
    • View Profile
Using a JavaScript, I can create a diagram showing the elements I'm interested in.
However, by default, the diagram shows some compartments of the elements resulting in a rather messy diagram with elements of different sized (large) object boxes.

I can make the diagram look nicer using a property of the diagram using "Diagram Properties => Elements => Show Compartments" and then ticking or unticking the desired compartments, e.g. do not tick the Attributes compartment.

Now I would like to know how to set this diagram property using my JavaScript.
Thanks.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13287
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How use JavaScript to filter Compartments as part of Diagram Properties?
« Reply #1 on: November 27, 2024, 12:26:34 am »
Probably in the StyleEx columns somewhere.

Geert

ea0522

  • EA User
  • **
  • Posts: 134
  • Karma: +5/-0
    • View Profile
Re: How use JavaScript to filter Compartments as part of Diagram Properties?
« Reply #2 on: November 27, 2024, 01:13:04 am »
Thanks for the quick reply and suggestion Geert.
Did some testing and it looks like it is stored in the PDATA column.

Now the next issue arises, as I cannot find how to set the value for this from JavaScript...
It seems not to be a property of the EA.Diagram object.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13287
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How use JavaScript to filter Compartments as part of Diagram Properties?
« Reply #3 on: November 27, 2024, 01:24:48 am »
Yeah, you might need to an sql update statement with Repository.Execute

Geert

ea0522

  • EA User
  • **
  • Posts: 134
  • Karma: +5/-0
    • View Profile
Re: How use JavaScript to filter Compartments as part of Diagram Properties?
« Reply #4 on: November 27, 2024, 01:50:40 am »
Found a solution I would like to share:

Code: [Select]
// Set the properties of curDiagram as EA.Diagram
curDiagram.HighlightImports = false;   // Hides the Namespace of Elements
curDiagram.ExtendedStyle    = "HideAtts=1;";   // Hides the Attribute compartment of Elements
curDiagram.StyleEx              = "HideConnStereotype=1;";  // Hides the Stereotype Labels of Connectors
curDiagram.Update();

Works for me in JavaScript.
Thanks to Geert for pointing in the right direction.

shimon

  • EA User
  • **
  • Posts: 133
  • Karma: +5/-0
    • View Profile
Re: How use JavaScript to filter Compartments as part of Diagram Properties?
« Reply #5 on: November 28, 2024, 12:02:05 am »
Nice.