This article provides information regarding the enhancements made to the sequence diagram editor in Version 7.0.5 of IBM® Rational® Software Architect for WebSphere® Software, IBM® Rational® Software Architect Standard Edition, and IBM® Rational® Software Modeler (hereafter referred to as "these Rational products." The key enhancements are the ability to move and reorder messages and lifelines. This article also explains an easy method to set classifier-inherited operations for messages.
Without the ability to reorder messages and lifelines within the sequence diagram editor, you would be forced to repetitively redraw (delete and recreate) existing sequence diagram elements to simulate reorder operations. For example, to reorder an existing message1 below message2, you would need to first delete message1 and then recreate the same message1 below message2. A similar problem would occur with lifelines.
The message and lifeline reordering operation provides the solution. The sequence diagram editor now has two modes for selection: The default is move mode, and the other is reorder mode. Dragging and dropping selected messages is treated differently in each mode. The reorder operation changes the order of sequence diagram elements (these are semantic changes); whereas, the move operation changes only the amount of space between sequence diagram elements (semantically, the sequence diagram remains the same).
The ability to set classifier-inherited operations for messages is now easier and more convenient, too. If the target lifeline represents a classifier, the sequence diagram editor now allows you to select either classifier-owned or inherited operations as the operation for the message. Previous versions of the sequence diagram editor allow you only to select classifier-owned operations. If you wanted to select classifier-inherited operations, you needed to do so from the Advanced Property page of a message event, which is extremely complicated and difficult to use. Selecting classifier-inherited operations for messages is a more common workflow.
The ability to change the order in which messages appear on a sequence diagram has been enhanced, making it easier to get them into the desired order. All elements within the diagram will be considered during a reorder operation, not just those visible on the screen.
A message set is a group of messages that need to be treated together as one atomic unit during a reorder operation. What actually constitutes a valid message set is defined by message set collection rules. Message set collection rules are context-sensitive. Based on your selection, different message set collection rules will be triggered and different message sets will be found.
In the context of reordering, it often makes sense to reorder the whole message set as a single unit so that you preserve the ordering within the set. To change the order of a message set, you follow these steps:
- Select the message set. Right-click on the first message in the set and select Message Set/Reorder as Figure 1 shows (alternatively, you can use Alt+left-click on the first message in the message set). The message set will be highlighted in blue for preview purposes. You see what is going to be reordered, and the sequence diagram editor is now in reorder mode.
Figure 1. Selecting a message set for reorder mode
- Drag the message where you want it to be. Left-click on the selected message set and drag it up or down the sequence diagram. Notice that a dotted line guide shows you exactly where the message set will be dropped (see Figure 2).
Figure 2. Dotted line guide appears while you are dragging message set
After the reorder, the message numbering will be updated to reflect the new order (Figure 3). Tip: Be sure to deselect the elements to exit reorder mode.
Figure 3. Result of reordering a message set
In special circumstances, other events will be automatically handled by the toolset. If a create message is reordered, the starting point of the created lifeline will be moved to match the new location of the created message. If a destroy message is reordered, the ending point of the destroyed lifeline will be moved to match the new location of the destroy message.
With the reorder operation, you can reorder message sets into, out of, and between combined fragments. When reordering a message set into a combined fragment, the tool first checks whether the target combined fragment is a valid container of the message set. The combined fragment is considered valid if all of the message set's covered lifelines are also covered by the combined fragment. If it is not valid, the tool prevents you from completing the operation.
- Select the message set. Right-click on the first message in the set and select Message Set/Reorder (alternatively, you can use Alt+left-click on the first message in the message set). The message set will be highlighted in blue for preview purposes. You can see what is going to be reordered, and the sequence diagram editor is now in reorder mode.
- Drag the message set into an invalid target combined fragment. Left-click and drag the selected message into a combined fragment. If the combined fragment is not a valid container of the selected message set, no feedback line will appear.
- Drag the message set into a valid target combined fragment. Left-click and drag the selected message into a combined fragment. If the combined fragment is a valid container of the selected message set, a dotted line will appear, showing you exactly where the message will be dropped (Figure 4).
Figure 4. Dotted line guide during drag/drop into a container
- Complete the drag operation. The message set is then reordered into the combined fragment. Figure 5 shows the result.
Figure 5. Result of reorder into a container
Follow similar steps to reorder a message set from a combined fragment into an interaction and to reorder a message set between combined fragments.
Sometimes, you want to reorder a particular message within a message set instead of reordering the whole message set. In order to complete that, they need to first break up the message from the message set.
To break up a synchronous message from a given message set, follow these steps:
- Select the message. Right-click the return part of the synchronous message and select Message Set/Reorder (alternatively, you can use Alt+left-click on the return message). The return message will be highlighted in blue for preview purposes.
Figure 6. Selecting the return part of synchronous message for reorder mode
- Drag the message. Left-click and drag the return message up until it is the next one above the send message of the same synchronous message.
Figure 7. Dotted line guide during drag/drop of return message
- Check the result. Complete the drag operation. The synchronous message gets separated from the message set and does not contain any nested messages.
Figure 8. Result of breaking up a synchronous message set
To break up an asynchronous message from a given message set, follow these steps:
- Select the behavior execution specification that the message belongs to. Left-click on the behavior execution specification.
Figure 9. Selecting behavior execution specification to resize
- Drag one of the handles of the border. Left-click and drag the behavior execution specification's handles to resize it until there is no nested message.
Figure 10. Behavior execution specification resize feedback
The asynchronous message is broken up from the message set. As Figure 11 illustrates, it shows the purchase element without any nested messages.
Figure 11. Result of breaking up an asynchronous message set
After breaking up the message from the message set, the message can then be reordered to the target location:
- Select the message set. Right-click on the send part of the message and select Message Set/Reorder (alternatively, you can use Alt+left-click on the send message). The message will be highlighted in blue for preview purposes. The editor is now in reorder mode (see Figure 12).
Figure 12. Selecting a single message for reorder mode
- Drag the element to the new location. Left-click and drag the selected message up or down the sequence diagram. Notice that a dotted line guide shows exactly where the message will be dropped.
Figure 13. Dotted line guide during drag/drop of a single message
- Check the result. Complete the drag operation. The message is moved to the new location, and all of the messages are renumbered appropriately.
Figure 14. Result of reordering a single message
Certain reorder operations may cause the target model to become invalid if they violate the UML2 specification. The toolset prevents invalid models from being created by validating the results of each reorder request before it is performed. If the result is an invalid model, the tool will abort the operation and display an error message.
Figure 15 shows an example.
Figure 15. User attempts an invalid reorder
The logout message is a destroy message. After the logout message, the customer's session with onlineStore is terminated. If you try to reorder the purchase message to place it after the logout message, this is not correct because the onlineStore no longer exists at that point. In such a situation, a Live Validation error message (Figure 16) will appear, saying "The requested action violates the integrity of the model," and you will not be able to complete the action.
Figure 16. Live Validation error message
Moving a message without changing its order within the other messages on the diagram has been simplified. By default, the sequence diagram editor is in move mode. Simply click and drag a message up or down, and other messages on the diagram will be shifted out of the way. This is useful to provide space for Note elements or to improve the aesthetic layout of the messages. The drag-and-drop action will change the amount of space between the messages but preserve the order of the messages.
Similar to message reordering, the lifeline reordering operation enables you to change the order of lifelines on the diagram. You can reorder a single lifeline from one location to another. Changing the order of lifelines does not change the semantics of the diagram, but it often improves the clarity or aesthetics of the diagram. For example, the lifeline of a wrapper class should probably be right next to the lifeline of the wrapped class. The tool also allows multiple lifelines to be selected together and reordered in one action.
- Select a single lifeline. Right-click, select the Reorder Lifelines command from the drop-down menu (alternatively, you can use Alt+left-click on the lifeline).
The selected lifeline will be highlighted in blue to provide feedback that the sequence diagram editor is now in reorder mode, indicating what is going to be reordered (see Figure 17).
Figure 17. Selecting a single lifeline for reorder mode
- Drag the lifelines to the new location. Left-click and drag the selected lifelines to the left or right. A dotted blue line will appear to indicate the insertion point for the selected lifelines. The blue line will appear only if the target insertion point is valid for the selected lifeline.
Figure 18. Dotted line guide during drag/drop of a single lifeline
- Check the result. Complete the drag operation.
The selected lifeline is reordered to the target location as Figure 19 shows.
Figure 19. Result of reordering a single lifeline
- Select multiple lifelines. Left-click on a lifeline and then use Ctrl+left-click to select additional lifelines. Right-click on the selected lifelines, select Reorder Lifelines from the drop-down menu (alternatively, you can use Alt+Shift+left-click on multiple lifelines).
The selected lifelines will be highlighted in blue to indicate that the sequence diagram editor is now in reorder mode and to show what is going to be reordered.
Figure 20. Selecting multiple lifelines
- Drag the lifelines. Left-click and drag the selected lifelines to the left or right.
A dotted blue line will indicate the insertion point for the selected lifelines. The blue line will appear only if the target insertion point is valid for the selected lifelines.
Figure 21. Dotted line guide during drag/drop of multiple lifelines
- Check the result. Complete the drag operation.
As Figure 22 shows, the selected lifelines are reordered to the target location.
Figure 22. Result of reorder of multiple lifelines
Similar to message moving, the lifeline moving operation enables you to change the amount of space between lifelines. This will create space for long message signatures and for inserting notes, comments, or constraints. By default, the sequence diagram editor is in move mode. Simply left-click and drag a lifeline left or right, and other lifelines on the diagram will be shifted out of the way.
Another enhancement made in these Rational software products is the ability to easily set classifier-inherited operations for messages. If the target lifeline represents a classifier, the sequence diagram editor now enables you to select either classifier-owned or inherited operations as the operation for the message.
In order to find qualified inherited operations, the target classifier's generalization hierarchy (based on generalization relationships) will be traversed. If the target classifier is of type class (or a subtype of class), the realization relationship hierarchy will also be traversed. Also, the provided interfaces of all class-owned ports will be considered and their operations will be added. If the target classifier is of type component, all operations from the component's provided interfaces will also be traversed, in addition to the generalization and realization hierarchies.
Figure 23. Creating an operation from the sequence diagram
As you can see from Figure 23, when creating a new operation from the sequence diagram, there is a drop-down menu in the Create New Operation dialog. It lists all of the available owners of the new operation.
Figure 24. Selecting an operation on the sequence diagram
When you double-click on a message operation signature on a sequence diagram, a list of available operations will display. That list contains the owned and inherited operations of the target classifier.
The enhancements described in this article improve the usability of the sequence diagram, thus making it easier for you to edit and modify your diagrams. Through the use of reordering single messages or entire message sets, you can change the order of the messages on the diagram in a very customizable way. Handling of classifier-inherited operations is also easier.
- Subscribe to the IBM developerWorks newsletter, a weekly update on the best of developerWorks tutorials, articles, downloads, community activities, webcasts and events.
- Subscribe to the Rational Edge newsletter for articles on the concepts behind effective software development.
Get products and technologies
- Download trial versions of IBM Rational software.
- Download these IBM product evaluation versions and get your hands on application development tools and middleware products from DB2®, Lotus®, Tivoli®, and WebSphere®.
Darren Coffin has been working in software verification on modeling tools with IBM Rational since 1999. He has worked extensively on testing a broad number of modeling features and diagrams. He is a graduate of Trent University, with a B.Sc. in Computer Studies and Environmental Resource Studies.
Michael Hanner joined IBM in 2002 with more than 15 years of experience in the software industry. He is the Rational Software Modeler product development lead. His responsibilities include the UML and domain modeling platforms, as well as the modeling for open source projects, such as EMF, GEF, GMF, and UML.