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 of the element at a minimum. For example, selecting a state from within a state machine diagram 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 in 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 the name of the class 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 Ctrl-Return on the keyboard or click elsewhere in the application to end the editing. Note that in some cases, interfaces may be rendered as a circle in lollipop notation, and therefore will not display compartments.

After editing an attribute or operation, you can directly add another attribute or operation without leaving the element by hitting 'return' on the keyboard instead of Ctrl-Return after editing the first attribute or operation.

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

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.

Figure 13-5. Add a new attribute or operation to a class inline

Editing Via the Details Pane

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

The Properties Tab

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.

Figure 13-6. 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 Namespace must be selected from the list of available options. Stereotypes can be applied through the Stereotypes dialog, accessed by right-clicking the Stereotypes field and selecting 'Edit' from the context menu that appears or clicking the ellipsis button . 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 13-7. Style tab for a class

The Style tab indicates 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. It is also possible to override diagram-level specifications for compartment visibility. 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:

  • Fill - Determines the background fill color of the element

  • Lines - Determines the border color of the element

  • Font - Determines the color and font of the text.

  • Visibility - Radio buttons and checkboxes determine the visibility of element compartments and association multiplicities of 1.

  • Shape Characteristics - Sets properties such as opacity for non-elemental items included in a diagram.

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.

The Documentation Tab

To add documentation to a model element, select the documentation tab in the Details pane. When you have imported Java source code, the Javadoc contained in the source code is likewise imported and viewed in the documentation tab. When working with text based IDEs, you put your Javadoc in doc comments ( /** */). When using Poseidon's HTML editor, this is not necessary. The doc comments are added automatically to your source code when you generate it.

Figure 13-8. Editing a method documentation.

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 in their own right; therefore, the context menu for an attribute will be different than that for the class in which it occurs. 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 13-9. Context menu options for a Use Case

Graphic Representations

Elements may be represented by imported graphics instead of the default UML representation. This can be particularly useful in diagrams such as the Use Case diagram, where actors can be displayed with various photographs rather than the usual 'stickman', or in Deployment diagrams where various nodes may be better represented by graphics rather than the standard cube.

Elements that may be represented by graphics: Class, Package, Actor, Interface, Collaboration, Usecase, Object, Lifeline, Component, Artifact, Instance specification, and Node.

To add an image representation:

  1. Select the desired element in the diagram.

  2. Click the 'Create Image Representation' button from the Properties tab of the Details pane.

  3. Select the desired image file.

  4. The selected image will be placed in the diagram in place of the default representation.

The following file extensions are supported: .jpg, .jpeg, .eps, .epsi, .epst, .wbpmp, .wbm, .bmp, .svg, .ps, .pdf, .gif, .png.

Undo/Redo

Sometimes when working with your models, you might have done something you did not really intend to do. If this happens, the ability to revert your work can be very valuable. Poseidon for UML offers such an undo mechanism. The Undo function is not limited to the last change you made - you can undo all the steps you took prior to that, and you can even redo the things you just undid.

To Undo or Redo actions:

Stereotypes

One of the general patterns of an architecture is the Model-View-Controller-Pattern, or the Boundary-Control-Entity-Schema , as it is often rephrased in the UML community. According to this, an architecture is constructed in three layers.

First, the Boundary is responsible for representing information to the user and receiving his interactions. Users of the system interact with this layer only. The next layer, Control, contains the rules on how to combine information and how to deal with interaction. It is responsible for transferring control based on the input received from the Boundary layer. And finally, the Entity layer holds the data and is responsible for its persistence. To which layer a class belongs is expressed using corresponding stereotypes. You obtain these in the Properties tab of each class. An example for the usage of stereotypes is shown below.

Figure 13-10. A Class diagram using stereotypes.

The code generation functionality of Poseidon for UML can distinguish between different stereotypes for the same element type. In this way it can select the appropriate template for generation based on both of these factors. Stereotypes can be displayed for nearly every element type.

Poseidon supports multiple stereotypes for single elements. Adding, editing, and removing these stereotypes is accomplished via a dialog that is accessible from the Details pane.

To access the Stereotype dialog:

  1. Select the element the stereotype applies to from the diagram, Details pane, or Navigation pane.

  2. Open the Properties tab for this element in the Details pane.

  3. Click the ellipsis button to open the stereotype dialog.

    Note that the previous method to access the dialog (right-click in the stereotype field and select 'Edit' from the menu) still works.

Figure 13-11. Stereotype dialog

Once this dialog is open, altering and applying stereotypes is quite simple. The buttons with the arrows allow you to add and remove stereotypes from the element. The 'Add' box below the list of stereotypes will create new stereotypes, but will not automatically add them to the element. Removal of stereotypes from an element is only possible through this dialog.

Selecting a stereotype and clicking the delete button will remove the stereotype from the model completely, not just from the selected element. To remove a stereotype from the element to which it is applied but leave the stereotype in the model, click the 'minus' button .

