Please note : This help page is for a BETA build of Enterprise Architect and may be incomplete/unfinished. The current official page can be found here.

Prev Next

Grid-Style Diagrams

Grid-style diagrams allow you to manage and organize diagrams, by sorting diagram elements into cells within a grid.  The grid functionality integrates with the new scripting API to facilitate setting the appearance of diagram elements dynamically, as the diagram is loaded.

Access

Properties Window

Select 'Enable' from the drop-down list for the option 'Grid-style' under the heading 'Appearance'.

This action turns on the 'grid-style' setting and opens the 'Grid- Style Properties' dialog, where you can specify settings such as number of columns and the height and width of cells.

Context Menu

For diagrams that are displayed with Grid-Style enabled, the context menu option 'Grid' offers a number of commands specific to grid-style diagrams.

They are:

  • Show Grid Lines
  • Show Grid Headers
  • Edit Grid
  • Compact Grid

Setting the Grid Style Properties

Enabling 'Grid-Style' on a diagram creates a number of columns and rows on the diagram, according the values specified in the 'Grid-Style Properties' dialog.

The 'Grid Properties' dialog is displayed at the time of enabling grid-style for a diagram.

  The dialog can also be displayed at any time after grid-style has been enabled, by selecting the context menu option 'Grid > Edit Grid'.

Altering the Grid Cells Using Scriptlets

Scriptlet artifacts can be used to run JavaScript code to access elements in a grid-style diagram and set the appearance of those elements.  For example, to set the font and background color, or to alter the text that is displayed.

Each Scriptlet has access to three global objects in addition to the standard automation environment. They are:

  • theDiagram - an automation Diagram interface to the diagram on which the Scriptlet resides
  • theElement - an automation Element interface to the Scriptlet artifact itself
  • theInstance - an automation DiagramObject interface to the Scriptlet artifact itself

When a diagram is viewed as a grid, we can use automation functions to retrieve elements at specified grid locations. The location format is the same as one sees in a spreadsheet, with columns labeled 'A', 'B', 'C', ..., 'AA', 'AB', etc. and the rows numbered in sequence.

To alter the appearance of a grid element, retrieve its underlying Object, using the function GetObjectByGrid.

To alter the value of a grid element, retrieve its underlying Element, using the function GetElementByGrid.

For example;

object = theDiagram.GetObjectByGrid("A", "2");

element = theDiagram.GetElementByGrid("A", "2");

A diagram can contain any number of Scriptlet artifacts.  The Scriptlets will run before the diagram is displayed, and whenever the diagram is reloaded.  When there are multiple Scriptlets on a diagram, the order in which they are executed is determined by their Z-order on the diagram.

Learn more