Creating a command

 

We are now going to create a command to generate the code template in our “JavaGenerator” J MDA component.

 

Figure 22. Creating a command

 

Steps:

1.      Select the “JavaGenerator” MDA component and click on the  icon in the explorer palette. The "Command to execute templates" window then appears.

2.      In the “Name” field, enter “generate”.

3.      In the “Label” field, enter “Generate”.

4.      In the “Activation fields”, check the two active tickboxes.

5.      Click on the  icon to open the window used to select the code template to execute. In this window, select the “ClassJavaTemplate” template from the dropdown list, and enter the generated file name in the form of a J expression. For example: “"C:\project\java\" + Name + ".java"”.

6.      In the “Operation definition” zone, enter “generate” in the “Name” field.

7.      In the “Operation definition” zone, select “Behavior profiles.JavaProfileImpementation” in the “Profile” field.

8.      In the “Metaclass(es) to which the command applies” field, select “Class” (located in the “Objecteering UML/Metamodel” package)

9.      Click on “OK” to confirm.

 

For more information on creating commands, please see “Creating commands”.

 

The result of these operations is shown below (Figure 23).

 

Figure 23. The new command appears in the J MDA component's “GUI extensions” folder