RSS

Search Engine

Thursday, July 22, 2010

Define EMF model

3.1. Create project

Create a new project "sawan.modi.emf.webpage.model" via File / New / Project... / Eclipse Modeling Framework /Empty EMF project

3.2. Create Ecore diagram

Select the folder "model". Create a Ecore diagram via right click on the folder "model" folder and select New / Other... / Ecore Tools / Ecore Diagram

Name your "Domain File Name" "webpage.ecore".

This should open a visual editor for creating EMF models.

Open the properties view via Window -> Show View -> Other -> Properties. This view will allow you to modify the attributes of your model elements.

Click on EClass and click into the editor to create the class.

Create the classes "MyWeb", "Webpage", "Category" and "Article".

Using the EAttribute node assign to each object the atttribute "name" of String "EString".

Add the attributes "title", "description" and "keywords" to "MyWeb" and "Webpage".

Select EReferences and create an arrow similar to the following picture. Make sure the upper bound is set to "*" and that the "Is Containment" property is flagged.

3.3. View Ecore diagram

Close the dialog and open the file "webpage.ecore". The result should look like the following.

Tip

Right click on any element and select "Show Properties View" to see the additional attributes of the node.

3.4. Create EMF Generator Model

Select your "webpage.ecore" -> Select File -> New -> Other -> EMF Generator model and create "webpage.genmodel" based on your "Ecore model".

Select your model and press load.

3.5. Set the package

Open "webpage.genmodel" and select the node "Webpage". Set the "base package" property to "sawan.modi.emf.webpage.model".

0 comments:

Post a Comment