org.eclipse.emf.codegen.ecore.genmodel.generator
Class GenBaseGeneratorAdapter

java.lang.Object
  extended byorg.eclipse.emf.common.notify.impl.SingletonAdapterImpl
      extended byorg.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter
          extended byorg.eclipse.emf.codegen.ecore.genmodel.generator.GenBaseGeneratorAdapter
All Implemented Interfaces:
Adapter, Adapter.Internal, GeneratorAdapter
Direct Known Subclasses:
GenClassGeneratorAdapter, GenEnumGeneratorAdapter, GenModelGeneratorAdapter, GenPackageGeneratorAdapter

public class GenBaseGeneratorAdapter
extends AbstractGeneratorAdapter

A base generator adapter implementation for GenModel elements. This base defines four project types for code generation and provides implementations of canGenerate(Object, Object), getGenerateChildren(Object, Object), and doGenerate(Object, Object, Monitor) that dispatch to project-type-specific methods, which can be overridden in subclasses.

Since:
2.2.0

Nested Class Summary
 
Nested classes inherited from class org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter
AbstractGeneratorAdapter.JETEmitterDescriptor
 
Nested classes inherited from class org.eclipse.emf.common.notify.Adapter
Adapter.Internal
 
Field Summary
static String EDIT_PROJECT_TYPE
          The project type constant representing an edit project.
static String EDITOR_PROJECT_TYPE
          The project type constant representing an editor project.
static String MODEL_PROJECT_TYPE
          The project type constant representing a model project.
static String TESTS_PROJECT_TYPE
          The project type constant representing a tests project.
 
Fields inherited from class org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter
adapterFactory, generatingObject, gifEmitters, importManager, jetEmitters, MANIFEST_ENCODING, message, OBJECT_ARGUMENT, PROPERTIES_ENCODING, uriConverter
 
Fields inherited from class org.eclipse.emf.common.notify.impl.SingletonAdapterImpl
targets
 
Constructor Summary
GenBaseGeneratorAdapter()
           
GenBaseGeneratorAdapter(GeneratorAdapterFactory generatorAdapterFactory)
           
 
Method Summary
protected  void addBaseTemplatePathEntries(List templatePath)
          Adds the default EMF template location to the base portion of the dynamic template path.
protected  void addClasspathEntries(JETEmitter jetEmitter)
          Adds the plug-ins required for GenModel/Ecore-based templates to the JETEmitter's classpath.
 boolean canGenerate(Object object, Object projectType)
          Based on the given project type, dispatches to one of canGenerateModel(Object), canGenerateEdit(Object), canGenerateEditor(Object), or canGenerateTests(Object).
 boolean canGenerateEdit(Object object)
          Delegates to the GenMoel element's canGenerateEdit() method.
 boolean canGenerateEditor(Object object)
          Delegates to the GenMoel element's canGenerateEditor() method.
 boolean canGenerateModel(Object object)
          Delegates to the GenMoel element's canGenerate() method.
 boolean canGenerateTests(Object object)
          Delegates to the GenMoel element's canGenerateTests() method.
protected  void clearImportManager()
          Clears the import manager and removes it from the GenModel.
protected  void createImportManager(String packageName, String className)
          Creates the import manager and stores it on the GenModel, for use its in computing names.
 Diagnostic doGenerate(Object object, Object projectType, Monitor monitor)
          Based on the given project type, dispatches to one of generateModel(Object, Monitor), generateEdit(Object, Monitor), generateEditor(Object, Monitor), or generateTests(Object, Monitor).
protected  void ensureProjectExists(String workspacePath, Object object, Object projectType, boolean force, Monitor monitor)
          Ensures that a project exists.
protected  Diagnostic generateEdit(Object object, Monitor monitor)
           
protected  Diagnostic generateEditor(Object object, Monitor monitor)
           
protected  Diagnostic generateModel(Object object, Monitor monitor)
           
