Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: ea0522 on November 26, 2024, 11:14:29 pm

Title: How use JavaScript to filter Compartments as part of Diagram Properties?
Post by: ea0522 on November 26, 2024, 11:14:29 pm
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.
Title: Re: How use JavaScript to filter Compartments as part of Diagram Properties?
Post by: Geert Bellekens on November 27, 2024, 12:26:34 am
Probably in the StyleEx columns somewhere.

Geert
Title: Re: How use JavaScript to filter Compartments as part of Diagram Properties?
Post by: ea0522 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.
Title: Re: How use JavaScript to filter Compartments as part of Diagram Properties?
Post by: Geert Bellekens on November 27, 2024, 01:24:48 am
Yeah, you might need to an sql update statement with Repository.Execute

Geert
Title: Re: How use JavaScript to filter Compartments as part of Diagram Properties?
Post by: ea0522 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.
Title: Re: How use JavaScript to filter Compartments as part of Diagram Properties?
Post by: shimon on November 28, 2024, 12:02:05 am
Nice.