Editing Elements

Now that new elements have been created, they must be modified in order to be meaningful to the model.

Inline Editing Text Values

The diagram drawing area in the Diagram pane not only allows for creating, deleting and moving graphical elements; it is also possible to enter values, such as names, directly into the elements without using a different pane. Exactly which element properties can be modified depends upon the specific element. Most of the elements allow editing of the name. In the case of a state diagram, for example, selecting a state and then typing will immediately open a small text editor. When editing is finished, the typed text will replace the previous text in the navigation tree and Properties tab as well as the diagram of the selected state.

Classes and interfaces offer far more options for editing values than just editing their names. Both of them are constructed of different parts called compartments. The first compartment holds the values for the name, the stereotype and the package of the class or interface. You can edit its name as described above; however, stereotypes and packages can only be changed using the Properties tab. The second and third compartments hold the attributes and operations defined for the class or interface (in UML, interfaces can have operations only). Inline editing works the same way here. Select the attribute or operation you want to change and start typing (or double-click on it to open the inline editor). Press 'return' on the keyboard to end the editing.

The attributes and operations compartments in the diagram can be set to invisible for the current diagram via the Context menu, or for the entire model via the 'Settings' dialog from the 'Edit' menu.

You can create a new attribute or operation by moving the mouse to the right side of the compartment and then clicking on the 'create' button that appears. As above, 'return' will end the editing and add the new attribute/operation to the class or interface.

Figure 7-14. Add a new attribute or operation to a class inline

Editing via the Details pane

There are many modifications that can be made to elements from the Details pane. You can add attributes and operations, rename elements, change namespaces and stereotypes, add colors and borders, and much more. This section will outline some of the most important modifications that can be made. Many of these procedures can be extrapolated to other editing procedures.

Let's look at a class element, as these are very frequently used elements.

The Properties Tab

The first tab you will see in the Details pane is the Properties tab.

Figure 7-15. Properties tab for a class

The toolbar across the top of the tab contains buttons for navigation between elements, creation buttons, and a delete button. These buttons will change depending on the type of element selected as the current active element.

Below this toolbar are the editable characteristics of the class. The name of the element can be typed directly into the name field with no restrictions. Likewise, Visibility and Modifiers can be directly modified from their checkboxes. Note, however, that these two properties are not displayed in the diagram itself, thus the changes made will be visible only from the Properties tab (the modifier 'abstract' is the exception to this). The Stereotype and Namespace must be selected from the dropdown list of available options. The Owned Elements section is automatically populated.

All changes made to the class are propagated throughout the model. For instance, when a namespace is changed, the navigation tree is updated and the class is moved from the original package to the new one that was just selected. This change is also reflected in the Diagram pane: the top compartment of the class will display <<from new_namespace>> in place of <<from old_namespace>> , where old_namespace and new_namespace refer to the original namespace and most recently selected namespace. This easy and convenient mechanism for changing namespaces is provided for nearly all of the elements.

To the left of the editable characteristics are elements which are affiliated with the selected element. In UML, operations and attributes are considered both an elements in their own right as well as a characteristics of a class. As they are elements, they have their own Properties tabs. Therefore, to edit the name or any other properties of an operation for example, we must go to the Properties tab of that operation. That is why it is not editable here. The remaining fields are: Extends, Implements, Associations, and Derived. These properties show different relations between the focused class and other model elements.

The Style Tab

Next we can look at the Style tab, which determines how the element is rendered in the diagram.

Figure 7-16. Style tab for a class

The Style tab determines which colors and fonts will be used to display the element. This is very useful when color-coding diagrams or highlighting aspects of the diagram. As with the properties tab, not all of the options make sense for every element. Therefore, only the appropriate style options are available.

Options for the Style tab:

Whereas changes made to an element in the Properties tab are propagated throughout the model, changes made to the style of an element apply to the current diagram only.

Editing via the Context menu

The Context menu can be accessed by right-clicking on an element in a diagram. Entries relevant to the selected element are displayed. Remember that things like attributes and operations are considered elements, therefore the context menu will be different than that for the class in which they occur. If you do not see what you expect, be sure that you have selected the proper element to be the active element.

The Show option displays all checked items in the diagram. In the case of a class element, this includes stereotype, package, and compartment options. Unchecked items remain hidden from view.

It is also possible to create things like attributes, operations, and dependent edges when appropriate. These items are listed towards the bottom of the context menu and, once created, are available for editing in the Properties tab.

Figure 7-17. Context menu options for a Use Case