protected  Diagnostic generateTests(Object object, Monitor monitor)
           
 Collection getGenerateChildren(Object object, Object projectType)
          Based on the given project type, dispatches to one of getGenerateModelChildren(Object), getGenerateEditChildren(Object), getGenerateEditorChildren(Object), or getGenerateTestsChildren(Object).
protected  Collection getGenerateEditChildren(Object object)
           
protected  Collection getGenerateEditorChildren(Object object)
           
protected  Collection getGenerateModelChildren(Object object)
           
protected  Collection getGenerateTestsChildren(Object object)
           
protected  Object getParent(Object object)
          Returns the container of the given object if it is a GenModel element, and null otherwise.
protected  List getUserTemplatePath()
          Returns the user-specified portion of the dynamic template path from the GenModel.
 
Methods inherited from class org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter
createCodeFormatter, createGIFEmitter, createInputStream, createJETEmitter, createMonitor, createOutputStream, doPostGenerate, doPreGenerate, ensureContainerExists, exists, formatCode, generate, generateGIF, generateJava, generateProperties, generateText, getAdapterFactory, getCanGenerateChildren, getCanGenerateParent, getContents, getEncoding, getGenerateParent, getGenerator, getGIFEmitter, getImportManager, getJETEmitter, getURIConverter, isAdapterForType, isReadOnly, postGenerate, preGenerate, setAdapterFactory, setStaticTemplateClass, setWriteable, toDiagnostic, toPlatformResourceURI, toURI, validateEdit
 
Methods inherited from class org.eclipse.emf.common.notify.impl.SingletonAdapterImpl
dispose, getTarget, notifyChanged, setTarget, unsetTarget
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.emf.codegen.ecore.generator.GeneratorAdapter
dispose
 

Field Detail

MODEL_PROJECT_TYPE

public static final String MODEL_PROJECT_TYPE
The project type constant representing a model project. This is the string "org.eclipse.emf.codegen.ecore.genmodel.generator.ModelProject".

See Also:
Constant Field Values

EDIT_PROJECT_TYPE

public static final String EDIT_PROJECT_TYPE
The project type constant representing an edit project. This is the string "org.eclipse.emf.codegen.ecore.genmodel.generator.EditProject".

See Also:
Constant Field Values

EDITOR_PROJECT_TYPE

public static final String EDITOR_PROJECT_TYPE
The project type constant representing an editor project. This is the string "org.eclipse.emf.codegen.ecore.genmodel.generator.EditorProject".

See Also:
Constant Field Values

TESTS_PROJECT_TYPE

public static final String TESTS_PROJECT_TYPE
The project type constant representing a tests project. This is the string "org.eclipse.emf.codegen.ecore.genmodel.generator.TestsProject".

See Also:
Constant Field Values
Constructor Detail

GenBaseGeneratorAdapter

public GenBaseGeneratorAdapter()

GenBaseGeneratorAdapter

public GenBaseGeneratorAdapter(GeneratorAdapterFactory generatorAdapterFactory)
Method Detail

canGenerate

public boolean canGenerate(Object object,
                           Object projectType)
Based on the given project type, dispatches to one of canGenerateModel(Object), canGenerateEdit(Object), canGenerateEditor(Object), or canGenerateTests(Object).

Specified by:
canGenerate in interface GeneratorAdapter
Specified by:
canGenerate in class AbstractGeneratorAdapter

canGenerateModel

public boolean canGenerateModel(Object object)
Delegates to the GenMoel element's canGenerate() method.


canGenerateEdit

public boolean canGenerateEdit(Object object)
Delegates to the GenMoel element's canGenerateEdit() method.


canGenerateEditor

public boolean canGenerateEditor(Object object)
Delegates to the GenMoel element's canGenerateEditor() method.


canGenerateTests

public boolean canGenerateTests(Object object)
Delegates to the GenMoel element's canGenerateTests() method.


getGenerateChildren

public Collection getGenerateChildren(Object object,
                                      Object projectType)
Based on the given project type, dispatches to one of getGenerateModelChildren(Object), getGenerateEditChildren(Object), getGenerateEditorChildren(Object), or getGenerateTestsChildren(Object).

Specified by:
getGenerateChildren in interface GeneratorAdapter
Overrides:
getGenerateChildren in class AbstractGeneratorAdapter

getGenerateModelChildren

protected Collection getGenerateModelChildren(Object object)

getGenerateEditChildren

protected Collection getGenerateEditChildren(Object object)

getGenerateEditorChildren

protected Collection getGenerateEditorChildren(Object object)

getGenerateTestsChildren

protected Collection getGenerateTestsChildren(Object object)

getParent

protected Object getParent(Object object)
Returns the container of the given object if it is a GenModel element, and null otherwise.


doGenerate

public Diagnostic doGenerate(Object object,
                             Object projectType,
                             Monitor monitor)
Based on the given project type, dispatches to one of generateModel(Object, Monitor), generateEdit(Object, Monitor), generateEditor(Object, Monitor), or generateTests(Object, Monitor).

Specified by:
doGenerate in class AbstractGeneratorAdapter

generateModel

protected Diagnostic generateModel(Object object,
                                   Monitor monitor)

generateEdit

protected Diagnostic generateEdit(Object object,
                                  Monitor monitor)

generateEditor

protected Diagnostic generateEditor(Object object,
                                    Monitor monitor)

generateTests

protected Diagnostic generateTests(Object object,
                                   Monitor monitor)

getUserTemplatePath

protected List getUserTemplatePath()
Returns the user-specified portion of the dynamic template path from the GenModel.

This method can be overridden, but to maintain compatibility with 2.2.1, it should not be invoked by subclasses, except from its own overrides. Nor should such overrides be invoked.

Overrides:
getUserTemplatePath in class AbstractGeneratorAdapter
Since:
org.eclipse.emf.codegen.ecore 2.2.2
See Also:
Generator.Options.templatePath, JETEmitter.JETEmitter(String[], String), JETCompiler.find(String[], String)

addBaseTemplatePathEntries

protected void addBaseTemplatePathEntries(List templatePath)
Adds the default EMF template location to the base portion of the dynamic template path. Subclasses may override this to add to the front of the path, and then invoke this implementation. *

To maintain compatibility with 2.2.1, this method should not be invoked by subclasses, except from its own overrides. Nor should such overrides be invoked.

Overrides:
addBaseTemplatePathEntries in class AbstractGeneratorAdapter
Since:
org.eclipse.emf.codegen.ecore 2.2.2
See Also:
Generator.Options.templatePath, JETEmitter.JETEmitter(String[], String), JETCompiler.find(String[], String)

addClasspathEntries

protected void addClasspathEntries(JETEmitter jetEmitter)
                            throws JETException
Adds the plug-ins required for GenModel/Ecore-based templates to the JETEmitter's classpath.

Overrides:
addClasspathEntries in class AbstractGeneratorAdapter
Throws:
JETException

createImportManager

protected void createImportManager(String packageName,
                                   String className)
Creates the import manager and stores it on the GenModel, for use its in computing names.

Overrides:
createImportManager in class AbstractGeneratorAdapter

clearImportManager

protected void clearImportManager()
Clears the import manager and removes it from the GenModel.

Overrides:
clearImportManager in class AbstractGeneratorAdapter

ensureProjectExists

protected void ensureProjectExists(String workspacePath,
                                   Object object,
                                   Object projectType,
                                   boolean force,
                                   Monitor monitor)
Ensures that a project exists. If not, a properly configured EMF project will be created. Similarly, if the project does exist and force is true, it will be reconfigured to match the default EMF configuration.

Overrides:
ensureProjectExists in class AbstractGeneratorAdapter

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.