GMF / GMF Code Samples

A bit of background: My GMF diagramming plugin allows for elements to be provided as shortcuts in the model. I have extended the plugin to allow for automatically adding new shortcuts to the diagram editors, if they are connections of edges in the model.

I wanted a way to test the following things with JUnit:

  1. Diagram files can be loaded
  2. Model files can be initialised by going Right Click > Initialise new my_diagram
  3. The visual display of the diagram files (which nodes are displayed, etc)
  4. Model files with diagram partitioning can be opened and traversed
  5. Shortcut elements are displayed as shortcuts
  6. My custom shortcut-generation functionality

I can’t go into a tutorial for each of these individual elements, but I can provide the code that I used to implement all of these (they are all grouped together into a JUnit Test Suite for Eclipse):

  1. Diagram files can be loaded (method)
  2. Model files can be initialised (helper method)
  3. The visual display of the diagram files
  4. Model files with diagram partitioning can be opened and traversed
  5. Shortcut elements are displayed as shortcuts (method)
  6. My custom shortcut-generation functionality (the project as a whole)

I’m not sure if this is any help to anybody, but it’s probably a good reference. Perhaps in the future I can release a GMFUnit wrapper around JUnit.