Reuse Model Elements in Different Diagrams
With VP-UML, you are able to show model elements in various diagrams to fit into different contexts. Two ways are provided to assist you in reusing model elements in different diagrams. This article will teach you firstly dragging and dropping from the tree to the diagram, secondly copying and pasting between diagrams and finally showing views.
Let’s create a class diagram (Vehicle) as follows in advance:
Dragging and dropping from the tree
- Create a new class diagram (Vehicle Rental) with two classes: Customer and Rentalaccordingly.
- Open Model Explorer and drag Vehicle class to the diagram next to Rentalclass.
- For connecting Rental class and Vehicle class, move the mouse over Rental class, press its resource icon Association -> Class and then drag it to Vehicleclass.
Copying and pasting between diagrams
- For copying a target class, open Vehicle diagram. Right click on PrivateCar class and select Copy > Copy with VP-UML EE from the pop-up menu.
- Next, turn to Vehicle Rental diagram. Right click on the space under Vehicle class where PrivateCar class will be pasted on. Select Paste View from the pop-up menu.
- Now, PrivateCar class is pasted under Vehicleclass as shown below:
- The relationship between Vehicle class and Private class can be revealed by right clicking on PrivateCar class and selecting Related Elements > Visualize Related Model Element… from the pop-up menu.
- In Visualize Related Model Element dialog box, check Vehicle for showing its relationship and then press Visualize button.
- As a result, their relationship is shown on the diagram.
Showing views
Moreover, you can view the source diagram of a specific model element.
- In Vehicle Rental, right click Vehicle class and select Related Elements > Show Other Views… from the pop-up menu.
- Once the Show View dialog box pops out, you can see the diagram (Vehicle) which contains the same class you selected is listed. Click Go to View to jump to and view the source diagram.
- Now, you can see the Vehicle class in source diagram (Vehicle).
How to try the sample
Download Reuse-model-elements and unzip it to get the .vpp file.
Leave a Reply
Want to join the discussion?Feel free to contribute!