Class Options
- java.lang.Object
-
- com.biomatters.geneious.publicapi.plugin.Options
-
- All Implemented Interfaces:
XMLSerializable
- Direct Known Subclasses:
OperationLocationOptions
public class Options extends java.lang.Object implements XMLSerializable
Provides options used byDocumentOperations
,SequenceAnnotationGenerators
andSequenceGraphs
. Handles creating a graphical user interface from the options, provides programmatic access to the options, and handles persistent storage. This class also provides various types of option implementations, such as Boolean, String, ComboBox and also provides the ability for custom types of options to be created. This class can be used in one of two ways. Either you subclass it (which is essential if you want to override the default layout of the graphical options panel) or you can just use it as is. For examples of both types of usage, seeSequenceAnnotationGenerator.getOptions
orDocumentOperation.getOptions
. Some of the other functionality provided by this class includes- Various types of options are available via
addBooleanOption
,addStringOption
,addMultipleLineStringOption
,addComboBoxOption
,addEditableComboBoxOption
,addRadioOption
,addIntegerOption
,addDoubleOption
,addDateOption
,addFileSelectionOption
,addExecutableFileSelectionOption
,addLabel
,addDivider
,addButtonOption
,addColorChooserOption
, or you can create custom option types by usingaddCustomOption
. - The ability to specify options as advanced
(
Option.setAdvanced
) which means when they are graphically displayed, advanced options are hidden by default, and the user has to click be "show more options" button to see the advanced options. - Provide tooltips via
Option.setDescription
- Provide help buttona via
Option.setHelp
- The ability to create child sets of options
(
addChildOptions
), which are either displayed one above the other (the default) or as separate pages (addChildOptionsPageChooser
). - The ability to change the enabled state of some options depending on the value
of other options. See
Options.Option.addDependent(com.biomatters.geneious.publicapi.plugin.Options.Option, Object)
,BooleanOption.addDependent
andRadioOption.addDependent
. SeeOption.setDisabledValue
for controlling the value returned from a dislabed option. - The ability to monitor changes in the value of an option and change another option value accordingly. See
Option.addChangeListener
. - The ability to set option values programmatically. To obtain a list of valid option names and values
use
getDescriptionAndState
and to set the values programmatically usesetStringValue
- The ability to customize the layout of the options by either using
beginAlignHorizontally
andendAlignHorizontally
or by subclassing Options and overridingcreatePanel
andcreateAdvancedPanel
-
The ability to save and restore the values of Options, either to preferences
(using
savePreferences
andrestorePreferences
or to XML (seevaluesToXML
andvaluesFromXML
). The default values can be restored usingrestoreDefaults
. - The ability to serialize the entire Options class to XML (see
XMLSerializable
). This differs from serializing just the values in that all labels, descriptions, dependencies etc are serialized. Note that prior to about 2007-08-10 it was not required that Options were XMLSerializable. Therefore it is not guarenteed that all sub-classes of Options are compatible with being XMLSerialized. Furthermore some Options instances may use ComboBox options by sub-classingOptions.OptionValue
, and not all of the existingOptions.OptionValue
sub-classes properly implement theXMLSerializable
contract. - The ability to add options that the user may assign multiple values to by using +/- buttons to create/remove additional fields.
See
addMultipleOptions
. - The ability to verify the current values are valid when the user clicks the OK button, and display a message to them if they are not
valid. See
verifyOptionsAreValid
. -
Other minor features available on Options include
setProOnly
,setFillHorizontalSpace
,setSpanningComponent
,setVisible
,setHidden
,setWarningMessage
,setRestoreDefaultApplies
,addCustomComponent
,getDialogOptions
,getOptionsHelp
,addDocumentSelectionOption
,addPrimerOption
,Option.addChildOptionsDependent
getPanel
orgetAdvancedPanel
have been made), programmatically changing the values (by usingsetValue
orsetStringValue
) may only be performed from the swing thread since changes to Option values are immediately mirrored to the graphical interface. Examples- Example 1. This illustrates how to create some simple options that allow the user to enter some text for an annotation type, together
with a checkbox and an integer field.
public class OptionsExample1 extends Options { private
StringOption
annotationType; privateBooleanOption
trimEnds; privateIntegerOption
numberOfBasesToTrim; public OptionsExample1() { annotationType =addStringOption
("annotationType","Annotation Type","CDS"); annotationType.setDescription
("The type of annotation to add to the sequence"); trimEnds =addBooleanOption
("trimEnds","Trim Ends",false); numberOfBasesToTrim =addIntegerOption
("numberOfBasesToTrim","Number Of Bases To Trim",5); } public String getAnnotationType() { return annotationType.getValue
(); } public int getNumberOfBasesToTrim() { if (trimEnds.getValue
()) { return numberOfBasesToTrim.getValue
(); } else { return 0; } } } - Example 2. The expands upon example 1 to link the checkbox and integer fields together so that
when the checkbox is unchecked the integer field is disabled. We also lay them out more appropriately in this example.
Notice that by setting a disabled value on numberOfBasesToTrim the implementation of getNumberOfBasesToTrim()
is much simpler and that trimEnds no longer needs to be declared as a field.
public class OptionsExample2 extends Options { private
StringOption
annotationType; privateIntegerOption
numberOfBasesToTrim; public OptionsExample2() { annotationType =addStringOption
("annotationType","Annotation Type","CDS"); annotationType.setDescription
("The type of annotation to add to the sequence");beginAlignHorizontally
(null,false);BooleanOption
trimEnds =addBooleanOption
("trimEnds","Trim Ends",false); numberOfBasesToTrim =addIntegerOption
("numberOfBasesToTrim","",5); Option basesLabel =addLabel
("bases");endAlignHorizontally
(); trimEnds.addDependent
(numberOfBasesToTrim, true); trimEnds.addDependent
(basesLabel,true); numberOfBasesToTrim.setDisabledValue
(0); } public String getAnnotationType() { return annotationType.getValue
(); } public int getNumberOfBasesToTrim() { return numberOfBasesToTrim.getValue
(); } } - Example 3. Illustrates the use of radio options, combo box options and change listeners
public class OptionsExample3 extends Options { private
StringOption
annotationType; privateIntegerOption
numberOfBasesToTrim; privateRadioOption
<TrimType> trimType; public static final TrimType trimByLength = new TrimType("trimByLength","By Length"); public static final TrimType trimVectors = new TrimType("trimVectors","Vectors"); public static final Sensitivity sensitivityHigh = new Sensitivity("high","UniVec (High sensitivity)","Recommended when the result will be inspected manually"); public static final Sensitivity sensitivityLow = new Sensitivity("low","UniVec_Core (Few false positives)","Recommended for automated pipelines"); privateComboBoxOption
<Sensitivity> sensitivity; privateIntegerOption
minimum; privateIntegerOption
maximum; public OptionsExample3() { annotationType =addStringOption
("annotationType","Annotation Type","CDS"); annotationType.setDescription
("The type of annotation to add to the sequence"); trimType =addRadioOption
("trimType","", Arrays.asList(trimByLength,trimVectors),trimByLength, Alignment.VERTICAL_ALIGN); numberOfBasesToTrim =addIntegerOption
("numberOfBasesToTrim","Number of Bases",5); sensitivity =addComboBoxOption
("sensitivity","Sensitivity", Arrays.asList(sensitivityHigh, sensitivityLow),sensitivityHigh); trimType.addDependent
(trimByLength, numberOfBasesToTrim, true); trimType.addDependent
(trimVectors, sensitivity, true);beginAlignHorizontally
(null,false); minimum =addIntegerOption
("min","Between",2,0,10); maximum =addIntegerOption
("max","and",7,0,10); // Add change listeners to ensure that minimum<=maximum : minimum.addChangeListener
(new SimpleListener() { public void objectChanged() { if (minimum.getValue
()>maximum.getValue
()) { maximum.setValue
(minimum.getValue
()); } } }); maximum.addChangeListener
(new SimpleListener() { public void objectChanged() { if (maximum.getValue
()<minimum.getValue
()) { minimum.setValue
(maximum.getValue
()); } } });endAlignHorizontally
(); } public Sensitivity getSensitivity() { return sensitivity.getValue
(); } public TrimType getTrimType() { return trimType.getValue
(); } public String getAnnotationType() { return annotationType.getValue
(); } public int getNumberOfBasesToTrim() { return numberOfBasesToTrim.getValue
(); } public static final class TrimType extends Options.OptionValue { public TrimType(String name, String label) { super(name, label); } } public static final class Sensitivity extends Options.OptionValue { public Sensitivity(String name, String label, String description) { super(name, label, description); } } }
DocumentOperation.getOptions
orSequenceAnnotationGenerator.getOptions
and Geneious handles displaying dialogs at appropriate times to display the options. However, should you wish to manually display an options dialog, the following code fragment illustrates how to do this.Options options = new OptionsExample1(); Dialogs.
showOptionsDialog
(options,"Choose Annotation",true);
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Options.Alignment
Used the specifying how other options for aOptions.RadioOption
are layed out.static class
Options.BooleanOption
An option that stores a Boolean and is represented graphically as a check box.static class
Options.ButtonOption
Provides the user with a button which may have actions associated with it by callingOptions.ButtonOption.addActionListener(java.awt.event.ActionListener)
.static class
Options.ComboBoxOption<ValueType extends Options.OptionValue>
An option that provides the user with a list of options in a combo boxstatic interface
Options.ComponentCreator
An interface for creating components on demand for use withaddCustomComponent(com.biomatters.geneious.publicapi.plugin.Options.ComponentCreator)
static class
Options.DateOption
An option that stores a date.static class
Options.DoubleOption
An option that stores an Double and is displayed graphically to the user as a single line text field with a spinner (up and down arrow) on the right-hand sidestatic class
Options.EditableComboBoxOption
Like a ComboBoxOption, but besides letting the user choose one of the preconfigured default values, also allows arbitrary custom strings to be entered.static class
Options.ExecutableFileSelectionOption
Provides the user with an executable file name and provides assistance with finding the location of it.static class
Options.FileSelectionOption
Provides functionality to let the user choose a file.static class
Options.IntegerOption
An option that stores an Integer and is displayed graphically to the user as a single line text field with a spinner (up and down arrow) on the right-hand side.static class
Options.LabelOption
An option that is only used for display purposes.static class
Options.MultipleLineStringOption
An option that stores a String and is displayed to the user as a multiple line text areastatic class
Options.MultipleOptions
Stores the multiple options added usingaddMultipleOptions(String, Options, boolean)
and provides methods to access the current values (Options.MultipleOptions.getValues()
) and to add change listeners (Options.MultipleOptions.addChangeListener(org.virion.jam.util.SimpleListener)
and to change the enabled stateOptions.MultipleOptions.setEnabled(boolean)
.static class
Options.Option<ValueType,ComponentType extends javax.swing.JComponent>
The base class of all types of options.static class
Options.OptionValue
Possible values that aOptions.RadioOption
orOptions.ComboBoxOption
can take on.static class
Options.PageChooserType
An enum listing the different types of child options choosers.static class
Options.RadioOption<ValueType extends Options.OptionValue>
An option that provides the user with a list of radio buttons to select one ofstatic class
Options.StringOption
An option that stores a String and is displayed graphically to the user as a single line text field.-
Nested classes/interfaces inherited from interface com.biomatters.geneious.publicapi.documents.XMLSerializable
XMLSerializable.OldVersionCompatible, XMLSerializable.VersionSupportType
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ASSOCIATED_OPTION_PROPERTY
The Components (or sub-components) returned byOptions.Option.getComponent()
may provide this property viaJComponent.getClientProperty(Object)
which will be a reference to the Option the component belongs to.-
Fields inherited from interface com.biomatters.geneious.publicapi.documents.XMLSerializable
ROOT_ELEMENT_NAME
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Options()
For use by subclasses only; Equivalent toOptions(getClass())
.Options(java.lang.Class cl)
Construct a new options.Options(java.lang.Class cl, java.lang.String preferenceNameSuffix)
Construct a new options.protected
Options(org.jdom.Element element)
Constructor for XML Serialization.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Options.BooleanOption
addBooleanOption(java.lang.String name, java.lang.String label, java.lang.Boolean defaultValue)
Add an option that stores a Boolean and is represented graphically as a check box.Options.ButtonOption
addButtonOption(java.lang.String name, java.lang.String label, java.lang.String buttonLabel)
Adds an option that is represented by a button, and may have actions attached to it which are activated when the user clicks the button (seeOptions.ButtonOption.addActionListener(java.awt.event.ActionListener)
).Options.ButtonOption
addButtonOption(java.lang.String name, java.lang.String label, java.lang.String buttonLabel, javax.swing.Icon icon, int alignment)
Adds an option that is represented by a button, and may have actions attached to it which are activated when the user clicks the button (seeOptions.ButtonOption.addActionListener(java.awt.event.ActionListener)
).void
addChangeListener(org.virion.jam.util.SimpleListener listener)
add a listener to be notified when the value of any option changes The listener is also notified if some options requires an active license, and the licence type changes.Options
addChildOptions(java.lang.String name, java.lang.String label, java.lang.String description)
Creates, adds and returns some child options.void
addChildOptions(java.lang.String name, java.lang.String label, java.lang.String description, Options childOptions)
void
addChildOptions(java.lang.String name, java.lang.String label, java.lang.String description, Options childOptions, boolean useParentPreferences)
Adds a set of existing Options as child options of this Options.void
addChildOptions(java.lang.String name, java.lang.String label, java.lang.String description, Options childOptions, double weightY, boolean useParentPreferences)
Adds a set of existing Options as child options of this Options with the specified vertical weight.Options.Option
addChildOptionsPageChooser(java.lang.String name, java.lang.String label, java.util.List<java.lang.String> disabledOptions, Options.PageChooserType type, boolean allChildOptionsApplySimultaneously)
Makes all previously added child options available via a list of tab buttons.void
addCollapsibleChildOptions(java.lang.String name, java.lang.String label, java.lang.String description, Options childOptions, boolean useParentPreferences, boolean defaultCollapsed)
Add child options that can be expanded and collapsed.Options.Option<java.awt.Color,javax.swing.JPanel>
addColorChooserOption(java.lang.String name, java.lang.String label, java.awt.Color defaultColor)
Add an option for letting the user choose a Color<T extends Options.OptionValue>
Options.ComboBoxOption<T>addComboBoxOption(java.lang.String name, java.lang.String label, java.util.List<? extends T> possibleValues, T defaultValue)
Add a new ComboBoxOption.<T extends Options.OptionValue>
Options.ComboBoxOption<T>addComboBoxOption(java.lang.String name, java.lang.String label, T[] possibleValues, T defaultValue)
Add a new ComboBoxOption.Options.Option
addCustomComponent(Options.ComponentCreator componentCreator)
Adds a custom component that will be laid out along with all the standard options.Options.Option
addCustomComponent(javax.swing.JComponent component)
Deprecated.Please instead useaddCustomComponent(ComponentCreator)
as Swing is not thread safe and Options are frequently constructed outside the Swing thread.<OptionType extends Options.Option>
OptionTypeaddCustomOption(OptionType option)
Add a custom option.Options.DateOption
addDateOption(java.lang.String name, java.lang.String label, java.util.Date defaultValue)
Add an option that stores a Date (day, month and year only) and is displayed graphically to the user as a set of 3 spinners together with a button that opens a new dialog for nicer date selection from a calendar style view.void
addDefaultsRestoredListener(org.virion.jam.util.SimpleListener listener)
add a listener to be notified when the options are restored to their defaults (e.g.Options.Option
addDivider(java.lang.String label)
Add a new divider that is displayed between options when the options are graphically presented to the user.DocumentSelectionOption
addDocumentSelectionOption(java.lang.String name, java.lang.String label, DocumentSelectionOption.FolderOrDocuments defaultValue, DocumentType allowedDocumentType, java.util.List<DocumentField> fieldsToDisplay, boolean allowMultipleSelections, java.util.List<AnnotatedPluginDocument> additionalDocuments)
Equivalent toaddDocumentSelectionOption(name, label, defaultValue, Collections.singleton(allowedDocumentType), null, null, fieldsToDisplay, allowMultipleSelections, additionalDocuments
(which takes a Set of DocumentTypes instead of a single DocumentType)DocumentSelectionOption
addDocumentSelectionOption(java.lang.String name, java.lang.String label, DocumentSelectionOption.FolderOrDocuments defaultValue, java.util.Set<DocumentType> allowedDocumentTypes, DocumentFilter documentFilter, java.lang.String documentTypeDescription, java.util.List<DocumentField> fieldsToDisplay, boolean allowMultipleSelections, java.util.List<AnnotatedPluginDocument> additionalDocuments)
An option to allow the user to select a number of documents of a particular type from their local database.Options.DoubleOption
addDoubleOption(java.lang.String name, java.lang.String label, java.lang.Double defaultValue)
Add an option that stores an Double and is displayed graphically to the user as a single line text field with a spinner (up and down arrow) on the right-hand sideOptions.DoubleOption
addDoubleOption(java.lang.String name, java.lang.String label, java.lang.Double defaultValue, java.lang.Double minimum, java.lang.Double maximum)
Add an option that stores an Double and is displayed graphically to the user as a single line text field with a spinner (up and down arrow) on the right-hand sideOptions.EditableComboBoxOption
addEditableComboBoxOption(java.lang.String name, java.lang.String label, java.lang.String defaultValue, java.lang.String[] selectableValues)
Add an option that stores a String that is displayed graphically to the user as a single line text field.Options.EditableComboBoxOption
addEditableComboBoxOption(java.lang.String name, java.lang.String label, java.lang.String defaultValue, java.lang.String[] selectableValues, int historySize)
Add an option that stores a String that is displayed graphically to the user as a single line text field.Options.ExecutableFileSelectionOption
addExecutableFileSelectionOption(java.lang.String name, java.lang.String label, java.lang.String fileName)
Adds an ExecutableFileSelectionOption where the default executable path is just the filename without a path component, i.e.Options.ExecutableFileSelectionOption
addExecutableFileSelectionOption(java.lang.String name, java.lang.String label, java.lang.String fileName, java.lang.String defaultValue)
Add an option that provides the user with an executable file name and provides assistance with finding the location of it.Options.FileSelectionOption
addFileSelectionOption(java.lang.String name, java.lang.String label, java.lang.String defaultValue)
Add an option that provides functionality to let the user choose a file.Options.FileSelectionOption
addFileSelectionOption(java.lang.String name, java.lang.String label, java.lang.String defaultValue, java.lang.String[] selectableFileNames, java.lang.String buttonLabel)
Add an option that provides functionality to let the user choose a file.Options.FileSelectionOption
addFileSelectionOption(java.lang.String name, java.lang.String label, java.lang.String defaultValue, java.lang.String[] selectableFileNames, java.lang.String buttonLabel, java.io.FilenameFilter filter)
Add an option that provides functionality to let the user choose a file.void
addHelpButton(java.lang.String dialogTitle, java.lang.String dialogMessage)
Equivalent toaddHelpButtonOption(String, String)
Options.Option
addHelpButtonOption(java.lang.String dialogTitle, java.lang.String dialogMessage)
Adds a little help button (with a question mark on it) which when clicked shows a dialog containing a message.Options.IntegerOption
addIntegerOption(java.lang.String name, java.lang.String label, java.lang.Integer defaultValue)
Add option that stores an Integer and is displayed graphically to the user as a single line text field with a spinner (up and down arrow) on the right-hand sideOptions.IntegerOption
addIntegerOption(java.lang.String name, java.lang.String label, java.lang.Integer defaultValue, java.lang.Integer minimum, java.lang.Integer maximum)
Add option that stores an Integer and is displayed graphically to the user as a single line text field with a spinner (up and down arrow) on the right-hand sideOptions.Option<java.lang.String,? extends javax.swing.JComponent>
addLabel(java.lang.String label)
Add a new label that is displayed between options when the options are graphically presented to the user.Options.Option<java.lang.String,? extends javax.swing.JComponent>
addLabel(java.lang.String label, boolean centreText, boolean spanEntirePanelWidth)
Add a new label that is displayed between options when the options are graphically presented to the user.Options.LabelOption
addLabelWithIcon(java.lang.String label, Icons icons)
Adds a label with an icon to the left of it.Options.MultipleLineStringOption
addMultipleLineStringOption(java.lang.String name, java.lang.String label, java.lang.String defaultValue, int rows, boolean lineWrap)
Add an option that stores a String and is displayed to the user as a multiple line text areaOptions.MultipleOptions
addMultipleOptions(java.lang.String name, Options multipleOptions, boolean isAdvanced)
Adds a set of Options so that the user is able to choose to have one or more instances of these child options through the use of +/- buttons to the right of the options.DocumentSelectionOption
addPrimerSelectionOption(java.lang.String name, java.lang.String label, DocumentSelectionOption.FolderOrDocuments defaultValue, boolean allowMultipleSelections, java.util.List<AnnotatedPluginDocument> additionalDocuments)
A convenience method for adding a document selection option for primers.<T extends Options.OptionValue>
Options.RadioOption<T>addRadioOption(java.lang.String name, java.lang.String label, java.util.List<T> possibleValues, T defaultValue, Options.Alignment alignment)
Construct a new Radio option.<T extends Options.OptionValue>
Options.RadioOption<T>addRadioOption(java.lang.String name, java.lang.String label, T[] possibleValues, T defaultValue, Options.Alignment alignment)
Construct a new Radio option.Options.Option<WritableDatabaseService,javax.swing.JComponent>
addServiceOption(java.lang.String name, java.lang.String label, WritableDatabaseService defaultValue)
Add an option that allows the user to select a WritableDatabaseService which appears under one of the services returned fromPluginUtilities.getWritableDatabaseServiceRoots()
.Options.Option<WritableDatabaseService,javax.swing.JComponent>
addServiceOption(java.lang.String name, java.lang.String label, WritableDatabaseService defaultValue, java.util.function.Predicate<GeneiousService> rootServiceValidator, boolean displayButton, boolean showNewFolderButton, boolean useStandardButtonLook, java.lang.String folderTreeDialogTitle, java.util.List<WritableDatabaseService> foldersToDisable)
Add an option that allows the user to select a WritableDatabaseService which appears under one of the services returned fromPluginUtilities.getWritableDatabaseServiceRoots()
.Options.StringOption
addStringOption(java.lang.String name, java.lang.String label, java.lang.String defaultValue)
Options.StringOption
addStringOption(java.lang.String name, java.lang.String label, java.lang.String defaultValue, java.lang.String watermarkText)
Add an option that stores a String that is displayed graphically to the user as a single line text field.boolean
areValuesGoodEnoughToContinue()
This is called by Geneious when the user clicks OK in the options dialog.void
beginAlignHorizontally()
Equivalent tobeginAlignHorizontally(null,false)
void
beginAlignHorizontally(java.lang.String label, boolean useEqualWidths)
Starts a row of horizontally aligned options that will later be finished with a call toendAlignHorizontally()
.boolean
canRestoreDefaults()
Return true if callingrestoreDefaults()
would change anything.protected javax.swing.JPanel
createAdvancedPanel()
Creates a graphical panel used to display advanced options.protected javax.swing.JPanel
createPanel()
Creates a graphical panel used to display these options.void
endAlignHorizontally()
Finishes a previously started row of horizontally aligned options (seebeginAlignHorizontally(String, boolean)
.void
fireListenersToFireAfterChangingAllValues()
Called in conjunction withinitializeListenersToFireAfterChangingAllValues()
to delay firing of listeners added to this Options and its child Option objects until such time as this method is called.void
fromXML(org.jdom.Element element)
Restore the object from the JDOM Element returned byXMLSerializable.toXML()
.javax.swing.JPanel
getAdvancedPanel()
Get a graphical panel used to display advanced options.java.util.Map<java.lang.String,Options>
getChildOptions()
Get all child options added usingaddChildOptions(String, String, String, Options)
.Options.Option
getChildOptionsPageChooser()
ifaddChildOptionsPageChooser(String, String, java.util.List, com.biomatters.geneious.publicapi.plugin.Options.PageChooserType, boolean)
has been called, return the option created for choosing which set of child options are currently active.java.lang.String
getDescriptionAndState()
Describe all properties and the state of these options.Dialogs.DialogOptions
getDialogOptions()
Returns aDialogs.DialogOptions
to use when laying out a dialog containing your options.java.awt.Component
getExtraLeftButtonPanelComponent()
Override this method and return a non-null component to have it displayed in the bottom left corner of this dialog alongside the extra-setting cog button and the help button.Icons
getIcons()
Gets Icons associated with these options.java.util.List<Options.MultipleOptions>
getMultipleOptions()
Get all multiple options added usingaddMultipleOptions(String, Options, boolean)
.Options.MultipleOptions
getMultipleOptions(java.lang.String name)
Get a set of multiple options added usingaddMultipleOptions(String, Options, boolean)
.java.util.Map<java.lang.String,Options.MultipleOptions>
getMultipleOptionsMap()
Get all the multiple options added usingaddMultipleOptions(String, Options, boolean)
.java.lang.String
getNamesAndValues(boolean includeLabelsToo)
Provides a text description of all option names and values.Options.Option
getOption(java.lang.String optionName)
Get an option or child option.java.util.List<Options.Option>
getOptions()
Get a list of all options added via any of the add*Option methods.java.lang.String
getOptionsHelp()
Override this method and return a non-null value to have it displayed as html in a dialog when the user clicks on a small help button in the corner of any window showing these options.javax.swing.JPanel
getPanel()
Get a graphical panel used to display these options.Options
getParentOptions()
java.lang.Object
getValue(java.lang.String optionName)
get the value of the option with the nameoptionName
.java.lang.String
getValueAsString(java.lang.String optionName)
Get the value of this option as a string.Geneious.MajorVersion
getVersionSupportForValuesToXML(XMLSerializable.VersionSupportType versionType)
boolean
hasAdvancedOptions()
Return true if any option or any child options returns true fromOptions.Option.isAdvanced()
boolean
hasBasicOptions()
Return true if any option or any child options returns false fromOptions.Option.isAdvanced()
void
initializeListenersToFireAfterChangingAllValues()
Causes this options to delay firing of all listeners added viaaddChangeListener(SimpleListener)
(or to anyOptions
' listeners added viaOptions.Option.addChangeListener(SimpleListener)
or to anyOptions.ChildOptions
) until such time asfireListenersToFireAfterChangingAllValues()
) is called.boolean
isEnabled()
Determine if these options appear enabled.boolean
isHideRestoreDefaultsButton()
boolean
isHorizontallyCompact()
Returns true if these options or any ancestor options have been set as horizontally compact usingsetHorizontallyCompact(boolean)
.boolean
isProOnly()
Determine whether or not these options require an active license.boolean
isVisible()
Return true if the graphical component that displays these options would be visible to the user when the panel is showing.void
removeChangeListener(org.virion.jam.util.SimpleListener listener)
Remove a listener to be notified when the value of any option changesvoid
removeDefaultsRestoredListener(org.virion.jam.util.SimpleListener listener)
Remove a listener to be notified when the options are restored to their defaults (e.g.void
restoreDefaults()
Restores all current option values and child options to their default values.void
restorePreferences()
Restore the current option values from the default persistent storage location by callingrestorePreferences(null, false)
.void
restorePreferences(java.lang.String preferenceNodeSuffix, boolean restorePreferencesOfOptionsThatHaveHadTheirValuesAlreadySet)
Restores the current option values from persistent storage, i.e.void
savePreferences()
Save the current option values persistently in the default storage location by callingsavePreferences(null)
void
savePreferences(java.lang.String preferenceNodeSuffix)
Save the current option values persistently, i.e.void
setChildOptionsCollapsed(java.lang.String name, boolean collapsed)
Set the collapsed state of child options added previously usingaddCollapsibleChildOptions(String, String, String, Options, boolean, boolean)
.void
setEnabled(boolean enabled)
Sets the enabled state of all these Options.void
setHideRestoreDefaultsButton(boolean hideRestoreDefaultsButton)
Sets whether to hide the "Restore Defaults" button in options dialogs.void
setHorizontallyCompact(boolean horizontallyCompact)
Flags the basic options to be displayed in a visually compact form suitable for displaying in a limited amount of space.void
setHorizontallyCompactAdvanced(boolean horizontallyCompact)
Flags the advanced options to be displayed in a visually compact form suitable for displaying in a limited amount of space.void
setIcons(Icons icons)
Sets Icons associated with these options.void
setInScrollPane(boolean inScrollPane)
Specifies whether the options should be displayed in a scroll pane if the panel is shrunk below it's preferred size.void
setLeftAlignLabels(boolean leftAlignLabels)
Ensures the labels of all options are left aligned rather than the default behaviour of aligning labels so that their right hand sides are vertically aligned with each other.void
setPlaceOptionsOnLeft(boolean placeOptionsOnLeft)
Attempts to place all options on the left instead of the normal centred layout.void
setProOnly(boolean proOnly)
Sets whether or not these options require an active license By default all options do not require an active license.void
setSavePreferencesForInvisibleChildOptions(boolean saveInvisibleChildOptions)
Sets whether or not calling restore defaults (restoreDefaults()
) or save preferences (savePreferences()
) will apply only to the child options (Options.ChildOptions
that are currently visible.boolean
setStringValue(java.lang.String optionName, java.lang.String value)
set the value of an optionvoid
setStringValueOrCrash(java.lang.String optionName, java.lang.String value)
LikesetStringValue(String, String)
but throws a DocumentOperationException if an option value can't be set rather than returning false.
UsesetStringValueOrCrash(java.lang.String, java.lang.String)
if it's a bug and Geneious should crash with an error report if the option can't be set.void
setStringValueOrFail(java.lang.String optionName, java.lang.String value)
LikesetStringValue(String, String)
but throws a DocumentOperationException if an option value can't be set rather than returning false.
UsesetStringValueOrFail(java.lang.String, java.lang.String)
if Geneious should fail gracefully if the option can't be set.boolean
setValue(java.lang.String optionName, java.lang.Object value)
set the value of an optionvoid
setValueOrCrash(java.lang.String optionName, java.lang.Object value)
LikesetValue(String, Object)
but throws an IllegalArgumentException if an option value can't be set rather than returning false UsesetValueOrCrash(java.lang.String, java.lang.Object)
if it's a bug and Geneious should crash with an error report if the option can't be set.void
setValueOrFail(java.lang.String optionName, java.lang.Object value)
LikesetValue(String, Object)
but throws a DocumentOperationException if an option value can't be set rather than returning false.
UsesetValueOrFail(java.lang.String, java.lang.Object)
if Geneious should fail gracefully if the option can't be set.void
setVerticallyCompact(boolean verticallyCompact)
Flags the basic options to be displayed in a visually compact form suitable for displaying in a limited amount of space.void
setVerticallyCompactAdvanced(boolean verticallyCompact)
Flags the advanced options to be displayed in a visually compact form suitable for displaying in a limited amount of space.void
setVisible(boolean visible)
Sets the visibility of the graphical component that displays these options and makes appropriate changes to the size of the window (if any) that contains the graphical component.java.lang.String
toString()
org.jdom.Element
toXML()
Convert object to a JDOM element.void
valuesFromXML(org.jdom.Element root)
Deserializes the current values for these options from XML.void
valuesFromXML(org.jdom.Element root, boolean includeOptionsWhichDontRestorePreferences)
Deserializes the current values for these options from XML.java.util.List<java.lang.String>
valuesFromXMLReturningErrors(org.jdom.Element root, boolean includeOptionsWhichDontRestorePreferences)
Deserializes the current values for these options from XML.org.jdom.Element
valuesToXML(Geneious.MajorVersion version, java.lang.String rootElementName)
Serializes the current values for these options to XML for use with a later call tovaluesFromXML(org.jdom.Element)
.org.jdom.Element
valuesToXML(Geneious.MajorVersion version, java.lang.String rootElementName, boolean excludeOptionsWhereRestorePreferenceApplies)
Serializes the current values for these options to XML for use with a later call tovaluesFromXML(org.jdom.Element)
.org.jdom.Element
valuesToXML(java.lang.String rootElementName)
Serializes the current values for these options to XML for use with a later call tovaluesFromXML(org.jdom.Element)
.java.lang.String
verifyOptionsAreValid()
Override this to have the current contents of options checked (for example String options that allow the user to enter arbitrary text) to make sure they are valid before proceeding.
-
-
-
Field Detail
-
ASSOCIATED_OPTION_PROPERTY
public static final java.lang.String ASSOCIATED_OPTION_PROPERTY
The Components (or sub-components) returned byOptions.Option.getComponent()
may provide this property viaJComponent.getClientProperty(Object)
which will be a reference to the Option the component belongs to.- Since:
- API 4.700 (Geneious 7.0.0)
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Options
protected Options()
For use by subclasses only; Equivalent toOptions(getClass())
.
-
Options
public Options(java.lang.Class cl)
Construct a new options.- Parameters:
cl
- a class used to generate a unique name under which persistent preferences can be stored. Usually this should be the class that these options are constructed within.
-
Options
public Options(java.lang.Class cl, java.lang.String preferenceNameSuffix)
Construct a new options.- Parameters:
cl
- a class used to generate a unique name under which persistent preferences can be stored. Usually this should be the class that these options are constructed within.preferenceNameSuffix
- A suffix to append to the unique name generated from the class. For example, a set of sequence alignment options may vary the value of this parameter depending on whether it is aligning nucleotide or protein sequences in order to have different preference sets for each type of sequence.- Throws:
java.lang.IllegalArgumentException
- if cl is null and the concrete class of these options is Options.class
-
Options
protected Options(org.jdom.Element element) throws XMLSerializationException
Constructor for XML Serialization. SeeXMLSerializable
- Throws:
XMLSerializationException
-
-
Method Detail
-
getDialogOptions
public Dialogs.DialogOptions getDialogOptions()
Returns aDialogs.DialogOptions
to use when laying out a dialog containing your options. You may specify an array of strings or actions when you construct your DialogOptions, and these will be displayed as the dialog's buttons. The operation will proceed if the user has clicked on the default button (seeDialogs.DialogOptions.setDefaultButton(com.biomatters.geneious.publicapi.components.Dialogs.DialogAction)
andDialogs.DialogOptions.setDefaultButton(String)
), and not if the user has clicked on any other button- Returns:
- the custom dialogOptions for your options
-
getExtraLeftButtonPanelComponent
public java.awt.Component getExtraLeftButtonPanelComponent()
Override this method and return a non-null component to have it displayed in the bottom left corner of this dialog alongside the extra-setting cog button and the help button.- Returns:
- A component to be shown on the left side of the same button panel which the OK and Cancel buttons are displayed
- Since:
- API 4.202300 (Geneious 2023.0.0)
-
getParentOptions
public Options getParentOptions()
- Returns:
- The Options that this Options was added to with
addChildOptions(String, String, String, Options)
or null if this has not been added to another Options - Since:
- API 4.14 (Geneious 5.1)
-
setEnabled
public void setEnabled(boolean enabled)
Sets the enabled state of all these Options. All contained Options are only considered enabled if they are themselves enabled and if their parent Options are enabled.- Parameters:
enabled
- whether or not these Options should be enabled.
-
setVisible
public void setVisible(boolean visible)
Sets the visibility of the graphical component that displays these 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 options should be visible.- See Also:
isVisible()
-
isVisible
public boolean isVisible()
Return true if the graphical component that displays these options would be visible to the user when the panel is showing.- Returns:
- true if the graphical component that displays these options would be visible to the user when the panel is showing.
- See Also:
setVisible(boolean)
-
isEnabled
public boolean isEnabled()
Determine if these options appear enabled. Options appear enabled only if they are currently set as enabled ( usingsetEnabled(boolean)
which is true by default) and if their parent options (if these Options are child options or multiple options inside other Options) appear enabled.- Returns:
- true if these options appear enabled.
-
setProOnly
public final void setProOnly(boolean proOnly)
Sets whether or not these options require an active license By default all options do not require an active license.- Parameters:
proOnly
- true if these options require an active license
-
isProOnly
public boolean isProOnly()
Determine whether or not these options require an active license.- Returns:
- true if these options require an active license
-
setIcons
public final void setIcons(Icons icons)
Sets Icons associated with these options. An icon may be displayed in the options window title bar in future (although currently it is not). If these options are added as a child of another set of options inside a PageChooser (addChildOptionsPageChooser(String, String, java.util.List, com.biomatters.geneious.publicapi.plugin.Options.PageChooserType, boolean)
addChildOptionsPageChooser} , then this specifies the icon will be used for the tab.- Parameters:
icons
- the icons
-
getIcons
public final Icons getIcons()
Gets Icons associated with these options. SeesetIcons(Icons)
for more information.- Returns:
- Icons associated with these options or null if it has no Icons.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the result of
getDescriptionAndState()
-
getDescriptionAndState
public final java.lang.String getDescriptionAndState()
Describe all properties and the state of these options.- Returns:
- a description of all properties and the state of these options.
- See Also:
getNamesAndValues(boolean)
-
getNamesAndValues
public final java.lang.String getNamesAndValues(boolean includeLabelsToo)
Provides a text description of all option names and values. For a more complete description of the options which includes all possible values for all options, seegetDescriptionAndState()
- Parameters:
includeLabelsToo
- to also include the label displayed next to each option- Returns:
- a text description of all option names and values.
- Since:
- API 4.611 (Geneious 6.1.1)
- See Also:
getDescriptionAndState()
-
getOptions
public final java.util.List<Options.Option> getOptions()
Get a list of all options added via any of the add*Option methods. (addBooleanOption
,addStringOption
,addOption
etc). Note that this does not include child options at usingaddChildOptions
. To obtain a list of those, usegetChildOptions()
.- Returns:
- all the contained options
-
addCustomOption
public final <OptionType extends Options.Option> OptionType addCustomOption(OptionType option)
Add a custom option. It will have its value reset to its default value. This method should be used only on custom option classes. For adding standard options useaddBooleanOption
,addStringOption
etc. To create a custom option type, extendOption
.- Parameters:
option
- the option to be added- Returns:
- the newly added custom Option
- Throws:
java.lang.NullPointerException
- if option is null
-
addCustomComponent
@Deprecated public final Options.Option addCustomComponent(javax.swing.JComponent component)
Deprecated.Please instead useaddCustomComponent(ComponentCreator)
as Swing is not thread safe and Options are frequently constructed outside the Swing thread.Adds a custom component that will be laid out along with all the standard options. Note: Ifcomponent
is notXMLSerializable
then if these options are serialized and deserialized, then deserialized component will be a blank panel. Note: For performance and thread safety reasons, it is almost always better to useaddCustomComponent(ComponentCreator)
instead where possible.- Parameters:
component
- the component to add which may want to implementXMLSerializable
.- Returns:
- An option that wraps the component. Methods such as
Option.setSpanningComponent
orOption.setFillHorizontalSpace
may be used on it to adjust the size of the component. - See Also:
addCustomComponent(ComponentCreator)
-
addCustomComponent
public final Options.Option addCustomComponent(Options.ComponentCreator componentCreator)
Adds a custom component that will be laid out along with all the standard options. This component is only created on demand shortly before the component is rendered (if at all) the first time. Note: If the component is notXMLSerializable
then if these options are serialized and deserialized, then deserialized component will be a blank panel.- Parameters:
componentCreator
- a ComponentCreator on whichOptions.ComponentCreator.create()
will be later called on the event dispatch thread to create the component when it is about to be rendered. This will be invoked at most once.- Returns:
- An option that wraps the component. Methods such as
Option.setSpanningComponent
orOption.setFillHorizontalSpace
may be used on it to adjust the size of the component. - Since:
- API 4.700 (Geneious 7.0.0)
-
addStringOption
public final Options.StringOption addStringOption(java.lang.String name, java.lang.String label, java.lang.String defaultValue, java.lang.String watermarkText)
Add an option that stores a String that is displayed graphically to the user as a single line text field. It will have its value set to its default value.- Parameters:
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.label
- a label describing this option to be displayed to the userdefaultValue
- the default value for this optionwatermarkText
- Watermark to display when no string is entered and textfield doesn't have focus, or null for none.- Returns:
- the newly added StringOption.
-
addStringOption
public final Options.StringOption addStringOption(java.lang.String name, java.lang.String label, java.lang.String defaultValue)
-
addEditableComboBoxOption
public final Options.EditableComboBoxOption addEditableComboBoxOption(java.lang.String name, java.lang.String label, java.lang.String defaultValue, java.lang.String[] selectableValues)
Add an option that stores a String that is displayed graphically to the user as a single line text field. Furthermore you can optionally provide a list of selectable strings to appear in the drop down combo box.- Parameters:
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.label
- a label describing this option to be displayed to the userdefaultValue
- the default value for this optionselectableValues
- some selectable values to display in the drop down box.- Returns:
- the newly added EditableComboBoxOption.
-
addEditableComboBoxOption
public final Options.EditableComboBoxOption addEditableComboBoxOption(java.lang.String name, java.lang.String label, java.lang.String defaultValue, java.lang.String[] selectableValues, int historySize)
Add an option that stores a String that is displayed graphically to the user as a single line text field. Furthermore you can optionally provide a list of selectable strings to appear in the drop down combo box.- Parameters:
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.label
- a label describing this option to be displayed to the userdefaultValue
- the default value for this optionselectableValues
- some selectable values to display in the drop down box.historySize
- the maximum number of user-entered strings to store as a history or 0 to keep no history- Returns:
- the newly added EditableComboBoxOption.
-
addBooleanOption
public final Options.BooleanOption addBooleanOption(java.lang.String name, java.lang.String label, java.lang.Boolean defaultValue)
Add an option that stores a Boolean and is represented graphically as a check box. It will have its value set to its default value.- Parameters:
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 option- Returns:
- the newly added BooleanOption.
-
addMultipleLineStringOption
public final Options.MultipleLineStringOption addMultipleLineStringOption(java.lang.String name, java.lang.String label, java.lang.String defaultValue, int rows, boolean lineWrap)
Add an option that stores a String and is displayed to the user as a multiple line text area It will have its value set to its default value.- Parameters:
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 optionrows
- the number of rows in the text area when displayed to the userlineWrap
- true if long lines should be wrapped when the text area is displayed to the user- Returns:
- the newly added MultipleLineStringOption.
-
addIntegerOption
public final Options.IntegerOption addIntegerOption(java.lang.String name, java.lang.String label, java.lang.Integer defaultValue, java.lang.Integer minimum, java.lang.Integer maximum)
Add option that stores an Integer and is displayed graphically to the user as a single line text field with a spinner (up and down arrow) on the right-hand side For information on what the initial value of this option is set to seeaddStringOption
.- Parameters:
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 optionminimum
- The minimum value that the option can havemaximum
- The maximum value that the option can have- Returns:
- the newly added IntegerOption.
-
addIntegerOption
public final Options.IntegerOption addIntegerOption(java.lang.String name, java.lang.String label, java.lang.Integer defaultValue)
Add option that stores an Integer and is displayed graphically to the user as a single line text field with a spinner (up and down arrow) on the right-hand side For information on what the initial value of this option is set to seeaddStringOption
.- Parameters:
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.label
- a label describing this option to be displayed to the user. eg. "My Awesome Option"defaultValue
- the default value for this option- Returns:
- the newly added IntegerOption.
-
addButtonOption
public final Options.ButtonOption addButtonOption(java.lang.String name, java.lang.String label, java.lang.String buttonLabel, javax.swing.Icon icon, int alignment)
Adds an option that is represented by a button, and may have actions attached to it which are activated when the user clicks the button (seeOptions.ButtonOption.addActionListener(java.awt.event.ActionListener)
).- Parameters:
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". Usually displayed to the left of the button.buttonLabel
- The text on the button itselficon
- An optional icon which will appear on the button. This icon is not XMLSerializable, and can be null.alignment
- choose how to align the button - only works on if this option is spanning (seeOptions.Option.setSpanningComponent(boolean)
). Choices areOptions.ButtonOption.LEFT
,Options.ButtonOption.CENTER
, andOptions.ButtonOption.RIGHT
-
addButtonOption
public final Options.ButtonOption addButtonOption(java.lang.String name, java.lang.String label, java.lang.String buttonLabel)
Adds an option that is represented by a button, and may have actions attached to it which are activated when the user clicks the button (seeOptions.ButtonOption.addActionListener(java.awt.event.ActionListener)
).- Parameters:
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". Usually displayed to the left of the button.buttonLabel
- The text on the button itself
-
addDoubleOption
public final Options.DoubleOption addDoubleOption(java.lang.String name, java.lang.String label, java.lang.Double defaultValue, java.lang.Double minimum, java.lang.Double maximum)
Add an option that stores an Double and is displayed graphically to the user as a single line text field with a spinner (up and down arrow) on the right-hand side For information on what the initial value of this option is set to seeaddStringOption
.- Parameters:
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.label
- a label describing this option to be displayed to the user. eg. "My Awesome Option"defaultValue
- the default value for this optionminimum
- The minimum value that the option can havemaximum
- The maximum value that the option can have- Returns:
- the newly added DoubleOption.
-
addDoubleOption
public final Options.DoubleOption addDoubleOption(java.lang.String name, java.lang.String label, java.lang.Double defaultValue)
Add an option that stores an Double and is displayed graphically to the user as a single line text field with a spinner (up and down arrow) on the right-hand side For information on what the initial value of this option is set to seeaddStringOption
.- Parameters:
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 option- Returns:
- the newly added DoubleOption.
-
addDateOption
public final Options.DateOption addDateOption(java.lang.String name, java.lang.String label, java.util.Date defaultValue)
Add an option that stores a Date (day, month and year only) and is displayed graphically to the user as a set of 3 spinners together with a button that opens a new dialog for nicer date selection from a calendar style view.- Parameters:
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 option- Returns:
- the newly added DateOption.
-
addServiceOption
public final Options.Option<WritableDatabaseService,javax.swing.JComponent> addServiceOption(java.lang.String name, java.lang.String label, WritableDatabaseService defaultValue)
Add an option that allows the user to select a WritableDatabaseService which appears under one of the services returned fromPluginUtilities.getWritableDatabaseServiceRoots()
. Appears as a label showing the name of the currently selected service with a button that pops up a tree to change the selected service.- Parameters:
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 option. May be null in which caseOptions.Option.getValue()
on the Option may return a dummy service (with unique ID 'dummy') that returns no documents from its retrieve methods.- Returns:
- the newly added ServiceOption.
- Since:
- API 4.600 (Geneious 6.0.0)
-
addServiceOption
public final Options.Option<WritableDatabaseService,javax.swing.JComponent> addServiceOption(java.lang.String name, java.lang.String label, WritableDatabaseService defaultValue, java.util.function.Predicate<GeneiousService> rootServiceValidator, boolean displayButton, boolean showNewFolderButton, boolean useStandardButtonLook, java.lang.String folderTreeDialogTitle, java.util.List<WritableDatabaseService> foldersToDisable)
Add an option that allows the user to select a WritableDatabaseService which appears under one of the services returned fromPluginUtilities.getWritableDatabaseServiceRoots()
. Appears as either a label showing the name of the currently selected service with a button that pops up a tree to change the selected service, or simply as a service tree, depending on the value of thedisplayButton
parameter.- Parameters:
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 option. May be null in which caseOptions.Option.getValue()
on the Option may return a dummy service (with unique ID 'dummy') that returns no documents from its retrieve methods.rootServiceValidator
- if not null, will be used to display only valid root services (and descendants)displayButton
- if true, this option will be displayed as a button that pops up a tree, otherwise the option will be displayed directly as a treeshowNewFolderButton
- if true, the user will be provided with a button allowing them to create a new folderuseStandardButtonLook
- if false, the button will have appear "flat" against the background panel (has no effect ifdisplayButton
is false)folderTreeDialogTitle
- if not null, this will be used as a title for the dialog displaying the service tree (has no effect ifdisplayButton
is false)foldersToDisable
- a list of folders (and descendants) to disable in the service tree selector- Returns:
- the newly added ServiceOption.
- Since:
- API 4.201900 (Geneious 2019.0.0)
-
addComboBoxOption
public final <T extends Options.OptionValue> Options.ComboBoxOption<T> addComboBoxOption(java.lang.String name, java.lang.String label, java.util.List<? extends T> possibleValues, T defaultValue)
Add a new ComboBoxOption. This is a list of values that are provided to the user graphically as a combo box. For information on what the initial value of this option is set to seeaddStringOption
.- Parameters:
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.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)- Returns:
- the newly added ComboBoxOption.
-
addDocumentSelectionOption
public final DocumentSelectionOption addDocumentSelectionOption(java.lang.String name, java.lang.String label, DocumentSelectionOption.FolderOrDocuments defaultValue, DocumentType allowedDocumentType, java.util.List<DocumentField> fieldsToDisplay, boolean allowMultipleSelections, java.util.List<AnnotatedPluginDocument> additionalDocuments)
Equivalent toaddDocumentSelectionOption(name, label, defaultValue, Collections.singleton(allowedDocumentType), null, null, fieldsToDisplay, allowMultipleSelections, additionalDocuments
(which takes a Set of DocumentTypes instead of a single DocumentType)- Since:
- API 4.15 (Geneious 5.1.1)
- See Also:
addPrimerSelectionOption(String, String, com.biomatters.geneious.publicapi.plugin.DocumentSelectionOption.FolderOrDocuments, boolean, java.util.List)
-
addDocumentSelectionOption
public final DocumentSelectionOption addDocumentSelectionOption(java.lang.String name, java.lang.String label, DocumentSelectionOption.FolderOrDocuments defaultValue, java.util.Set<DocumentType> allowedDocumentTypes, DocumentFilter documentFilter, java.lang.String documentTypeDescription, java.util.List<DocumentField> fieldsToDisplay, boolean allowMultipleSelections, java.util.List<AnnotatedPluginDocument> additionalDocuments)
An option to allow the user to select a number of documents of a particular type from their local database. The list of documents is taken from the search index, so the user will not be able to choose documents unless search indexing has completed. To add a primer selection option, seeaddPrimerOption
.- Parameters:
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". The name is used to restore recently used documents (if available), provide different names for this option if it is used for different purposes. UseDocumentSelectionOption.setPreferenceKeyForChooserDialog(String)
to stop options with the same name from sharing preferenceslabel
- A label describing this option to be displayed to the user. eg. "My Awesome Option"defaultValue
- The default value for this option.allowedDocumentTypes
- The types of documents to allow the user to choose from (for exampleDocumentType.OLIGO_DOC_TYPE
). The type you want to search on must be a type defined prior to the documents being indexed so if you introduce a new document type that matches existing documents those documents will not be found.documentFilter
- An optional filter to further reject documents even if they are one of the provided allowedDocumentTypes. May be null to perform no additional filtering. The filter must not load the internal PluginDocuments. Instead it must only filter using properties of the AnnotatedPluginDocumentdocumentTypeDescription
- An optional description of what the allowedDocumentTypes and documentFilter accept. For example "linear nucleotide sequences". May be null in which case this implementation will choose an reasonable descriptionfieldsToDisplay
- A list ofDocumentFields
which will be displayed in columns in the document selection dialog. If the list is null, then one will be created from the fields present on the documents.allowMultipleSelections
- True if the user is able to select more than one document at a time, also enables folder selectionadditionalDocuments
- A list of additional documents (possibly not in the user's database), which the user can also choose from- Returns:
- The newly added DocumentSelectionOption.
- Since:
- API 4.810 (Geneious 8.1.0)
- See Also:
addPrimerSelectionOption(String, String, com.biomatters.geneious.publicapi.plugin.DocumentSelectionOption.FolderOrDocuments, boolean, java.util.List)
,DocumentSelectionOption.setAllowSearchCache(boolean)
,DocumentSelectionOption.setPreferenceKeyForChooserDialog(String)
-
addPrimerSelectionOption
public final DocumentSelectionOption addPrimerSelectionOption(java.lang.String name, java.lang.String label, DocumentSelectionOption.FolderOrDocuments defaultValue, boolean allowMultipleSelections, java.util.List<AnnotatedPluginDocument> additionalDocuments)
A convenience method for adding a document selection option for primers. It adds some standard fields which are useful for primers.
-
addComboBoxOption
public final <T extends Options.OptionValue> Options.ComboBoxOption<T> addComboBoxOption(java.lang.String name, java.lang.String label, T[] possibleValues, T defaultValue)
Add a new ComboBoxOption. This is a list of values that are provided to the user graphically as a combo box. For information on what the initial value of this option is set to seeaddStringOption
.- Parameters:
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.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)- Returns:
- the newly added ComboBoxOption.
-
addRadioOption
public final <T extends Options.OptionValue> Options.RadioOption<T> addRadioOption(java.lang.String name, java.lang.String label, T[] possibleValues, T defaultValue, Options.Alignment alignment)
Construct a new Radio option. This is a list of values that are provided to the user graphically as a set of radio buttons For information on what the initial value of this option is set to seeaddStringOption
.- Parameters:
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.label
- a non-null label describing this option to be displayed to the user. eg. "My Awesome Option"possibleValues
- An array containing all possible values (i.e. all the radio button names)defaultValue
- the default value for this option, not nullalignment
- the alignment of the radio buttons (horizontally or vertically)- Returns:
- the newly added RadioOption.
-
addRadioOption
public final <T extends Options.OptionValue> Options.RadioOption<T> addRadioOption(java.lang.String name, java.lang.String label, java.util.List<T> possibleValues, T defaultValue, Options.Alignment alignment)
Construct a new Radio option. This is a list of values that are provided to the user graphically as a set of radio buttons For information on what the initial value of this option is set to seeaddStringOption
.- Parameters:
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.label
- a non-null label describing this option to be displayed to the user. eg. "My Awesome Option"possibleValues
- An array containing all possible values (i.e. all the radio button names)defaultValue
- the default value for this optionalignment
- the alignment of the radio buttons (horizontally or vertically). Also consider usingOptions.RadioOption.setDependentPosition(RadioOption.DependentPosition)
in addition to this- Returns:
- the newly added RadioOption.
-
addColorChooserOption
public final Options.Option<java.awt.Color,javax.swing.JPanel> addColorChooserOption(java.lang.String name, java.lang.String label, java.awt.Color defaultColor)
Add an option for letting the user choose a Color- Parameters:
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.label
- a non-null label describing this option to be displayed to the user. eg. "My Awesome Option"defaultColor
- the default value for this option- Returns:
- the newly added Option. The value can be obtained via
Options.Option.getValue()
- Since:
- API 4.1100 (Geneious 11.0.0)
-
addFileSelectionOption
public final Options.FileSelectionOption addFileSelectionOption(java.lang.String name, java.lang.String label, java.lang.String defaultValue, java.lang.String[] selectableFileNames, java.lang.String buttonLabel)
Add an option that provides functionality to let the user choose a file. For example, the cost matrix selection when doing a clustal alignment For information on what the initial value of this option is set to seeaddStringOption
. If the file is expected to be an executable file, useaddExecutableFileSelectionOption(String, String, String)
instead- Parameters:
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.label
- a label describing this option to be displayed to the user. eg. "My Awesome Option"defaultValue
- the default value for this optionselectableFileNames
- A list of selectable filenames to be provided to the user.buttonLabel
- The text displayed on the button instead of "Browse"- Returns:
- the newly added FileSelectionOption.
- See Also:
addExecutableFileSelectionOption(String, String, String)
-
addFileSelectionOption
public final Options.FileSelectionOption addFileSelectionOption(java.lang.String name, java.lang.String label, java.lang.String defaultValue, java.lang.String[] selectableFileNames, java.lang.String buttonLabel, java.io.FilenameFilter filter)
Add an option that provides functionality to let the user choose a file. For example, the cost matrix selection when doing a clustal alignment For information on what the initial value of this option is set to seeaddStringOption
. If the file is expected to be an executable file, useaddExecutableFileSelectionOption(String, String, String)
instead- Parameters:
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.label
- a label describing this option to be displayed to the user. eg. "My Awesome Option"defaultValue
- the default value for this optionselectableFileNames
- A list of selectable filenames to be provided to the user.buttonLabel
- The text displayed on the button instead of "Browse"filter
- Filter which matches filenames which are a valid selection. This field is not serialized.- Returns:
- the newly added FileSelectionOption.
- See Also:
addExecutableFileSelectionOption(String, String, String)
-
addFileSelectionOption
public final Options.FileSelectionOption addFileSelectionOption(java.lang.String name, java.lang.String label, java.lang.String defaultValue)
Add an option that provides functionality to let the user choose a file. For example, the cost matrix selection when doing a clustal alignment For information on what the initial value of this option is set to seeaddStringOption
.- Parameters:
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.label
- a label describing this option to be displayed to the user. eg. "My Awesome Option"defaultValue
- the default value for this option- Returns:
- the newly added FileSelectionOption.
-
addExecutableFileSelectionOption
public final Options.ExecutableFileSelectionOption addExecutableFileSelectionOption(java.lang.String name, java.lang.String label, java.lang.String fileName)
Adds an ExecutableFileSelectionOption where the default executable path is just the filename without a path component, i.e. assuming that the executable is on the PATH. This is the same asaddExecutableFileSelectionOption(String,String,String,String)
with arguments (name, label, fileName, fileName).- Parameters:
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.label
- a label describing this option to be displayed to the user. eg. "My Awesome Option"fileName
- The name of the executable file (without a path component) that we are looking for, e.g. "clustalw.exe". This will also be the default value for this option.- Returns:
- the newly added ExecutableFileSelectionOption.
-
addExecutableFileSelectionOption
public final Options.ExecutableFileSelectionOption addExecutableFileSelectionOption(java.lang.String name, java.lang.String label, java.lang.String fileName, java.lang.String defaultValue)
Add an option that provides the user with an executable file name and provides assistance with finding the location of it. For example, when doing a clustal alignment, the option to choose the location of the clustal executable. Provides the user with an executable file name and provides assistance with finding the location of it. For information on what the initial value of this option is set to seeaddStringOption
.- Parameters:
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.label
- a label describing this option to be displayed to the user. eg. "My Awesome Option"fileName
- The name of the executable file (without a path component) that we are looking for, e.g. "clustalw.exe". This will also be the default value for this option.defaultValue
- The default location of the executable file; If you don't have a good default for this, it's probably best to assume it is on the PATH, and calladdExecutableFileSelectionOption(String, String, String)
instead.- Returns:
- the newly added ExecutableFileSelectionOption.
-
beginAlignHorizontally
public void beginAlignHorizontally(java.lang.String label, boolean useEqualWidths)
Starts a row of horizontally aligned options that will later be finished with a call toendAlignHorizontally()
. The row will contain all options added between those two calls. At the time when the panel is created, all options in the row must agree whether they are advanced or not (seeOptions.Option.isAdvanced()
). The row will fill any remaining available horizontal space if any of the options in the row would (seeOptions.Option.isFillHorizontalSpace()
or ifuseEqualWidths
is true. The row will stretch over the entire width of the options panel iflabel
is null. A call to this method must precede exactly one corresponding later call toendAlignHorizontally()
. While the aligned row of options is being populated (i.e. in the time between callingbeginAlignHorizontally(String, boolean)
and the corresponding call toendAlignHorizontally()
), it is illegal to call eitherbeginAlignHorizontally(String, boolean)
,createPanel()
orcreateAdvancedPanel()
.- Parameters:
label
- An optional label that is to be displayed at the left side of the current row in the options panel. A value of null indicates that no label will be displayed and that the horizontally aligned components will begin at the very left of the panel. A empty string label means that the horizontally aligned components will start to the right of standard component labels.useEqualWidths
- true to make all horizontally alignment options have equal widths. This also expands the row to use the full width available.
-
beginAlignHorizontally
public void beginAlignHorizontally()
Equivalent tobeginAlignHorizontally(null,false)
- Since:
- API 4.1000 (Geneious 10.0.0)
-
endAlignHorizontally
public void endAlignHorizontally()
Finishes a previously started row of horizontally aligned options (seebeginAlignHorizontally(String, boolean)
. After this method has been called, it is then again legal to call(String, boolean)
, or to callcreatePanel()
orcreateAdvancedPanel()
.
-
getChildOptions
public final java.util.Map<java.lang.String,Options> getChildOptions()
Get all child options added usingaddChildOptions(String, String, String, Options)
. The key in the returned map is the name specified as the parameter to addChildOptions.- Returns:
- all child options.
-
setSavePreferencesForInvisibleChildOptions
public void setSavePreferencesForInvisibleChildOptions(boolean saveInvisibleChildOptions)
Sets whether or not calling restore defaults (restoreDefaults()
) or save preferences (savePreferences()
) will apply only to the child options (Options.ChildOptions
that are currently visible. This value set by this method replaces the parameter allChildOptionsApplySimultaneously's value from an earlier call toaddChildOptionsPageChooser(String, String, java.util.List, com.biomatters.geneious.publicapi.plugin.Options.PageChooserType, boolean)
- Parameters:
saveInvisibleChildOptions
- true to restore defaults and save preferences for invisible child options.- Since:
- API 4.52 (Geneious 5.5.2)
-
addChildOptionsPageChooser
public final Options.Option addChildOptionsPageChooser(java.lang.String name, java.lang.String label, java.util.List<java.lang.String> disabledOptions, Options.PageChooserType type, boolean allChildOptionsApplySimultaneously)
Makes all previously added child options available via a list of tab buttons. For example, when choosing to do an alignment, there are buttons along the top to select whether to do Geneious or clustal alignment. These are implemented as child options (usingaddChildOptions
followed by calling this method. When choosing to build a tree from unaligned sequences, the alignment and tree building options are implemented as child options without calling this method.- Parameters:
name
- A programmatic name used for referring to the option created for choosing which options are visible. This option can be retrieved usinggetChildOptionsPageChooser()
.label
- A label displayed to the userdisabledOptions
- provides a list of child option names that are disabledtype
- the PageChooserType type of the chooserallChildOptionsApplySimultaneously
- If this is false then after calling this method, choosing to restore defaults (restoreDefaults()
) or save preferences (savePreferences()
) will apply only to the child options of the currently visible page or to all pages if the options are not yet displayed.- Returns:
- An option representing the page chooser. The string value (obtained using
Options.Option.getValueAsString()
) of the returned option will match the name of the currently selected child options (which is the first parameter given toaddChildOptions(String, String, String, Options)
) - Throws:
java.lang.IllegalStateException
- if this method is called more than once or ifaddChildOptions
has been called less than twice.- See Also:
Options.Option.addChildOptionsDependent(Options, Object, boolean)
-
getChildOptionsPageChooser
public final Options.Option getChildOptionsPageChooser()
ifaddChildOptionsPageChooser(String, String, java.util.List, com.biomatters.geneious.publicapi.plugin.Options.PageChooserType, boolean)
has been called, return the option created for choosing which set of child options are currently active. The string value (obtained usingOptions.Option.getValueAsString()
) of the returned option will match the name of the currently selected child options. (which is the first parameter given toaddChildOptions(String, String, String, Options)
)- Returns:
- The child selection option or null if
addChildOptionsPageChooser(String, String, java.util.List, com.biomatters.geneious.publicapi.plugin.Options.PageChooserType, boolean)
has not been called.
-
addChildOptions
public final Options addChildOptions(java.lang.String name, java.lang.String label, java.lang.String description)
Creates, adds and returns some child options. This is a convenience method that is equivalent to calling:
addChildOption(name, label, description, new Options(getClass()), true)
- Parameters:
name
- specifies a prefix use for referencing individual options within childOptionslabel
- a label for the child options. If this label is not an empty string, a divider is created (when not usingaddChildOptionsPageChooser(String, String, java.util.List, com.biomatters.geneious.publicapi.plugin.Options.PageChooserType, boolean)
).description
- used mostly for tool tips- Returns:
- the newly created child options
- See Also:
addChildOptionsPageChooser(String, String, java.util.List, com.biomatters.geneious.publicapi.plugin.Options.PageChooserType, boolean)
,Options.Option.addChildOptionsDependent(Options, Object, boolean)
-
addChildOptions
public final void addChildOptions(java.lang.String name, java.lang.String label, java.lang.String description, Options childOptions)
CallsaddChildOptions(name,label,description,childOptions,false)
. WhensavePreferences()
is called on the parent options, the child options will have its preferences saved in its usual location (independent of the parent's preferences). UseaddChildOptions(String, String, String, Options, boolean)
if the child options should store its preferences with the parent.- Parameters:
name
- seeaddChildOptions(String, String, String, Options, boolean)
label
- seeaddChildOptions(String, String, String, Options, boolean)
description
- seeaddChildOptions(String, String, String, Options, boolean)
childOptions
- seeaddChildOptions(String, String, String, Options, boolean)
- See Also:
addChildOptionsPageChooser(String, String, java.util.List, com.biomatters.geneious.publicapi.plugin.Options.PageChooserType, boolean)
,Options.Option.addChildOptionsDependent(Options, Object, boolean)
-
addChildOptions
public final void addChildOptions(java.lang.String name, java.lang.String label, java.lang.String description, Options childOptions, boolean useParentPreferences)
Adds a set of existing Options as child options of this Options. When displayed graphically, all child options will be available to the user. IfaddChildOptionsPageChooser(String, String, java.util.List, com.biomatters.geneious.publicapi.plugin.Options.PageChooserType, boolean)
addChildOptionsPageChooser} is called after all child options have been added, then each set of child options is made graphically available in a separate tab. Individual options within childOptions can be referenced programmatically by prepending the name as a prefix followed by "." For example, if childOptions contains an option called "test", and name is "child", then setStringValue("child.test","abc") will set the value of that option.- Parameters:
name
- specifies a prefix use for referencing individual options within childOptionslabel
- a label for the child options. If this label is not an empty string, a divider is created (when not usingaddChildOptionsPageChooser(String, String, java.util.List, com.biomatters.geneious.publicapi.plugin.Options.PageChooserType, boolean)
).description
- used mostly for tool tipschildOptions
- the child optionsuseParentPreferences
- If true, Store the preferences for this child when callingsavePreferences()
on this parent Options in a sub-node of the parent's preferences. If false, store the preferences for this child in its default preference node (independent of the parent preferences). NOTE: WhensavePreferences()
is called on the child options directly, its default location is always used.- See Also:
addChildOptionsPageChooser(String, String, java.util.List, com.biomatters.geneious.publicapi.plugin.Options.PageChooserType, boolean)
,Options.Option.addChildOptionsDependent(Options, Object, boolean)
-
addChildOptions
public final void addChildOptions(java.lang.String name, java.lang.String label, java.lang.String description, Options childOptions, double weightY, boolean useParentPreferences)
Adds a set of existing Options as child options of this Options with the specified vertical weight. When displayed graphically, all child options will be available to the user. IfaddChildOptionsPageChooser(String, String, java.util.List, com.biomatters.geneious.publicapi.plugin.Options.PageChooserType, boolean)
addChildOptionsPageChooser} is called after all child options have been added, then each set of child options is made graphically available in a separate tab. Individual options within childOptions can be referenced programmatically by prepending the name as a prefix followed by "." For example, if childOptions contains an option called "test", and name is "child", then setStringValue("child.test","abc") will set the value of that option.- Parameters:
name
- specifies a prefix use for referencing individual options within childOptionslabel
- a label for the child options. If this label is not an empty string, a divider is created (when not usingaddChildOptionsPageChooser(String, String, java.util.List, com.biomatters.geneious.publicapi.plugin.Options.PageChooserType, boolean)
).description
- used mostly for tool tipschildOptions
- the child optionsweightY
- the vertical weight of this options panel (i.e. weightY)useParentPreferences
- If true, Store the preferences for this child when callingsavePreferences()
on this parent Options in a sub-node of the parent's preferences. If false, store the preferences for this child in its default preference node (independent of the parent preferences). NOTE: WhensavePreferences()
is called on the child options directly, its default location is always used.- Since:
- API 4.1021 (Geneious 10.2.1)
- See Also:
GridBagConstraints.weighty
,addChildOptionsPageChooser(String, String, java.util.List, com.biomatters.geneious.publicapi.plugin.Options.PageChooserType, boolean)
,Options.Option.addChildOptionsDependent(Options, Object, boolean)
-
addCollapsibleChildOptions
public final void addCollapsibleChildOptions(java.lang.String name, java.lang.String label, java.lang.String description, Options childOptions, boolean useParentPreferences, boolean defaultCollapsed)
Add child options that can be expanded and collapsed. If a child options page chooser is added, these child options will not be one of the choices within the chooser, it will be kept outside the chooser. Only the basic panel for the child options will be within a collapsible panel, any advanced options will not be. Currently the collapsed state of the child options is remembered in preferences but this may be changed in the future.- Parameters:
name
- specifies a prefix use for referencing individual options within childOptionslabel
- a label for the child options which is shown on the expander button. must not be null or emptydescription
- short description of the options used as the tooltip for the expander buttonchildOptions
- the child optionsuseParentPreferences
- If true, Store the preferences for this child when callingsavePreferences()
on this parent Options in a sub-node of the parent's preferences. If false, store the preferences for this child in its default preference node (independent of the parent preferences). NOTE: WhensavePreferences()
is called on the child options directly, its default location is always used.defaultCollapsed
- whether or not the child options should be collapsed or not by default.- Since:
- API 4.11 (Geneious 5.0)
- See Also:
addChildOptionsPageChooser(String, String, java.util.List, com.biomatters.geneious.publicapi.plugin.Options.PageChooserType, boolean)
,Options.Option.addChildOptionsDependent(Options, Object, boolean)
-
setChildOptionsCollapsed
public final void setChildOptionsCollapsed(java.lang.String name, boolean collapsed)
Set the collapsed state of child options added previously usingaddCollapsibleChildOptions(String, String, String, Options, boolean, boolean)
.- Parameters:
name
- name of the child options (passed in toaddCollapsibleChildOptions(String, String, String, Options, boolean, boolean)
collapsed
- true to collapse the child options, false to expand them.- Since:
- API 4.11 (Geneious 5.0)
-
addMultipleOptions
public final Options.MultipleOptions addMultipleOptions(java.lang.String name, Options multipleOptions, boolean isAdvanced)
Adds a set of Options so that the user is able to choose to have one or more instances of these child options through the use of +/- buttons to the right of the options. For example, this can be used to create the interface available when doing an advanced Geneious database search. In order to create a nice looking interface, you should consider usingbeginAlignHorizontally(String, boolean)
andendAlignHorizontally()
when constructing themultipleOptions
parameter. Multiple options can have their values set and retrieved programatically viasetStringValue(String, String)
andgetValueAsString(String)
by using an option name of the form "multipleName.[0|1|2|...].childName". When usingsetStringValue(String,String)
, the numeric index may be equal to current number of values (found usingOptions.MultipleOptions.getValues()
.size()) to add a new set of values to these multiple options. Example:
Implementation note: This feature is implemented by XMLSerializing the// First create some multiOptions consisting of a string and an integer displayed horizontally adjacent: Options multiOptions = new Options(OptionsTest.class); multiOptions.beginAlignHorizontally(null, false); multiOptions.addStringOption("stringOption", "String", "defaultValue"); multiOptions.addIntegerOption("integerOption", "Integer", 5); multiOptions.endAlignHorizontally(); final Options options = new Options(OptionsTest.class); options.addMultipleOptions("multi",multiOptions, false); options.setStringValue("multi.0.stringOption","test"); options.setStringValue("multi.0.integerOption","6"); // Now add a second set of values: options.setStringValue("multi.1.stringOption", "test2"); // this implicity adds "multi.1.integerOption" with value the default value (5) options.getValueAsString("multi.1.integerOption"); // returns "5";
multipleOptions
parameter and deserializing it again to create the multiple instances. While Options is XMLSerializable, it is not guarenteed that sub-classes fulfil the XMLSerializable contract. Trying to add multiple options for this case will cause a IllegalArgumentException to be thrown.- Parameters:
name
- a programatic name for referring to the multiple options.multipleOptions
- the multiple options to add.isAdvanced
- true if these multiple options should appear in the advanced panel instead of the standard panel.- Returns:
- the newly added multiple options.
- Throws:
java.lang.IllegalArgumentException
- if multipleOptions does not fulfil the XMLSerializable contract, or if any option in multiOptions is advanced.- See Also:
getMultipleOptions(String)
,Options.MultipleOptions.getValues()
-
getMultipleOptions
public final Options.MultipleOptions getMultipleOptions(java.lang.String name)
Get a set of multiple options added usingaddMultipleOptions(String, Options, boolean)
.- Parameters:
name
- the name of some multiple options specified as the first parameter toaddMultipleOptions(String, Options, boolean)
- Returns:
- the multiple options added using #addMultipleOptions(String, Options, boolean) or null if there are no multiple options with this name.
-
getMultipleOptions
public final java.util.List<Options.MultipleOptions> getMultipleOptions()
Get all multiple options added usingaddMultipleOptions(String, Options, boolean)
.- Returns:
- all multiple options.
- Since:
- API 4.51 (Geneious 5.5.1)
-
getMultipleOptionsMap
public final java.util.Map<java.lang.String,Options.MultipleOptions> getMultipleOptionsMap()
Get all the multiple options added usingaddMultipleOptions(String, Options, boolean)
.- Returns:
- a map of all multiple option names keyed to their multiple options
- Since:
- API 4.1101 (Geneious 11.0.1)
-
addDivider
public final Options.Option addDivider(java.lang.String label)
Add a new divider that is displayed between options when the options are graphically presented to the user.- Parameters:
label
- An optional label to display to the left of the divider. Must not be null but may be an empty string.- Returns:
- the newly added divider option
-
addLabel
public final Options.Option<java.lang.String,? extends javax.swing.JComponent> addLabel(java.lang.String label)
Add a new label that is displayed between options when the options are graphically presented to the user. This is a convenience method for callingaddLabel(String, false, false)
.- Parameters:
label
- The label to display to the user- Returns:
- the newly added label option
-
addLabel
public final Options.Option<java.lang.String,? extends javax.swing.JComponent> addLabel(java.lang.String label, boolean centreText, boolean spanEntirePanelWidth)
Add a new label that is displayed between options when the options are graphically presented to the user. The option's value is the text displayed by the label, and can be changed and queried viaOptions.Option.setValue(Object)
andOptions.Option.getValue()
, respectively.- Parameters:
label
- The label to display to the usercentreText
- centre the textspanEntirePanelWidth
- make this label span the entire width of the panel rather than using only the space to the right of standard component labels.- Returns:
- the newly added label option. This is guaranteed to be a
Options.LabelOption
, but this method is not declared to return that for backwards compatibility reasons.
-
addLabelWithIcon
public Options.LabelOption addLabelWithIcon(java.lang.String label, Icons icons)
Adds a label with an icon to the left of it.- Parameters:
label
- the labelicons
- the icon. Using an icon fromStandardIcons
is recommended.- Returns:
- the label option added.
-
savePreferences
public final void savePreferences(java.lang.String preferenceNodeSuffix)
Save the current option values persistently, i.e. across instantiations of the Java Virtual Machine. Next time these options are instantiated, they can be reset to these values instead of their defaults by usingrestorePreferences()
. Typically, this should only be called immediately after a dialog containing the options panel has its OK button clicked.- Parameters:
preferenceNodeSuffix
- An optional name under which the preferences should be stored. Varying this value allows storage of independent sets of preference values. Use null to store in the default location. Note that this suffix is used in addition to any suffix passed to the constructor, e.g. toOptions(Class, String)
.
-
savePreferences
public final void savePreferences()
Save the current option values persistently in the default storage location by callingsavePreferences(null)
-
restorePreferences
public final void restorePreferences()
Restore the current option values from the default persistent storage location by callingrestorePreferences(null, false)
. This method should always be called from the Swing thread for Options which have previously had their GUI created via callinggetPanel()
. For Options which have not yet had Swing components created, it is OK to call this outside of the Swing thread. Note: If there is no value for an option in preferences then it value isn't changed by this method.
-
restorePreferences
public final void restorePreferences(java.lang.String preferenceNodeSuffix, boolean restorePreferencesOfOptionsThatHaveHadTheirValuesAlreadySet)
Restores the current option values from persistent storage, i.e. across instantiations of the Java Virtual Machine. Typically, after clicking OK after showing a dialog containing the options,savePreferences()
is called. Immediately prior to showing a dialog in future, restorePreferences() should be called. Note: If there is no value for an option in preferences then it value isn't changed by this method.- Parameters:
preferenceNodeSuffix
- An optional name under which the preferences should be restored from. Varying this value allows storage of independent sets of preference values. Use null to restore from the default location. Note that this suffix is used in addition to any suffix passed to the constructor, e.g. toOptions(Class, String)
.restorePreferencesOfOptionsThatHaveHadTheirValuesAlreadySet
- In some cases it is not desirable to restore the preferences of Options that have had their value manually set. For example, an operation may want to set the value of an Option to match some property of of the selected documents. In this case when restorePreferences is later called, with this parameter false, the Options with values already set won't be restored to their saved values.
-
restoreDefaults
public final void restoreDefaults()
Restores all current option values and child options to their default values. If these Options have child options in a page chooser, and we are currently displaying these options graphically, then only those options on the currently visible page will have their defaults restored. This method does not affect the current values stored in preferences. If you wish to restore these to their defaults, immediately callsavePreferences()
after this method.- See Also:
canRestoreDefaults()
-
initializeListenersToFireAfterChangingAllValues
public void initializeListenersToFireAfterChangingAllValues()
Causes this options to delay firing of all listeners added viaaddChangeListener(SimpleListener)
(or to anyOptions
' listeners added viaOptions.Option.addChangeListener(SimpleListener)
or to anyOptions.ChildOptions
) until such time asfireListenersToFireAfterChangingAllValues()
) is called. This can be useful when sequentially setting the values of an Option viasetValue(String, Object)
, when listeners would otherwise be firing on the Options in an incomplete state and which might lead to wrong behaviour.- Since:
- API 4.1103 (Geneious 11.0.3)
- See Also:
fireListenersToFireAfterChangingAllValues()
,addChangeListener(SimpleListener)
,Options.Option.addChangeListener(SimpleListener)
-
fireListenersToFireAfterChangingAllValues
public void fireListenersToFireAfterChangingAllValues()
Called in conjunction withinitializeListenersToFireAfterChangingAllValues()
to delay firing of listeners added to this Options and its child Option objects until such time as this method is called.- Since:
- API 4.1103 (Geneious 11.0.3)
- See Also:
initializeListenersToFireAfterChangingAllValues()
-
addDefaultsRestoredListener
public void addDefaultsRestoredListener(org.virion.jam.util.SimpleListener listener)
add a listener to be notified when the options are restored to their defaults (e.g. when the restore defaults button is pressed in option dialogs).- Parameters:
listener
- the listener to be notified- Since:
- API 4.50 (Geneious 5.5.0)
- See Also:
restoreDefaults()
-
removeDefaultsRestoredListener
public void removeDefaultsRestoredListener(org.virion.jam.util.SimpleListener listener)
Remove a listener to be notified when the options are restored to their defaults (e.g. when the restore defaults button is pressed in option dialogs).- Parameters:
listener
- the listener added usingaddDefaultsRestoredListener(org.virion.jam.util.SimpleListener)
.- Since:
- API 4.50 (Geneious 5.5.0)
-
canRestoreDefaults
public final boolean canRestoreDefaults()
Return true if callingrestoreDefaults()
would change anything.- Returns:
- true if calling
restoreDefaults()
would change anything.
-
isHideRestoreDefaultsButton
public boolean isHideRestoreDefaultsButton()
- Returns:
- true if the "Restore Defaults" button or menu option should be hidden for dialogs shown on these options using methods such as
Dialogs.showOptionsDialog(Options, String, boolean)
- Since:
- API 4.202121 (Geneious 2021.2.1)
-
setHideRestoreDefaultsButton
public void setHideRestoreDefaultsButton(boolean hideRestoreDefaultsButton)
Sets whether to hide the "Restore Defaults" button in options dialogs. The default behaviour is to show the "Restore Defaults" button.- Parameters:
hideRestoreDefaultsButton
- true if the "Restore Defaults" button or menu option should be hidden for dialogs shown on these options using methods such asDialogs.showOptionsDialog(Options, String, boolean)
- Since:
- API 4.202120 (Geneious 2021.2.0)
-
valuesToXML
public final org.jdom.Element valuesToXML(java.lang.String rootElementName)
Serializes the current values for these options to XML for use with a later call tovaluesFromXML(org.jdom.Element)
. This does not serialize the options (names, descriptions etc) themselves. UsetoXML()
to do this- Parameters:
rootElementName
- the name of the root element for the returned XML- Returns:
- an XML representation of the option values.
- See Also:
valuesFromXML(org.jdom.Element)
-
getVersionSupportForValuesToXML
public final Geneious.MajorVersion getVersionSupportForValuesToXML(XMLSerializable.VersionSupportType versionType)
Gets the version support as defined byXMLSerializable.OldVersionCompatible.getVersionSupport(com.biomatters.geneious.publicapi.documents.XMLSerializable.VersionSupportType)
for use withvaluesToXML(com.biomatters.geneious.publicapi.plugin.Geneious.MajorVersion, String)
- Parameters:
versionType
- the version support type- Returns:
- the version support
- Since:
- API 4.600 (Geneious 6.0.0)
-
valuesToXML
public final org.jdom.Element valuesToXML(Geneious.MajorVersion version, java.lang.String rootElementName)
Serializes the current values for these options to XML for use with a later call tovaluesFromXML(org.jdom.Element)
. This does not serialize the options (names, descriptions etc) themselves. UsetoXML()
to do this- Parameters:
version
- the version of Geneious to make the XML compatible withrootElementName
- the name of the root element for the returned XML- Returns:
- an XML representation of the option values.
- Since:
- API 4.600 (Geneious 6.0.0)
- See Also:
valuesFromXML(org.jdom.Element)
-
valuesToXML
public final org.jdom.Element valuesToXML(Geneious.MajorVersion version, java.lang.String rootElementName, boolean excludeOptionsWhereRestorePreferenceApplies)
Serializes the current values for these options to XML for use with a later call tovaluesFromXML(org.jdom.Element)
. This does not serialize the options (names, descriptions etc) themselves. UsetoXML()
to do this- Parameters:
version
- the version of Geneious to make the XML compatible withrootElementName
- the name of the root element for the returned XMLexcludeOptionsWhereRestorePreferenceApplies
- true to exclude option values from the returned XML for whichis true
. This is useful when we want to save the values of only those options that would not be saved duringrestorePreferences()
- Returns:
- an XML representation of the option values. If excludeOptionsWhereRestorePreferenceApplies==true and no applicable options were found, then null may be returned
- Since:
- API 4.810 (Geneious 8.1.0)
- See Also:
valuesFromXML(org.jdom.Element)
-
valuesFromXML
public final void valuesFromXML(org.jdom.Element root)
Deserializes the current values for these options from XML. CallsvaluesFromXML(root, true)
This does not deserialize the options (names, descriptions etc) themselves. UsefromXML(org.jdom.Element)
to do this. This method should always be called from the Swing thread for Options which have previously had their GUI created via callinggetPanel()
. For Options which have not yet had Swing components created, it is OK to call this outside of the Swing thread.- Parameters:
root
- some XML returned from a previous call tovaluesToXML(String)
. Must not be null- See Also:
valuesToXML(String)
,valuesFromXML(Element, boolean)
-
valuesFromXML
public final void valuesFromXML(org.jdom.Element root, boolean includeOptionsWhichDontRestorePreferences)
Deserializes the current values for these options from XML. This does not deserialize the options (names, descriptions etc) themselves. UsefromXML(org.jdom.Element)
to do this. This method should always be called from the Swing thread for Options which have previously had their GUI created via callinggetPanel()
. For Options which have not yet had Swing components created, it is OK to call this outside of the Swing thread.- Parameters:
root
- some XML returned from a previous call tovaluesToXML(String)
. Must not be nullincludeOptionsWhichDontRestorePreferences
- true to include options for whichOptions.Option.setRestorePreferenceApplies(boolean)
is false.- Since:
- API 4.702 (Geneious 7.0.2)
- See Also:
valuesToXML(String)
-
valuesFromXMLReturningErrors
public final java.util.List<java.lang.String> valuesFromXMLReturningErrors(org.jdom.Element root, boolean includeOptionsWhichDontRestorePreferences)
Deserializes the current values for these options from XML. This does not deserialize the options (names, descriptions etc) themselves. UsefromXML(org.jdom.Element)
to do this.- Parameters:
root
- some XML returned from a previous call tovaluesToXML(String)
. Must not be nullincludeOptionsWhichDontRestorePreferences
- true to include options for whichOptions.Option.setRestorePreferenceApplies(boolean)
is false.- Returns:
- a list of errors if some of the options or values can't be deserialized.
- Since:
- API 4.910 (Geneious 9.1.0)
- See Also:
valuesToXML(String)
-
addChangeListener
public final void addChangeListener(org.virion.jam.util.SimpleListener listener)
add a listener to be notified when the value of any option changes The listener is also notified if some options requires an active license, and the licence type changes.- Parameters:
listener
- the listener to be notified
-
removeChangeListener
public final void removeChangeListener(org.virion.jam.util.SimpleListener listener)
Remove a listener to be notified when the value of any option changes- Parameters:
listener
- the listener added usingaddChangeListener(org.virion.jam.util.SimpleListener)
.
-
verifyOptionsAreValid
public java.lang.String verifyOptionsAreValid()
Override this to have the current contents of options checked (for example String options that allow the user to enter arbitrary text) to make sure they are valid before proceeding. When used in a graphical environment, if this function returns a non-null value, then the options dialog will remain open for the user to correct the invalid input. The default implementation of this method returns the first non-null result of calling this method on the first visible child options or null if these Options have no child options. To preserve this behavior, it is strongly recommended that any class that overrides this method begin its implementation with code similar to the following:String superMessage = super.verifyOptionsAreValid(); if (superMessage != null) { return superMessage; }
areValuesGoodEnoughToContinue()
and verifyOptionsAreValid are two methods that essentially provide the same functionality, although depending on your use case, one may be simpler to implement than the other. For example verifyOptionsAreValid handles displaying a dialog for you. It is recommended that an Options implementation only implement one of these two methods.- Returns:
- null if the current option values are valid or a String message describing how the options are invalid.
- See Also:
areValuesGoodEnoughToContinue()
-
areValuesGoodEnoughToContinue
public boolean areValuesGoodEnoughToContinue()
This is called by Geneious when the user clicks OK in the options dialog. The options may wish to confirm with the user (by displaying a dialog) if they really want to continue using the selected options. For example, the Geneious assembler checks if the user probably has enough free memory to perform the assembly with these options and warns them if not. The default implementation of this method returns the false if any of the visible child options returns false, or returns true otherwise. To preserve this behavior, it is strongly recommended that any class that overrides this method begin its implementation with the following:if (!super.areValuesGoodEnoughToContinue()) { return false; }
areValuesGoodEnoughToContinue andverifyOptionsAreValid()
are two methods that essentially provide the same functionality, although depending on your use case, one may be simpler to use than the other. For example verifyOptionsAreValid handles displaying a dialog for you. It is recommended that an Options implementation only implement one of these two methods.- Returns:
- false to cancel pressing the OK button (it goes back to showing the options again)
- Since:
- API 4.14 (Geneious 5.1)
- See Also:
verifyOptionsAreValid()
-
getPanel
public final javax.swing.JPanel getPanel()
Get a graphical panel used to display these options. Multiple calls to this method return the same panel which is created once viacreatePanel()
and cached.
This method must be called from the swing thread.- Returns:
- a graphical panel used to display these options or null if there are no options
-
hasAdvancedOptions
public final boolean hasAdvancedOptions()
Return true if any option or any child options returns true fromOptions.Option.isAdvanced()
- Returns:
- true if any option or any child options returns true from
Options.Option.isAdvanced()
-
hasBasicOptions
public final boolean hasBasicOptions()
Return true if any option or any child options returns false fromOptions.Option.isAdvanced()
- Returns:
- true if any option or any child options returns false from
Options.Option.isAdvanced()
-
createPanel
protected javax.swing.JPanel createPanel()
Creates a graphical panel used to display these options. This includes all options added using any of the add*Option methods. (addBooleanOption
,addStringOption
,addOption
etc). andaddChildOptions
. Override this method to customise the layout of the options. This method is called the first timegetPanel()
is called and the return value cached. The default implementation displays a vertical list of all non-advanced options, one per line. If you do choose to customise the layout, the custom components must automatically listen to changes to themselves and immediately reflect those in the values of the options. The components must also listen to changes in the value of their responding Option and reflect that in the value of the component. The recommended way to do this automatically is to useOptions.Option.getComponent()
which automatically does all of this. So just add that component to an appropriate location within a panel. For example, here is a code fragment of some options which customise their layoutprivate static class CustomOptions extends Options { final StringOption test; final BooleanOption test2; public CustomOptions() { super(CustomOptions.class); test=addStringOption ("test", "test", "value"); test2=addBooleanOption ("test2", "test2", true); } protected JPanel createPanel() { JPanel panel =new JPanel(); // Add both the label and the component: panel.add(new JLabel(test.getLabel())); panel.add(test.getComponent()); // For a boolean (checkbox) option, it doesn't have a separate label so just add the component: panel.add(test2.getComponent()); return panel; } }
- Returns:
- a graphical panel used to display these options or null if there are no options
- Throws:
java.lang.IllegalStateException
- If there is a row created withbeginAlignHorizontally(String, boolean)
,endAlignHorizontally()
in which some options are advanced and some are nonadvanced.
-
setLeftAlignLabels
public void setLeftAlignLabels(boolean leftAlignLabels)
Ensures the labels of all options are left aligned rather than the default behaviour of aligning labels so that their right hand sides are vertically aligned with each other. This method is only applicable for options within their own row (i.e. not inside abeginAlignHorizontally()
block)- Parameters:
leftAlignLabels
- true to left align labels of options- Throws:
java.lang.IllegalStateException
- ifgetPanel()
orgetAdvancedPanel()
has already been called on these options.- Since:
- API 4.202011 (Geneious 2020.1.1)
-
setPlaceOptionsOnLeft
public void setPlaceOptionsOnLeft(boolean placeOptionsOnLeft)
Attempts to place all options on the left instead of the normal centred layout. Options within child options will not be affected, they should call this method themselves if they want to be placed on the left. This method will also setsetHorizontallyCompact(boolean)
to the same value passed into this method.- Parameters:
placeOptionsOnLeft
- true to place options on the left of the dialog instead of in the centre- Throws:
java.lang.IllegalStateException
- ifgetPanel()
orgetAdvancedPanel()
has already been called on these options.- Since:
- API 4.202220 (Geneious 2022.2.0)
-
getAdvancedPanel
public final javax.swing.JPanel getAdvancedPanel()
Get a graphical panel used to display advanced options. Multiple calls to this method return the same panel which is created once viacreateAdvancedPanel()
and cached.- Returns:
- a graphical panel used to display the advanced options or null if there are no advanced options.
-
createAdvancedPanel
protected javax.swing.JPanel createAdvancedPanel()
Creates a graphical panel used to display advanced options. Override this method to customise the layout of the advanced options. This method is called the first timegetAdvancedPanel()
is called and the return value cached. The default implementation displays a vertical list of all advanced options, one per line.- Returns:
- a graphical panel used to display the advanced options or null if there are no advanced options.
- Throws:
java.lang.IllegalStateException
- If there is a row created withbeginAlignHorizontally(String, boolean)
,endAlignHorizontally()
in which some options are advanced and some are nonadvanced.
-
getValue
public final java.lang.Object getValue(java.lang.String optionName)
get the value of the option with the nameoptionName
. As of 2007-04-16, it is not specified whether this will return the exact same object that was last set on this option, or a copy of that value (the value set on the object may have been passed tosetValue(String, Object)
,Options.Option.setDisabledValue(Object)
or to the Option's constructor as the default value.- Parameters:
optionName
- the name of the option to get the value for- Returns:
- the value or null if there is no option with this name.
-
setValue
public final boolean setValue(java.lang.String optionName, java.lang.Object value)
set the value of an option- Parameters:
optionName
- the name of the option to set the value forvalue
- the value to set. Note - since Options are implemented using Java generics, there is no way to ensure that value is the correct class type at run time. Therefore, the value given here it is converted to a string and then converted back to an object of the expected type, or the default option value if it is invalid. Essentially, this is what this method implementation looks like:
Note: This method is not thread safe. See documentation towards the end ofreturn setStringValue(optionName, value.toString());
Options
. Warning: It is almost always preferable to useOptions.Option.setValue(Object)
because it is typesafe. The Option object on which to set the value can either be obtained viagetOption(String)
, or may be exposed by the Options subclass via a getter method (e.g.getMaxIterationsOption()
or similar). A subclass may also choose to provide direct getter and setter methods for particular option values, e.g.int getMaxIterations()
andsetMaxIterations(int)
in the example case of an option holding the maximum number of iterations for something.- Returns:
- false if there is not an option with this name or the option can't be set to this value (e.g. it being a combo box with a limited supported values, or the option may be disabled)
-
setValueOrFail
public final void setValueOrFail(java.lang.String optionName, java.lang.Object value) throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
LikesetValue(String, Object)
but throws a DocumentOperationException if an option value can't be set rather than returning false.
UsesetValueOrFail(java.lang.String, java.lang.Object)
if Geneious should fail gracefully if the option can't be set. For example a workflow may have been written so set operation values, but if that operation has been changed in later versions we should fail gracefully.
UsesetValueOrCrash(java.lang.String, java.lang.Object)
instead if it's a bug and Geneious should crash with an error report if the option can't be set. For example a Biomatters developer is calling one bundled plugin from another bundled plugin.- Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- if either an option with this name does not exist or if the value is invalid for that option.- Since:
- API 4.201900 (Geneious 2019.0.0)
-
setValueOrCrash
public final void setValueOrCrash(java.lang.String optionName, java.lang.Object value)
LikesetValue(String, Object)
but throws an IllegalArgumentException if an option value can't be set rather than returning false UsesetValueOrCrash(java.lang.String, java.lang.Object)
if it's a bug and Geneious should crash with an error report if the option can't be set. For example a Biomatters developer is calling one bundled plugin from another bundled plugin.
UsesetValueOrFail(java.lang.String, java.lang.Object)
instead if Geneious should fail gracefully if the option can't be set. For example a workflow may have been written so set operation values, but if that operation has been changed in later versions we should fail gracefully.- Throws:
java.lang.IllegalArgumentException
- if either an option with this name does not exist or if the value is invalid for that option.- Since:
- API 4.201900 (Geneious 2019.0.0)
-
setStringValue
public final boolean setStringValue(java.lang.String optionName, java.lang.String value)
set the value of an option- Parameters:
optionName
- the name of the option to set the value forvalue
- a string representation of the value to set. The string will be converted to an object of the expected type, or the default option value if it is invalid. Note: This method is not thread safe. See documentation towards the end ofOptions
.- Returns:
- false if there is not an option with this name or the option can't be set to this value (e.g. it being a combo box with a limited supported values). This will return true on a disabled option that has a
Options.Option.setDisabledValue(Object)
as long as the value set is what the option would return fromOptions.Option.getValueWhenEnabled()
-
setStringValueOrFail
public final void setStringValueOrFail(java.lang.String optionName, java.lang.String value) throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
LikesetStringValue(String, String)
but throws a DocumentOperationException if an option value can't be set rather than returning false.
UsesetStringValueOrFail(java.lang.String, java.lang.String)
if Geneious should fail gracefully if the option can't be set. For example a workflow may have been written so set operation values, but if that operation has been changed in later versions we should fail gracefully.
UsesetStringValueOrCrash(java.lang.String, java.lang.String)
instead if it's a bug and Geneious should crash with an error report if the option can't be set. For example a Biomatters developer is calling one bundled plugin from another bundled plugin.- Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- if either an option with this name does not exist or if the value is invalid for that option.- Since:
- API 4.201900 (Geneious 2019.0.0)
-
setStringValueOrCrash
public final void setStringValueOrCrash(java.lang.String optionName, java.lang.String value)
LikesetStringValue(String, String)
but throws a DocumentOperationException if an option value can't be set rather than returning false.
UsesetStringValueOrCrash(java.lang.String, java.lang.String)
if it's a bug and Geneious should crash with an error report if the option can't be set. For example a Biomatters developer is calling one bundled plugin from another bundled plugin.
UsesetStringValueOrFail(java.lang.String, java.lang.String)
instead if Geneious should fail gracefully if the option can't be set. For example a workflow may have been written so set operation values, but if that operation has been changed in later versions we should fail gracefully.- Throws:
com.biomatters.geneious.publicapi.plugin.DocumentOperationException
- if either an option with this name does not exist or if the value is invalid for that option.- Since:
- API 4.201900 (Geneious 2019.0.0)
-
getOption
public final Options.Option getOption(java.lang.String optionName)
Get an option or child option.- Parameters:
optionName
- the name of the option or the childOptions name followed by a "." followed by an option name within those child options.- Returns:
- the Option corresponding to this name, or null if it doesn't exist.
-
getValueAsString
public final java.lang.String getValueAsString(java.lang.String optionName)
Get the value of this option as a string. Note: It is usually preferable to useOptions.Option.getValue()
because it is typesafe. If you don't have the Option object available, usegetOption(String)
. A subclass may also choose to expose the Option via a getter method (e.g.getMaxIterationsOption()
or similar) so that it can be typed correctly rather than just as a generic Option. A subclass may also choose to provide direct getter and setter methods for particular option values, e.g.int getMaxIterations()
andsetMaxIterations(int)
in the example case of an option holding the maximum number of iterations for something.- Parameters:
optionName
- the name of the option to get the value for, or empty string if the option does not exist- Returns:
- the value of this option is a string.
-
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
-
setHorizontallyCompact
public void setHorizontallyCompact(boolean horizontallyCompact)
Flags the basic options to be displayed in a visually compact form suitable for displaying in a limited amount of space. When horizontally compact, the options will be left aligned rather than centered. CallsetHorizontallyCompactAdvanced(boolean)
to make the advanced options horizontally compact.- Parameters:
horizontallyCompact
- true to display a compact form of these options.- Throws:
java.lang.IllegalStateException
- ifgetPanel()
has already been called on these options.
-
setHorizontallyCompactAdvanced
public void setHorizontallyCompactAdvanced(boolean horizontallyCompact)
Flags the advanced options to be displayed in a visually compact form suitable for displaying in a limited amount of space. When horizontally compact, the options will be left aligned rather than centered.- Parameters:
horizontallyCompact
- true to display a compact form of these options.- Throws:
java.lang.IllegalStateException
- ifgetPanel()
has already been called on these options.
-
setInScrollPane
public void setInScrollPane(boolean inScrollPane)
Specifies whether the options should be displayed in a scroll pane if the panel is shrunk below it's preferred size. By default this is true.- Parameters:
inScrollPane
- true to have the options added to scroll pane- Throws:
java.lang.IllegalStateException
- ifgetPanel()
has already been called on these options.
-
setVerticallyCompact
public void setVerticallyCompact(boolean verticallyCompact)
Flags the basic options to be displayed in a visually compact form suitable for displaying in a limited amount of space. CallsetVerticallyCompactAdvanced(boolean)
to make the advanced panel vertically compact.- Parameters:
verticallyCompact
- true to display a compact form of these options.- Throws:
java.lang.IllegalStateException
- ifgetPanel()
has already been called on these options.
-
setVerticallyCompactAdvanced
public void setVerticallyCompactAdvanced(boolean verticallyCompact)
Flags the advanced options to be displayed in a visually compact form suitable for displaying in a limited amount of space.- Parameters:
verticallyCompact
- true to display a compact form of these options.- Throws:
java.lang.IllegalStateException
- ifgetPanel()
has already been called on these options.
-
isHorizontallyCompact
public boolean isHorizontallyCompact()
Returns true if these options or any ancestor options have been set as horizontally compact usingsetHorizontallyCompact(boolean)
.- Returns:
- true if these options or any ancestor options have been set as horizontally compact using
setHorizontallyCompact(boolean)
.
-
addHelpButton
public void addHelpButton(java.lang.String dialogTitle, java.lang.String dialogMessage)
Equivalent toaddHelpButtonOption(String, String)
- Since:
- API 4.610 (Geneious 6.1.0)
-
addHelpButtonOption
public Options.Option addHelpButtonOption(java.lang.String dialogTitle, java.lang.String dialogMessage)
Adds a little help button (with a question mark on it) which when clicked shows a dialog containing a message. Alternatively, to add a help button associated with a particular option, useOptions.Option.setHelp(String)
- Parameters:
dialogTitle
- the title of the dialogdialogMessage
- the contents of the dialog, which may be html.- Returns:
- an Option representing the button.
- Since:
- API 4.711 (Geneious 7.1.1)
- See Also:
Options.Option.setHelp(String)
-
getOptionsHelp
public java.lang.String getOptionsHelp()
Override this method and return a non-null value to have it displayed as html in a dialog when the user clicks on a small help button in the corner of any window showing these options.- Returns:
- an html fragment with help pertaining to these options or null for no help
- Since:
- API 4.800 (Geneious 8.0.0)
-
-