Paste from Project Browser
As well as creating new elements in a diagram, you can drag existing elements from the Project Browser into the current diagram.
When you drag an existing element into the diagram, the Paste Element dialog displays to prompt you to select the type of paste action to carry out. (If the dialog does not display, press and hold [Ctrl] while dragging the element onto the diagram.)
Three paste options are available:
- Paste the element as a simple link. In this case the original element exists both in the current diagram and in the original source diagram. Changes to the element are reflected in all diagrams in which it is shown.
- Paste as an instance of the element. If the element can have instances such as an Object, Sequence instance or Node instance, you can drop the element in as an instance of the source element, with the classifier pre-set to the original source. This is useful when creating multiple instances of a Class in a Sequence diagram or Communication diagram.
If you select this option, the Copy connectors checkbox is enabled. If you select this checkbox, any connectors between the original element and any other elements that have also been pasted to this diagram are reproduced as connectors between the instances.
- Create as a child of the source element. This automatically creates a new Class - which you are prompted to name - with a Generalization connector back to the source. This is very useful when you have a Class library or framework from which you inherit new forms; for example, you can paste a Hashtable as "MyHashtable" which automatically becomes a child of the original Hashtable. Used with the Override parent operations feature, this is a quick way to create new structures based on frameworks such as the Java SDK and the .NET SDK.
You can make your selection on this dialog the default for:
- all drag and drop operations, or
- only those where you display this Paste Element dialog.
If you select the This Dialog checkbox, you should then select the Only show this dialog when [Ctrl]+Mouse drag is used checkbox and, on the Diagram Behavior page of the Options dialog, the Auto Instance checkbox.
The effect of these selections is to give you two default paste options:
- Just drag the element onto the diagram and automatically create an instance
- Press [Ctrl] while you drag the element from the Project Browser, displaying the Paste Element dialog, and click on the OK button to automatically paste the element according to whatever option you last selected from the dialog.
If you select the All Drag and Drop checkbox on the Paste Element dialog, this deselects the Auto Instance checkbox on the Options dialog and enables you to add existing elements to the diagram according to the paste option you selected, without pressing [Ctrl] and without displaying a dialog. (If you want to change the default paste option, press [Ctrl] as you drag to display the dialog again and make your changes.)