Creating navigation nodes

 

Adding a navigation node

Navigation nodes are elements which belong to the profile's reference metamodel. Examples of navigation nodes could be the “Package”, “Class” or “Operation” metaclasses. A “Package” navigation node would browse all the packages belonging to a given package, while a “Class” navigation node would browse the classes belonging to the package in question. An “Operation” navigation node would browse all the operations belonging to a given class.

 

To add a new navigation node to your diagram, code or documentation template, simply click on the  icon on the top-left of the template design window and select the type of UML element you wish to retrieve using the scan method (Figure 110).

 

Figure 110. Creating a navigation node

 

Steps:

1.      Click on the  icon. The “Selection of a scan method” window then appears.

2.      In this window, select the element you wish to scan for. Elements of the indicated type will be retrieved by this method. In our example, the scan method will return the classes belonging to a package.

3.      Click on “OK” to confirm.

 

If you want to create a node without navigating to another element, select “Retrieve the current element” in the previous dialog box.

 

Navigation node properties

The properties of a navigation node are presented on the top-right of the template design window, when a navigation node has been selected, as shown in Figure 111.

 

Figure 111. The properties of a navigation node

 

Property

Description

Scan method

This property corresponds to the method used on the current element to obtain its sub-elements. In the example shown in Figure 146 above, the current element is a package and the “OwnedElementClas” method is called to retrieve the classes of this package.

Metaclass

This property indicates the metaclass returned by the scan method.

Filter

This property is used to filter elements according to their stereotypes, tagged values, notes or properties. By double-clicking on the  button when the field is selected, the window shown in Figure 8-8 appears.

Triggered action

This property indicates code to be executed for each element scanned by the scan method. For example, traces can be displayed.

This property is not available for code templates.

Memorize

This property is used to memorize the elements that are browsed by the navigation node. This field must contain a character string representing the name of the element to retain. This name can then be used to retrieve the memorized element.

 

 

Adding a navigation node

After adding a navigation node, you can modify the J code defined in the “Scan method” property, for example, to add a filter.

In the figure 111, instead of “OwnedElementClass”, you can replace by “OwnedElementClass.<select (IsAbstract)” to retrieve only the abstract classes.

 

For more information on entering J code, please see “Inserting J code”.