Class DocumentSelectionOption
- java.lang.Object
-
- com.biomatters.geneious.publicapi.plugin.Options.Option<DocumentSelectionOption.FolderOrDocuments,javax.swing.JPanel>
-
- com.biomatters.geneious.publicapi.plugin.DocumentSelectionOption
-
- All Implemented Interfaces:
XMLSerializable
public final class DocumentSelectionOption extends Options.Option<DocumentSelectionOption.FolderOrDocuments,javax.swing.JPanel>
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. UsegetDocuments()
to get the list of selected documents because this will get the correct child documents if a folder is selected. A DocumentSelectionOption can be created usingOptions.addDocumentSelectionOption
orOptions.addPrimerOption
- Since:
- API 4.14 (Geneious 5.1)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
DocumentSelectionOption.DoNotRememberInPreferences
An interface that documents used in a DocumentSelectionOption may implement so that the option doesn't cache their instance and reuse it on future instances of these options.static class
DocumentSelectionOption.FolderOrDocuments
The value type for DocumentSelectionOption which represents either a list of selected documents or a single selected folder which contains some documents of the correct type.static class
DocumentSelectionOption.OptionValueCreator
-
Nested classes/interfaces inherited from interface com.biomatters.geneious.publicapi.documents.XMLSerializable
XMLSerializable.OldVersionCompatible, XMLSerializable.VersionSupportType
-
-
Field Summary
-
Fields inherited from interface com.biomatters.geneious.publicapi.documents.XMLSerializable
ROOT_ELEMENT_NAME
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.swing.JPanel
createComponent()
Create a graphical component representing this option.boolean
getAllDocumentsUsedWhenNothingSelected()
Get whether all documents of the given type are used when nothing is selected.java.util.List<AnnotatedPluginDocument>
getDocuments()
Get the list of selected documents.static AnnotatedPluginDocument
getOptionPlaceholder(java.lang.String label, java.lang.String id)
A convenience method to get a placeholder that may be used as option in the document chooser.java.lang.String
getValueAsString(DocumentSelectionOption.FolderOrDocuments value)
Converts this value to a String suitable for returning fromOptions.getValueAsString(String)
.DocumentSelectionOption.FolderOrDocuments
getValueFromString(java.lang.String value)
Convert a String into an instance of the object type used by this option.protected void
handleSetEnabled(javax.swing.JPanel component, boolean enabled)
Set the enabled state of a component.void
setAllDocumentsUsedWhenNothingSelected(boolean allDocumentsUsedWhenNothingSelected)
Set whether all documents of the given type are used when nothing is selected.void
setAllowMultipleSelectionOnSingleChooserStyleInterface(boolean allowMultipleSelectionOnSingleChooserStyleInterface)
If this Option was created with allowMultipleSelections==false viaOptions.addDocumentSelectionOption
this setter can be used to allow the selection of multiple documents in the document chooser.void
setAllowSearchCache(boolean allowSearchCache)
Set whether or not it is feasible for this document selection option to cache all potential documents from all databases in memory.void
setCanChooseNone(boolean canChooseNone)
Sets whether or not "None" or "All Documents in Database" is available as an option for the user to choose.void
setOptionValueCreator(DocumentSelectionOption.OptionValueCreator optionValueCreator)
Used to override the look of the OptionValues displayed in the combo box.void
setPreferenceKeyForChooserDialog(java.lang.String preferenceKeyForChooserDialog)
Sets the preference key used for storing the user's recently used documents and preferred folder in the popup dialog for choosing documents.protected void
setValueOnComponent(javax.swing.JPanel component, DocumentSelectionOption.FolderOrDocuments value)
Set the value on this component.org.jdom.Element
toXML()
Convert object to a JDOM element.-
Methods inherited from class com.biomatters.geneious.publicapi.plugin.Options.Option
addChangeListener, addChildOptionsDependent, addDependent, addDependentIfNot, addLayoutDependent, fromXML, generateValidValue, getComponent, getComponentWithUnitsAndHelpButton, getDefaultValue, getDependents, getDependentsIfNot, getDescription, getDescriptionAndState, getDisplayedLabel, getExtraPersistentInformation, getHelp, getLabel, getName, getNormalizedStringValue, getParentOptions, getPossibleValues, getValue, getValueAsString, getVerticalWeight, hasComponentBeenCreated, hideWarningMessage, isAdvanced, isAlwaysUsesDefaultPreferenceLocation, isEnabled, isFillHorizontalSpace, isProOnly, isRestoreDefaultApplies, isRestorePreferenceApplies, isSpanningComponent, isVisible, moveToOptions, removeChangeListener, restoreDefault, setAdvanced, setAlwaysUsesDefaultPreferenceLocation, setDefaultValue, setDescription, setDisabledValue, setEnabled, setExtraPersistentInformation, setFillHorizontalSpace, setHelp, setHidden, setHidden, setLabelComponent, setPreferredHeight, setPreferredWidth, setProOnly, setRestoreDefaultApplies, setRestorePreferenceApplies, setShouldSaveValue, setSpanningComponent, setValue, setValue, setValueFromString, setVerticalWeight, setVisible, setWarningMessage, shouldSaveValue, toString
-
-
-
-
Method Detail
-
setAllowSearchCache
public void setAllowSearchCache(boolean allowSearchCache)
Set whether or not it is feasible for this document selection option to cache all potential documents from all databases in memory. For example, you could cache all OligoSequenceDocuments, but not all SequenceDocuments. If setAllowSearchCache is not called, then only known rare document types will be cached (e.g. OligoSequenceDocuments and Restriction Enzyme Collection)- Parameters:
allowSearchCache
- whether or not it is feasible for this document selection option to cache all potential documents from all databases in memory.- Since:
- API 4.810 (Geneious 8.1.0)
-
setPreferenceKeyForChooserDialog
public void setPreferenceKeyForChooserDialog(java.lang.String preferenceKeyForChooserDialog)
Sets the preference key used for storing the user's recently used documents and preferred folder in the popup dialog for choosing documents. The default implementation uses the name of this Option.- Parameters:
preferenceKeyForChooserDialog
- a preference key used for storing the user's recently used documents and preferred folder in the popup dialog for choosing documents- Since:
- API 4.810 (Geneious 8.1.0)
-
setAllDocumentsUsedWhenNothingSelected
public void setAllDocumentsUsedWhenNothingSelected(boolean allDocumentsUsedWhenNothingSelected)
Set whether all documents of the given type are used when nothing is selected. If true, when nothing is selected the main component will say something like "All Oligos in Database" and the chooser dialog will have a button "Use All". Only applies whenallowMultipleSelections
is true Defaults to false- Parameters:
allDocumentsUsedWhenNothingSelected
- true if having no documents selected means that all documents will be used
-
setCanChooseNone
public void setCanChooseNone(boolean canChooseNone)
Sets whether or not "None" or "All Documents in Database" is available as an option for the user to choose. IfallowMultipleSelectionOnSingleChooserStyleInterface
andallDocumentsUsedWhenNothingSelected
are both true, this will show "All Documents in Database", otherwise it will show "None". Even if this is set to false, this will show "None" / "All Documents in Database" if there are no recent documents and no document is passed in as a default value.- Parameters:
canChooseNone
- true if the user can choose "None" or "All Documents in Database" as an option- Since:
- API 4.810 (Geneious 8.1.0)
-
setAllowMultipleSelectionOnSingleChooserStyleInterface
public void setAllowMultipleSelectionOnSingleChooserStyleInterface(boolean allowMultipleSelectionOnSingleChooserStyleInterface)
If this Option was created with allowMultipleSelections==false viaOptions.addDocumentSelectionOption
this setter can be used to allow the selection of multiple documents in the document chooser. The design of the single document chooser user interface component in the Options dialog will still appear like a single document user interface If multiple documents have been selected an entry'X documents - [folder]'
will be shown.- Parameters:
allowMultipleSelectionOnSingleChooserStyleInterface
- set to true if multiple selections in the chooser are allowed- Since:
- API 4.900 (Geneious 9.0.0)
-
setOptionValueCreator
public void setOptionValueCreator(DocumentSelectionOption.OptionValueCreator optionValueCreator)
Used to override the look of the OptionValues displayed in the combo box. The default implementation displays the name of the document.- Parameters:
optionValueCreator
- the optionValueCreator- Since:
- API 4.810 (Geneious 8.1.0)
-
getAllDocumentsUsedWhenNothingSelected
public boolean getAllDocumentsUsedWhenNothingSelected()
Get whether all documents of the given type are used when nothing is selected. If true, when nothing is selected the main component will say something like "All Oligos in Database" and the chooser dialog will have a button "Use All".
Note that this does not effect the behaviour of the chooser;getDocuments()
will still return empty even if there are documents and this field is set to true. It is up to calling code to interpret what the "empty" means.- Returns:
- true if the options are configured such that an empty selection means "all documents", false if an empty selection would truly mean that there are no documents to use.
- Since:
- API 4.700 (Geneious 7.0.0)
-
handleSetEnabled
protected void handleSetEnabled(javax.swing.JPanel component, boolean enabled)
Description copied from class:Options.Option
Set the enabled state of a component. A sub-class need only override this if it needs to do something more complicated than calling setEnabled on this component- Overrides:
handleSetEnabled
in classOptions.Option<DocumentSelectionOption.FolderOrDocuments,javax.swing.JPanel>
- Parameters:
component
- the component to set the enabled state ofenabled
- true if it should be enabled
-
getValueAsString
public java.lang.String getValueAsString(DocumentSelectionOption.FolderOrDocuments value)
Description copied from class:Options.Option
Converts this value to a String suitable for returning fromOptions.getValueAsString(String)
. The String representation is also used for serialization of option values.The default implementation just calls {@link #Object#toString()}.
This method is the inverse ofOptions.Option.getValueFromString(String)
.- Overrides:
getValueAsString
in classOptions.Option<DocumentSelectionOption.FolderOrDocuments,javax.swing.JPanel>
- Parameters:
value
- the value to convert to a string.- Returns:
- the value as a string.
-
getValueFromString
public DocumentSelectionOption.FolderOrDocuments getValueFromString(java.lang.String value)
Description copied from class:Options.Option
Convert a String into an instance of the object type used by this option. This method should generally create a new object every time it is invoked. Only disregard this advice if you know what you are doing - e.g. it is safe to maintain an object pool and return the same object more than once if your Option's ValueType is immutable. This method is the inverse ofOptions.Option.getValueAsString(Object)
.- Specified by:
getValueFromString
in classOptions.Option<DocumentSelectionOption.FolderOrDocuments,javax.swing.JPanel>
- Parameters:
value
- the string representation of the object value- Returns:
- the object value or the default value if the string representation is not valid.
-
getDocuments
public java.util.List<AnnotatedPluginDocument> getDocuments()
Get the list of selected documents. If a folder is selected then this will return all the documents of the correct type which are currently in the folder or any sub-folder.
This method will return an empty list even ifsetAllDocumentsUsedWhenNothingSelected(boolean)
has been called. It is up to the caller to determine what an "empty" selection means.- Returns:
- the currently selected documents, may be empty even when "all documents" is intended. See also DocumentChooserDialog.showChooserDialog() for typical return values.
-
setValueOnComponent
protected void setValueOnComponent(javax.swing.JPanel component, DocumentSelectionOption.FolderOrDocuments value)
Description copied from class:Options.Option
Set the value on this component.- Specified by:
setValueOnComponent
in classOptions.Option<DocumentSelectionOption.FolderOrDocuments,javax.swing.JPanel>
- Parameters:
component
- a component return fromOptions.Option.createComponent()
value
- the value to set.
-
createComponent
protected javax.swing.JPanel createComponent()
Description copied from class:Options.Option
Create a graphical component representing this option. The implementation is responsible for making sure that the returned component is initialised to the current value ofOptions.Option.getValue()
. The implementation is also responsible for making sure that the returned component listens to any changes made to itself and reflects those changes in the value of this option using theOptions.Option.setValue(Object)
method. This method will only be called once for each instance of an Option. After it has been called, getComponent() will return a cached copy of it.- Specified by:
createComponent
in classOptions.Option<DocumentSelectionOption.FolderOrDocuments,javax.swing.JPanel>
- Returns:
- a graphical component representing this option. May not be null.
-
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
- Overrides:
toXML
in classOptions.Option<DocumentSelectionOption.FolderOrDocuments,javax.swing.JPanel>
- Returns:
- object encoded as a JDOM element
-
getOptionPlaceholder
public static AnnotatedPluginDocument getOptionPlaceholder(java.lang.String label, java.lang.String id)
A convenience method to get a placeholder that may be used as option in the document chooser. The functionality of this option has to be defined by the implementation; e.g. by checking the return value of the document chooser and performing the corresponding functionality if the value equals or contains this placeholder.- Parameters:
label
- The label to show in the optionid
- An identifier used to differentiate this option from other placeholder options. This identifier should be consistent for each invocation of the options. Usually the class name if only one placeholder options is used, might be appended with a number.- Returns:
- an
AnnotatedPluginDocument
representing an option in the placeholder. - Since:
- API 4.201900 (Geneious 2019.0.0)
-
-