Class DocumentSelectionOption

    • 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 when allowMultipleSelections 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. If allowMultipleSelectionOnSingleChooserStyleInterface and allDocumentsUsedWhenNothingSelected 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 via Options.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 class Options.Option<DocumentSelectionOption.FolderOrDocuments,​javax.swing.JPanel>
        Parameters:
        component - the component to set the enabled state of
        enabled - true if it should be enabled
      • 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 of Options.Option.getValueAsString(Object) .

        Specified by:
        getValueFromString in class Options.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 if setAllDocumentsUsedWhenNothingSelected(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.
      • 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 of Options.Option.getValue(). The implementation is also responsible for making sure that the returned component listens to any changes made to itself and reflects those changes in the value of this option using the Options.Option.setValue(Object) method. This method will only be called once for each instance of an Option. After it has been called, getComponent() will return a cached copy of it.
        Specified by:
        createComponent in class Options.Option<DocumentSelectionOption.FolderOrDocuments,​javax.swing.JPanel>
        Returns:
        a graphical component representing this option. May not be null.
      • 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 option
        id - 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)