This is the most simple way to create an instance of your metamodel. You right click on the root class/model object of you metamodel (in our example, it is the Fsm class) : actually all your classes are only available, for creation, through this root class (remember, the containment property).
|You should favour this solution if your metamodel is relatively stable, as it allows you to customize the generated editor to match your metamodel specificities. (see the end of this article: http://www.eclipse.org/articles/Article-Using%20EMF/using-emf.html )|
This is the most ergonomic – but longest – way to create an instance of your metamodel. We will not detail the process here, but only give you the main lines:
once your metamodel is created, you can create a model for model generation, called genmodel :
File > New > Other > Eclipse Modeling Framework folder > EMF Models
choose a name for your genmodel (fsm.genmodel is ok)
select Load from an EMF core model button, and find your metamodel (fsm.ecore)
select the unique package fsm
you need to change, in the Properties tab of your genmodel, the model directory, in order to avoid weird behavior (particularly if the project you are working in was not set as a “Java project”) : please change the property called Model Directory (in the Model folder), to /MyFirstEMFSamples.model/src, so that the EMF source code is generated in a new empty project that will exclusively contain this source code.
right-click on the root node of your fsm.genmodel, and choose the Generate all item.
To be able to use the generated reflexive editor, you have to launch a new runtime workbench, through the tool bar menu:
Run > Run As > Run-time Workbench (in eclipse 3.0.2)
or Run > Run... > Eclipse application item in the right part > New button > Apply button > Run button at the bottom (eclipse 3.1)
a new eclipse application is launched, so now you can create a new simple project (e.g called MyFirstEMFInstances), and select File > New > Other > Example EMF Creation Wizards folder > Fsm Model
now, to create an EMF model, you have to follow the same principles as the creation of an ecore model. So, you can report to the metamodel creation steps, section 2.1, p.3, and adapt them (for example, the model object, which was EPackage in the metamodel creation, becomes Fsm in the EMF model creation)
as you work in another Eclipse environment, you will probably want to copy the models that you created this way in your initial project (the one named MyFirstEMFSamples). Simply do it.