Stereotype Properties

  • Name - Name of the stereotype

  • Base Class - The stereotype is intended for this type of element

  • Namespace - Namespace of the stereotype

  • Extends - Indicates a parent stereotype, if necessary

  • Modifiers - Additional characteristics of the stereotype

  • Tag Definitions - Tags defined here will be included in any element to which the stereotype is applied

Below illustrates a Tagged Values tab for a class with the above pictured 'Stereotype' applied.

Graphical Representations

When stereotypes are displayed in an element, they may also include a graphic. The graphics are assigned to the stereotypes from Settings dialog (Edit -> Settings -> Stereotype Icons).

  1. Open the file chooser from the 'Path to Icon' column.

  2. Navigate to the desired file and click 'Open'.

  3. The Settings dialog will display a preview of the icon.

  4. The stereotype icon will be displayed along with the name of the stereotype.

Copying, Cutting, and Pasting Elements

Copying a class from one diagram to another is simple, right? Select the class, copy, paste... but what happens to the class if the name of the class is changed, or an attribute is added, or any of a host of other possible edits are made? Beginning with Poseidon 3.1 the answer is, 'That depends.'

Prior to 3.1 (and in the Community Edition), the copy function merely copied the representation of that element. There still existed only one of that element in the model. To illustrate, a model is created with a single class diagram consisting of a single class. The Model Index view and Diagram Centric view each show one class in the model. A new, empty class diagram is created, and the class is copied to the new diagram. Now the Diagram Centric view will show two classes - one in each diagram. But the Model Index view will still show only one class - this single class is represented in two different diagrams. Any changes made to this single element, regardless of the diagram in which it appears, will be reflected in all representations of the element.

Poseidon 3.1 introduces the concept of 'complete copy', where the element itself is copied. Following the previous example, if the class were complete copied and then pasted to a new diagram, the Model Index would now show two classes. At this stage, the classes are identical, but because they are completely separate entities, changes to one class will not affect the other.

'Cut Representation' and 'Complete Cut' follow the same scheme as the copy functions.

Note: Complete Copy, Complete Cut, and Clone Model are not available in the Community Edition.

Elements

To cut a model element:

  • The 'Complete Cut' button

  • The quick-key combination 'Ctrl-X'

  • The context menu option 'Cut Complete' for the selected element

  • The Edit menu option 'Cut Complete'.

Note: Complete Cut is not available in the Community Edition.

To copy a model element:

  • The 'Complete Copy' button

  • The quick-key combination 'Ctrl-C'

  • The context menu option 'Copy Complete' for the selected element

  • The Edit menu option 'Copy Complete'.

Note: Complete Copy is not available in the Community Edition.

Element Representations

To cut only the representation of an element:

  • The 'Cut' button

  • The quick-key combination 'Ctrl-Shift-X'

  • The context menu option 'Cut' for the selected element

  • The Edit menu option 'Cut'.

To copy only the representation of an element:

  • The 'Copy' button

  • The quick-key combination 'Ctrl-Shift-C'

  • The context menu option 'Copy' for the selected element

  • The Edit menu option 'Copy'.

Premium editions of Poseidon for UML also allow you to clone diagrams with one click. See the Section called Cloning Diagrams in Chapter 11.

Removing and Deleting Elements

With drawing tools like Visio or Powerpoint, deleting an element from a diagram simply removes the figure from that single location. With full-blown UML modeling tools this is different. You are always working on a single, consistent model. The different diagrams and the elements contained within them are just components of views rendered from this single model, even if the diagrams are constantly used as a means to change the model. The consequence of this is that modifications to any element within a diagram are applied to the element, not to the diagram. As such, a change made to the element will be seen throughout the entire model.

It then follows that selecting an element and then pressing delete means that the element itself is deleted, meaning that it no longer exists within the model and is removed from all aspects of the model, including other diagrams. Additionally, all connections to other elements, such as associations or inheritances, are completely removed. Note that there is a big difference between deleting an element from a model and removing an element from a diagram.

This leads us to use different terminology with different meanings: You can delete an element from the model, which means that the element is removed entirely and is no longer available in the Navigation pane or in any of the diagrams, or you can just remove its figure from the current diagram you are working with, leaving the element available to the rest of the model. These are very different things, and different commands are used to achieve them.

To completely remove an element from the model:

To remove an element's representation from the current diagram:

The element, as part of the model, remains untouched in other diagrams and it also remains in the tree in the Navigation pane. For elements that are connected to other elements through, for example, an association or inheritance, removing the first element (e.g. a class) means that the association is no longer valid; therefore, the second element (e.g. the association) is also removed from the diagram, but is likewise still accessible from the navigation pane or other diagrams.

If you want to remove an element but not the connections it has to other elements, you can detach it by selecting the connection and dragging the handle at the end of it to another element before you remove the element.