Scriptlets in Enterprise Architect 16 – A Step Beyond Static View
Sparx Systems Enterprise Architect 16 now includes a New Scriptlet element that provides a dynamic view of your diagram. Scriptlet is a JavaScript-based powerhouse that allows you to access the underlying diagram and element API for customizing element appearance, text, tagged values, and other properties. Scriptlets are executed automatically when the diagram containing them is reloaded or they can be executed manually on demand.
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
Figure 1 Scriptlet in Toolbox
Key Points
- Apply change to the appearance of elements, names, and tagged values.
- Updates to dynamic properties can be automated.
- Create your spreadsheets with the new Grid Style diagrams and Scriptlets.
- Update the Grid style diagrams using new cell references (A:1, A:2, etc.,) API.
- Dynamically colour code elements based on your rules.
- Populate and edit a table of data.
- Render graphics.
- Validate model elements in a diagram.
How to use Scriptlets in EA 16?
- Drag-drop the Scriptlet element from the toolbox.
- Double click on the artifact to open the scripting pad.
- Edit the script as required.
- Reload the diagram to run the script automatically or right-click on the Scriptlet element and choose ‘Run Script’ from the context menu to run manually.
- Multiple Scriptlet elements can be used on a single diagram and, the Z-order of the Scriptlets on the diagram determines the order in which they are executed.
- Scriptlets are model-based and therefore the same Scriptlet element can be used on multiple diagrams.
Using Scriptlets in MDG Technologies
- Scriptlets can be incorporated into the definition of an element stereotype, as part of a Profile in an MDG Technology.
- Scriptlets can therefore be used to make on-the-fly changes to an element’s properties and presentation.
- To add a Scriptlet to an element stereotype, create an attribute named ‘_scriptlet’ within the element used to define the stereotype, and enter the script code into the ‘Initial Value’ field of that attribute’s properties.
Further InformationÂ
Please contact us or write an email to info@sparxsystems.in to have a live demo about the new EA 16 features and capabilities.         Â