org.eclipse.emf.codegen.jet
Class JETNature

java.lang.Object
  extended byorg.eclipse.emf.codegen.jet.JETNature
All Implemented Interfaces:
IJETNature, org.eclipse.core.resources.IProjectNature

public class JETNature
extends Object
implements IJETNature


Field Summary
protected static String BUILDER
           
protected static String DEFAULT_TEMPLATE_CONTAINER_NAME
           
protected static String JET_NATURE_PROPERTIES_FILE
           
protected static String JET_SETTINGS_NODE
           
protected  org.eclipse.core.resources.IContainer jetJavaSourceContainer
           
protected  org.eclipse.core.resources.IProject jetProject
           
protected  List jetTemplateContainers
           
protected static String SOURCE_CONTAINER_NODE
           
protected static String TEMPLATE_CONTAINER_NODE
           
 
Fields inherited from interface org.eclipse.emf.codegen.jet.IJETNature
NATURE_ID
 
Constructor Summary
JETNature()
          Constructor for JETNature.
 
Method Summary
protected  void addToFrontOfBuildSpec(String builderID)
          Adds a builder to the build spec for the given project.
protected  void commitXML(Document document)
           
 void configure()
           
 void configure(org.eclipse.core.runtime.IProgressMonitor monitor)
           
protected  void createDefaultJETSettingsFile(List templateContainers, org.eclipse.core.resources.IContainer sourceContainer)
          Writes the default file
 void deconfigure()
           
protected  Element getChildWithLocalName(Element element, String localName)
          Returns the child with the given local name.
static String getContainer(org.eclipse.core.resources.IProject project, org.eclipse.core.resources.IContainer container)
           
static org.eclipse.core.resources.IContainer getContainer(org.eclipse.core.resources.IProject project, org.eclipse.core.runtime.IPath path)
           
static org.eclipse.core.resources.IContainer getContainer(org.eclipse.core.resources.IProject project, String path)
           
static String getContainers(org.eclipse.core.resources.IProject project, List containers)
           
static List getContainers(org.eclipse.core.resources.IProject project, String paths)
           
protected  org.eclipse.core.resources.IContainer getContainerValue(Element element, String localName)
          Returns the container defined from the base Element passed in.
protected  List getContainerValues(Element element, String localName)
          Returns the containers defined from the base Element passed in.
protected  org.eclipse.core.runtime.IPath getDefaultSourcePath()
          Returns the project's root directory
 org.eclipse.core.resources.IContainer getJavaSourceContainer()
          Returns the container where the generated Java sources go.
 org.eclipse.core.resources.IContainer getJavaSourceContainerFromFile()
          Returns the template file from the .jetproperties file
 org.eclipse.core.resources.IProject getProject()
           
static JETNature getRuntime(org.eclipse.core.resources.IProject project)
          Get a JETNature that corresponds to the supplied project.
 List getTemplateContainers()
          Returns the containers where the templates are located.
 List getTemplateContainersFromFile()
          Returns the template path from the .jetproperties file.
protected  void initJavaSourceContainer(org.eclipse.core.runtime.IProgressMonitor monitor)
          Initializes the Java Source Container
protected  void initTemplateContainer(org.eclipse.core.runtime.IProgressMonitor monitor)
          Initializes the template container.
protected  Document parseJETSettings()
          Parse the JET settings file for the root element.
static byte[] readContentsAsBytes(InputStream input)
          Reads an input stream and converts it to bytes
protected  StringReader readJETSettingFile()
          Open the JET Settings file and return a StringReader on the contents
protected  void setContainerValue(org.eclipse.core.resources.IContainer container, Element element, String localName)
          Sets the template container location in the settings file
protected  void setContainerValues(List containers, Element element, String localName)
          Sets the template container locations in the settings file
 void setDefaults(org.eclipse.core.runtime.IProgressMonitor monitor)
          Sets the containers to their defaults.
 void setJavaSourceContainer(org.eclipse.core.resources.IContainer javaSourceContainer)
          Sets the container where the generated Java sources go.
 void setJavaSourceContainerToFile(org.eclipse.core.resources.IContainer sourceContainer)
          Writes the Java Source Container Location to a file
 void setProject(org.eclipse.core.resources.IProject project)
           
 void setTemplateContainers(List templateContainers)
          Sets the containers where the templates are located.
 void setTemplateContainersToFile(List templateContainers)
          Writes the Template Container Location to a file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUILDER

