Interface FilteredComboBoxModel<T>

    • Field Detail

      • COMBO_BOX_NULL_CAPTION

        static final PropertyValue<String> COMBO_BOX_NULL_CAPTION
        Specifies the caption used by default to represent null in combo box models. Value type: String
        Default value: -
    • Method Detail

      • addSelectionListener

        void addSelectionListener​(EventDataListener<T> listener)
        Parameters:
        listener - a listener notified each time the selection changes
      • removeSelectionListener

        void removeSelectionListener​(EventDataListener<T> listener)
        Parameters:
        listener - a selection listener to remove
      • setContents

        void setContents​(Collection<T> contents)
        Resets the contents of this model using the values found in contents, if contents is null then the model is considered to be cleared.
        Parameters:
        contents - the contents to display in this combo box model
        See Also:
        isCleared()
      • addItem

        void addItem​(T item)
        Adds the given item to this model, respecting the sorting order if specified. If this model already contains the item, calling this method has no effect. Note that if the item does not satisfy the include condition, it will be filtered right away.
        Parameters:
        item - the item to add
        See Also:
        FilteredModel.setIncludeCondition(Predicate)
      • removeItem

        void removeItem​(T item)
        Removes the given item from this model
        Parameters:
        item - the item to remove
      • replaceItem

        void replaceItem​(T item,
                         T replacement)
        Replaces the given item in this combo box model
        Parameters:
        item - the item to replace
        replacement - the replacement item
      • isCleared

        boolean isCleared()
        Returns:
        true if the model data has been cleared and needs to be refreshed
      • isSelectionEmpty

        boolean isSelectionEmpty()
        Returns:
        true if no value is selected or if the value representing null is selected
      • isNullSelected

        boolean isNullSelected()
        Returns true if this model contains null and it is selected.
        Returns:
        true if this model contains null and it is selected, false otherwise
        See Also:
        isIncludeNull()
      • selectedValue

        T selectedValue()
        Returns:
        the selected value, null in case the value representing null is selected
        See Also:
        isNullSelected()
      • setSortComparator

        void setSortComparator​(Comparator<T> sortComparator)
        Sets the Comparator used when sorting the items visible in this model and sorts the model accordingly. This Comparator must take into account the null value if a nullValueString is specified. If a null sortComparator is provided no sorting will be performed.
        Parameters:
        sortComparator - the Comparator, null if the contents of this model should not be sorted
      • getSortComparator

        Comparator<T> getSortComparator()
        Returns:
        the Comparator used when sorting the contents of this model
      • setIncludeNull

        void setIncludeNull​(boolean includeNull)
        Parameters:
        includeNull - if true then a null value is included as the first item
        See Also:
        setNullItem(Object)
      • isIncludeNull

        boolean isIncludeNull()
        Returns:
        true if a null value is included
      • setNullItem

        void setNullItem​(T nullItem)
        Sets the item that should represent the null value in this model. Note that setIncludeNull(boolean) must be called as well to enable the null value.
        Parameters:
        nullItem - the item representing null
        See Also:
        setIncludeNull(boolean)
      • setFilterSelectedItem

        void setFilterSelectedItem​(boolean filterSelectedItem)
        Specifies whether filtering can change the selected item, if true then the selected item is set to null when the currently selected item is filtered from the model, otherwise the selected item can potentially represent a value which is not currently visible in the model. This is true by default.
        Parameters:
        filterSelectedItem - if true then the selected item is changed when it is filtered out,
      • isFilterSelectedItem

        boolean isFilterSelectedItem()
        Specifies whether filtering can change the selected item, if true then the selected item is set to null when the currently selected item is filtered from the model, otherwise the selected item can potentially represent a value which is not currently visible in the model. This is true by default.
        Returns:
        true if the selected item is changed when it is filtered out
      • setSelectedItem

        void setSelectedItem​(Object item)
        Parameters:
        item - the item to select
      • getSize

        int getSize()
        Returns:
        the number of visible items in this model
      • getElementAt

        T getElementAt​(int index)
        Parameters:
        index - the index
        Returns:
        the item at the given index
      • getSelectedItem

        Object getSelectedItem()
        Returns:
        the selected item
      • createSelectorValue

        <V> Value<V> createSelectorValue​(FilteredComboBoxModel.ItemFinder<T,​V> itemFinder)
        Type Parameters:
        V - the value type
        Parameters:
        itemFinder - responsible for finding the item to select
        Returns:
        a value linked to the selected item via the given finder instance
      • clear

        void clear()
        Clears all items from this combo box model