Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Creating a new Disease Model Plug-in"
Line 295: | Line 295: | ||
The file should now build without errors. | The file should now build without errors. | ||
− | ''The | + | ''The Preceding steps may not be needed - need to double check this.'' |
− | + | =Final Configuration of plugin.xml= | |
+ | Once again, open plugin.xml file | ||
− | + | go to the '''Runtime''' tab. | |
− | + | Under '''Exported Packages''' click Add | |
− | + | select ''all'' of the packages that appear and add them. | |
− | + | ||
− | select all of | + | |
save the plugin.xml | save the plugin.xml | ||
Line 317: | Line 316: | ||
− | Next Click on the Extensions tab | + | Next Click on the '''Extensions''' tab |
Click Add: | Click Add: | ||
Line 329: | Line 328: | ||
save the plugin.xml | save the plugin.xml | ||
− | Still on the | + | Still on the '''Extensions''' page click on the extension you just added and |
expand it by clicking the (+). | expand it by clicking the (+). | ||
Line 343: | Line 342: | ||
click on the child node (dublin_core) | click on the child node (dublin_core) | ||
− | on the RHS fill in at least the first four entries | + | on the RHS fill in ''at least the first four entries'' |
− | Follow the same | + | Follow the same procedure to Add another extension for org.eclipse.emf.edit.itemProviderAdapterFactories |
Click on the extension org.eclipse.emf.edit.itemProviderAdapterFactories | Click on the extension org.eclipse.emf.edit.itemProviderAdapterFactories | ||
− | expand it by clicking (+) | + | ''expand it by clicking'' (+) |
click on factory | click on factory | ||
Line 367: | Line 366: | ||
Next click on the extension org.eclipse.emf.edit.itemProviderAdapterFactories and move it up until the order of | Next click on the extension org.eclipse.emf.edit.itemProviderAdapterFactories and move it up until the order of | ||
− | the | + | the extensions, top to bottom, is |
− | org.eclipse.emf.edit.itemProviderAdapterFactories | + | * org.eclipse.emf.edit.itemProviderAdapterFactories |
− | + | * org.eclise.emf.ecore.generated_package | |
− | org.eclise.emf.ecore.generated_package | + | * org.eclipse.ohf.stem.dieseasemodels.diseasemodel |
− | + | ||
− | org.eclipse.ohf.stem.dieseasemodels.diseasemodel | + | |
Click on the extension | Click on the extension | ||
Line 379: | Line 376: | ||
org.eclipse.emf.ecore.genearted_package | org.eclipse.emf.ecore.genearted_package | ||
− | expand it by clicking (+) | + | ''expand it by clicking'' (+) |
click on the child node | click on the child node | ||
Line 394: | Line 391: | ||
model/yourdieasemodel.genmodel | model/yourdieasemodel.genmodel | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | '''Adding Supported Types''' | ||
+ | |||
+ | ''This is done most easily by editing the xml itself.'' | ||
click on the plugin.xml tab on the bottom of the window. This is an xml view for your | click on the plugin.xml tab on the bottom of the window. This is an xml view for your | ||
Line 425: | Line 429: | ||
− | You should see a total of three extensions listed. | + | You should now see a total of three extensions listed. |
− | |||
− | + | * org.eclipse.emf.edit.itemProviderAdapterFactories | |
+ | * org.eclise.emf.ecore.generated_package | ||
+ | * org.eclipse.ohf.stem.dieseasemodels.diseasemodel | ||
− | click on the Build tab | + | click on the '''Build''' tab |
− | under Binary Build select | + | under '''Binary Build''' select '''icons''' by ckecking the check box. |
− | save the plugin.xml | + | '''save the plugin.xml''' |
+ | go to the '''Overview''' tab again | ||
− | + | under '''General Information''' | |
− | + | ||
− | under General Information | + | |
Under Activator click browse and select | Under Activator click browse and select | ||
− | org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel.provider.YourdiseasemodelEditPlugin$Implementation | + | '''org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel.provider.YourdiseasemodelEditPlugin$Implementation''' |
set Name: to | set Name: to | ||
− | %pluginName | + | '''%pluginName''' |
set Provider: to | set Provider: to | ||
− | %providerName | + | '''%providerName''' |
− | click the checkbox to | + | click the checkbox to: '''"Activate this plug-in when one of its classes is loaded"''' |
− | + | ||
− | "Activate this plug-in when one of its classes is loaded" | + | |
under Execution Environments (if it is not already there) click add | under Execution Environments (if it is not already there) click add | ||
Line 464: | Line 466: | ||
− | + | click on the '''dependencies''' tab again | |
− | + | ||
− | click on the dependencies tab again | + | |
order the dependencies top to bottom as follows | order the dependencies top to bottom as follows |
Revision as of 20:45, 18 December 2007
Contents
- 1 PreRequisites
- 2 Create a new Project For your Plug-in
- 3 Creating the Required Packages
- 4 Defining your Disease Model Interface
- 5 Adding required Dependencies to your plug-in MANIFEST
- 6 Generating the EMF Model
- 7 Using the EMF Model to Generate Model Code
- 8 Customizing the Disease Model Implementation Class (your code goes here!!)
- 9 Editing the autogenerated genmodel file
- 10 Using EMF to generate the rest of the required code
- 11 Final Configuration of plugin.xml
PreRequisites
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
enter
Project Name: org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel
click on the project
right click
Creating the Required Packages
and create four new packages:
org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel
org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel.impl
org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel.provider
org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel.util
Defining your Disease Model Interface
Select the package:
org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel
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. This is used by the Eclipse Modeling Framework to generate code for your model.
Adding required Dependencies to your plug-in MANIFEST
Having now created the Interface, you will see errors (see the red indicators in figure 3) indicating 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
This last dependency assumes you are extending a build in disease model (almost certainly the case). If you are extending your own existing extension then you much also add that dependency.
hit <ctrl S> to save your changes
Generating the EMF Model
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:
yourdiseasemodel.genmodel
click next
select annoted Java
click Finish
Using the EMF Model to Generate Model Code
Look at the package explorer.
EMF will have generate two files in the model subfolder
yourdieasemodel.ecore
and
yourdiseasemodel.genmodel
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
Note:
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.
Customizing the Disease Model Implementation Class (your code goes here!!)
open the .impl project and edit the file
YourDiseaseModelImpl.java
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, all of your model code will go in this implementation class by overriding superclass methods such as computeNewDiseaseState() and/or doModelSpecificAdjustments().
Editing the autogenerated genmodel file
This step ensures that the files we are about to autogenerate will go in the right place.
If it is not already open in your environment, 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
/org.eclipse.ohf.stem.tests.diseasemodels.yourdiseasemodel/src
moving the .tests. from the end of the path to just after .stem.
Using EMF to generate the rest of the required code
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 entire generated package entitled
org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel.presentation
this package 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
YourdiseasemodelEditPlugin()
DefinitionsEditPlugin.INSTANCE,
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.
The following steps may not be needed - need to double check this.
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. The Preceding steps may not be needed - need to double check this.
Final Configuration of plugin.xml
Once again, open plugin.xml file
go to the Runtime tab.
Under Exported Packages click Add
select all of the packages that appear 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*
to:
org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel.impl.YourDiseaseModelImpl
click on the child node (dublin_core)
on the RHS fill in at least the first four entries
Follow the same procedure 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
http:///org/eclipse/ohf/stem/diseasemodels/yourdiseasemodel.ecore
(note, emf erroneously uses a '.' in the uri. we must be use '/')
under class* change the class to
org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel.provider.YourdiseasemodelItemProviderAdapterFactory
Next click on the extension org.eclipse.emf.edit.itemProviderAdapterFactories and move it up until the order of
the extensions, top to bottom, is
- org.eclipse.emf.edit.itemProviderAdapterFactories
- org.eclise.emf.ecore.generated_package
- org.eclipse.ohf.stem.dieseasemodels.diseasemodel
Click on the extension
org.eclipse.emf.ecore.genearted_package
expand it by clicking (+)
click on the child node
on the RHS change the uri* to
"http:///org/eclipse/ohf/stem/diseasemodels/yourdiseasemodel.ecore
change the class* to
org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel.YourdiseasemodelPackage
make sure the genmodel* is
model/yourdieasemodel.genmodel
Adding Supported Types
This is done most easily by editing the xml itself.
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
org.eclipse.emf.edit.provider.IStructuredItemContentProvider
org.eclipse.emf.edit.provider.ITreeItemContentProvider
org.eclipse.emf.edit.provider.IItemLabelProvider
org.eclipse.emf.edit.provider.IItemPropertySource">
...
</factory>
Leave all the other attributes under factory unchanged
You should now see a total of three extensions listed.
- org.eclipse.emf.edit.itemProviderAdapterFactories
- org.eclise.emf.ecore.generated_package
- org.eclipse.ohf.stem.dieseasemodels.diseasemodel
click on the Build tab
under Binary Build select icons by ckecking the check box.
save the plugin.xml
go to the Overview tab again
under General Information
Under Activator click browse and select
org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel.provider.YourdiseasemodelEditPlugin$Implementation
set Name: to
%pluginName
set Provider: to
%providerName
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
...runtime
...ecore
...stem.diseasemodel
...stem.core
...stem.definitions
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
Bundle-Activator:
org.eclipse.ohf.stem.diseasemodels.yourdiseasemodel.provider.YourdiseasemodelEditPlugin$Implementation
Go to the Overview Tab
click on "update classpath settings"
click on
AT THIS TIME MANIFEST EXPORT TAGS ARE STILL WRONG
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.