Also see GMF for more details. Having issues? Look at GMF Troubleshooting.

This tutorial applies to GMF 2.0.2; GEF SDK 3.3.2.

Some more tutorials:

  1. GMF Diagram Partitioning
  • Open up the GMF cheat sheet (CS), we will use this to do most of the work.
  • Create a new project (CS)
  • Create an ecore model, either by hand or through Java annotations
    • In this example, I am using the following .ecore:
      • [package "foo"] ns: "org.package.bar", uri: "http://jevon.org/package"
        • [class Application]
          • reference pages [0..*] : Page **(make sure you set 'containment' to true!)**
        • [class Page]
          • attribute title : String
          • attribute content : String
          • reference links [0..*] : Link **(again with containment to true)**
        • [class Link]
          • reference page [0..1] : Page **(containment to false)**
  • Create .genmodel (CS)
    • Set the package manually to org.foo - this will create the edit code in org.foo.*
    • Right click the root of the .genmodel
      • Generate model code
      • Generate edit code
    • _If there are any errors, make sure your .ecore model is behaving. Once you do this, make sure you do the following:_
      • Delete the .genmodel, plugin.xml, MANIFEST.MF files
      • Delete the .edit project
      • Try creating the model again
  • Create .gmfgraph (CS)
    • Select "Application" as the diagram element
    • There are three types of elements here: node; link; and label.
      • Application (the root): all to blank
      • Page: set as node
        • title: set as label
        • content: set as label
      • Link: set as link
  • Create .gmftool (CS)
    • Select "Application" as the diagram element
    • Once again, three types of elements:
      • Application (the root): all to blank
      • Page: set as node
      • Link: set as link
  • Create .gmfmap (CS)
    • Wizard properties
      • Canvas mapping: [package foo] / Application
      • Nodes area: select Page
      • Links area: select Link
      • _If you don't have any Nodes or Links displaying here... I haven't worked out why yet._
    • Edit feature label mapping
      • select .gmfmap / Mapping / pages: Page / Node / Feature Label
        • set Diagram Label to PageTitle
  • Generate code (CS)
    • gmfmap > create generator
    • gmfgen > generate diagram code
  • Run as Eclipse application
  • Create a new diagram by selecting New > Examples > Foo diagram

This will allow the generation of the following ecore-based XML model:

<?xml version="1.0" encoding="UTF-8"?>
<org.package.bar:Application xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:org.package.bar="http://jevon.org/package">
  <pages title="a page" content="some content">
    <links page="//@pages.1"/>
    <links page="//@pages.2"/>
  </pages>
  <pages title="another page" content="some content"/>
  <pages title="yet another"/>
</org.package.bar:Application>

If you are having any issues, try looking at GMF Troubleshooting.