public abstract class BaseOptionTemplateSection extends AbstractTemplateSection
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.
KEY_ACTIVATOR_SIMPLE, KEY_PACKAGE_NAME, KEY_PLUGIN_CLASS, KEY_PLUGIN_ID, KEY_PLUGIN_NAME, model, project
Constructor and Description |
---|
BaseOptionTemplateSection() |
Modifier and Type | Method and Description |
---|---|
protected TemplateOption |
addBlankField(int pageIndex)
Adds a blank field with a default height to provide spacing.
|
protected TemplateOption |
addBlankField(int height,
int pageIndex)
Adds a blank field with a specific height to provide spacing.
|
protected ComboChoiceOption |
addComboChoiceOption(String name,
String label,
String[][] choices,
String value,
int pageIndex)
Force a combo choice representation.
|
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)
The default implementation of the interface method.
|
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.
|
addPages, createExtension, generateFiles, generateFiles, getDependencies, getDescription, getManifestHeader, getNumberOfWorkUnits, getPagesAdded, getPluginResourceBundle, getPluginResourceString, getSourceFolder, getTargetVersion, getTemplateLocation, hasBundleManifest, isOkToCreateFile, isOkToCreateFolder, markPagesAdded, setManifestHeader, updateModel
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLabel, getNewFiles, getPage, getPageCount, getUsedExtensionPoint
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 appearprotected 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 appearprotected 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 appearprotected ComboChoiceOption addComboChoiceOption(String name, String label, String[][] choices, String value, int pageIndex)
name
- label
- choices
- value
- pageIndex
- protected TemplateOption addBlankField(int pageIndex)
pageIndex
- a zero-based index of a page where this option should appearprotected TemplateOption addBlankField(int height, int pageIndex)
height
- specifies the height of the blank field in pixelspageIndex
- a zero-based index of a page where this option should appearprotected 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 optionpublic boolean getBooleanOption(String key)
key
- the unique name of the optionpublic 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 optionpublic 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
fileName
- the name of the file in which the key was found. You can use
it to return different values for different files.key
- the replacement key found in the template fileAbstractTemplateSection.getReplacementString(String, String)
public void execute(IProject project, IPluginModelBase model, IProgressMonitor monitor) throws CoreException
AbstractTemplateSection
execute
in interface ITemplateSection
execute
in class AbstractTemplateSection
project
- the workspace project that contains the plug-inmodel
- structured representation of the plug-in manifestmonitor
- progress monitor to indicate execution progressCoreException
- if there is a problem generating resourcesprotected void registerOption(TemplateOption option, Object value, int pageIndex)
option
- the option to registervalue
- the initial valuepageIndex
- the page index to which this option belongs
Copyright (c) 2000, 2017 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.