public static class Options.ComboBoxOption<ValueType extends Options.OptionValue> extends Options.Option<ValueType,ComponentType>
XMLSerializable.OldVersionCompatible, XMLSerializable.VersionSupportType
ROOT_ELEMENT_NAME
Modifier | Constructor and Description |
---|---|
protected |
Options.ComboBoxOption(org.jdom.Element e)
Constructor for XML Serialization.
|
protected |
Options.ComboBoxOption(String name,
String label,
List<? extends ValueType> possibleValues,
ValueType defaultValue)
Construct a new ComboBoxOption.
|
protected |
Options.ComboBoxOption(String name,
String label,
ValueType[] options,
ValueType defaultValue)
Construct a new ComboBoxOption.
|
Modifier and Type | Method and Description |
---|---|
void |
addPossibleValue(ValueType newValue)
Add a new value for this option.
|
protected JComboBox |
createComponent()
Create a graphical component representing this option.
|
protected ValueType |
generateValidValue(ValueType value)
Converts a potentially invalid value into a valid one.
|
protected String |
getPossibleValues()
Provide a descriptive string representation of possible values of this option.
|
ValueType |
getValueFromString(String valueString)
Convert a String into an instance of the object type used by this option.
|
void |
setAcceptsUnknownPossibleValues(boolean acceptsUnknownPossibleValues)
Sets whether or not this combo box allows
Options.Option.setValue(Object) or Options.setStringValue(String, String) to accept values not in the list of ComboBoxOrRadioOption#getPossibleOptionValues() . |
void |
setPossibleValues(List<? extends ValueType> possibleValues)
Set the values the user can select from in the combo box.
|
protected void |
setValueOnComponent(JComboBox component,
Options.OptionValue value)
Set the value on this component.
|
org.jdom.Element |
toXML()
Convert object to a JDOM element.
|
addChangeListener, addChildOptionsDependent, addDependent, fromXML, getComponent, getDefaultValue, getDescription, getDescriptionAndState, getDisplayedLabel, getExtraPersistentInformation, getLabel, getName, getParentOptions, getValue, getValueAsString, getValueAsString, getVerticalWeight, handleSetEnabled, hideWarningMessage, isAdvanced, isEnabled, isFillHorizontalSpace, isProOnly, isRestoreDefaultApplies, isRestorePreferenceApplies, isSpanningComponent, isVisible, moveToOptions, removeChangeListener, restoreDefault, setAdvanced, setAlwaysUsesDefaultPreferenceLocation, setDefaultValue, setDescription, setDisabledValue, setEnabled, setExtraPersistentInformation, setFillHorizontalSpace, setHidden, setLabelComponent, setPreferredHeight, setPreferredWidth, setProOnly, setRestoreDefaultApplies, setRestorePreferenceApplies, setShouldSaveValue, setSpanningComponent, setValue, setValue, setValueFromString, setVerticalWeight, setVisible, setWarningMessage, shouldSaveValue, toString
protected Options.ComboBoxOption(org.jdom.Element e) throws XMLSerializationException
XMLSerializable
XMLSerializationException
protected Options.ComboBoxOption(String name, String label, ValueType[] options, ValueType defaultValue)
name
- the name to be used for referencing this option. For example from scripts or source code which wish to programmatically get or set the value of this option.
Names should be in standard Java variable name style eg. "myAwesomeOption".label
- a label describing this option to be displayed to the user. eg. "My Awesome Option"defaultValue
- the default value for this optionoptions
- An array containing all possible values (i.e. all the entries to appear in the combo box)protected Options.ComboBoxOption(String name, String label, List<? extends ValueType> possibleValues, ValueType defaultValue)
name
- the name to be used for referencing this option. For example from scripts or source code which wish to programmatically get or set the value of this option.
Names should be in standard Java variable name style eg. "myAwesomeOption".label
- a label describing this option to be displayed to the user. eg. "My Awesome Option"defaultValue
- the default value for this optionpossibleValues
- A list containing all possible values (i.e. all the entries to appear in the combo box)public org.jdom.Element toXML()
XMLSerializable
XMLSerializable.fromXML(org.jdom.Element)
can completely
restore the objects representation.
It is recommended that the returned element use XMLSerializable.ROOT_ELEMENT_NAME
as its name,
in which case it must not define an attribute called "type". In this case,
fromXML, will be called with an element whose name may differ from the element
return from this function. This recommendation allows a more compact representation
of the XML can be stored.
This method generally should not be called directly. Instead, you should usually call
XMLSerializer.classToXML(String, XMLSerializable)
which calls this method internally.
PluginDocument implementations of this method may choose to throw an XMLSerializationException
,
enclosed in a RuntimeException
.toXML
in interface XMLSerializable
toXML
in class Options.Option<ValueType extends Options.OptionValue,JComboBox>
public void setPossibleValues(List<? extends ValueType> possibleValues)
possibleValues
- A list containing all possible values (i.e. all the entries to appear in the combo box)public void addPossibleValue(ValueType newValue)
newValue
- New option value to add.protected String getPossibleValues()
Options.Option
Options.ComboBoxOrRadioOption.getPossibleOptionValues()
to
get possible values as a List of OptionValues.getPossibleValues
in class Options.Option<ValueType extends Options.OptionValue,JComboBox>
Options.ComboBoxOrRadioOption.getPossibleOptionValues()
public ValueType getValueFromString(String valueString)
Options.Option
Options.Option.getValueAsString(Object)
.getValueFromString
in class Options.Option<ValueType extends Options.OptionValue,JComboBox>
valueString
- the string representation of the object valueprotected JComboBox createComponent()
Options.Option
Options.Option.getValue()
.
The implementation is also responsible for making sure that the returned component
listens to any changes made to itself and
reflects those changes in the value of this option
using the Options.Option.setValue(Object)
method.
This method will only be called once for each instance of an Option.
After it has been called, getComponent() will return a cached copy of it.createComponent
in class Options.Option<ValueType extends Options.OptionValue,JComboBox>
protected void setValueOnComponent(JComboBox component, Options.OptionValue value)
Options.Option
setValueOnComponent
in class Options.Option<ValueType extends Options.OptionValue,JComboBox>
component
- a component return from Options.Option.createComponent()
value
- the value to set.protected ValueType generateValidValue(ValueType value)
Options.Option
candidateValue
, implying that all
values are valid. Subclasses can override this method e.g. to
clamp integer values to a certain interval, or to ensure that a
disabled radio item cannot be selected. If a new value is
determined to be invalid, a subclass may choose to return the
current value (Options.Option.getValue()
or any arbitrary other value.
IMPORTANT: subclasses which implement this method should call Options.Option.setDefaultValue(Object)
at the end of their constructor(s)generateValidValue
in class Options.Option<ValueType extends Options.OptionValue,JComboBox>
value
- the value to determine the validity ofpublic void setAcceptsUnknownPossibleValues(boolean acceptsUnknownPossibleValues)
Options.Option.setValue(Object)
or Options.setStringValue(String, String)
to accept values not in the list of ComboBoxOrRadioOption#getPossibleOptionValues()
.
WARNING: Since setStringValue instantiates a new OptionValue, setAcceptsUnknownPossibleValues must not be used on ComboBox Options that use custom OptionValue sub-classes.acceptsUnknownPossibleValues
- true to accept unknown values and automatically add the to the list of getPossibleOptionValues()
.