Generating the EMF tooling

Generating the EMF tooling

In addition to providing the Ecore meta-metamodel, EMF also comes with support for building (more or less usable) editors. These are generated automatically from the metamodel we just defined. In order to define example models (which we will do below) we have to generate these editors. Also, we have to generate the implementation classes for our metamodel. To generate all these things, we have to define a markup model that contains a number of specifics to control the generation of the various artifacts. This markup model is called genmodel .

So we have to define the genmodel first. Select the data.ecore model in the explorer and right mouse click to NewOtherEclipse Modelling FrameworkEMF Generator Model. Follow the following five steps; note that they are also illustrated in the next figure.

  1. Select EMF Generator Model

  2. Define the name

  3. Select the folder

  4. Select Ecore model as source

  5. Press the Load button and then Finish

Figure 6. Creating the genmodel

Creating the genmodel


As a consequence, you will get the finished EMF genmodel . It is a kind of "wrapper" around the original metamodel, thus, it has the same structure, but the model elements have different properties. As of now, you do not have to change any of these.

Figure 7. Structure of the genmodel

Structure of the genmodel


You can now generate the other projects.

Figure 8. Generate editing projects

Generate editing projects


You now have all the generated additional projects.

Figure 9. Generated projects

Generated projects


We will not look any deeper at these additional projects for now. However, there is one important thing to point out: The generator also generated the implementation classes for the metamodel. If you take a look into xpand.demo.emf.datamodel/src folder, you can find classes (actually, interfaces at the top level) that represent the concepts defined in your metamodel. These can be used to access the model. For some more details on how to use the EMF model APIs as well as the reflective cousins, take a look at http://voelterblog.blogspot.com/2005/12/codeblogck-emf_10.html.