Class Options.ComboBoxOption<ValueType extends Options.OptionValue>

    • Constructor Detail

      • ComboBoxOption

        protected ComboBoxOption​(java.lang.String name,
                                 java.lang.String label,
                                 ValueType[] options,
                                 ValueType defaultValue)
        Construct a new ComboBoxOption. This is a list of options that are provided to the user graphically as a 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. 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
        options - An array containing all possible values (i.e. all the entries to appear in the combo box)
      • ComboBoxOption

        protected ComboBoxOption​(java.lang.String name,
                                 java.lang.String label,
                                 java.util.List<? extends ValueType> possibleValues,
                                 ValueType defaultValue)
        Construct a new ComboBoxOption. This is a list of options that are provided to the user graphically as a 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. 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
        possibleValues - A list containing all possible values (i.e. all the entries to appear in the combo box)
    • Method Detail

      • toXML

        public org.jdom.Element toXML()
        Description copied from interface: XMLSerializable
        Convert object to a JDOM element. The representation should be complete so that XMLSerializable.fromXML(org.jdom.Element) can completely restore the object's representation.

        It is recommended that the returned element use XMLSerializable.ROOT_ELEMENT_NAME as its name, in which case it must not define an attribute called "type". In this case, fromXML, will be called with an element whose name may differ from the element return from this function. This recommendation allows a more compact representation of the XML can be stored.

        This method generally should not be called directly. Instead, you should usually call XMLSerializer.classToXML(String, XMLSerializable) which calls this method internally.

        PluginDocument implementations of this method may choose to throw an XMLSerializationException, enclosed in a RuntimeException.

        Specified by:
        toXML in interface XMLSerializable
        Overrides:
        toXML in class Options.Option<ValueType extends Options.OptionValue,​javax.swing.JComboBox<com.biomatters.geneious.publicapi.plugin.Options.OptionValueWrapper>>
        Returns:
        object encoded as a JDOM element
      • setPossibleValues

        public void setPossibleValues​(java.util.List<? extends ValueType> possibleValues)
        Set the values the user can select from in the combo box. If the existing value is not in the list of new possible values, the existing value becomes the first new possible value.
        Parameters:
        possibleValues - A list containing all possible values (i.e. all the entries to appear in the combo box)
      • addPossibleValue

        public void addPossibleValue​(ValueType newValue)
        Add a new value for this option. The value will be appended to the end of the ComboBox returned by getComponent() without changing the selection, i.e. the new value will initially not be selected.
        Parameters:
        newValue - New option value to add.
      • getPossibleValues

        public java.lang.String getPossibleValues()
        Description copied from class: Options.Option
        Provide a descriptive string representation of possible values of this option. For example, combo box and radio options should provide a list of all available values. The default implementation returns null. Radio and ComboBox options provide Options.ComboBoxOrRadioOption.getPossibleOptionValues() to get possible values as a List of OptionValues.
        Overrides:
        getPossibleValues in class Options.Option<ValueType extends Options.OptionValue,​javax.swing.JComboBox<com.biomatters.geneious.publicapi.plugin.Options.OptionValueWrapper>>
        Returns:
        a descriptive string representation of possible values of this option or null if this option may have any String value.
        See Also:
        Options.ComboBoxOrRadioOption.getPossibleOptionValues()
      • getValueFromString

        public ValueType getValueFromString​(java.lang.String valueString)
        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<ValueType extends Options.OptionValue,​javax.swing.JComboBox<com.biomatters.geneious.publicapi.plugin.Options.OptionValueWrapper>>
        Parameters:
        valueString - the string representation of the object value
        Returns:
        the object value or the default value if the string representation is not valid.
      • createComponent

        protected javax.swing.JComboBox 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<ValueType extends Options.OptionValue,​javax.swing.JComboBox<com.biomatters.geneious.publicapi.plugin.Options.OptionValueWrapper>>
        Returns:
        a graphical component representing this option. May not be null.
      • setPrototypeDisplayValue

        public void setPrototypeDisplayValue​(ValueType prototypeDisplayValue)
        Sets a prototype display value for both the combo box and its drop down list. This should be used on combo boxes which may contain thousands of items in order to improve performance. On combo boxes with fewer items, it is often desirable for them to be as wide as their widest option, in which case it is preferable to not call this method. For combo boxes where item heights may differ, use setPrototypeDisplayValueWithVariableHeight(OptionValue) instead.
        Parameters:
        prototypeDisplayValue - the prototype value used for calculating a fixed width and height for the combo box.
        Since:
        API 4.202110 (Geneious 2021.1.0)
        See Also:
        setPrototypeDisplayValueWithVariableHeight(OptionValue)
      • setPrototypeDisplayValueWithVariableHeight

        public void setPrototypeDisplayValueWithVariableHeight​(ValueType prototypeDisplayValue)
        Sets a prototype display value for the combo box but not its drop down list. It is better to use setPrototypeDisplayValue(OptionValue) instead if all items in the combo box will have the same height as each other.
        Parameters:
        prototypeDisplayValue - the prototype value used for calculating a fixed width for the combo box.
        Since:
        API 4.202120 (Geneious 2021.2.0)
        See Also:
        setPrototypeDisplayValueWithVariableHeight(OptionValue)
      • generateValidValue

        protected ValueType generateValidValue​(ValueType value)
        Description copied from class: Options.Option
        Converts a potentially invalid value into a valid one. The default implementation always returns candidateValue, implying that all values are valid. Subclasses can override this method e.g. to clamp integer values to a certain interval, or to ensure that a disabled radio item cannot be selected. If a new value is determined to be invalid, a subclass may choose to return the current value (Options.Option.getValue() or any arbitrary other value. IMPORTANT: subclasses which implement this method should call Options.Option.setDefaultValue(Object) at the end of their constructor(s)
        Overrides:
        generateValidValue in class Options.Option<ValueType extends Options.OptionValue,​javax.swing.JComboBox<com.biomatters.geneious.publicapi.plugin.Options.OptionValueWrapper>>
        Parameters:
        value - the value to determine the validity of
        Returns:
        an allowed value.
      • setAcceptsUnknownPossibleValues

        public void setAcceptsUnknownPossibleValues​(boolean acceptsUnknownPossibleValues)
        Sets whether or not this combo box allows Options.Option.setValue(Object) or Options.setStringValue(String, String) to accept values not in the list of Options.ComboBoxOrRadioOption.getPossibleOptionValues(). WARNING: Since setStringValue instantiates a new OptionValue, setAcceptsUnknownPossibleValues must not be used on ComboBox Options that use custom OptionValue sub-classes.
        Parameters:
        acceptsUnknownPossibleValues - true to accept unknown values and automatically add the to the list of getPossibleOptionValues().
        Since:
        API 4.700 (Geneious 7.0.0)