Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "STEM Model Generator/EAnnotations"

(Running the Code Generator)
(Ecore Settings)
Line 1: Line 1:
 
STEM Model Generator EAnnotation info coming soon.  
 
STEM Model Generator EAnnotation info coming soon.  
  
== Ecore Settings ==
+
== Ecore EAnnotations ==
 +
To generate code complying with the STEM API, additional information must be passed to the code generator that is out-of-scope to EMF's Ecore and GenModel schemas.  To get around this, Ecore EAnnotations are used to pass information to the code generator. In order to use an Ecore/GenModel that wasn't generated automatically, you need to add these EAnnotations by hand.
 +
 
 +
=== Adding an EAnnotation to an EPackage/EClass/EAttribute ===
 +
It's easy to add an EAnnotation to an existing Ecore model instance using the Ecore Editor.
 +
 
 +
# Open your project's .ecore file in the EMF Ecore Editor
 +
# Right click on the object you wish to EAnnotate.
 +
#: '''New Child''', select '''EAnnotation'''
 +
# Right click on the new EAnnotation and select '''Show Properties View'''
 +
# In the properties view, enter a value for the '''Source'''
 +
#: '' '''Note:''' This is generally a URI.  See below for appropriate EAnnotation Source values for use with STEM's Model Generator''
  
 
== GenModel Settings  ==
 
== GenModel Settings  ==

Revision as of 18:43, 5 September 2012

STEM Model Generator EAnnotation info coming soon.

Ecore EAnnotations

To generate code complying with the STEM API, additional information must be passed to the code generator that is out-of-scope to EMF's Ecore and GenModel schemas. To get around this, Ecore EAnnotations are used to pass information to the code generator. In order to use an Ecore/GenModel that wasn't generated automatically, you need to add these EAnnotations by hand.

Adding an EAnnotation to an EPackage/EClass/EAttribute

It's easy to add an EAnnotation to an existing Ecore model instance using the Ecore Editor.

  1. Open your project's .ecore file in the EMF Ecore Editor
  2. Right click on the object you wish to EAnnotate.
    New Child, select EAnnotation
  3. Right click on the new EAnnotation and select Show Properties View
  4. In the properties view, enter a value for the Source
    Note: This is generally a URI. See below for appropriate EAnnotation Source values for use with STEM's Model Generator

GenModel Settings

To take advantage of the STEM Model Generator's custom templates, you must enable Dynamic Templates in your project's GenModel.

  1. Open your project's .genmodel in the EMF Generator editor
  2. Select the top level item (the GenModel)
  3. Right click and select Show Properties View
  4. Apply the following settings exactly as specified. When finished, Save the GenModel.
Property Value
Compliance Level 6.0
Runtime Version 2.7
Suppress Notification true
Public Constructors true
Dynamic Templates true
Force Overwrite true
Templates Directory platform:/plugin/org.eclipse.stem.model.codegen/templates
Template Plug-in Variables STEM_CODEGEN=org.eclipse.stem.model.codegen
Update Classpath true

Running the Code Generator

After you finish editing the Ecore and GenModel, you can now run the STEM Model Generator directly. The STEM Model Generator acts as an EMF Generator Adapter, therefore it runs automatically when you execute the EMF Code Generator.

  1. Open your project's .genmodel in the EMF Generator editor
  2. Select the top-level item (the GenModel)
  3. Right click and select a Generate option (Generate All, for example)
  4. Wait while the EMF Code Generator + STEM Model Generator run

Back to the top