Book a Demo

Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Prev Next

Create an Add-In

Model Based Add-Ins are defined within the model, using Classes that are stereotyped as 'JavascriptAddin'. Using these stereotyped Classes, you can specify Receptions, Methods and Properties that together define the behaviors of the Add-In, and how it responds to the various events occurring within the system.

Receptions are defined for the Class, by specifying a signal that will be received. The Receptions allow you to specify JavaScript code that will be executed in response to receipt of the corresponding signal.  Signals that are relevant to your Model Based Add-In should be included within the model in which you are defining or using Model Based Add-Ins. The Model Wizard (Start Page 'Create from Pattern' tab) offers a pattern that contains all of the signals relevant to Model Based Add-Ins, providing an easy means by which to include these signals in your model.

Functions defined as methods of the Class can be called by the Receptions code, while the Class attributes can be used to define global variables that are available to the executing code.

Create a JavaScript Add-In

Step

Action

See also

1

Click on the Choose perspective button. icon and select the 'Management > Model Add-Ins' Perspective.

2

Create or open a (Class) diagram on which to work, then open the 'Model Add-Ins' page of the Diagram Toolbox.

(Use the Toolbox menu to select the 'Model Add-ins' page of the Toolbox.)

Class

3

Create a JavascriptAddin by dropping the 'JavascriptAddin' icon from the toolbox onto a diagram.

The name of your JavascriptAddin Class will be used in generated JavaScript code.  It needs to be a valid JavaScript identifier.

4

Locate the Signal Library.  Signals are used to define the entry points into your Add-In.

If not already in your model, the Signal Library is available for import as a model pattern.

Signal Reference Library

5

Open the receptions list.  Add a reception for any Signal that you want to receive.  A reasonable starting point would be to include:

  • EA_Connect
  • EA_GetMenuItems
  • EA_MenuClick
Reception

6

Open the Behavior window for your Class ('Develop > Source Code > Behavior').

This shows all the available behavioral features that you can add code to, including the receptions created previously.

Examples for the signals discussed earlier are:

EA_Connect

     return "";

EA_GetMenuItems

     if(MenuName == "-Example Add-in")

          return ["Item 1", "Item 2", "-", "About"];

     else

          return "-Example Add-in";

EA_MenuClick

     Session.Prompt("You clicked " + ItemName, 1);

Edit Add-In Code Editing Source Code

7

Enable your Add-In using the 'Manage Add-Ins' dialog.

If security is enabled in your model, this requires model administration rights.

Model Add-In Management

8

You can now test and further develop your Add-In.

Learn more