java.lang.Object
is.codion.swing.common.model.component.combobox.ItemComboBoxModel<T>
Type Parameters:
T - the type of value wrapped by this combo box models items
All Implemented Interfaces:
is.codion.common.model.FilterModel<is.codion.common.item.Item<T>>, FilterComboBoxModel<is.codion.common.item.Item<T>>, ComboBoxModel<is.codion.common.item.Item<T>>, ListModel<is.codion.common.item.Item<T>>

public final class ItemComboBoxModel<T> extends Object
A ComboBoxModel implementation based on the Item class.
See Also:
  • Method Details

    • indexOf

      public int indexOf(T value)
      Returns the index of the Item representing the given value, -1 if this model does not contain such an Item.
      Parameters:
      value - the value
      Returns:
      the index of the Item representing the given value, -1 if not found
    • itemComboBoxModel

      public static <T> ItemComboBoxModel<T> itemComboBoxModel()
      Type Parameters:
      T - the Item value type
      Returns:
      a new combo box model
    • itemComboBoxModel

      public static <T> ItemComboBoxModel<T> itemComboBoxModel(List<is.codion.common.item.Item<T>> items)
      Type Parameters:
      T - the Item value type
      Parameters:
      items - the items
      Returns:
      a new combo box model
    • sortedItemComboBoxModel

      public static <T> ItemComboBoxModel<T> sortedItemComboBoxModel()
      Type Parameters:
      T - the Item value type
      Returns:
      a new combo box model
    • sortedItemComboBoxModel

      public static <T> ItemComboBoxModel<T> sortedItemComboBoxModel(List<is.codion.common.item.Item<T>> items)
      Type Parameters:
      T - the Item value type
      Parameters:
      items - the items
      Returns:
      a new combo box model
    • sortedItemComboBoxModel

      public static <T> ItemComboBoxModel<T> sortedItemComboBoxModel(Comparator<is.codion.common.item.Item<T>> comparator)
      Type Parameters:
      T - the Item value type
      Parameters:
      comparator - the comparator to use when sorting
      Returns:
      a new combo box model
    • sortedItemComboBoxModel

      public static <T> ItemComboBoxModel<T> sortedItemComboBoxModel(List<is.codion.common.item.Item<T>> items, Comparator<is.codion.common.item.Item<T>> comparator)
      Type Parameters:
      T - the Item value type
      Parameters:
      items - the items
      comparator - the comparator to use when sorting
      Returns:
      a new combo box model
    • booleanItemComboBoxModel

      public static ItemComboBoxModel<Boolean> booleanItemComboBoxModel()
      Constructs a new Boolean based ItemComboBoxModel with null as the initially selected value.
      Returns:
      a Boolean based ItemComboBoxModel
    • booleanItemComboBoxModel

      public static ItemComboBoxModel<Boolean> booleanItemComboBoxModel(String nullCaption)
      Constructs a new Boolean based ItemComboBoxModel with null as the initially selected value.
      Parameters:
      nullCaption - the string representing a null value
      Returns:
      a Boolean based ItemComboBoxModel
    • booleanItemComboBoxModel

      public static ItemComboBoxModel<Boolean> booleanItemComboBoxModel(String nullCaption, String trueCaption, String falseCaption)
      Constructs a new Boolean based ItemComboBoxModel with null as the initially selected value.
      Parameters:
      nullCaption - the string representing a null value
      trueCaption - the string representing the boolean value 'true'
      falseCaption - the string representing the boolean value 'false'
      Returns:
      a Boolean based ItemComboBoxModel
    • refresher

      public final is.codion.common.model.FilterModel.Refresher<is.codion.common.item.Item<T>> refresher()
      Specified by:
      refresher in interface is.codion.common.model.FilterModel<T>
    • refresh

      public final void refresh()
      Specified by:
      refresh in interface is.codion.common.model.FilterModel<T>
    • refresh

      public final void refresh(Consumer<Collection<is.codion.common.item.Item<T>>> onRefresh)
      Specified by:
      refresh in interface is.codion.common.model.FilterModel<T>
    • items

      public final FilterComboBoxModel.ComboBoxItems<is.codion.common.item.Item<T>> items()
      Specified by:
      items in interface FilterComboBoxModel<T>
      Specified by:
      items in interface is.codion.common.model.FilterModel<T>
    • selection

      public final FilterComboBoxModel.ComboBoxSelection<is.codion.common.item.Item<T>> selection()
      Specified by:
      selection in interface FilterComboBoxModel<T>
      Specified by:
      selection in interface is.codion.common.model.FilterModel<T>
    • getSelectedItem

      public final is.codion.common.item.Item<T> getSelectedItem()
      Specified by:
      getSelectedItem in interface ComboBoxModel<T>
      Specified by:
      getSelectedItem in interface FilterComboBoxModel<T>
      Returns:
      the selected item, N.B. this can include the nullItem in case it has been set via FilterComboBoxModel.ComboBoxItems.nullItem(), FilterComboBoxModel.ComboBoxSelection.value() is usually what you want
    • setSelectedItem

      public final void setSelectedItem(Object item)
      Specified by:
      setSelectedItem in interface ComboBoxModel<T>
    • addListDataListener

      public final void addListDataListener(ListDataListener listener)
      Specified by:
      addListDataListener in interface ListModel<T>
    • removeListDataListener

      public final void removeListDataListener(ListDataListener listener)
      Specified by:
      removeListDataListener in interface ListModel<T>
    • getElementAt

      public final is.codion.common.item.Item<T> getElementAt(int index)
      Specified by:
      getElementAt in interface ListModel<T>
    • getSize

      public final int getSize()
      Specified by:
      getSize in interface ListModel<T>
    • createSelectorValue

      public final <V> is.codion.common.value.Value<V> createSelectorValue(FilterComboBoxModel.ItemFinder<is.codion.common.item.Item<T>,V> itemFinder)
      Specified by:
      createSelectorValue in interface FilterComboBoxModel<T>
      Type Parameters:
      V - the value type
      Parameters:
      itemFinder - responsible for finding the item to select
      Returns:
      a Value linked to the selected item using the given FilterComboBoxModel.ItemFinder instance