One of the latest features of Sparx Enterprise Architect 15 is the model based add-ins which can be created using JavaScript. These model based add-ins are defined by a combination of Receptions, Attributes and Operations which can be easily added in a model by just creating with a valid stereotyped classes.
Assuming having basic knowledge with Sparx Traditional add-ins, broadcast events and JavaScript.
Why model based add-ins
-
- Accessed by all the users within a model
- Purely Model specific
- No installation, registry entries , distribution or license worries
- Self-Documenting as everything is modelled and created directly in EA
Prerequisites
-
- Signal Reference Library ( Broadcast Events ) - Defines the entry points to the add-In similar to the com class in the traditional add-ins
- Referencing relevant signals in the receptions
What is Signal Reference Library
These are Signal elements which contain definitions of all the Enterprise architect broadcast events. Signals that are added to the add-in will receive an event when triggered similar to traditional add-ins. EAExample model contains all the broadcast event signals under the package Example Model.EA 15 Examples.Dynamic Model Based Add-Ins.Broadcast Types
Mandatory Signals or Events for Add-in
-
- EA_Connect
- EA_GetMenuItems
- EA_MenuClick
All the available events references can be found here https://www.sparxsystems.com/enterprise_architect_user_guide/15.0/automation/broadcastevents.html
To Create an JavaScript Add-In
- Create a Signal Reference Library referring EAExample model. (Simple way would be just do an XMI export of the Broadcast Types package from EA model and import into your working model).
- Create a package in the root node for modelling the add-in
- Create a class object with stereotype JavascriptAddin ( this stereotyped element can be found in Model Add-Ins tool box as shown below
- The name of the above defined will be used in the JavaScript code. In our case it will be “Javascript Addin”
- Add the signal reference in the created class using the reception.
- To Access Reception Right-click on the Class element and select the 'Features | Receptions' option. The Features window displays, at the 'Receptions' page.
- Add the required events by clicking the button to the right of the New Receptiontext in the 'Name' column , the dialog will show the available Signals ( it will automatically fetch the parameters details from the object )
- To Access Reception Right-click on the Class element and select the 'Features | Receptions' option. The Features window displays, at the 'Receptions' page.
- Once selected all the added signals will be displayed in the class object.
- After adding these events, its time to play with some JavaScript codes.
- Please open the behavior window (Develop > Source Code > Behavior) make sure the created class object “Javascript Addin” has been selected. It will show all the added events to which we need to add the code
- Codes for these events are similar to the traditional add-ins ( please refer the attached model for more details )
- Finally make sure the add-in is enabled. To enable the add-in Specialize -> Manage-Addin and please click Load on startup
- Once the add-in is loaded you can find it in the ribbon
Note:
- The above referenced model can be downloaded from the http://sparxsystems.in/downloads/Demo Jacascript Add-in SSIN.zip
- EAExample model contains two example Javascript add-ins by default, you need to just enable it in the manage add-ins for using.
For more details or customization please contact This email address is being protected from spambots. You need JavaScript enabled to view it.
- Create a class object with stereotype JavascriptAddin ( this stereotyped element can be found in Model Add-Ins tool box as shown below