public class SwingEntityComboBoxModel extends SwingFilteredComboBoxModel<Entity> implements EntityComboBoxModel
| Constructor and Description |
|---|
SwingEntityComboBoxModel(java.lang.String entityId,
EntityConnectionProvider connectionProvider) |
| Modifier and Type | Method and Description |
|---|---|
void |
addRefreshListener(EventListener listener) |
EntityComboBoxModel |
createForeignKeyFilterComboBoxModel(java.lang.String foreignKeyPropertyId)
Returns a combo box model for selecting a foreign key value for filtering this model
|
void |
forceRefresh()
Forces a refresh of this model, disregarding the staticData directive
|
EntityConnectionProvider |
getConnectionProvider() |
Entity |
getEntity(Entity.Key primaryKey) |
java.lang.String |
getEntityId() |
FilterCondition<Entity> |
getForeignKeyFilterCondition()
Use this method to retrieve the default foreign key filter condition model if you
want to add a custom
FilterCondition to this model via FilteredModel.setFilterCondition(FilterCondition). |
java.util.Collection<Entity> |
getForeignKeyFilterEntities(java.lang.String foreignKeyPropertyId) |
Condition.Provider |
getSelectConditionProvider() |
protected java.util.List<Entity> |
initializeContents() |
boolean |
isStaticData() |
boolean |
isStrictForeignKeyFiltering() |
void |
linkForeignKeyComboBoxModel(java.lang.String foreignKeyPropertyId,
EntityComboBoxModel foreignKeyModel)
Links the given combo box model representing master entities to this combo box model
so that selection in the master model filters this model according to the selected master entity
|
protected java.util.List<Entity> |
performQuery()
Retrieves the entities to present in this EntityComboBoxModel, taking into account
the
getSelectConditionProvider() specified for this model |
void |
removeRefreshListener(EventListener listener) |
void |
setForeignKeyFilterEntities(java.lang.String foreignKeyPropertyId,
java.util.Collection<Entity> entities)
Filters this combo box model so that only entities referencing the given foreign key entities
via the given foreign key property are shown.
|
void |
setSelectConditionProvider(Condition.Provider selectConditionProvider)
Sets the condition provider to use when querying data
|
void |
setSelectedEntityByKey(Entity.Key key)
Selects the entity with the given primary key, if the entity is not available
in the model this method returns silently without changing the selection
|
EntityComboBoxModel |
setStaticData(boolean staticData)
Specifies whether or not this models data should be considered static, that is, only fetched once.
|
void |
setStrictForeignKeyFiltering(boolean strictForeignKeyFiltering)
Specifies whether foreign key filtering should be strict or not.
|
java.lang.String |
toString() |
protected Entity |
translateSelectionItem(java.lang.Object item) |
addFilteringListener, addItem, addListDataListener, addSelectionListener, allowSelectionChange, clear, contains, filterContents, fireContentsChanged, getAllItems, getElementAt, getFilterCondition, getFilteredItemCount, getFilteredItems, getNullValue, getSelectedItem, getSelectedValue, getSize, getSortComparator, getVisibleItemCount, getVisibleItems, isCleared, isFiltered, isFilterSelectedItem, isNullValueSelected, isSelectionEmpty, isVisible, refresh, removeFilteringListener, removeItem, removeListDataListener, removeSelectionListener, setContents, setFilterCondition, setFilterSelectedItem, setNullValue, setSelectedItem, setSortComparatorclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddItem, addSelectionListener, getElementAt, getNullValue, getSelectedItem, getSelectedValue, getSize, getSortComparator, isCleared, isFilterSelectedItem, isNullValueSelected, isSelectionEmpty, removeItem, removeSelectionListener, setContents, setFilterSelectedItem, setNullValue, setSelectedItem, setSortComparatoraddFilteringListener, contains, filterContents, getAllItems, getFilterCondition, getFilteredItemCount, getFilteredItems, getVisibleItemCount, getVisibleItems, isFiltered, isVisible, removeFilteringListener, setFilterConditionclear, refreshpublic SwingEntityComboBoxModel(java.lang.String entityId,
EntityConnectionProvider connectionProvider)
entityId - the id of the entity this combo box model should representconnectionProvider - a EntityConnectionProvider instancepublic final java.lang.String toString()
toString in class java.lang.Objectpublic final EntityConnectionProvider getConnectionProvider()
getConnectionProvider in interface EntityDataProviderpublic final java.lang.String getEntityId()
getEntityId in interface EntityDataProviderpublic final void forceRefresh()
forceRefresh in interface EntityComboBoxModelEntityComboBoxModel.setStaticData(boolean)public final boolean isStaticData()
isStaticData in interface EntityComboBoxModelEntityComboBoxModel.forceRefresh()public final EntityComboBoxModel setStaticData(boolean staticData)
EntityComboBoxModel.forceRefresh() disregards this directive.setStaticData in interface EntityComboBoxModelstaticData - the valuepublic final Entity getEntity(Entity.Key primaryKey)
getEntity in interface EntityComboBoxModelprimaryKey - the primary key of the entity to fetch from this modelpublic final void setSelectedEntityByKey(Entity.Key key)
setSelectedEntityByKey in interface EntityComboBoxModelkey - the primary key of the entity to selectpublic final void setSelectConditionProvider(Condition.Provider selectConditionProvider)
setSelectConditionProvider in interface EntityComboBoxModelselectConditionProvider - the condition providerpublic final Condition.Provider getSelectConditionProvider()
getSelectConditionProvider in interface EntityComboBoxModelpublic final FilterCondition<Entity> getForeignKeyFilterCondition()
FilterCondition to this model via FilteredModel.setFilterCondition(FilterCondition).
FilterCondition fkCondition = model.getForeignKeyFilterCondition();
model.setFilterCondition(new FilterCondition() {
public boolean include(Entity item) {
return fkCondition.include(item) && ...;
}
});
getForeignKeyFilterCondition in interface EntityComboBoxModelFilterCondition based on the foreign key filter entitiesEntityComboBoxModel.setForeignKeyFilterEntities(String, Collection)public final void setForeignKeyFilterEntities(java.lang.String foreignKeyPropertyId,
java.util.Collection<Entity> entities)
setForeignKeyFilterEntities in interface EntityComboBoxModelforeignKeyPropertyId - the property IDentities - the entitiespublic final java.util.Collection<Entity> getForeignKeyFilterEntities(java.lang.String foreignKeyPropertyId)
getForeignKeyFilterEntities in interface EntityComboBoxModelforeignKeyPropertyId - the ID of the foreign key propertypublic final void setStrictForeignKeyFiltering(boolean strictForeignKeyFiltering)
setStrictForeignKeyFiltering in interface EntityComboBoxModelstrictForeignKeyFiltering - the valueEntityComboBoxModel.setForeignKeyFilterEntities(String, Collection)public final boolean isStrictForeignKeyFiltering()
isStrictForeignKeyFiltering in interface EntityComboBoxModelpublic final EntityComboBoxModel createForeignKeyFilterComboBoxModel(java.lang.String foreignKeyPropertyId)
createForeignKeyFilterComboBoxModel in interface EntityComboBoxModelforeignKeyPropertyId - the ID of the property with which values to create the combo box modelEntityComboBoxModel.linkForeignKeyComboBoxModel(String, EntityComboBoxModel)public final void linkForeignKeyComboBoxModel(java.lang.String foreignKeyPropertyId,
EntityComboBoxModel foreignKeyModel)
linkForeignKeyComboBoxModel in interface EntityComboBoxModelforeignKeyPropertyId - the ID of the foreign key propertyforeignKeyModel - the combo box model to linkpublic final void addRefreshListener(EventListener listener)
addRefreshListener in interface EntityComboBoxModellistener - a listener to be notified each time this model is refreshedpublic final void removeRefreshListener(EventListener listener)
removeRefreshListener in interface EntityComboBoxModellistener - the listener to removeprotected final Entity translateSelectionItem(java.lang.Object item)
translateSelectionItem in class SwingFilteredComboBoxModel<Entity>item - the item to be selectedprotected final java.util.List<Entity> initializeContents()
initializeContents in class SwingFilteredComboBoxModel<Entity>protected java.util.List<Entity> performQuery()
getSelectConditionProvider() specified for this modelgetSelectConditionProvider()