This section provides techniques for creating, linking and showing operations while working with sequence or collaboration diagrams.
Use the context menu of the link to create a new operation or constructor. Double-clicking the message link displays the source code. This option is disabled if the object is associated with a read-only class.
To create a new operation or constructor:
Create a message link between two objects. The supplier object must be associated with a class.
Select the message link on a sequence diagram.
Right click on the link and choose New > Operation or
New > Constructor. When creating a new operation, a dialog displays where
you can designate the name, modifiers, return type, and parameters for the
new operation. At a minimum, enter the name for the operation, and click
Finish. Together uses the data entered in the dialog to create the operation
in the class, and update the link properties with the new operation.
Once you create the operation, you can double-click the message link label on the diagram enabling the in-place editor to modify the operation, or as an alternative, you can modify the operation using the Properties view.
The maximum length of a message link label is 400 pixels. If your message label is longer than this, then it displays on the diagram with an ellipse at the end to indicate that the message link holds more information. You can click the message link label to reveal the entire message.
TIP: Creating a new constructor on the message link sets the link type to creation.
Use the context menu of the link to associate a message link with an operation. Once the operation has been associated with a message link, double-clicking the message link displays the source code of this operation in the editor.
To create a message link that calls an operation:
Create a message link between two objects. The supplier object must be associated with a class.
Select the message link on a sequence diagram.
Right click on the link and choose Select Operation from the context menu. The Select Operation command expands to display:
a submenu that shows any operations that are "local" to the diagram.
the More option for browsing operations that you can associate with the object.
Choose an operation from the list, or select More to associate an operation that is not local to the diagram. This renames the message link to the chosen operation's name.
NB: Once a message link has been associated with an operation, you can rename the operation directly on the class diagram or in the source code, and the sequence/collaboration diagram displays the new name.
To unlink an operation from a message link:
Select the link on the sequence diagram.
Right click on the link, and select Unlink Operation from the context menu.
Once an operation has been associated with a message link, use the message link context menu to show the operation in the editor, package explorer, or model navigator. Right click on the message link, and select Show Operation > In Editor (In Package Explorer or In Model Navigator).
Alternatively, to show the source code of an operation in the editor, double-click the message link in the sequence diagram. The source code displays highlighting the operation.