Module is.codion.swing.common.model
Class ItemComboBoxModel<T>
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>>
A ComboBoxModel implementation based on the
Item class.-
Nested Class Summary
Nested classes/interfaces inherited from interface is.codion.swing.common.model.component.combobox.FilterComboBoxModel
FilterComboBoxModel.ComboBoxItems<T>, FilterComboBoxModel.ComboBoxSelection<T>, FilterComboBoxModel.ItemFinder<T,V>, FilterComboBoxModel.NullItem<T> 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.FilteredItems<T extends Object>, is.codion.common.model.FilterModel.Items<T extends Object>, is.codion.common.model.FilterModel.Refresher<T extends Object>, is.codion.common.model.FilterModel.VisibleItems<T extends Object> -
Field Summary
Fields inherited from interface is.codion.swing.common.model.component.combobox.FilterComboBoxModel
NULL_CAPTIONFields inherited from interface is.codion.common.model.FilterModel
ASYNC_REFRESH -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddListDataListener(ListDataListener listener) static ItemComboBoxModel<Boolean>Constructs a new Boolean based ItemComboBoxModel with null as the initially selected value.static ItemComboBoxModel<Boolean>booleanItemComboBoxModel(String nullCaption) Constructs a new Boolean based ItemComboBoxModel with null as the initially selected value.static ItemComboBoxModel<Boolean>booleanItemComboBoxModel(String nullCaption, String trueCaption, String falseCaption) Constructs a new Boolean based ItemComboBoxModel with null as the initially selected value.final <V> is.codion.common.value.Value<V>createSelectorValue(FilterComboBoxModel.ItemFinder<is.codion.common.item.Item<T>, V> itemFinder) final is.codion.common.item.Item<T>getElementAt(int index) final is.codion.common.item.Item<T>final intgetSize()intReturns the index of the Item representing the given value, -1 if this model does not contain such an Item.static <T> ItemComboBoxModel<T>static <T> ItemComboBoxModel<T>itemComboBoxModel(List<is.codion.common.item.Item<T>> items) final FilterComboBoxModel.ComboBoxItems<is.codion.common.item.Item<T>>items()final voidrefresh()final voidrefresh(Consumer<Collection<is.codion.common.item.Item<T>>> onRefresh) final is.codion.common.model.FilterModel.Refresher<is.codion.common.item.Item<T>>final voidremoveListDataListener(ListDataListener listener) final FilterComboBoxModel.ComboBoxSelection<is.codion.common.item.Item<T>>final voidsetSelectedItem(Object item) static <T> ItemComboBoxModel<T>static <T> ItemComboBoxModel<T>sortedItemComboBoxModel(Comparator<is.codion.common.item.Item<T>> comparator) static <T> ItemComboBoxModel<T>sortedItemComboBoxModel(List<is.codion.common.item.Item<T>> items) static <T> ItemComboBoxModel<T>sortedItemComboBoxModel(List<is.codion.common.item.Item<T>> items, Comparator<is.codion.common.item.Item<T>> comparator)
-
Method Details
-
indexOf
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
- Type Parameters:
T- the Item value type- Returns:
- a new combo box model
-
itemComboBoxModel
- Type Parameters:
T- the Item value type- Parameters:
items- the items- Returns:
- a new combo box model
-
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 itemscomparator- the comparator to use when sorting- Returns:
- a new combo box model
-
booleanItemComboBoxModel
Constructs a new Boolean based ItemComboBoxModel with null as the initially selected value.- Returns:
- a Boolean based ItemComboBoxModel
-
booleanItemComboBoxModel
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 valuetrueCaption- 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:
refresherin interfaceis.codion.common.model.FilterModel<T>
-
refresh
public final void refresh()- Specified by:
refreshin interfaceis.codion.common.model.FilterModel<T>
-
refresh
- Specified by:
refreshin interfaceis.codion.common.model.FilterModel<T>
-
items
- Specified by:
itemsin interfaceFilterComboBoxModel<T>- Specified by:
itemsin interfaceis.codion.common.model.FilterModel<T>
-
selection
- Specified by:
selectionin interfaceFilterComboBoxModel<T>- Specified by:
selectionin interfaceis.codion.common.model.FilterModel<T>
-
getSelectedItem
- Specified by:
getSelectedItemin interfaceComboBoxModel<T>- Specified by:
getSelectedItemin interfaceFilterComboBoxModel<T>- Returns:
- the selected item, N.B. this can include the
nullItemin case it has been set viaFilterComboBoxModel.ComboBoxItems.nullItem(),FilterComboBoxModel.ComboBoxSelection.value()is usually what you want
-
setSelectedItem
- Specified by:
setSelectedItemin interfaceComboBoxModel<T>
-
addListDataListener
- Specified by:
addListDataListenerin interfaceListModel<T>
-
removeListDataListener
- Specified by:
removeListDataListenerin interfaceListModel<T>
-
getElementAt
- Specified by:
getElementAtin interfaceListModel<T>
-
getSize
public final int getSize() -
createSelectorValue
public final <V> is.codion.common.value.Value<V> createSelectorValue(FilterComboBoxModel.ItemFinder<is.codion.common.item.Item<T>, V> itemFinder) - Specified by:
createSelectorValuein interfaceFilterComboBoxModel<T>- Type Parameters:
V- the value type- Parameters:
itemFinder- responsible for finding the item to select- Returns:
- a
Valuelinked to the selected item using the givenFilterComboBoxModel.ItemFinderinstance
-