Class Options.MultipleOptions
- java.lang.Object
-
- com.biomatters.geneious.publicapi.plugin.Options.MultipleOptions
-
- All Implemented Interfaces:
XMLSerializable
- Enclosing class:
- Options
public static final class Options.MultipleOptions extends java.lang.Object implements XMLSerializable
Stores the multiple options added usingOptions.addMultipleOptions(String, Options, boolean)
and provides methods to access the current values (getValues()
) and to add change listeners (addChangeListener(org.virion.jam.util.SimpleListener)
and to change the enabled statesetEnabled(boolean)
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.biomatters.geneious.publicapi.documents.XMLSerializable
XMLSerializable.OldVersionCompatible, XMLSerializable.VersionSupportType
-
-
Field Summary
-
Fields inherited from interface com.biomatters.geneious.publicapi.documents.XMLSerializable
ROOT_ELEMENT_NAME
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChangeListener(org.virion.jam.util.SimpleListener listener)
Add a listener to be notified when any of the values or number of values for these multiple options change.void
addOptionsToShowOnlyInFirstRow(Options.Option... options)
Add options that should only show up in the first instance of these multi options.Options
addValue(boolean fireChangeListeners)
Clone and add a new copy of the master options to these multiple options.void
fromXML(org.jdom.Element element)
Restore the object from the JDOM Element returned byXMLSerializable.toXML()
.javax.swing.JComponent
getComponent()
Get a component used to display these multiple options.Options
getMasterOptions()
Returns the options that were used to construct this MultipleOptions.java.util.List<Options>
getValues()
Get all the current values for a set of multiple options.boolean
isEnabled()
Determine if these MultipleOptions appear enabled.void
removeChangeListener(org.virion.jam.util.SimpleListener listener)
Removes a listener previously added usingaddChangeListener(org.virion.jam.util.SimpleListener)
.void
removeOptionsFromOptionsToShowOnlyInFirstRow(Options.Option... options)
Removes options that were previously added to only show up in the first instance of these multi options so that these options show up in all rows again.void
removeValue(Options value)
Removes one of the multiple options terms.void
restoreDefaults()
Restores these MultipleOptions to their default value (i.e.void
setAddOptionsUnderneathCurrentIndex(boolean addOptionsUnderneathCurrentIndex)
Set whether new options that are added with the 'add button' should appear directly underneath the option whose add button was pressed, or whether they should be added at the bottom of the options (default).void
setAllowPreferenceRestorationEvenIfSetValueCalled(boolean value)
Allows these MultipleOptions to have their preferences restored even if they detect that some of their child options have had their values set already.void
setButtonVisibility(boolean isShowAddButton, boolean isShowRemoveButton)
Use this method to show or hide all of the add or remove buttons for this MultipleOptions.void
setCanRemoveFirstRow(boolean canRemoveFirstRow)
Set whether or not the user can remove the first row or not.void
setCurrentValuesAsDefaults()
Sets the current values of these multiple options as the default values.void
setEnabled(boolean enabled)
Sets the enabled state of all these MultipleOptions.void
setVisible(boolean visible)
Sets the visibility of the graphical component that displays these multiple options and makes appropriate changes to the size of the window (if any) that contains the graphical component.org.jdom.Element
toXML()
Convert object to a JDOM element.
-
-
-
Method Detail
-
getValues
public java.util.List<Options> getValues()
Get all the current values for a set of multiple options. Values can also be retrieved usingOptions.getValueAsString(String)
. See the documentation inOptions.addMultipleOptions(String, Options, boolean)
for details.- Returns:
- all current values of these multiple options. Each element in this list will be a new instance of the options specified as the second parameter to
Options.addMultipleOptions(String, Options, boolean)
- See Also:
Options.addMultipleOptions(String, Options, boolean)
-
addChangeListener
public void addChangeListener(org.virion.jam.util.SimpleListener listener)
Add a listener to be notified when any of the values or number of values for these multiple options change.- Parameters:
listener
- the listener to be notified
-
removeChangeListener
public void removeChangeListener(org.virion.jam.util.SimpleListener listener)
Removes a listener previously added usingaddChangeListener(org.virion.jam.util.SimpleListener)
.- Parameters:
listener
- the listener previously provided toaddChangeListener(org.virion.jam.util.SimpleListener)
.
-
setEnabled
public void setEnabled(boolean enabled)
Sets the enabled state of all these MultipleOptions. All contained Options are only considered enabled if they are themselves enabled and if their parent MultipleOptions are enabled.- Parameters:
enabled
- whether or not these MultipleOptions should be enabled.
-
setVisible
public void setVisible(boolean visible)
Sets the visibility of the graphical component that displays these multiple options and makes appropriate changes to the size of the window (if any) that contains the graphical component.- Parameters:
visible
- whether or not the graphical component that displays these multiple options should be visible.
-
isEnabled
public boolean isEnabled()
Determine if these MultipleOptions appear enabled. MultipleOptions appear enabled only if they are currently set as enabled ( usingsetEnabled(boolean)
which is true by default) and if all their parent options appear enabled.- Returns:
- true if these options appear enabled.
-
addValue
public Options addValue(boolean fireChangeListeners)
Clone and add a new copy of the master options to these multiple options.- Parameters:
fireChangeListeners
- whether to fire the value change listeners for the multiple options- Returns:
- the new copy of the master options that were added
-
removeValue
public void removeValue(Options value)
Removes one of the multiple options terms. If the last value is removed, it is strongly advised you calladdValue(boolean)
shortly after or things may behave weirdly.- Parameters:
value
- the value to remove. This should be one of the values returned fromgetValues()
- Since:
- API 4.600 (Geneious 6.0.0)
-
getComponent
public javax.swing.JComponent getComponent()
Get a component used to display these multiple options. This component includes all the +/- buttons as well as the panels showing the contained options.- Returns:
- a component used to display these multiple options
-
toXML
public org.jdom.Element toXML()
Description copied from interface:XMLSerializable
Convert object to a JDOM element. The representation should be complete so thatXMLSerializable.fromXML(org.jdom.Element)
can completely restore the object's representation. It is recommended that the returned element useXMLSerializable.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 callXMLSerializer.classToXML(String, XMLSerializable)
which calls this method internally. PluginDocument implementations of this method may choose to throw anXMLSerializationException
, enclosed in aRuntimeException
.- Specified by:
toXML
in interfaceXMLSerializable
- Returns:
- object encoded as a JDOM element
-
fromXML
public void fromXML(org.jdom.Element element) throws XMLSerializationException
Description copied from interface:XMLSerializable
Restore the object from the JDOM Element returned byXMLSerializable.toXML()
. This method generally should not be called directly. Instead, you should usually callXMLSerializer.classFromXML(org.jdom.Element)
orXMLSerializer.classFromXML(org.jdom.Element, Class)
which calls this method internally. It is optional to implement this method. Instead of implementing an empty constructor and implementing this method properly, the implementation may instead throw an UnsupportedOperationException and implement a constructor that takes a singleElement
as a parameter. This allows for cleaner code such as support for final fields in the XMLSerializable class. The element parameter should not be modified since it may be reused. If you need a modified version of it, take a copy withElement.clone()
.- Specified by:
fromXML
in interfaceXMLSerializable
- Parameters:
element
- representation from a previous call toXMLSerializable.toXML()
- Throws:
XMLSerializationException
- if the Element can't be converted into this type of object
-
restoreDefaults
public void restoreDefaults()
Restores these MultipleOptions to their default value (i.e. one copy of the options, at its default values).- Since:
- API 4.40 (Geneious 5.4.0)
-
setAllowPreferenceRestorationEvenIfSetValueCalled
public void setAllowPreferenceRestorationEvenIfSetValueCalled(boolean value)
Allows these MultipleOptions to have their preferences restored even if they detect that some of their child options have had their values set already. This can be useful in situations where you wish to set an initial value on certain of the options instances, but not have this prevent a user's previous settings from taking effect.- Parameters:
value
- the desired value of this setting- Since:
- API 4.201900 (Geneious 2019.0.0)
-
setCurrentValuesAsDefaults
public void setCurrentValuesAsDefaults()
Sets the current values of these multiple options as the default values.- Since:
- API 4.700 (Geneious 7.0.0)
-
getMasterOptions
public Options getMasterOptions()
Returns the options that were used to construct this MultipleOptions. You can alter the value of theOptions.Option
s inside theOptions
, but do not add any further options.- Returns:
- the options that were used to construct this MultipleOptions
- Since:
- API 4.40 (Geneious 5.4.0)
- See Also:
MultipleOptions(String, Options, boolean)
-
setButtonVisibility
public void setButtonVisibility(boolean isShowAddButton, boolean isShowRemoveButton)
Use this method to show or hide all of the add or remove buttons for this MultipleOptions. If you want to disable the first row, seesetCanRemoveFirstRow(boolean)
.- Parameters:
isShowAddButton
- True to show all add buttons, false to disableisShowRemoveButton
- True to show all remove buttons, false to disable- Since:
- API 4.1101 (Geneious 11.0.1)
- See Also:
setCanRemoveFirstRow(boolean)
-
setCanRemoveFirstRow
public void setCanRemoveFirstRow(boolean canRemoveFirstRow)
Set whether or not the user can remove the first row or not. Note that no matter what value is set here, if there is only a single row it cannot be removed. This method is intended for use cases where the first row has special significance such that the user can never remove it even if they add other rows.- Parameters:
canRemoveFirstRow
- can user remove the first row or not- Since:
- API 4.1101 (Geneious 11.0.1)
- See Also:
setButtonVisibility(boolean, boolean)
-
setAddOptionsUnderneathCurrentIndex
public void setAddOptionsUnderneathCurrentIndex(boolean addOptionsUnderneathCurrentIndex)
Set whether new options that are added with the 'add button' should appear directly underneath the option whose add button was pressed, or whether they should be added at the bottom of the options (default).- Parameters:
addOptionsUnderneathCurrentIndex
- true if the options should be added immediately underneath the current option, false if it should be added at the end- Since:
- API 4.201900 (Geneious 2019.0.0)
-
addOptionsToShowOnlyInFirstRow
public void addOptionsToShowOnlyInFirstRow(Options.Option... options)
Add options that should only show up in the first instance of these multi options. This method is intended for use cases where the first row has special options that should not be repeated, such as headers. Note: the options will still be added, but the status will be set asinvisible
.- Parameters:
options
- options that are supposed to show up only on the first instance of these multi options.- Since:
- API 4.201900 (Geneious 2019.0.0)
-
removeOptionsFromOptionsToShowOnlyInFirstRow
public void removeOptionsFromOptionsToShowOnlyInFirstRow(Options.Option... options)
Removes options that were previously added to only show up in the first instance of these multi options so that these options show up in all rows again.- Parameters:
options
- options that are supposed to show up in all rows but might have been previously limited to the first row only. Options that were not previously added withaddOptionsToShowOnlyInFirstRow(Option...)
will be ignored.- Since:
- API 4.201900 (Geneious 2019.0.0)
-
-