Generators

org.topcased.generator
Class AbstractGenerator

java.lang.Object
  extended by org.topcased.generator.AbstractGenerator
Direct Known Subclasses:
OutlineGenerator, PropertiesViewGenerator

public abstract class AbstractGenerator
extends java.lang.Object

An abstract implementation of a generator using JET and JMerge to generate code for EMF projects.
Creation : 9 nov. 2005


Field Summary
static java.lang.String JAVA_BUILDER
          The Java builder id
static java.lang.String JCONTROL_MODEL_NAME
          The name of the JControl model
static java.lang.String MANIFEST_BUILDER
          The Manifest builder id
static java.lang.String PDE_NATURE
          The PDE nature id
protected static java.lang.String PROPERTIES_ENCODING
          Encoding for properties file
static java.lang.String SCHEMA_BUILDER
          The Schema builder id
static java.lang.String SOURCE_DIRECTORY
          The name of the src directory
 
Constructor Summary
AbstractGenerator()
           
 
Method Summary
protected static org.eclipse.core.resources.ICommand[] addDefaultBuilders(org.eclipse.core.resources.IProjectDescription projectDescription)
          Add the default builders if they are not already present in the given IProjectDescription.
protected static java.lang.String[] addDefaultNatures(org.eclipse.core.resources.IProjectDescription projectDescription)
          Add the default natures if they are not already present in the given IProjectDescription.
protected  void applyTemplate(java.lang.Object input, java.lang.String templateURI, org.eclipse.core.runtime.IPath outputFile, boolean isOverwrite)
          Apply a JET template to an object.
protected static org.eclipse.core.resources.IProject createEMFProject(java.lang.String projectName)
          Create an empty EMF Project with default values.
protected abstract  JETEmitter createJETEmitter(java.lang.String templateURI)
          Creates the JET Emitter to use for the generation.
protected  void createPackage(java.lang.String packageName, org.eclipse.core.resources.IProject project)
          Creates the given package on the project
abstract  org.eclipse.core.resources.IProject generate(org.eclipse.core.runtime.IProgressMonitor monitor)
          Launch the generation.
protected  java.lang.String getTemplateURI(org.osgi.framework.Bundle bundle, java.lang.String relativePath)
          Returns a template URI for the given bundle and path relative to this bundle.
static void organizeImports(org.eclipse.core.resources.IProject project)
          Performs an Organize imports on the generated project.
protected static boolean validateEdit(org.eclipse.core.resources.IFile file)
          Check whether the file can be modified
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JCONTROL_MODEL_NAME

public static final java.lang.String JCONTROL_MODEL_NAME
The name of the JControl model

See Also:
Constant Field Values

PDE_NATURE

public static final java.lang.String PDE_NATURE
The PDE nature id

See Also:
Constant Field Values

JAVA_BUILDER

public static final java.lang.String JAVA_BUILDER
The Java builder id

See Also:
Constant Field Values

MANIFEST_BUILDER

public static final java.lang.String MANIFEST_BUILDER
The Manifest builder id

See Also:
Constant Field Values

SCHEMA_BUILDER

public static final java.lang.String SCHEMA_BUILDER
The Schema builder id

See Also:
Constant Field Values

SOURCE_DIRECTORY

public static final java.lang.String SOURCE_DIRECTORY
The name of the src directory

See Also:
Constant Field Values

PROPERTIES_ENCODING

protected static final java.lang.String PROPERTIES_ENCODING
Encoding for properties file

See Also:
Constant Field Values
Constructor Detail

AbstractGenerator

public AbstractGenerator()
Method Detail

generate

public abstract org.eclipse.core.resources.IProject generate(org.eclipse.core.runtime.IProgressMonitor monitor)
                                                      throws org.eclipse.core.runtime.CoreException
Launch the generation. Subclass must implements this method to customize their own generation.

Parameters:
monitor - the monitor for the work progression
Returns:
the generated project
Throws:
org.eclipse.core.runtime.CoreException - if the generation fails

addDefaultNatures

protected static java.lang.String[] addDefaultNatures(org.eclipse.core.resources.IProjectDescription projectDescription)
Add the default natures if they are not already present in the given IProjectDescription.
Default implementation adds the Java and the PDE natures.

Parameters:
projectDescription - an existing project description
Returns:
the new natures array

addDefaultBuilders

protected static org.eclipse.core.resources.ICommand[] addDefaultBuilders(org.eclipse.core.resources.IProjectDescription projectDescription)
Add the default builders if they are not already present in the given IProjectDescription.
Default implementation adds the Java, the Manifest and the Schema builder.

Parameters:
projectDescription - an existing project description
Returns:
the new builders array

createEMFProject

protected static org.eclipse.core.resources.IProject createEMFProject(java.lang.String projectName)
Create an empty EMF Project with default values.

Parameters:
projectName - the name of the project to create.
Returns:
the newly created project

organizeImports

public static void organizeImports(org.eclipse.core.resources.IProject project)
Performs an Organize imports on the generated project.

Parameters:
project - the generated project

validateEdit

protected static boolean validateEdit(org.eclipse.core.resources.IFile file)
Check whether the file can be modified

Parameters:
file -
Returns:
true if it is OK

applyTemplate

protected void applyTemplate(java.lang.Object input,
                             java.lang.String templateURI,
                             org.eclipse.core.runtime.IPath outputFile,
                             boolean isOverwrite)
                      throws JETException,
                             org.eclipse.core.runtime.CoreException
Apply a JET template to an object.

Parameters:
input - the input object
templateURI -
outputFile -
isOverwrite - whether the file should be overwritten
Throws:
JETException
org.eclipse.core.runtime.CoreException

createJETEmitter

protected abstract JETEmitter createJETEmitter(java.lang.String templateURI)
Creates the JET Emitter to use for the generation.

Parameters:
templateURI - the template URI.
Returns:
a JET Emitter

getTemplateURI

protected java.lang.String getTemplateURI(org.osgi.framework.Bundle bundle,
                                          java.lang.String relativePath)
Returns a template URI for the given bundle and path relative to this bundle.

Parameters:
bundle -
relativePath -
Returns:
a string URI

createPackage

protected void createPackage(java.lang.String packageName,
                             org.eclipse.core.resources.IProject project)
                      throws org.eclipse.core.runtime.CoreException
Creates the given package on the project

Parameters:
packageName - the name of the package to create if not exists
project - the project where generates
Throws:
org.eclipse.core.runtime.CoreException - if the generation failed

Generators

Copyright (c) 2005 TOPCASED Contributors 2005 - 2007. All rights reserved.