Interface FilterComboBoxModel<T>

Type Parameters:
T - the type of values in this combo box model
All Superinterfaces:
ComboBoxModel<T>, is.codion.common.model.FilterModel<T>, ListModel<T>
All Known Implementing Classes:
ItemComboBoxModel

public interface FilterComboBoxModel<T> extends is.codion.common.model.FilterModel<T>, ComboBoxModel<T>
A combo box model based on FilterModel.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Responsible for finding an item of type FilterComboBoxModel.ItemFinder by a single value of type FilterComboBoxModel.ItemFinder.

    Nested classes/interfaces inherited from interface is.codion.common.model.FilterModel

    is.codion.common.model.FilterModel.AbstractRefresher<T extends Object>, is.codion.common.model.FilterModel.Refresher<T extends Object>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final is.codion.common.property.PropertyValue<String>
    Specifies the caption used by default to represent null in combo box models.

    Fields inherited from interface is.codion.common.model.FilterModel

    ASYNC_REFRESH
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(T item)
    Adds the given item to this model, respecting the sorting order if specified.
    void
    Clears all items from this combo box model, including the null item and sets the selected item to null
    boolean
     
    is.codion.common.value.Value<Comparator<T>>
    Controls the Comparator used when sorting the visible items in this model and sorts the model accordingly.
    <V> is.codion.common.value.Value<V>
     
    static <T> FilterComboBoxModel<T>
     
    is.codion.common.state.State
    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.
     
    is.codion.common.state.State
     
    is.codion.common.value.Value<T>
    Controls the item that should represent the null value in this model.
    boolean
    Returns true if this model contains null and it is selected.
    void
    remove(T item)
    Removes the given item from this model
    void
    replace(T item, T replacement)
    Replaces the given item in this combo box model
    is.codion.common.value.Value<Function<Object,T>>
    Provides a way for the combo box model to translate an item when it is selected, such as selecting the String "1" in a String based model when selected item is set to the number 1.
     
    is.codion.common.state.StateObserver
     
    is.codion.common.event.EventObserver<T>
     
    void
    Resets the items of this model using the values found in items.
    void
    Sorts the items in this model
    is.codion.common.value.Value<Predicate<T>>
    Provides a way for the model to prevent the addition of certain items.
    is.codion.common.value.Value<Predicate<T>>
    Provides a way for the combo box model to prevent the selection of certain items.

    Methods inherited from interface javax.swing.ComboBoxModel

    setSelectedItem

    Methods inherited from interface is.codion.common.model.FilterModel

    containsItem, filtered, filteredCount, filteredItems, filterItems, includeCondition, items, refresh, refresher, refreshThen, visible, visibleCount, visibleItems

    Methods inherited from interface javax.swing.ListModel

    addListDataListener, getElementAt, getSize, removeListDataListener
  • Field Details

    • COMBO_BOX_NULL_CAPTION

      static final is.codion.common.property.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 Details

    • clear

      void clear()
      Clears all items from this combo box model, including the null item and sets the selected item to null
    • cleared

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

      void setItems(Collection<T> items)
      Resets the items of this model using the values found in items.
      Parameters:
      items - the items to display in this combo box model
      Throws:
      IllegalArgumentException - in case an item fails validation
      See Also:
    • add

      void add(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
      Throws:
      IllegalArgumentException - in case the item fails validation
      See Also:
      • FilterModel.includeCondition()
    • remove

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

      void replace(T item, T replacement)
      Replaces the given item in this combo box model
      Parameters:
      item - the item to replace
      replacement - the replacement item
      Throws:
      IllegalArgumentException - in case the replacement item fails validation
    • sortItems

      void sortItems()
      Sorts the items in this model
      See Also:
    • comparator

      is.codion.common.value.Value<Comparator<T>> comparator()
      Controls the Comparator used when sorting the visible items in this model and sorts the model accordingly. This Comparator must take into account the null value if a null item has been set via nullItem(). If a null comparator is provided no sorting will be performed.
      Returns:
      the Value controlling the comparator used when sorting, value may be null if the items of this model should not be sorted
    • validator

      is.codion.common.value.Value<Predicate<T>> validator()
      Provides a way for the model to prevent the addition of certain items. Trying to add items that fail validation will result in an exception. Note that any translation of the selected item is done before validation.
      Returns:
      the Value controlling the item validator
    • selectedItemTranslator

      is.codion.common.value.Value<Function<Object,T>> selectedItemTranslator()
      Provides a way for the combo box model to translate an item when it is selected, such as selecting the String "1" in a String based model when selected item is set to the number 1.
      Returns:
      the Value controlling the selected item translator
    • validSelectionPredicate

      is.codion.common.value.Value<Predicate<T>> validSelectionPredicate()
      Provides a way for the combo box model to prevent the selection of certain items.
      Returns:
      the Value controlling the valid selection predicate
    • includeNull

      is.codion.common.state.State includeNull()
      Returns:
      the State controlling whether a null value is included as the first item
      See Also:
    • nullItem

      is.codion.common.value.Value<T> nullItem()
      Controls the item that should represent the null value in this model. Note that includeNull() must be used as well to enable the null value.
      Returns:
      the Value controlling the item representing null
      See Also:
    • nullSelected

      boolean nullSelected()
      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:
    • selectionEmpty

      is.codion.common.state.StateObserver selectionEmpty()
      Returns:
      a StateObserver indicating whether the selection is empty or the value representing null is selected
    • selectedValue

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

      T getSelectedItem()
      Specified by:
      getSelectedItem in interface ComboBoxModel<T>
      Returns:
      the selected item, N.B. this can include the nullItem in case it has been set via nullItem(), selectedValue() is usually what you want
    • filterSelectedItem

      is.codion.common.state.State 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.
      Returns:
      the State controlling whether the selected item is changed when it is filtered
    • createSelectorValue

      <V> is.codion.common.value.Value<V> createSelectorValue(FilterComboBoxModel.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
    • selectionEvent

      is.codion.common.event.EventObserver<T> selectionEvent()
      Returns:
      an observer notified each time the selection changes
    • filterComboBoxModel

      static <T> FilterComboBoxModel<T> filterComboBoxModel()
      Type Parameters:
      T - the item type
      Returns:
      a new FilterComboBoxModel instance