protected static final String BUILDER
See Also:
Constant Field Values

DEFAULT_TEMPLATE_CONTAINER_NAME

protected static final String DEFAULT_TEMPLATE_CONTAINER_NAME
See Also:
Constant Field Values

JET_NATURE_PROPERTIES_FILE

protected static final String JET_NATURE_PROPERTIES_FILE
See Also:
Constant Field Values

TEMPLATE_CONTAINER_NODE

protected static final String TEMPLATE_CONTAINER_NODE
See Also:
Constant Field Values

SOURCE_CONTAINER_NODE

protected static final String SOURCE_CONTAINER_NODE
See Also:
Constant Field Values

JET_SETTINGS_NODE

protected static final String JET_SETTINGS_NODE
See Also:
Constant Field Values

jetProject

protected org.eclipse.core.resources.IProject jetProject

jetTemplateContainers

protected List jetTemplateContainers

jetJavaSourceContainer

protected org.eclipse.core.resources.IContainer jetJavaSourceContainer
Constructor Detail

JETNature

public JETNature()
Constructor for JETNature.

Method Detail

getRuntime

public static JETNature getRuntime(org.eclipse.core.resources.IProject project)
Get a JETNature that corresponds to the supplied project.

Parameters:
project - IProject
Returns:
JETNature

getTemplateContainers

public List getTemplateContainers()
Description copied from interface: IJETNature
Returns the containers where the templates are located.

Specified by:
getTemplateContainers in interface IJETNature
Returns:
the containers where the templates are located.

getJavaSourceContainer

public org.eclipse.core.resources.IContainer getJavaSourceContainer()
Description copied from interface: IJETNature
Returns the container where the generated Java sources go.

Specified by:
getJavaSourceContainer in interface IJETNature
Returns:
the container where the generated Java sources go.

setTemplateContainers

public void setTemplateContainers(List templateContainers)
Description copied from interface: IJETNature
Sets the containers where the templates are located.

Specified by:
setTemplateContainers in interface IJETNature

setJavaSourceContainer

public void setJavaSourceContainer(org.eclipse.core.resources.IContainer javaSourceContainer)
Description copied from interface: IJETNature
Sets the container where the generated Java sources go.

Specified by:
setJavaSourceContainer in interface IJETNature
Parameters:
javaSourceContainer - the new location.

configure

public void configure()
               throws org.eclipse.core.runtime.CoreException
Specified by:
configure in interface org.eclipse.core.resources.IProjectNature
Throws:
org.eclipse.core.runtime.CoreException

configure

public void configure(org.eclipse.core.runtime.IProgressMonitor monitor)
               throws org.eclipse.core.runtime.CoreException
Throws:
org.eclipse.core.runtime.CoreException

setDefaults

public void setDefaults(org.eclipse.core.runtime.IProgressMonitor monitor)
                 throws org.eclipse.core.runtime.CoreException
Sets the containers to their defaults.

Throws:
org.eclipse.core.runtime.CoreException

deconfigure

public void deconfigure()
                 throws org.eclipse.core.runtime.CoreException
Specified by:
deconfigure in interface org.eclipse.core.resources.IProjectNature
Throws:
org.eclipse.core.runtime.CoreException

getProject

public org.eclipse.core.resources.IProject getProject()
Specified by:
getProject in interface org.eclipse.core.resources.IProjectNature

setProject

public void setProject(org.eclipse.core.resources.IProject project)
Specified by:
setProject in interface org.eclipse.core.resources.IProjectNature

initTemplateContainer

protected void initTemplateContainer(org.eclipse.core.runtime.IProgressMonitor monitor)
                              throws org.eclipse.core.runtime.CoreException
Initializes the template container.

Throws:
org.eclipse.core.runtime.CoreException

initJavaSourceContainer

protected void initJavaSourceContainer(org.eclipse.core.runtime.IProgressMonitor monitor)
                                throws org.eclipse.core.runtime.CoreException
Initializes the Java Source Container

Throws:
org.eclipse.core.runtime.CoreException

getDefaultSourcePath

protected org.eclipse.core.runtime.IPath getDefaultSourcePath()
Returns the project's root directory


addToFrontOfBuildSpec

protected void addToFrontOfBuildSpec(String builderID)
                              throws org.eclipse.core.runtime.CoreException
Adds a builder to the build spec for the given project.

Throws:
org.eclipse.core.runtime.CoreException

getTemplateContainersFromFile

public List getTemplateContainersFromFile()
Returns the template path from the .jetproperties file.


getJavaSourceContainerFromFile

public org.eclipse.core.resources.IContainer getJavaSourceContainerFromFile()
Returns the template file from the .jetproperties file


parseJETSettings

protected Document parseJETSettings()
                             throws ParserConfigurationException,
                                    SAXException,
                                    IOException,
                                    org.eclipse.core.runtime.CoreException
Parse the JET settings file for the root element.

Throws:
ParserConfigurationException
SAXException
IOException
org.eclipse.core.runtime.CoreException

readJETSettingFile

protected StringReader readJETSettingFile()
                                   throws org.eclipse.core.runtime.CoreException,
                                          IOException
Open the JET Settings file and return a StringReader on the contents

Throws:
org.eclipse.core.runtime.CoreException
IOException

getContainerValues

protected List getContainerValues(Element element,
                                  String localName)
Returns the containers defined from the base Element passed in.


getContainerValue

protected org.eclipse.core.resources.IContainer getContainerValue(Element element,
                                                                  String localName)
Returns the container defined from the base Element passed in.


setContainerValues

protected void setContainerValues(List containers,
                                  Element element,
                                  String localName)
Sets the template container locations in the settings file


setContainerValue

protected void setContainerValue(org.eclipse.core.resources.IContainer container,
                                 Element element,
                                 String localName)
Sets the template container location in the settings file


getChildWithLocalName

protected Element getChildWithLocalName(Element element,
                                        String localName)
Returns the child with the given local name.


readContentsAsBytes

public static byte[] readContentsAsBytes(InputStream input)
                                  throws IOException
Reads an input stream and converts it to bytes

Throws:
IOException

setTemplateContainersToFile

public void setTemplateContainersToFile(List templateContainers)
                                 throws org.eclipse.core.runtime.CoreException
Writes the Template Container Location to a file

Throws:
org.eclipse.core.runtime.CoreException

setJavaSourceContainerToFile

public void setJavaSourceContainerToFile(org.eclipse.core.resources.IContainer sourceContainer)
                                  throws org.eclipse.core.runtime.CoreException
Writes the Java Source Container Location to a file

Throws:
org.eclipse.core.runtime.CoreException

createDefaultJETSettingsFile

protected void createDefaultJETSettingsFile(List templateContainers,
                                            org.eclipse.core.resources.IContainer sourceContainer)
                                     throws org.eclipse.core.runtime.CoreException,
                                            IOException
Writes the default file

Throws:
org.eclipse.core.runtime.CoreException
IOException

commitXML

protected void commitXML(Document document)
                  throws org.eclipse.core.runtime.CoreException,
                         ClassNotFoundException,
                         IOException
Throws:
org.eclipse.core.runtime.CoreException
ClassNotFoundException
IOException

getContainer

public static org.eclipse.core.resources.IContainer getContainer(org.eclipse.core.resources.IProject project,
                                                                 org.eclipse.core.runtime.IPath path)

getContainer

public static org.eclipse.core.resources.IContainer getContainer(org.eclipse.core.resources.IProject project,
                                                                 String path)

getContainers

public static List getContainers(org.eclipse.core.resources.IProject project,
                                 String paths)

getContainers

public static String getContainers(org.eclipse.core.resources.IProject project,
                                   List containers)

getContainer

public static String getContainer(org.eclipse.core.resources.IProject project,
                                  org.eclipse.core.resources.IContainer container)

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