E
- the type of EntityEditModel
used by this EntityTableModel
public interface EntityTableModel<E extends EntityEditModel> extends EntityDataProvider, FilteredModel<Entity>, Refreshable
Entity
objectsModifier and Type | Interface and Description |
---|---|
static class |
EntityTableModel.InsertAction
Defines the actions a table model can perform when entities are inserted via the associated edit model
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PREFERENCES_COLUMN_INDEX |
static java.lang.String |
PREFERENCES_COLUMN_VISIBLE |
static java.lang.String |
PREFERENCES_COLUMN_WIDTH |
static java.lang.String |
PREFERENCES_COLUMNS |
Modifier and Type | Method and Description |
---|---|
void |
addEntities(java.util.List<Entity> entities,
boolean atTop,
boolean sortAfterAdding)
Adds the given entities to this table model, it is recommended to only manually add entities
directly to this table model after they have been inserted into the underlying table
since otherwise they will disappear during the next table model refresh.
|
void |
addSelectionChangedListener(EventListener listener) |
void |
deleteSelected()
Deletes the selected entities
|
java.util.List<Entity> |
getAllItems() |
ColumnSummaryModel |
getColumnSummaryModel(java.lang.String propertyId)
Returns the
ColumnSummaryModel associated with the property identified by propertyId |
EntityTableConditionModel |
getConditionModel() |
Domain |
getDomain() |
E |
getEditModel()
Returns the
EntityEditModel associated with this table model |
java.util.Collection<Entity> |
getEntitiesByKey(java.util.Collection<Entity.Key> keys)
Finds entities according to the values in
keys |
Entity |
getEntityByKey(Entity.Key primaryKey) |
Entity.Definition |
getEntityDefinition() |
int |
getFetchCount()
Returns the maximum number of records to fetch via the underlying query the next time
this table model is refreshed, a value of -1 means all records should be fetched
|
EntityTableModel.InsertAction |
getInsertAction() |
java.lang.Object |
getPropertyBackgroundColor(int row,
Property property) |
int |
getPropertyColumnIndex(java.lang.String propertyId) |
State |
getQueryConditionRequiredState()
Returns a State controlling whether this table model should display all underlying entities
when no query condition has been set.
|
int |
getRowCount() |
java.util.Iterator<Entity> |
getSelectedEntitiesIterator()
Returns an Iterator which iterates through the selected entities
|
SelectionModel<Entity> |
getSelectionModel() |
java.lang.String |
getStatusMessage() |
java.lang.String |
getTableDataAsDelimitedString(char delimiter) |
boolean |
hasEditModel() |
int |
indexOf(Entity.Key primaryKey) |
boolean |
isBatchUpdateAllowed() |
boolean |
isDeleteAllowed() |
boolean |
isReadOnly() |
boolean |
isRefreshOnForeignKeyConditionValuesSet() |
boolean |
isRemoveEntitiesOnDelete() |
boolean |
isUpdateAllowed() |
void |
refreshEntities(java.util.List<Entity.Key> keys)
Refreshes the entities with the given keys by re-selecting them from the underlying database.
|
void |
replaceEntities(java.util.Collection<Entity> entities)
Replaces the given entities in this table model
|
void |
replaceForeignKeyValues(java.lang.String foreignKeyEntityId,
java.util.Collection<Entity> foreignKeyValues)
For every entity in this table model, replaces the foreign key instance bearing the primary
key with the corresponding entity from
foreignKeyValues , useful when property
values have been changed in the referenced entity that must be reflected in the table model. |
void |
savePreferences()
Saves any user preferences
|
EntityTableModel<E> |
setBatchUpdateAllowed(boolean batchUpdateAllowed) |
void |
setColumns(java.lang.String... propertyIds)
Arranges the column model so that only the given columns are visible and in the given order
|
void |
setEditModel(E editModel)
Associates the given
EntityEditModel with this EntityTableModel , this enables delete/update
functionality via this table model as well as enabling it to
react to delete events in the edit model. |
EntityTableModel<E> |
setFetchCount(int fetchCount)
Sets the maximum number of records to fetch via the underlying query the next time
this table model is refreshed, a value of -1 means all records should be fetched
|
void |
setForeignKeyConditionValues(ForeignKeyProperty foreignKeyProperty,
java.util.Collection<Entity> foreignKeyValues)
Sets
foreignKeyValues as the search condition values for the given foreignKeyProperty
and refreshes this table model. |
EntityTableModel<E> |
setInsertAction(EntityTableModel.InsertAction insertAction) |
EntityTableModel |
setRefreshOnForeignKeyConditionValuesSet(boolean value) |
EntityTableModel<E> |
setRemoveEntitiesOnDelete(boolean value) |
void |
setSelectedByKey(java.util.Collection<Entity.Key> keys)
Sets the selected entities according to the primary keys in
primaryKeys |
void |
update(java.util.List<Entity> entities)
Updates the given entities.
|
getConnectionProvider, getEntityId
addFilteringListener, contains, filterContents, getFilterCondition, getFilteredItemCount, getFilteredItems, getVisibleItemCount, getVisibleItems, isFiltered, isVisible, removeFilteringListener, setFilterCondition
clear, refresh
static final java.lang.String PREFERENCES_COLUMNS
static final java.lang.String PREFERENCES_COLUMN_WIDTH
static final java.lang.String PREFERENCES_COLUMN_VISIBLE
static final java.lang.String PREFERENCES_COLUMN_INDEX
Domain getDomain()
Entity.Definition getEntityDefinition()
E getEditModel()
EntityEditModel
associated with this table modeljava.lang.IllegalStateException
- in case no edit model has been associated with this table modelsetEditModel(EntityEditModel)
boolean hasEditModel()
EntityTableModel
contains a EntityEditModel
void setEditModel(E editModel)
EntityEditModel
with this EntityTableModel
, this enables delete/update
functionality via this table model as well as enabling it to
react to delete events in the edit model.
Throws a RuntimeException in case the edit model has been previously seteditModel
- the edit model to associate with this table modeljava.lang.IllegalStateException
- in case an EntityEditModel
has already been associated with this EntityTableModel
java.lang.IllegalArgumentException
- in case the given EntityEditModel
is not based on the same entityId as this EntityTableModel
deleteSelected()
,
update(java.util.List)
void setForeignKeyConditionValues(ForeignKeyProperty foreignKeyProperty, java.util.Collection<Entity> foreignKeyValues)
foreignKeyValues
as the search condition values for the given foreignKeyProperty
and refreshes this table model.foreignKeyProperty
- the ID of the foreign key propertyforeignKeyValues
- the entities to use as condition valuesvoid replaceForeignKeyValues(java.lang.String foreignKeyEntityId, java.util.Collection<Entity> foreignKeyValues)
foreignKeyValues
, useful when property
values have been changed in the referenced entity that must be reflected in the table model.foreignKeyEntityId
- the entity ID of the foreign key valuesforeignKeyValues
- the foreign key entitiesvoid addEntities(java.util.List<Entity> entities, boolean atTop, boolean sortAfterAdding)
entities
- the entities to addatTop
- if true then items are added at the top of the table model, else at the bottomsortAfterAdding
- if true and sorting is enabled then the model is sorted after addingTableSortModel.isSortingEnabled()
void replaceEntities(java.util.Collection<Entity> entities)
entities
- the entities to replacevoid refreshEntities(java.util.List<Entity.Key> keys)
keys
- the keys of the entities to refreshEntityTableConditionModel getConditionModel()
EntityTableConditionModel
instance used by this table modelboolean isDeleteAllowed()
hasEditModel()
,
setEditModel(EntityEditModel)
boolean isReadOnly()
EntityEditModel
or if that edit model is read onlyhasEditModel()
,
setEditModel(EntityEditModel)
boolean isUpdateAllowed()
hasEditModel()
,
setEditModel(EntityEditModel)
boolean isBatchUpdateAllowed()
EntityTableModel<E> setBatchUpdateAllowed(boolean batchUpdateAllowed)
batchUpdateAllowed
- true if this model should allow multiple entities to be updated at a timeEntityTableModel
instanceColumnSummaryModel getColumnSummaryModel(java.lang.String propertyId)
ColumnSummaryModel
associated with the property identified by propertyId
propertyId
- the ID of the propertyColumnSummaryModel
for the given property IDjava.lang.Object getPropertyBackgroundColor(int row, Property property)
row
- the row for which to retrieve the background colorproperty
- the property for which to retrieve the background colorEntity.Definition.Builder#setColorProvider(Entity.ColorProvider)
int getPropertyColumnIndex(java.lang.String propertyId)
propertyId
- the propertyIdjava.lang.String getStatusMessage()
int getFetchCount()
EntityTableModel<E> setFetchCount(int fetchCount)
fetchCount
- the fetch countvoid update(java.util.List<Entity> entities) throws ValidationException, DatabaseException
entities
- the entities to updateDatabaseException
- in case of a database exceptionCancelException
- in case the user cancels the operationRecordModifiedException
- in case an entity was modified by another userValidationException
- in case validation failsjava.lang.IllegalStateException
- in case this table model has no edit model or if the edit model does not allow updatingEntity.Validator.validate(java.util.Collection)
void deleteSelected() throws DatabaseException
DatabaseException
- in case of a database exceptionCancelException
- in case the user cancels the operationjava.lang.IllegalStateException
- in case this table model has no edit model or if the edit model does not allow deletingState getQueryConditionRequiredState()
boolean isRemoveEntitiesOnDelete()
EntityTableModel<E> setRemoveEntitiesOnDelete(boolean value)
value
- true if entities that are deleted via the associated edit model
should be automatically removed from this table modelEntityTableModel
instanceEntityTableModel.InsertAction getInsertAction()
EntityTableModel<E> setInsertAction(EntityTableModel.InsertAction insertAction)
insertAction
- the action to perform when entities are inserted via the associated edit modeljava.util.Collection<Entity> getEntitiesByKey(java.util.Collection<Entity.Key> keys)
keys
keys
- the primary key values to use as conditionkeys
void setSelectedByKey(java.util.Collection<Entity.Key> keys)
primaryKeys
keys
- the primary keys of the entities to selectjava.util.Iterator<Entity> getSelectedEntitiesIterator()
Entity getEntityByKey(Entity.Key primaryKey)
primaryKey
- the primary key to search byint indexOf(Entity.Key primaryKey)
primaryKey
- the primary keyvoid savePreferences()
void setColumns(java.lang.String... propertyIds)
propertyIds
- the column identifiersjava.lang.String getTableDataAsDelimitedString(char delimiter)
delimiter
- the delimiterjava.util.List<Entity> getAllItems()
getAllItems
in interface FilteredModel<Entity>
int getRowCount()
SelectionModel<Entity> getSelectionModel()
SelectionModel
void addSelectionChangedListener(EventListener listener)
listener
- notified when the selection changes in the underlying selection modelEntityTableModel setRefreshOnForeignKeyConditionValuesSet(boolean value)
value
- true if this table model should automatically refresh when foreign key condition values are setEntityTableModel
instancesetForeignKeyConditionValues(ForeignKeyProperty, Collection)
boolean isRefreshOnForeignKeyConditionValuesSet()
setForeignKeyConditionValues(ForeignKeyProperty, Collection)