Creating a UML diagram with Eclipse Papyrus

Yesterday, I upgraded my Eclipse to Kepler. I needed to create a UML class diagram and decided to try out Papyrus – an Eclipse incubator project.  It wasn’t as straightforward as I expected so blogging about what to do and what not to do.  Class_Diagram

I think this project needs more documentation (and a few more features) before using it seriously.  Luckily, my diagram was trivial.  In fact, it was so trivial, I decided to switch to PowerPoint (or in my clas – Open Office Drawing)

Regardless, here’s what I learned before giving up on it.

Creating a diagram

  1. File > New > Papyrus Project
  2. Enter project name
  3. Click NEXT (Do not click Finish.  I was unable to use papyrus > new diagram > create new class diagram when I didn’t create one right away)
  4. UML
  5. Click next
  6. Enter diagram name and click “UML Class Diagram”
  7. Click finish

Adding a class

  1. Switch to the Papyrus Perspective
  2. Drag a “Class” node from the palette view at right
  3. Click the “Class 1” name once and then type the name of your class.  (Do not double click the class box as it opens a hyberlink view.  Do not click the class box and expect to type in it
  4. Drag an ‘Operation” node from the palette at right onto your class
  5. Click “Operation 1” and type the name of your method (Do not add an operation to the model explorer view at left as it will not show up in the diagram)

Preferences

In the Eclipse preferences, you can set a number of view preferences.  They are extremely granular.  For example, I wanted to hide the fourth “section” of the UML diagram showing just class name, attributes and operations.  To do this, I had to:

  1. Preferences > Papyrus > Diagrams > PapyrusUMLClassDiagram > Class Node
  2. Uncheck “show compartment” in NestedClassifierComponent section
  3. Preferences > Papyrus > Diagrams > PapyrusUMLClassDiagram > Interface Node
  4. Uncheck “show compartment” in NestedClassifierComponent section
  5. Delete my diagram and create a new one as I could not figure out how to get preferences to take effect on an existing diagram.

What still puzzles me

There has to be a way to refresh the graphical view to sync with the model explorer and update based on workspace preferences.