Modify Elements

Once we have arrived at a desired element, we may need to make some modifications. Poseidon provides several ways of changing information relating to an element.

Change Elements

The quickest and easiest way to change information relevant to an element is to change it directly in the diagram. Be aware, however, that not all information can be changed in this way.

At this point in the tour, the Diagram pane should be displaying the class diagram titled, 'Design' and the Details pane should be displaying information about the attribute 'email'. We will now change the name of an operation from the same class, 'Customer'.

In the Diagram pane, double-click on the operation 'checkPwd()' in the class 'Customer'. The Details pane displays the information about this operation, and the text in the Diagram pane itself is now editable from a text box. Change the name of the operation to 'checkPassword()' and then press Ctrl-Return or click elsewhere in the diagram.

Figure 4-11. Change an operation name in a diagram

The name change will be propagated throughout the model, with 'Customer.checkPwd()' replaced by 'Customer.checkPassword()' in every instance.

Another method of changing information is via the Details pane. Select the operation 'checkPassword()' again. Notice that the Details pane provides lots of information about this operation. In the 'name' field, change the name from 'checkPassword()' back to 'checkPwd()' and press return or change the focus of the window by moving the mouse out of the Details pane. The change will now be reflected back in the diagram.

Figure 4-12. Change operation name from the Details pane

Create Elements

Creating new elements is just as simple as modifying existing ones. And just like changing elements, there are several ways to create new ones.

Perhaps we would like to associate a discount program with customers. Let's create a new package, Discount. In the 'Design' class diagram, click on the 'Package' button from the Diagram pane toolbar. A cross-hair appears. Click in the Diagram pane to place the new package into the diagram. Rename this class 'discount' using one of the methods outlined in the previous section.

Now that we have the package, we need to associate it with the package 'Customer'. We could do this by creating a new association through the toolbar and connecting the association ends to the classes, or we could speed things up and use the aptly-named 'Rapid Buttons'. Click on the new package 'discount'. Several buttons appear around the edges of the package. Click and hold the mouse button down on the left rapid button. Drag the crosshair that appears onto the package 'Customer' and release the mouse button. An association has now been created.

Now perhaps we need to make a connection between 'Discount' and a region because different discount schemes are offered in different regions. This will require the addition of another package and another association. One rapid button can take care of everything. Select 'Discount' in the diagram. Click (and this time do not hold) the mouse button on the right rapid button for the package 'Discount'. An new package and an association have been added to the diagram. Rename the new package 'Region'.

Figure 4-13. Add a package to a diagram with the rapid buttons

Delete Elements

So after further review, we have decided that the package 'Discount' is a good idea, but not for this diagram. We have further decided that the 'Region' package is unnecessary and will not be used elsewhere in the model. Let's first delete 'Region' completely.

Select the package 'Region' in the Diagram pane. Now press the 'Del' key. A dialog box will prompt you before removing the class. Notice that the association has been deleted as well, as there is no point to an association with only one end.

Figure 4-14. Delete an element from a model

To delete an element without encountering the dialog box, you can press Ctrl and mouseover the element. A delete rapid button will appear in the upper right corner.

The package 'Discount' is a different story. We may need to use this again elsewhere, so we just want to remove it from this one diagram, not from the entire model. To remove it from this diagram, select the element in the Diagram pane and press the 'Remove from Diagram' button. A rapid button exists to do this as well; hold Ctrl and mouseover the element. Then use the 'Remove from Diagram' button.

Alternatively, you can cut an element from the diagram using either the Cut option from the main toolbar, Cut from the Edit menu, or the shortcut Ctrl-Shift-X. You will not encounter a warning here, but the package still exists within the model and can be viewed from the Navigation pane.

Notice that the element no longer appears in the Navigation pane under the class diagram. Change the Navigation pane to display the Model Index view and take a look at the packages listed there. You will see that, although it is not included in any current diagrams, the package 'Discount' still exists and is ready to be used in another diagram.

Figure 4-15. Remove an element from a diagram

Now that you have seen some of the basic ways of working with models in Poseidon, you should be ready to strike out on your own and see all that Poseidon has to offer.