How to show Association and Dependency in class diagram [message #1857618] |
Thu, 16 February 2023 20:20  |
Eclipse User |
|
|
|
I reserved a java package to class diagram use below steps, but after all I done only show the Realization and Generalization relationship.
How to show Association and Dependency?
Reverse engineering a Java program(from https://www.eclipse.org/forums/index.php/t/1084034/)
1. Make a new folder in a new location on your hard disk, call it "Engineering"
2. Inside Engineering make another folder called "Code"
3. Download the file "Code.zip" into the "Engineering" folder and unzip it
4. Papyrus Java reverse engineering works only in a Java package. To have a clear, easy to use structure we will create one Papyrus workspace containing two Papyrus projects: a Java project for reverse engineering and a Papyrus project for editing and forward engineering
a. Start Papyrus / File / Switch workspace / Other / Browse
b. Select your Engineering folder
c. Papyrus will shut down and restart in the Engineering workspace
5. File / New / Project / Java / Java Project. Call it "Reverse". Click "No" on the "Open associated perspective" menu.
6. File / New / Papyrus / Papyrus Project / UML call it "Forward" / Finish
a. We now have 2 Projects in our Project explorer
7. Import the Java source code into Papyrus. Note that you must import *.java source code, not *.class compiled binaries
a. Create a Java package in Reverse. Right click in src package in Reverse / New / Package, call it "Import"
b. Right click on the new Import package / Import / General / File system / Next / From directory / find and select the Code directory / Select all / Deselect loggerControl.txt / Finish
8. The imported classes appear on Project Explorer. They have not yet been reverse engineered (Papyrus cannot use them yet).
a. To reverse engineer, right click on the Import package / Java / Java Reverse
b. The reverse engineer menu appears. Rename the default creation package to "Forward" and click OK. The reverse engineered classes appear in a package in the Forward project. Papyrus can use these reversed classes now!
c. (Note: it is also possible to reverse engineer one class at a time by right clicking on the class)
9. Click "Save all" in menu to save your work
10. Take a look at the imported classes via Model Explorer. See the classes, associations, operations and attributes.
11. Now look at your reverse engineered classes in a class diagram
a. Right click on the Forward package / New Diagram / Class diagram
b. Select all classes and drag them to the diagram
12. Click anywhere on the diagram, press CTRL-A to select all classes on the diagram, and using Papyrus menu select Arrange All. The classes line up on the diagram
13. Making sure all classes are still selected, press CTRL-F5 or use Papyrus menu Diagram / Filters / Show/Hide compartments
a. On the first class, expand and select only attributes and operations
b. Click on Propagate selection to make all other classes the same. Click OK.
14. Now classes show the right compartments but we must tell Papyrus to show contents.
a. Making sure all classes are still selected, press F4 or use Papyrus menu Diagram / Filters / Select the elements to show. Click Select All and OK.
b. Making sure all classes are still selected, use Papyrus menu Arrange All to clean up the diagram
15. We still don't see the associations.
a. Right click anywhere on diagram / Filters / Show All Related Links
b. Now we see a generalization and an interface realization association
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.27143 seconds