Skip to main content
Jump to: navigation, search

Creating a new Disease Model Plug-in

Creating a new Disease Model Plug-in


You must first have your development environment set up and have the STEM sourcecode installed and running. Make sure you have the latest version of EMF installed.

Create a new Project For your Plug-in

> File>new>other>Eclipse Modeling Framework>Empty EMF Project

The NEW EMPTY EMF PROJECT wizard will open


Project Name: org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel

click on the project

right click

and create four new packages:





Select the package:


right click, >New > Interface

Edit the Interface so your model extends the appropriate STEM build in Model (e.g., StochasticSEIRDiseaseModel) as

shown below:

import org.eclipse.ohf.stem.diseasemodels.standard.StochasticSEIRDiseaseModel;

/** * This interface is an EMF Model. * * @model */ public interface YourDiseaseModel extends StochasticSEIRDiseaseModel {


NOTE: The Java doc above the interface declaration is required.

You will most likely see an error (see the red indicators in figure 3) that the class extended cannot be resolved.

To fix this, in the Eclipse Package Explored, open the META-INF folder and double click the

MANIFEST.MF file to open it.

Below the edit window it will probably open, by default, in the OVERVIEW view. Click on the DEPENDENCIES tab.

you will have to add several dependencies.

Click >add

select org.eclipse.core.runtime

Click >add

select org.eclipse.ohf.stem.core

Click >add

select org.eclipse.ohf.stem.definitions

Click >add

select org.eclipse.ohf.stem.diseasemodels

hit <ctrl S> to save your changes

Click on your package

right click

select >new>other>Eclipse Modeling Framework>New EMF Model

in the EMF Model wizare, open the folder org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel

and select the model subfolder.

under filename type:


click next

select annoted Java

click Finish

Look at the package explorer.

EMF will have generate two files in the model subfolder




open yourdiseasemodel.genmodel

right click

you will see a tree appear in the editor window

select the top node

right click

select Generate Model Code


You should now see a file plugin.xml below the 'model' folder in the package explorer for your new EMF project.

Close the MANIFEST.MF file and open plugin.xml

notice that they now provide the same information for your plugin.

open the .impl project and edit the file

Edit the class definition so instead of

  public class YourDiseaseModelImpl extends EObjectImpl implements YourDiseaseModel  {

have it extend the appropriate STEM built in model. For example,

public class YourDiseaseModelImpl extends StochasticSEIRDiseaseModelImpl implements YourDiseaseModel {

since this is a generated class you must also change constructor the java doc from @generated to @generated NOT


* An implementation of the model object 'Your Disease Model'.


* @generated NOT

change the constructor definition to make it Public (by default EMF makes it Protected).

since this is a generated class you must also change constructor the java doc from @generated to @generated NOT




* @generated NOT


and, if needed, add the import for the STEM built in model. e.g.,

import org.eclipse.ohf.stem.diseasemodels.standard.impl.StochasticSEIRDiseaseModelImpl;

Eventually, your model code will go in this implementation class.

If it is not already open in your envronment, go the the toolbar and select

>Window>show view>Other>General>Properties to open the properties view.

Select the properties view.

Once again, double click on the file yourdiseasemodel.genmodel

The .genmodel tree will appear in the editor and the .genmodel properies will appear in the properties view.

Scroll down to the +Edit section and change the Edit Directory to

/org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel/src   (removing the .edit from the path)

Scroll down to the +Editor section and change the Editor Directory to

/org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel/src   (removing the .editor from the path)

Scroll down to the +Tests section and change the Tests Directory to


in the model folder double click on yourdiseasemodel.genmodel

click on the top Yourdiseasemodel node in the editor window

right click

select Generate Edit Code

right click

select Generate Editor Code

Go to the Package Explorer and DELETE the generated package enitled


this is not needed.

Next, Open the file org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel.provider.YourDiseaseModelEditPlugin

Eclipse will indicate that the Import

import org.eclipse.ohf.stem.definitions.edges.provider.DefinitionsEditPlugin;

"cannot be resolved". Remove it. hit <ctrl S> to save.

Scroll down to the method



will show up as "cannot be resolved". Click on DefinitionsEditPlugin, right click, and select

>source>add import to find the import. hit <ctrl S> to save.

Go to the file org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel.provider.YourDiseaseModelItemProvider

Delete the method public ResourceLocator getResourceLocator()

remove the import

import org.eclipse.emf.common.util.ResourceLocator;

The file should now build without errors.

Final Configuration of plugin.xml

Open plugin.xml again

go to Runtime

Under Exported Packages click Add

select all of them and add them.

save the plugin.xml

On the Right hand side (see figure 8) click the Calculate Uses button.

save the plugin.xml

Next Click on the Extensions tab

Click Add:

add the extension org.eclipse.ohf.stem.dieseasemodels.diseasemodel

(be careful NOT to select org.eclipse.ohf.stem.dieseasemodels.disease)

click save

save the plugin.xml

Still on the extensions page click on the extension you just added and

expand it by clicking the (+).

Click on the child node (org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel.DiseaseModel1)

On the RHS under Extension Element Details change the class*



click on the child node (dublin_core)

on the RHS fill in at least the first four entries

Follow the same proceedure to Add another extension for org.eclipse.emf.edit.itemProviderAdapterFactories

Click on the extension org.eclipse.emf.edit.itemProviderAdapterFactories

expand it by clicking (+)

click on factory

on the RHS change the uri to


(note, emf erroneously uses a '.' in the uri. we must be use '/')

under class* change the class to


Next click on the extension org.eclipse.emf.edit.itemProviderAdapterFactories and move it up until the order of

the extentions, top to bottom, is




Click on the extension


expand it by clicking (+)

click on the child node

on the RHS change the uri* to


change the class* to


make sure the genmodel* is


click on the plugin.xml tab on the bottom of the window. This is an xml view for your

entire plugin.xml configuration.

in the node:

<extension point="org.eclipse.emf.edit.itemProviderAdapterFactories">

change the factory attribute supportedTypes to be:

<factory ... supportedTypes = "org.eclipse.emf.edit.provider.IEditingDomainItemProvider




Leave all the other attributes under factory unchanged

You should see a total of three extensions listed. The one above as well as


and org.eclipse.emf.ecore.generated_package

click on the Build tab

under Binary Build select (Check) icons

save the plugin.xml

go to the Overview tab again

under General Information

Under Activator click browse and select


set Name: to


set Provider: to


click the checkbox to

"Activate this plug-in when one of its classes is loaded"

under Execution Environments (if it is not already there) click add

select J2SE1.5 (or above)

click on the dependencies tab again

order the dependencies top to bottom as follows






With the single exception of the ...runtime dependency click on each one in turn, click Properties, and then

make sure that the checkbox "Rexport this dependency" is selected.

open the MANIFEST.MF Tab

If it is missing, under Bundle-Verion: and a line

Bundle-ClassPath: .

make sure the bundle activator line has $Implementation



Go to the Overview Tab

click on "update classpath settings"

click on


go to the menu bar

click >run>open run dialog

click on the Plug-ins tab

select (check) your plugin org.eclipse.ohf.stem.diseasemodes.yourdiseasemodel

on the RHS select:

Organize the plug-in using "Organize the Manifest Wizard" and configure the wizard as shown in figure 10.

Back to the top