ilog.rules.studio.res.generator
Class IlrVelocityGenerator
- java.lang.Object
-
- ilog.rules.studio.res.generator.IlrFileGenerator
-
- ilog.rules.studio.res.generator.IlrVelocityGenerator
-
- All Implemented Interfaces:
- org.eclipse.jface.wizard.IWizardNode
- Direct Known Subclasses:
- IlrTraceFileGenerator
public abstract class IlrVelocityGenerator extends IlrFileGenerator
Adds a generator to the generator list in the New Client Project for RuleApps wizard. Contrary to theIlrFileGenerator
, when you extend this class you will use velocity as the template generator.- Since:
- JRules 6.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ilog.rules.studio.res.generator.IlrFileGenerator
IlrFileGenerator.Parameter, IlrFileGenerator.RuleApp, IlrFileGenerator.RulesetArchive
-
-
Field Summary
-
Fields inherited from class ilog.rules.studio.res.generator.IlrFileGenerator
contentCreated, JAR_EXTENSION
-
-
Constructor Summary
Constructors Constructor and Description IlrVelocityGenerator()
Constructs a new generator.
-
Method Summary
Methods Modifier and Type Method and Description void
generateProjectContent(org.eclipse.jdt.core.IJavaProject javaProject)
Generates the content of the Java project.protected void
generateVelocityFile(java.lang.String path, java.lang.String filePrefix, java.lang.String templatePath, java.lang.String newFilename, java.lang.String extension, java.lang.Object userData)
Manages the velocity generator in thegenerateProjectContent(IJavaProject)
method.protected void
generateVelocityFile(java.lang.String path, java.lang.String filePrefix, java.lang.String templateDirectory, java.lang.String templatePath, java.lang.String newFilename, java.lang.String extension, java.lang.Object userData)
Manages the velocity generator in thegenerateProjectContent(IJavaProject)
method.protected void
generateVelocityFileInSrc(java.lang.String packagePrefix, java.lang.String filePrefix, java.lang.String templatePath, java.lang.String newFilename, java.lang.String extension, java.lang.Object userData)
Manages the velocity generator in thegenerateProjectContent(IJavaProject)
method.protected void
generateVelocityFileInSrc(java.lang.String packagePrefix, java.lang.String filePrefix, java.lang.String templateDirectory, java.lang.String templatePath, java.lang.String newFilename, java.lang.String extension, java.lang.Object userData)
Manages the velocity generator in thegenerateProjectContent(IJavaProject)
method.protected java.lang.String
getGeneratedExtension()
Gets the name (name and extension) of the file that will be created by thegenerateVelocityFile(String,String,String,String,String,Object)
method.protected java.lang.String
getGeneratedFileName()
Gets the name (without extension) of the file that will be created by thegenerateVelocityFile(String,String,String,String,String,Object)
method.protected java.lang.String
getGeneratedName()
Gets the extension of the file that will be created by thegenerateVelocityFile(String,String,String,String,String,Object)
method.protected abstract org.osgi.framework.Bundle
getTemplateBundle()
Gets the bundle which contains the template.protected abstract java.lang.String
getTemplateDirectory()
Gets the location (from the bundle) the template paths will be relative to.protected abstract org.apache.velocity.VelocityContext
initializeContext(java.lang.Object userData, org.apache.velocity.VelocityContext context)
Initializes a velocity context.-
Methods inherited from class ilog.rules.studio.res.generator.IlrFileGenerator
addContainerEntryInClasspath, addLibraryEntryInClasspath, addProjectEntryInClasspath, addVariableEntryInClasspath, changeInClassName, changeInMethodName, completeProjectFromTemplate, copyFile, createPackage, createProjectFromTemplate, generateLaunchConfigurationFile, generateProjectContent, generateProjectContent, generateProjectContent, getCompletionWizard, getCreationWizard, getExecutionServerHome, getInParameters, getInParameters, getInParameters, getInParameters, getInParametersImports, getInParametersImports, getJavaProject, getJavaProjectNameAsClassName, getLaunchConfigurationName, getNewParameter, getNewRulesetArchive, getNotAllowedDescription, getOutParameters, getOutParameters, getOutParametersImports, getParameters, getParameters, getParametersImports, getProject, getRuleAppProject, getRulesetArchives, getRulesetArchives, getRuleStudioHome, getSignatures, getUTF8CharsetAsString, getWizard, getXOMPath, initialize, isAllowed, isJavaProject, setJavaNature, setSignatures
-
-
-
-
Constructor Detail
-
IlrVelocityGenerator
public IlrVelocityGenerator()
Constructs a new generator. The class that extends this one must declare a public default constructor, which calls this constructor. The default constructor is the only one called to create a generator.- Since:
- JRules 6.6
-
-
Method Detail
-
getTemplateBundle
protected abstract org.osgi.framework.Bundle getTemplateBundle()
Gets the bundle which contains the template.- Returns:
- The bundle where the templates are stored
-
getTemplateDirectory
protected abstract java.lang.String getTemplateDirectory()
Gets the location (from the bundle) the template paths will be relative to.- Returns:
- The location where the templates are stored.
-
generateProjectContent
public void generateProjectContent(org.eclipse.jdt.core.IJavaProject javaProject)
Generates the content of the Java project.The default implementation creates a src directory in the Java project.
- Overrides:
generateProjectContent
in classIlrFileGenerator
- Parameters:
javaProject
- The destination of the Java project files.- See Also:
IlrFileGenerator.generateProjectContent(IJavaProject)
-
generateVelocityFileInSrc
protected void generateVelocityFileInSrc(java.lang.String packagePrefix, java.lang.String filePrefix, java.lang.String templatePath, java.lang.String newFilename, java.lang.String extension, java.lang.Object userData)
Manages the velocity generator in thegenerateProjectContent(IJavaProject)
method. This method uses thegetTemplateDirectory()
method to know where to look for the template files specified by templatePath parameter. TheinitializeContext(Object,VelocityContext)
method is called to get the parameter values to put in the template file.- Parameters:
packagePrefix
- The relative path to the src directory to create the file. If the package does not exist, it is created. If the path is null, the file will be generated in the project root directory.filePrefix
- The prefix that will be added to the template file to compute the generated file name.templatePath
- The relative path of the .vm file. The path is relative to the path specified by thegetTemplateDirectory()
method. The path separator is '/' even on Windows.newFilename
- The generated file name. If the value is null, the generated file name will be computed replacing the ".vm" extension in the template file name by the extension specified in the extension parameter.extension
- The extension to use to compute the generated file name using the template file name. It is used only if the newFilename parameter is null.userData
- An object that will be transmitted to theinitializeContext(Object,VelocityContext)
method.
-
generateVelocityFileInSrc
protected void generateVelocityFileInSrc(java.lang.String packagePrefix, java.lang.String filePrefix, java.lang.String templateDirectory, java.lang.String templatePath, java.lang.String newFilename, java.lang.String extension, java.lang.Object userData)
Manages the velocity generator in thegenerateProjectContent(IJavaProject)
method. The template file specified bytemplatePath
parameter is relative to thetemplateDirectory
parameter. TheinitializeContext(Object,VelocityContext)
method is called to get the parameter values to put in the template file.- Since:
- JRules 6.5
- Parameters:
packagePrefix
- The relative path to the src directory to create the file. If the package does not exist, it is created. If the path is null, the file will be generated in the project root directory.filePrefix
- The prefix that will be added to the template file to compute the generated file name.templateDirectory
- The location (an absolute path) where the template path will be relative to.templatePath
- The relative path of the .vm file. The path is relative to the path specified by thetemplateDirectory
parameter. The path separator is '/' even on Windows.newFilename
- The generated file name. If the value is null, the generated file name will be computed replacing the ".vm" extension in the template file name by the extension specified in the extension parameter.extension
- The extension to use to compute the generated file name using the template file name. It is used only if thenewFilename
parameter is null.userData
- An object that will be transmitted to theinitializeContext(Object,VelocityContext)
method.
-
generateVelocityFile
protected void generateVelocityFile(java.lang.String path, java.lang.String filePrefix, java.lang.String templatePath, java.lang.String newFilename, java.lang.String extension, java.lang.Object userData)
Manages the velocity generator in thegenerateProjectContent(IJavaProject)
method. This method uses thegetTemplateDirectory()
method to know where to look for the template files specified by templatePath parameter. TheinitializeContext(Object,VelocityContext)
method is called to get the parameter values to put in the template file.- Parameters:
path
- The relative path to the project directory to create the file. If the path does not exist, it is created. If the path is null, the file will be generated in the project root directory (it is equivalent to set the path to "").filePrefix
- The prefix that will be added to the template file to compute the generated file name.templatePath
- The relative path of the .vm file. The path is relative to the path specified by thegetTemplateDirectory()
method. The path separator is '/' even on Windows.newFilename
- The generated file name. If the value is null, the generated file name will be computed replacing the ".vm" extension in the template file name by the extension specified in the extension parameter.extension
- The extension to use to compute the generated file name using the template file name. It is used only if the newFilename parameter is null.userData
- An object that will be transmitted to theinitializeContext(Object,VelocityContext)
method.
-
generateVelocityFile
protected void generateVelocityFile(java.lang.String path, java.lang.String filePrefix, java.lang.String templateDirectory, java.lang.String templatePath, java.lang.String newFilename, java.lang.String extension, java.lang.Object userData)
Manages the velocity generator in thegenerateProjectContent(IJavaProject)
method. The template file specified bytemplatePath
parameter is relative to thetemplateDirectory
parameter. TheinitializeContext(Object,VelocityContext)
method is called to get the parameter values to put in the template file.- Since:
- JRules 6.5
- Parameters:
path
- The relative path to the project directory to create the file. If the path does not exist, it is created. If the path is null, the file will be generated in the project root directory (it is equivalent to set the path to "").filePrefix
- The prefix that will be added to the template file to compute the generated file name.templateDirectory
- The location (an absolute path) where the template path will be relative to.templatePath
- The relative path of the .vm file. The path is relative to the path specified by thetemplateDirectory
parameter. The path separator is '/' even on Windows.newFilename
- The generated file name. If the value is null, the generated file name will be computed replacing the ".vm" extension in the template file name by the extension specified in the extension parameter.extension
- The extension to use to compute the generated file name using the template file name. It is used only if thenewFilename
parameter is null.userData
- An object that will be transmitted to theinitializeContext(Object,VelocityContext)
method.
-
initializeContext
protected abstract org.apache.velocity.VelocityContext initializeContext(java.lang.Object userData, org.apache.velocity.VelocityContext context)
Initializes a velocity context. This method is called when the velocity context is initialized in thegenerateVelocityFile(String,String,String,String,String,Object)
method. It gets the parameters to put in the velocity template.- Parameters:
userData
- The object specified in thegenerateVelocityFile(String,String,String,String,String,Object)
method.context
- The velocity context to fill.- Returns:
- The filled velocity context.
-
getGeneratedExtension
protected java.lang.String getGeneratedExtension()
Gets the name (name and extension) of the file that will be created by thegenerateVelocityFile(String,String,String,String,String,Object)
method.- Since:
- JRules 6.0.1
- Returns:
- The name of the file that will be created.
-
getGeneratedFileName
protected java.lang.String getGeneratedFileName()
Gets the name (without extension) of the file that will be created by thegenerateVelocityFile(String,String,String,String,String,Object)
method.- Since:
- JRules 6.0.1
- Returns:
- The name of the file that will be created.
-
getGeneratedName
protected java.lang.String getGeneratedName()
Gets the extension of the file that will be created by thegenerateVelocityFile(String,String,String,String,String,Object)
method.- Since:
- JRules 6.0.1
- Returns:
- The name of the file that will be created.
-
-