Creating commands
Overview of commands
Each J MDA component selected in a project comes with a set of commands, each represented by a pop-up menu item available for the elements concerned. The selection of one of these menu items activates a J method defined in Objecteering MDA Modeler.
Commands are instances which are stereotyped command. They have a label attribute which defines the label displayed in menus.
Commands are created in the GUI extensions folder belonging to the J MDA component.
Two different types of command can be created:
· commands to execute J code (see Figures 164)
· commands to execute templates (see Figures 165)
Creating a command to execute J code
Commands to execute J code can be
created by clicking on the
icon
from a J MDA component or from its GUI
extensions folder.

Figure 164. Creating a command to execute J code
Steps:
1. In the explorer, click on the J MDA component or on its GUI extensions folder in which you want to create the command.
2.
Click on the
icon.
3. Enter a name for the command.
4. Enter the label which will appear in the menu.
5. Define the activation mode (please refer to the related paragraph further on in this section for further details).
6. Select the operation that will be run by this command. An operation that can be referenced by a command is a public operation with no parameters. Without closing the window, you can create a new operation in a profile implementation referenced by the MDA component, and then drag and drop this new operation in the Invoked operation field.
7. Click on OK to confirm.
The Activation mode
The three fields which appear in the Activation zone of the Command window have the following purpose:
· Can be activated in editing mode: This indicates that the menu associated with the command is only present in an editor in edit mode.
· Can be activated in consulting mode: This indicates that the menu associated with the command is only present in an editor in consult mode.
· Can be activated on a read only object: This indicates that the menu associated with the command is also present on elements which cannot be modified.
Once the command has been created, the J code that will be executed must be entered in a JCode note attached to the operation.
Creating a command to execute templates
Commands to execute J code can be
created by clicking on the
icon from a J MDA component or from its GUI extensions folder.

Figure 165. Creating a command to execute templates
Steps:
1. In the explorer, click on the J MDA component in which you want to create the command.
2.
Click on the
icon.
3. Enter a name for the command.
4. Enter the label which will appear in the menu. This field can remain empty. In this case, the label automatically takes the same value as the name of the command.
5. Define the activation mode (please refer to the paragraph in this section for further details).
6. Select the templates to execute. Details on the associated icons are provided in the table below. You may define as many templates as you like, in any order and of any type (diagram, documentation, code). It is also possible to run the same template several times but using different parameters (for example, generate design documentation in HTML format, then in RTF format and finally in PDF format).
|
The ... icon |
is used
to ... |
|
|
add a diagram template and define its execution parameters. |
|
|
add a documentation template and define its execution parameters. |
|
|
add a code template and define its execution parameters. |
|
|
delete the selected template. This icon is only available when a template has been selected. |
|
|
Reorganize the template execution order, by moving the selected template up a level. This icon is only available if the template can be moved up. |
|
|
Reorganize the template execution order, by moving the selected template down a level. This icon is only available if the template can be moved down. |
7. Define the operation that will contain the J code used to execute the templates.
8. Define the metaclasses or stereotypes on which the command will be available.
9. Click on OK to confirm.
After clicking on the OK button, a command is created for each metaclass or stereotype you selected. Given that it is not possible to have several commands all with the same name, the name of the command created is prefixed by the name of the selected metaclass, if several metaclasses have been selected. This rule does not apply if only one metaclass has been selected. In this case, the name of the command created is the name entered in the Name field.
A J operation is also created for each metaclass or stereotype you selected. If a J operation of the same name already exists, you will be asked to confirm whether or not to update the J code of this operation. This operation contains the J code used to execute templates. If modifications have to be made to template execution (execution order, template addition, etc), only the code of this operation can be updated. After creation, when this command is edited, a window identical to the Defining a command to execute J code window (Figure 164) appears.
For more information on entering J code to execute templates, please see Running templates using J scripts.
The window shown in Figure 165 can only be confirmed if the contents of all the fields have been defined. If this is not the case, an error message appears at the bottom of the window (see Figure 166 below).

Figure 166. An error message appearing when the creation of a command to execute template is confirmed
Defining a diagram template's execution properties
After clicking on the icon, a window appears, in which you can enter the execution properties of a diagram template (Figure 167).

Figure 167. Defining the execution parameters for a diagram template
|
The
field |
is used
to ... |
|
Template |
select the template to be executed. The list contains all the diagram templates defined on the profile implementations referenced by the MDA component. |
|
Recursive launch |
apply the template to components. Only NameSpace elements are browsed. |
The OK button is only active when all the parameters have been defined.
After clicking on the OK button, the template appears in the command creation window.
Defining a documentation template's execution properties
After clicking on the icon, a window appears, in which you can enter the execution properties of a documentation template (Figure 168).

Figure 168. Defining the execution parameters for a documentation template
|
The
field |
is used
to ... |
|
Template |
select the template to be executed. The list contains all the documentation templates defined on the profile implementations referenced by the MDA component. |
|
Filename |
select the file name generated by the template. This field has to be a J expression. For example, "C:\project\" + Name + ".rtf". |
|
Format |
Select the format: - XML (DocBook) - Multiple HTML - generation in several files - Simple HTML - generation in one file - PDF (Portable Document Format) -
RTF ( - RTF (Rich Text Format) with round trip tags |
The OK button is only active when all the parameters have been defined.
After clicking on the OK button, the template appears in the command creation window.
Defining a code template's execution properties
After clicking on the icon, a window appears, in which you can enter the execution properties of a documentation template (Figure 169).

Figure 169. Defining the execution parameters for a code template
|
The
field |
is used
to ... |
|
Template |
select the template to be executed. The list contains all the code templates defined on the profile implementations referenced by the MDA component. |
|
File name |
select the file name generated by the template. This field has to be a J expression. For example, "C:\project\" + Name + ".java". |
The OK button is only active when all the parameters have been defined.
After clicking on the OK button, the template appears in the command creation window.
Toolbar
The icons appearing in the MDA tab of the auxiliary window can be used to run the following commands:
|
Icon |
Description |
|
|
This icon is used to open this page. |
|
|
This icon is used to check that the command has been correctly modeled. |