Package org.eclipse.pde.ui.templates
Class TemplateOption
- java.lang.Object
-
- org.eclipse.pde.ui.templates.TemplateField
-
- org.eclipse.pde.ui.templates.TemplateOption
-
- Direct Known Subclasses:
AbstractChoiceOption
,BlankField
,BooleanOption
,ChoiceOption
,StringOption
public abstract class TemplateOption extends TemplateField
The base class of all the template options. Options have unique name and a value that can be changed. The value of the option is automatically available to the template files - can be accessed by substitution (e.g. $value_name$) or as part of conditional code generation (e.g. if value_name).- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description TemplateOption(BaseOptionTemplateSection section, String name, String label)
Creates a new option for the provided template section.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getMessageLabel()
Returns the label of this option that can be presented in the messages to the user.String
getName()
Returns the unique name of this optionObject
getValue()
Returns the value of this option.boolean
isEmpty()
Returns whether this option is currently empty.boolean
isEnabled()
Returns whether this option is enabled.boolean
isRequired()
Returns whether this option is required (cannot be empty)void
setEnabled(boolean enabled)
Sets the enabled state of this option.void
setName(String name)
Changes the unique name of this optionvoid
setRequired(boolean required)
Marks this option as required.void
setValue(Object value)
Sets the new value of this option.-
Methods inherited from class org.eclipse.pde.ui.templates.TemplateField
createControl, createLabel, getLabel, getSection, setLabel
-
-
-
-
Constructor Detail
-
TemplateOption
public TemplateOption(BaseOptionTemplateSection section, String name, String label)
Creates a new option for the provided template section.- Parameters:
section
- the parent template sectionname
- the unique name of this optionlabel
- presentable label of this option
-
-
Method Detail
-
getName
public String getName()
Returns the unique name of this option- Returns:
- option name
-
setName
public void setName(String name)
Changes the unique name of this option- Parameters:
name
- the new option name
-
getValue
public Object getValue()
Returns the value of this option.- Returns:
- the current value
-
isEmpty
public boolean isEmpty()
Returns whether this option is currently empty. The actual semantics of the result depends on the implementing option.- Returns:
- true if option is empty, false otherwise.
-
setRequired
public void setRequired(boolean required)
Marks this option as required. Required options must be set by the user. An option that is empty and is marked required will be flagged as an error in the wizard.- Parameters:
required
- the new value of the property- See Also:
isEmpty()
-
isRequired
public boolean isRequired()
Returns whether this option is required (cannot be empty)- Returns:
- true if this option is required, false otherwise.
-
setValue
public void setValue(Object value)
Sets the new value of this option.- Parameters:
value
- the new value
-
isEnabled
public boolean isEnabled()
Returns whether this option is enabled. The actual presentation of enabled state depends on the implementing option.- Returns:
- true if option is enabled and can be modified.
-
setEnabled
public void setEnabled(boolean enabled)
Sets the enabled state of this option. The action presentation of the enabled state depends on the implementing option.- Parameters:
enabled
- the new enabled state
-
getMessageLabel
public String getMessageLabel()
Returns the label of this option that can be presented in the messages to the user. The default implementation trims the 'label' property from mnemonics and from the trailing column.- Returns:
- the label to show to the user
-
-