|
Eclipse PDE Release 3.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.pde.ui.templates.AbstractTemplateSection
org.eclipse.pde.ui.templates.BaseOptionTemplateSection
This class adds a notion of options to the default template section implementation. Options have values and visual presence that allows users to change them. When a section is configured with a number of options, they become available to the code generator and can take part in conditional code emitting.
This class is typically used in conjunction with OptionTemplateWizardPage . The later is capable of creating UI based on the list of options it was given, thus simplifying new template section creation.
Field Summary |
Fields inherited from class org.eclipse.pde.ui.templates.AbstractTemplateSection |
KEY_PACKAGE_NAME, KEY_PLUGIN_CLASS, KEY_PLUGIN_ID, KEY_PLUGIN_NAME, model, project |
Constructor Summary | |
BaseOptionTemplateSection()
|
Method Summary | |
protected TemplateOption |
addOption(String name,
String label,
boolean value,
int pageIndex)
Adds a boolean option with a provided name, label and initial value. |
protected TemplateOption |
addOption(String name,
String label,
String[][] choices,
String value,
int pageIndex)
Adds a choice option with a provided name, label, list of choices and the initial value (choice). |
protected TemplateOption |
addOption(String name,
String label,
String value,
int pageIndex)
Adds a string option with a provided name, label and initial value. |
void |
execute(IProject project,
IPluginModelBase model,
IProgressMonitor monitor)
Modifies the superclass implementation by adding the initialization step before commencing execution. |
boolean |
getBooleanOption(String key)
Returns a boolean value of the option with a given name. |
String |
getReplacementString(String fileName,
String key)
Expands variable substitution to include all string options defined in this template. |
String |
getStringOption(String name)
Returns a string value of the option with a given name. |
Object |
getValue(String name)
Returns the value of the option with a given name. |
protected void |
initializeFields(IFieldData data)
Initializes options in the wizard page using the data provided by the method parameters. |
void |
initializeFields(IPluginModelBase model)
Initializes options in the wizard page using the data provided by the method parameters. |
protected void |
initializeOption(String name,
Object value)
Initializes the option with a given unique name with the provided value. |
boolean |
isDependentOnParentWizard()
Returns true if this template depends on values set in the parent wizard. |
protected void |
registerOption(TemplateOption option,
Object value,
int pageIndex)
Registers the provided option and sets the initial value. |
void |
setOptionEnabled(String name,
boolean enabled)
Enables the option with a given name. |
abstract void |
validateOptions(TemplateOption changed)
Subclasses must implement this method in order to validate options whose value have been changed by the user. |
Methods inherited from class org.eclipse.pde.ui.templates.AbstractTemplateSection |
addPages, createExtension, generateFiles, getDependencies, getDescription, getNumberOfWorkUnits, getPagesAdded, getPluginResourceBundle, getPluginResourceString, getSourceFolder, getTemplateLocation, isOkToCreateFile, isOkToCreateFolder, markPagesAdded, updateModel |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.eclipse.pde.ui.templates.ITemplateSection |
getLabel, getNewFiles, getPage, getPageCount, getUsedExtensionPoint |
Constructor Detail |
public BaseOptionTemplateSection()
Method Detail |
protected TemplateOption addOption(String name, String label, boolean value, int pageIndex)
name
- the unique name of the option (can be used as a variable in
conditional code emitting and variable substitution)label
- presentable name of the optionvalue
- initial value of the optionpageIndex
- a zero-based index of a page where this option should appear
protected TemplateOption addOption(String name, String label, String value, int pageIndex)
name
- the unique name of the option (can be used as a variable in
conditional code emitting and variable substitution)label
- presentable name of the optionvalue
- initial value of the optionpageIndex
- a zero-based index of a page where this option should appear
protected TemplateOption addOption(String name, String label, String[][] choices, String value, int pageIndex)
name
- the unique name of the option (can be used as a variable in
conditional code emitting and variable substitution)label
- presentable name of the optionchoices
- an array of choices that the user will have when setting the
value of the option. Each array position should accept an
array of String objects of size 2, the first being the unique
name and the second the presentable label of the choice.value
- initial value (choice) of the optionpageIndex
- a zero-based index of a page where this option should appear
protected void initializeOption(String name, Object value)
name
- option unique namevalue
- the initial value of the optionpublic String getStringOption(String name)
name
- the unique name of the option
public boolean getBooleanOption(String key)
public void setOptionEnabled(String name, boolean enabled)
name
- the unique name of the optionenabled
- the enable state that the option should havepublic Object getValue(String name)
getValue
in interface IVariableProvider
getValue
in class AbstractTemplateSection
name
- the name of the option
IVariableProvider.getValue(String)
public boolean isDependentOnParentWizard()
true
if this template depends on the data set in
the parent wizard, false
otherwise.protected void initializeFields(IFieldData data)
The method is called before the actual plug-in has been built.
data
- plug-in data as defined in the common plug-in project wizard
pagespublic void initializeFields(IPluginModelBase model)
This method is called after the plug-in has already been created or as part of new extension creation (inside the manifest editor). Either way, the plug-in properties in the model have been fully set and the model can be used to initialize options that cannot be initialized independently.
model
- the model of the plug-in manifest file.public abstract void validateOptions(TemplateOption changed)
changed
- the option whose value has been changed by the userpublic String getReplacementString(String fileName, String key)
getReplacementString
in interface ITemplateSection
getReplacementString
in class AbstractTemplateSection
AbstractTemplateSection.getReplacementString(String, String)
public void execute(IProject project, IPluginModelBase model, IProgressMonitor monitor) throws CoreException
execute
in interface ITemplateSection
execute
in class AbstractTemplateSection
CoreException
ITemplateSection.execute(IProject, IPluginModelBase,
IProgressMonitor)
protected void registerOption(TemplateOption option, Object value, int pageIndex)
option
- the option to registervalue
- the initial valuepageIndex
- the page index to which this option belongs
|
Eclipse PDE Release 3.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |