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:

Class diagram - Vehicle

Class diagram – Vehicle

Dragging and dropping from the tree

  1. Create a new class diagram (Vehicle Rental) with two classes: Customer and Rentalaccordingly.

    Create two classes on new class diagram

    Create two classes on new class diagram

  2. Open Model Explorer and drag Vehicle class to the diagram next to Rentalclass.

    Drag Vehicle class from Model Explorer

    Drag Vehicle class from Model Explorer

  3. 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.

    Connect Rental class and Vehicle class

    Connect Rental class and Vehicle class

Copying and pasting between diagrams

  1. 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.

    Copy PrivateCar class

    Copy PrivateCar class

  2. 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.Right click to paste the selected=
  3. Now, PrivateCar class is pasted under Vehicleclass as shown below:

    PrivateCar is pasted

    PrivateCar is pasted

  4. 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.

    Right click to visualize relationship

    Right click to visualize relationship

  5. In Visualize Related Model Element dialog box, check Vehicle for showing its relationship and then press Visualize button.

    Check a relationship to visualize

    Check a relationship to visualize

  6. As a result, their relationship is shown on the diagram.

    The relationship is shown

    The relationship is shown

Showing views

Moreover, you can view the source diagram of a specific model element.

  1. In Vehicle Rental, right click Vehicle class and select Related Elements > Show Other Views… from the pop-up menu.

    Right click to show other views

    Right click to show other views

  2. 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.

    Show View dialog box

    Show View dialog box

  3. Now, you can see the Vehicle class in source diagram (Vehicle).

    Vehicle class in source diagram

    Vehicle class in source diagram

How to try the sample

Download Reuse-model-elements and unzip it to get the .vpp file.

1419 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply