public abstract static class Options.Option<ValueType,ComponentType extends JComponent> extends Object implements XMLSerializable
setValue(Object).XMLSerializable.OldVersionCompatible, XMLSerializable.VersionSupportTypeROOT_ELEMENT_NAME| Modifier | Constructor and Description |
|---|---|
protected |
Options.Option(org.jdom.Element element)
Constructor for XML Serialization.
|
protected |
Options.Option(String name,
String label,
ValueType defaultValue)
Construct a new option
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(SimpleListener listener)
Add a listener to be notified when the value of this option changes.
|
void |
addChildOptionsDependent(Options childOptions,
ValueType valueRequiredForDependentToBeEnabled,
boolean displayThisOptionInChildOptionsHeading)
Make the enabled state of some child options depend on the current value of this option.
|
void |
addDependent(Options.Option dependent,
ValueType valueRequiredForDependentToBeEnabled)
Makes another option's enabled state depend on the current value of this option.
|
protected abstract ComponentType |
createComponent()
Create a graphical component representing this option.
|
void |
fromXML(org.jdom.Element element)
|
protected ValueType |
generateValidValue(ValueType candidateValue)
Converts a potentially invalid value into a valid one.
|
ComponentType |
getComponent()
Get a graphical component representing this option.
|
ValueType |
getDefaultValue()
Get the default value for this option
|
String |
getDescription()
Get a one line description for this option.
|
String |
getDescriptionAndState()
Describe all properties and the state of this option.
|
String |
getDisplayedLabel()
Get a label displayed next to this option.
|
protected String |
getExtraPersistentInformation()
Gets any information in addition to the option value that should be
persistent between instances.
|
String |
getLabel()
Get the label display to the user for this option
|
String |
getName()
Get the name to be used for referencing this option.
|
Options |
getParentOptions()
Returns the Options in which this option is contained
|
protected String |
getPossibleValues()
Provide a descriptive string representation of possible values of this option.
|
ValueType |
getValue()
Get the current value of this option.
|
String |
getValueAsString()
Converts the current value of this option to a String by calling
getValueAsString(getValue())
This method is the inverse of getValueFromString(String). |
String |
getValueAsString(ValueType value)
Converts this value to a String suitable for returning from
Options.getValueAsString(String). |
abstract ValueType |
getValueFromString(String value)
Convert a String into an instance of the object type used by this option.
|
double |
getVerticalWeight()
Get the weighting used to decide how much this component should stretch when its container is resized.
|
protected void |
handleSetEnabled(ComponentType component,
boolean enabled)
Set the enabled state of a component.
|
void |
hideWarningMessage()
Hides the warning message tooltip for this option if it is visible
|
boolean |
isAdvanced()
determine whether or not this option is advanced (appears in the advanced options panel)
|
boolean |
isEnabled()
Query whether this option is currently enabled.
|
boolean |
isFillHorizontalSpace()
Should this option's component fill all available horizontal space.
|
boolean |
isProOnly()
determine whether or not this option requires an active license.
|
boolean |
isRestoreDefaultApplies()
Returns true if calling
Options.restoreDefaults() should restore this setting to its default value |
boolean |
isRestorePreferenceApplies()
Returns true if calling
Options.restorePreferences() should restore this setting to its value saved in preferences, and
shouldSaveValue() returns true |
protected boolean |
isSpanningComponent()
Does the default generated panel treat this options's component as spanning
when it has an empty label? Spanning means that it uses the entire width of the panel rather
than just the space to the right of all the labels.
|
boolean |
isVisible()
Get the visibility of the graphical component for this option.
|
boolean |
moveToOptions(Options newParentOptions,
String optionalNewLabel,
String optionalNewName)
Moves this Option from its current parent Options to another parent Options.
|
void |
removeChangeListener(SimpleListener listener)
remove a listener to be notified when the value of this option changes
|
void |
restoreDefault()
Restore this option to its default value
|
void |
setAdvanced(boolean advanced)
Set this option as an advanced option, which means it will only appear in the advanced options panel.
|
void |
setAlwaysUsesDefaultPreferenceLocation(boolean alwaysUsesDefaultPreferenceLocation)
Occasionally when dealing with Options we want some values to remain persistent across different
sets of preferences.
|
void |
setDefaultValue(ValueType defaultValue)
Changes the default value for this option.
|
void |
setDescription(String description)
Set a one line description for this option.
|
void |
setDisabledValue(ValueType value)
Changes the value observed through
getValue() when the option is disabled
(i.e. |
void |
setEnabled(boolean enabled)
Set whether this option is currently enabled
|
protected void |
setExtraPersistentInformation(String extras)
Sets any information in addition to the option value that should be
persistent between instances.
|
void |
setFillHorizontalSpace(boolean fillHorizontalSpace)
Set whether this option's component should fill all available horizontal space.
|
void |
setHidden()
Marks this option as a hidden option, i.e.
|
void |
setLabelComponent(JLabel jlabel)
Sets the label component associated with this Option so that its visibility and enabled
state change correctly when the associated Option changes visibility or enabled.
|
void |
setPreferredHeight(int preferredHeightInPixels)
Sets the preferred height of the component which will be returned from
getComponent(), keeping the component
at its current preferred width. |
void |
setPreferredWidth(int preferredWidthInPixels)
Sets the preferred width of the component which will be returned from
getComponent(), keeping the component
at its current preferred height. |
void |
setProOnly(boolean proOnly)
Sets whether or not this option requires an active license.
|
void |
setRestoreDefaultApplies(boolean restoreDefaultApplies)
Set whether calling
Options.restoreDefaults() should restore this setting to its default value. |
void |
setRestorePreferenceApplies(boolean restorePreferenceApplies)
Set whether calling
Options.restorePreferences() should restore this setting to its value saved in preferences. |
void |
setShouldSaveValue(boolean shouldSaveValue)
Sets whether the option will not save its value to preferences and save its value when you call
Options.valuesToXML(String) on its parent options. |
void |
setSpanningComponent(boolean isSpanningComponent)
Set whether the default generated panel treats this options's component as spanning
when it has an empty label.
|
void |
setValue(ValueType value)
set the current value of this option
|
void |
setValue(ValueType value,
boolean isForUsageTracking)
set the current value of this option
|
void |
setValueFromString(String value)
Set the value of this option from a string representation of the value
|
protected abstract void |
setValueOnComponent(ComponentType component,
ValueType value)
Set the value on this component.
|
void |
setVerticalWeight(double weightY)
Set the weighting used to decide how much this component should stretch when its container is resized.
|
void |
setVisible(boolean visible)
Sets the visibility of the graphical component that displays this option together with its label and
makes appropriate changes to the size of the window (if any) that contains the graphical component.
|
void |
setWarningMessage(String message)
Sets a warning message displayed in a
BubbleToolTip on the option component. |
boolean |
shouldSaveValue()
If this method returns false, then the option will not save its value to preferences, nor will it save its value when you call
Options.valuesToXML(String) on its parent options. |
String |
toString()
|
org.jdom.Element |
toXML()
Convert object to a JDOM element.
|
protected Options.Option(org.jdom.Element element)
throws XMLSerializationException
XMLSerializable
Sub-classes must call this when desrializing using from their constructor that takes a
single Element paramter (see XMLSerializable.element - the element passed to the constructorXMLSerializationExceptionprotected Options.Option(String name, String label, 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 optionpublic boolean shouldSaveValue()
Options.valuesToXML(String) on its parent options.Options.valuesToXML(String)isRestorePreferenceApplies()public void setShouldSaveValue(boolean shouldSaveValue)
Options.valuesToXML(String) on its parent options.
This is the same as calling setRestorePreferenceApplies(boolean) ,
but with the add effect of controlling whether this option's value is saved in Options.valuesToXML(String). valuesToXML is used for sending options to Geneious Server and for the save/restore profiles.
Warning: In most cases you should use setRestorePreferenceApplies(boolean) instead. You should never use this method on options that get sent to Geneious Server.isRestorePreferenceApplies()public final void addChildOptionsDependent(Options childOptions, ValueType valueRequiredForDependentToBeEnabled, boolean displayThisOptionInChildOptionsHeading)
childOptions - the child options whose enabled state will change. These must have been already added using Options.addChildOptions(String, String, String, Options).valueRequiredForDependentToBeEnabled - the value this option is required to have in order for the child options to be enabled. If the option has any other value, the child options will be disabled.displayThisOptionInChildOptionsHeading - if this is true, then the component for this option will be displayed inside the bounding box heading panel of the child options.public final void addDependent(Options.Option dependent, ValueType valueRequiredForDependentToBeEnabled)
setDisabledValue(Object) which can be useful for example to make a BooleanOption
return false (or true) from getValue() when it is disabled as
a result of being a dependent of another option.
An option may be a dependent of more than one option which means that that all
the options it depends on must have the correct values for the option to be enabled.dependent - the option whose enabled state will changevalueRequiredForDependentToBeEnabled - the value that this option is required to have for the dependent to be enabled. While this option has any other value, then the dependent will be disabled.public final void setWarningMessage(String message)
BubbleToolTip on the option component.message - the message to display (may be plaintext or html). Passing in null will have the effect of hiding the tooltip if it is already visible.hideWarningMessage()public final void hideWarningMessage()
setWarningMessage(String)public final void fromXML(org.jdom.Element element)
throws XMLSerializationException
XMLSerializable.fromXML(org.jdom.Element).
This implementation just throws a UnsupportedOperationException.
It is final - all subclasses should use the constructor (Element) option described
in XMLSerializable.fromXML in interface XMLSerializableelement - representation from a previous call to XMLSerializable.toXML()XMLSerializationException - if the Element can't be converted into this type of objectpublic org.jdom.Element toXML()
XMLSerializableXMLSerializable.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 XMLSerializablepublic final ValueType getValue()
isEnabled() == false
and setDisabledValue(Object) has previously been called with a
non-null value, then that value will be returned instead of the actual
value that has previously set on this option through setValue(Object).
Also, if this option is enabled but setValue(Object) has never
been called, then the value returned will be the default value passed
to this Option's constructor.
As of 2007-04-16, in neither of these cases is it specified whether
the exact same object that was previously set will be returned, or
whether a copy of that object will be returned.IllegalStateException - if this option has not been added to Options.
This can only happen when using custom options, as they are the
only ones with a public constructor and can then be created without
being added right away.protected String getPossibleValues()
Options.ComboBoxOrRadioOption.getPossibleOptionValues() to
get possible values as a List of OptionValues.Options.ComboBoxOrRadioOption.getPossibleOptionValues()public final String getDescriptionAndState()
public String toString()
toString in class ObjectgetDescriptionAndState()public final void setValue(ValueType value)
value - the value to setpublic final void setValue(ValueType value, boolean isForUsageTracking)
value - the value to setisForUsageTracking - true to have the change in value logged by usage trackingpublic final void setDisabledValue(ValueType value)
getValue() when the option is disabled
(i.e. isEnabled() == false). This can be either a fixed specified
value, or null to indicate that it should be the same as if the option
was not disabled (this is the default behaviour before this method gets
called).value - the value returned by getValue() when isEnabled()==false, or null
to indicate that getValue() should return the same value as if
isEnabled() was true.protected ValueType generateValidValue(ValueType candidateValue)
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 (getValue() or any arbitrary other value.
IMPORTANT: subclasses which implement this method should call setDefaultValue(Object) at the end of their constructor(s)candidateValue - the value to determine the validity ofpublic final String getDescription()
public final void setDescription(String description)
description - a one line description for this option or null to give the option no description.public final void setProOnly(boolean proOnly)
proOnly - true if this option requires an active license.public final boolean isProOnly()
public void setHidden()
IllegalStateException - if this option's component has already been added to any container component.setVisible(boolean)public final void setAdvanced(boolean advanced)
advanced - true if this should be an advanced optionIllegalStateException - if this option's component has already been added to any container component.public final boolean isAdvanced()
public final String getName()
public final ValueType getDefaultValue()
public final void setDefaultValue(ValueType defaultValue)
defaultValue - the new default value for this option.public final String getLabel()
public String getDisplayedLabel()
getLabel()
except for BooleanOption which does not display a label next to the check box.public abstract ValueType getValueFromString(String value)
getValueAsString(Object) .value - the string representation of the object valuepublic String getValueAsString(ValueType value)
Options.getValueAsString(String).
The String representation is also used for serialization of option values.
The default implementation just calls #Object#toString().
getValueFromString(String).value - the value to convert to a string.public final String getValueAsString()
getValueAsString(getValue())
This method is the inverse of getValueFromString(String).public final void setValueFromString(String value)
value - a string representation of the desired value for this option. If the string representation is invalid, the option will be set to the default value.public void restoreDefault()
public final void addChangeListener(SimpleListener listener)
listener - the listener to be notifiedpublic final void removeChangeListener(SimpleListener listener)
listener - the listener to be notifiedpublic final boolean isEnabled()
setEnabled(boolean)
which is true by default)
and if all the parent Options are enabled.
An option may also appear disabled if it requires an active license and there is currently no active license.
And Option may also appear disabled if it is a dependent of another option (see addDependent(com.biomatters.geneious.publicapi.plugin.Options.Option, Object) that does not have the correct value.public final void setEnabled(boolean enabled)
enabled - true if it should be enabledprotected void handleSetEnabled(ComponentType component, boolean enabled)
component - the component to set the enabled state ofenabled - true if it should be enabledpublic void setVisible(boolean visible)
visible - whether or not the graphical component that displays this option should be visible.public boolean isVisible()
setVisible(boolean)protected abstract void setValueOnComponent(ComponentType component, ValueType value)
component - a component return from createComponent()value - the value to set.public final ComponentType getComponent()
protected abstract ComponentType createComponent()
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 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.protected String getExtraPersistentInformation()
protected void setExtraPersistentInformation(String extras)
extras - any additional persistent information or null if this option has none.public void setLabelComponent(JLabel jlabel)
Options.createPanel().jlabel - a label that is associated with this option.public final void setSpanningComponent(boolean isSpanningComponent)
isSpanningComponent - true if this option's component should be a spanning component.isSpanningComponent(),
isFillHorizontalSpace(),
setFillHorizontalSpace(boolean)protected boolean isSpanningComponent()
setSpanningComponent(boolean),
isFillHorizontalSpace(),
setFillHorizontalSpace(boolean)public final double getVerticalWeight()
GridBagConstraints.weighty,
setVerticalWeight(double)public final void setVerticalWeight(double weightY)
weightY - the vertical weight of this option's componentGridBagConstraints.weightypublic final void setAlwaysUsesDefaultPreferenceLocation(boolean alwaysUsesDefaultPreferenceLocation)
Options.restorePreferences() is called.
A Options.ExecutableFileSelectionOption automatically
calls this method in its constructor.alwaysUsesDefaultPreferenceLocation - true to always store the value of this preference in the default preference location.public final void setFillHorizontalSpace(boolean fillHorizontalSpace)
fillHorizontalSpace - true if this option's component should fill all available horizontal space.isFillHorizontalSpace(),
isSpanningComponent(),
setSpanningComponent(boolean)public final boolean isFillHorizontalSpace()
setFillHorizontalSpace(boolean),
isSpanningComponent(),
setSpanningComponent(boolean)public boolean isRestoreDefaultApplies()
Options.restoreDefaults() should restore this setting to its default valueOptions.restoreDefaults() should restore this setting to its default valuepublic void setRestoreDefaultApplies(boolean restoreDefaultApplies)
Options.restoreDefaults() should restore this setting to its default value.
Note that calling restoreDefault() will still restore this setting to its default value.restoreDefaultApplies - true if calling Options.restoreDefaults() should restore this setting to its default valuepublic boolean isRestorePreferenceApplies()
Options.restorePreferences() should restore this setting to its value saved in preferences, and
shouldSaveValue() returns trueOptions.restorePreferences() should restore this setting to its value saved in preferences, and
() returns truepublic void setRestorePreferenceApplies(boolean restorePreferenceApplies)
Options.restorePreferences() should restore this setting to its value saved in preferences.restorePreferenceApplies - true if calling Options.restorePreferences() should restore this setting to its value saved in preferences.public Options getParentOptions()
public void setPreferredWidth(int preferredWidthInPixels)
getComponent(), keeping the component
at its current preferred height.preferredWidthInPixels - the preferred width of the component. If this is 0, then the component will continue to use its current or default preferred width.public void setPreferredHeight(int preferredHeightInPixels)
getComponent(), keeping the component
at its current preferred width.preferredHeightInPixels - the preferred height of the component. If this is 0, then the component will continue to use its current or default preferred height.public boolean moveToOptions(Options newParentOptions, String optionalNewLabel, String optionalNewName)
newParentOptions - the Options to move this Option tooptionalNewLabel - a new label (see getLabel()) to assign to this Option or null to leave it unchanged.optionalNewName - a new name (see getName() ()})to assign to this Option or null to leave it unchanged.