edit this page - page history - about editing

Using EOpposite in GMF

GMF / EMF / Ecore

By using the "EOpposite" feature, you can have models instead of:
- Page A
  - Link Z to: Page B
- Page B

To be instead:
- Page A
  - Link Z to: Page B
- Page B in: Z

More information about this is available in the article on Ecore, specifically I want to be able to go backwards through a reference.

Set EOpposite properly in the Ecore model


In the example above, you want the following model:
- Page
  - reference "in": 0..* of type Link
  - containment reference "links": 0..* of type Link, containment is true
- Link
  - reference "to": 1 of type Page

To set EOpposite properly, you want to change this to:
- Page
  - reference "in": 0..* of type Link, EOpposite is Link.to
  - containment reference "links": 0..* of type Link, containment is true, EOpposite is Link.from
- Link
  - reference "to": 1 of type Page, EOpposite is Page.in
  - reference "from": 1 of type Page, EOpposite is Page.links
  1. Regenerate the .genmodel from your changed .ecore file
  2. Regenerate the Model, Edit and Editor code

Set the Link Mapping properly in .gmfmap

  1. In Link Mapping, make sure Source Feature and Target Feature are properly set.
  2. Regenerate the .gmfmap file
  3. Regenerate the diagram code
Categories: GMF | EMF | Ecore | Technology
edit this page - what links to here? - page history - top
Last edited by jevon jevon 105 months ago