Interface EntityComboBoxModel
- All Superinterfaces:
ComboBoxModel<Entity>
,FilterComboBoxModel<Entity>
,FilterModel<Entity>
,ListModel<Entity>
A ComboBoxModel based on an Entity, showing by default all the entities in the underlying table.
To filter a EntityComboBoxModel
use filter()
to set a Predicate
or configure ForeignKey
based filtering.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Builds aEntityComboBoxModel
.static interface
Controls the filters for aEntityComboBoxModel
static interface
Controls a foreign key filter for aEntityComboBoxModel
Nested classes/interfaces inherited from interface is.codion.swing.common.model.component.combobox.FilterComboBoxModel
FilterComboBoxModel.ComboBoxItems<T>, FilterComboBoxModel.ComboBoxSelection<T>, FilterComboBoxModel.ItemFinder<T,
V> Nested classes/interfaces inherited from interface is.codion.common.model.FilterModel
FilterModel.AbstractRefresher<T>, FilterModel.FilteredItems<T>, FilterModel.Items<T>, FilterModel.Refresher<T>, FilterModel.VisibleItems<T>
-
Field Summary
Modifier and TypeFieldDescriptionstatic final PropertyValue<Boolean>
Specifies whether entity combo box models handle entity edit events, by replacing updated entities and removing deleted ones Value type: Boolean Default value: trueFields inherited from interface is.codion.swing.common.model.component.combobox.FilterComboBoxModel
NULL_CAPTION
Fields inherited from interface is.codion.common.model.FilterModel
ASYNC_REFRESH
-
Method Summary
Modifier and TypeMethodDescriptionstatic EntityComboBoxModel.Builder
builder
(EntityType entityType, EntityConnectionProvider connectionProvider) Controls the condition supplier to use when querying data, setting this to null reverts back to the original condition, set viaEntityComboBoxModel.Builder.condition(Supplier)
or the default one, fetching all underlying entities, if none was specified.<T> Value<T>
createSelectorValue
(Attribute<T> attribute) Creates aValue
linked to the selected entity via the value of the given attribute.filter()
find
(Entity.Key primaryKey) void
select
(Entity.Key primaryKey) Selects the entity with the given primary key, whether filtered or visible.Methods inherited from interface javax.swing.ComboBoxModel
setSelectedItem
Methods inherited from interface is.codion.swing.common.model.component.combobox.FilterComboBoxModel
createSelectorValue, getSelectedItem, items, selection
Methods inherited from interface is.codion.common.model.FilterModel
refresh, refresh, refresher
Methods inherited from interface javax.swing.ListModel
addListDataListener, getElementAt, getSize, removeListDataListener
-
Field Details
-
HANDLE_EDIT_EVENTS
Specifies whether entity combo box models handle entity edit events, by replacing updated entities and removing deleted ones- Value type: Boolean
- Default value: true
-
-
Method Details
-
connectionProvider
EntityConnectionProvider connectionProvider()- Returns:
- the connection provider used by this combo box model
-
entityType
EntityType entityType()- Returns:
- the type of the entity this combo box model is based on
-
find
- Parameters:
primaryKey
- the primary key of the entity to fetch from this model- Returns:
- the entity with the given key if found in the model, an empty Optional otherwise
-
select
Selects the entity with the given primary key, whether filtered or visible. If the entity is not available in the model this method returns silently without changing the selection.- Parameters:
primaryKey
- the primary key of the entity to select
-
condition
Controls the condition supplier to use when querying data, setting this to null reverts back to the original condition, set viaEntityComboBoxModel.Builder.condition(Supplier)
or the default one, fetching all underlying entities, if none was specified.- Returns:
- a value controlling the condition supplier
-
filter
EntityComboBoxModel.Filter filter()- Returns:
- the
EntityComboBoxModel.Filter
instance
-
createSelectorValue
Creates aValue
linked to the selected entity via the value of the given attribute.- Type Parameters:
T
- the attribute type- Parameters:
attribute
- the attribute- Returns:
- a
Value
for selecting items by attribute value
-
builder
static EntityComboBoxModel.Builder builder(EntityType entityType, EntityConnectionProvider connectionProvider) - Parameters:
entityType
- the type of the entity this combo box model should representconnectionProvider
- a EntityConnectionProvider instance- Returns:
- a new
EntityComboBoxModel.Builder
instance
-