|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.table.AbstractTableModel
org.jminor.common.model.AbstractFilteredTableModel<Entity,Property>
org.jminor.framework.client.model.DefaultEntityTableModel
public class DefaultEntityTableModel
A TableModel implementation for displaying and working with entities.
String entityID = "some.entity"; String clientTypeID = "JavadocDemo"; User user = new User("scott", "tiger"); EntityConnectionProvider connectionProvider = EntityConnectionProviders.createConnectionProvider(user, clientTypeID); EntityTableModel tableModel = new DefaultEntityTableModel(entityID, connectionProvider); EntityEditModel editModel = ...; tableModel.setEditModel(editModel); EntityTablePanel panel = new EntityTablePanel(model);
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.jminor.common.model.FilteredTableModel |
---|
FilteredTableModel.SortingState |
Field Summary |
---|
Fields inherited from class javax.swing.table.AbstractTableModel |
---|
listenerList |
Constructor Summary | |
---|---|
DefaultEntityTableModel(String entityID,
EntityConnectionProvider connectionProvider)
Instantiates a new DefaultEntityTableModel with default column and search models. |
|
DefaultEntityTableModel(String entityID,
EntityConnectionProvider connectionProvider,
EntityTableSearchModel searchModel)
Instantiates a new DefaultEntityTableModel. |
Method Summary | |
---|---|
void |
addEntitiesByPrimaryKeys(List<Entity.Key> primaryKeys,
boolean atFront)
Retrieves the entities identified by the given primary keys and adds them to this table model |
void |
deleteSelected()
Deletes the selected entities |
protected void |
doRefresh()
Refreshes the data in this table model. |
StateObserver |
getBatchUpdateAllowedState()
|
Class<?> |
getColumnClass(int columnIndex)
|
protected Class |
getColumnClass(Property columnIdentifier)
|
protected Comparable |
getComparable(Object object,
Property columnIdentifier)
|
EntityConnectionProvider |
getConnectionProvider()
|
EntityEditModel |
getEditModel()
Returns the edit model associated with this table model, throws a RuntimeExcption in case no edit model has been associated with this table model |
List<Entity> |
getEntitiesByPrimaryKeys(List<Entity.Key> keys)
Finds entities according to the values in keys |
Collection<Entity> |
getEntitiesByPropertyValues(Map<String,Object> values)
Finds entities according to the values of propertyValues |
Entity |
getEntityByPrimaryKey(Entity.Key primaryKey)
|
String |
getEntityID()
|
int |
getFetchCount()
Returns the maximum number of records to fetch via the underlying query, by default this returns -1, meaning all records should be fetched |
List<Entity.Key> |
getPrimaryKeysOfSelectedEntities()
|
Color |
getPropertyBackgroundColor(int row,
Property columnProperty)
|
PropertySummaryModel |
getPropertySummaryModel(Property property)
Returns the PropertySummaryModel associated with the given property |
PropertySummaryModel |
getPropertySummaryModel(String propertyID)
Returns the PropertySummaryModel associated with the property identified by propertyID |
protected Criteria<Property.ColumnProperty> |
getQueryCriteria()
|
ReportDataWrapper |
getReportDataSource()
Returns an initialized ReportDataWrapper instance, the default implementation returns null. |
EntityTableSearchModel |
getSearchModel()
|
protected String |
getSearchValueAt(int rowIndex,
Property columnIdentifier)
Returns the value to use when searching through the table. |
Iterator<Entity> |
getSelectedEntitiesIterator()
Returns an Iterator which iterates through the selected entities |
Map<String,Collection<Entity>> |
getSelectionDependencies()
|
SortingDirective |
getSortingDirective(String propertyID)
|
String |
getStatusMessage()
|
List<Property> |
getTableColumnProperties()
|
Object |
getValueAt(int rowIndex,
int columnIndex)
|
Collection<Object> |
getValues(Property property,
boolean selectedOnly)
|
protected void |
handleDelete(DeleteEvent event)
|
boolean |
hasEditModel()
|
int |
indexOf(Entity.Key primaryKey)
|
boolean |
isBatchUpdateAllowed()
|
boolean |
isCellEditable(int rowIndex,
int columnIndex)
|
boolean |
isDeleteAllowed()
|
boolean |
isDetailModel()
|
boolean |
isQueryConfigurationAllowed()
|
boolean |
isQueryCriteriaRequired()
|
boolean |
isReadOnly()
|
boolean |
isUpdateAllowed()
|
protected List<Entity> |
performQuery(Criteria<Property.ColumnProperty> criteria)
Queries for the data used to populate this EntityTableModel when it is refreshed |
void |
replaceEntities(Collection<Entity> entities)
Replaces the given entities in this table model |
void |
replaceForeignKeyValues(String foreignKeyEntityID,
Collection<Entity> newForeignKeyValues)
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. |
EntityTableModel |
setBatchUpdateAllowed(boolean batchUpdateAllowed)
|
EntityTableModel |
setDetailModel(boolean detailModel)
|
void |
setEditModel(EntityEditModel editModel)
Associates the given edit model with this table model, this enables delete/update functionality via this table model as well as enabling it to react to delete events in the edit model. |
EntityTableModel |
setFetchCount(int fetchCount)
Sets the maximum number of records to fetch via the underlying query, a value of -1 means all records should be fetched |
void |
setForeignKeySearchValues(String referencedEntityID,
List<Entity> referenceEntities)
Refreshes this table model according the the given values by finding the first foreign key property referencing the entity identified by referencedEntityID and setting referenceEntities
as the criteria values. |
EntityTableModel |
setQueryConfigurationAllowed(boolean value)
Specifies whether or not the underlying query should be configurable |
EntityTableModel |
setQueryCriteriaRequired(boolean value)
|
EntityTableModel |
setReportDataSource(ReportDataWrapper reportDataSource)
Sets the report data source to use during report generation |
void |
setSelectedByPrimaryKeys(List<Entity.Key> keys)
Sets the selected entities according to the primary keys in primaryKeys |
void |
setSortingDirective(String propertyID,
SortingDirective directive,
boolean addColumnToSort)
|
void |
setValueAt(Object aValue,
int rowIndex,
int columnIndex)
|
String |
toString()
|
void |
update(List<Entity> entities)
Updates the given Entities. |
Methods inherited from class javax.swing.table.AbstractTableModel |
---|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnName, getListeners, getTableModelListeners, removeTableModelListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.jminor.common.model.FilteredModel |
---|
addFilteringListener, contains, filterContents, getAllItems, getFilterCriteria, getFilteredItemCount, getFilteredItems, getVisibleItemCount, getVisibleItems, isFiltered, isVisible, removeFilteringListener, setFilterCriteria |
Methods inherited from interface javax.swing.table.TableModel |
---|
addTableModelListener, getColumnCount, getColumnName, getRowCount, removeTableModelListener |
Methods inherited from interface org.jminor.common.model.Refreshable |
---|
clear, refresh |
Constructor Detail |
---|
public DefaultEntityTableModel(String entityID, EntityConnectionProvider connectionProvider)
entityID
- the entity IDconnectionProvider
- the db providerpublic DefaultEntityTableModel(String entityID, EntityConnectionProvider connectionProvider, EntityTableSearchModel searchModel)
entityID
- the entity IDconnectionProvider
- the db providersearchModel
- the search modelMethod Detail |
---|
public final String toString()
toString
in class Object
public final void setEditModel(EntityEditModel editModel)
setEditModel
in interface EntityTableModel
editModel
- the edit model to associate with this table modelEntityTableModel.deleteSelected()
,
EntityTableModel.update(java.util.List)
public final boolean hasEditModel()
hasEditModel
in interface EntityTableModel
public final List<Property> getTableColumnProperties()
getTableColumnProperties
in interface EntityTableModel
public final boolean isQueryConfigurationAllowed()
isQueryConfigurationAllowed
in interface EntityTableModel
public final EntityTableModel setQueryConfigurationAllowed(boolean value)
setQueryConfigurationAllowed
in interface EntityTableModel
value
- the value
public final int getFetchCount()
getFetchCount
in interface EntityTableModel
public final EntityTableModel setFetchCount(int fetchCount)
setFetchCount
in interface EntityTableModel
fetchCount
- the fetch count
public final boolean isDetailModel()
isDetailModel
in interface EntityTableModel
public final EntityTableModel setDetailModel(boolean detailModel)
setDetailModel
in interface EntityTableModel
detailModel
- if set to true then this table model will not run a query unless a query criteria has been specified
EntityTableModel.setQueryCriteriaRequired(boolean)
public final boolean isQueryCriteriaRequired()
isQueryCriteriaRequired
in interface EntityTableModel
public final EntityTableModel setQueryCriteriaRequired(boolean value)
setQueryCriteriaRequired
in interface EntityTableModel
value
- if set to true then all underlying entities are shown
when no criteria is applied, which can be problematic in the case of huge datasets.
public final String getEntityID()
getEntityID
in interface EntityDataProvider
public final EntityTableSearchModel getSearchModel()
getSearchModel
in interface EntityTableModel
public final EntityEditModel getEditModel()
getEditModel
in interface EntityTableModel
EntityTableModel.setEditModel(EntityEditModel)
public final EntityConnectionProvider getConnectionProvider()
getConnectionProvider
in interface EntityDataProvider
public final boolean isBatchUpdateAllowed()
isBatchUpdateAllowed
in interface EntityTableModel
public final EntityTableModel setBatchUpdateAllowed(boolean batchUpdateAllowed)
setBatchUpdateAllowed
in interface EntityTableModel
batchUpdateAllowed
- true if this model should allow multiple entities to be updated at a time
public final StateObserver getBatchUpdateAllowedState()
getBatchUpdateAllowedState
in interface EntityTableModel
EntityTableModel.isBatchUpdateAllowed()
public final boolean isDeleteAllowed()
isDeleteAllowed
in interface EntityTableModel
public boolean isUpdateAllowed()
isUpdateAllowed
in interface EntityTableModel
public final boolean isReadOnly()
isReadOnly
in interface EntityTableModel
EntityTableModel.setEditModel(EntityEditModel)
public final ReportDataWrapper getReportDataSource()
getReportDataSource
in interface EntityTableModel
EntityTableModel.getSelectedEntitiesIterator()
public final EntityTableModel setReportDataSource(ReportDataWrapper reportDataSource)
setReportDataSource
in interface EntityTableModel
reportDataSource
- the data source
public final Class<?> getColumnClass(int columnIndex)
getColumnClass
in interface TableModel
getColumnClass
in class AbstractTableModel
public final Object getValueAt(int rowIndex, int columnIndex)
getValueAt
in interface TableModel
public final boolean isCellEditable(int rowIndex, int columnIndex)
isCellEditable
in interface TableModel
isCellEditable
in class AbstractTableModel
public final void setValueAt(Object aValue, int rowIndex, int columnIndex)
setValueAt
in interface TableModel
setValueAt
in class AbstractTableModel
public Color getPropertyBackgroundColor(int row, Property columnProperty)
getPropertyBackgroundColor
in interface EntityTableModel
row
- the row for which to retrieve the background colorcolumnProperty
- the column property for which to retrieve the background color
Entity.Definition.setBackgroundColorProvider(org.jminor.framework.domain.Entity.BackgroundColorProvider)
,
EntityTableCellRenderer
public final Collection<Object> getValues(Property property, boolean selectedOnly)
getValues
in interface EntityTableModel
property
- the property for which to retrieve the valuesselectedOnly
- if true only values from the selected entities are returned
property
from the entities in the table modelpublic final Entity getEntityByPrimaryKey(Entity.Key primaryKey)
getEntityByPrimaryKey
in interface EntityTableModel
primaryKey
- the primary key to search by
public final int indexOf(Entity.Key primaryKey)
indexOf
in interface EntityTableModel
primaryKey
- the primary key
public final String getStatusMessage()
getStatusMessage
in interface EntityTableModel
public final void addEntitiesByPrimaryKeys(List<Entity.Key> primaryKeys, boolean atFront)
addEntitiesByPrimaryKeys
in interface EntityTableModel
primaryKeys
- the primary keysatFront
- if true the entities are added to the frontpublic final void replaceEntities(Collection<Entity> entities)
replaceEntities
in interface EntityTableModel
entities
- the entities to replacepublic void setForeignKeySearchValues(String referencedEntityID, List<Entity> referenceEntities)
referencedEntityID
and setting referenceEntities
as the criteria values. If no foreign key property is found this method has no effect.
setForeignKeySearchValues
in interface EntityTableModel
referencedEntityID
- the ID of the master entityreferenceEntities
- the entities to use as criteria valuesEntityTableModel.isDetailModel()
public final void replaceForeignKeyValues(String foreignKeyEntityID, Collection<Entity> newForeignKeyValues)
foreignKeyValues
, useful when property
values have been changed in the referenced entity that must be reflected in the table model.
replaceForeignKeyValues
in interface EntityTableModel
foreignKeyEntityID
- the entity ID of the foreign key valuesnewForeignKeyValues
- the foreign key entitiespublic final List<Entity.Key> getPrimaryKeysOfSelectedEntities()
getPrimaryKeysOfSelectedEntities
in interface EntityTableModel
public final void setSelectedByPrimaryKeys(List<Entity.Key> keys)
primaryKeys
setSelectedByPrimaryKeys
in interface EntityTableModel
keys
- the primary keys of the entities to selectpublic final List<Entity> getEntitiesByPrimaryKeys(List<Entity.Key> keys)
keys
getEntitiesByPrimaryKeys
in interface EntityTableModel
keys
- the primary key values to use as condition
keys
public final Collection<Entity> getEntitiesByPropertyValues(Map<String,Object> values)
propertyValues
getEntitiesByPropertyValues
in interface EntityTableModel
values
- the property values to use as condition mapped
to their respective propertyIDs
properties
public final void deleteSelected() throws CancelException, DatabaseException
deleteSelected
in interface EntityTableModel
CancelException
- in case the user cancels the operation
DatabaseException
- in case of a database exceptionpublic final void update(List<Entity> entities) throws CancelException, ValidationException, DatabaseException
update
in interface EntityTableModel
entities
- the Entities to update
CancelException
- in case the user cancels the operation
ValidationException
- in case validation fails
DatabaseException
- in case of a database exception
RecordModifiedException
- in case an entity was modified by another userEntity.Validator.validate(java.util.Collection, int)
public final Map<String,Collection<Entity>> getSelectionDependencies()
getSelectionDependencies
in interface EntityTableModel
public final PropertySummaryModel getPropertySummaryModel(String propertyID)
propertyID
getPropertySummaryModel
in interface EntityTableModel
propertyID
- the ID of the property
public final PropertySummaryModel getPropertySummaryModel(Property property)
getPropertySummaryModel
in interface EntityTableModel
property
- the property
public final Iterator<Entity> getSelectedEntitiesIterator()
getSelectedEntitiesIterator
in interface EntityTableModel
EntityTableModel.getReportDataSource()
public final SortingDirective getSortingDirective(String propertyID)
getSortingDirective
in interface EntityTableModel
propertyID
- the propertyID
public final void setSortingDirective(String propertyID, SortingDirective directive, boolean addColumnToSort)
setSortingDirective
in interface EntityTableModel
propertyID
- the propertyIDdirective
- the sorting directiveaddColumnToSort
- if false then the sorting state is cleared, otherwise
this column is added to the sorted column set according to getSortingPriority()
protected final void doRefresh()
doRefresh
in class AbstractFilteredTableModel<Entity,Property>
protected List<Entity> performQuery(Criteria<Property.ColumnProperty> criteria)
criteria
- a criteria
getQueryCriteria()
protected final Class getColumnClass(Property columnIdentifier)
getColumnClass
in class AbstractFilteredTableModel<Entity,Property>
columnIdentifier
- the column identifier
protected final Comparable getComparable(Object object, Property columnIdentifier)
getComparable
in class AbstractFilteredTableModel<Entity,Property>
object
- the valuecolumnIdentifier
- the column identifier
protected final String getSearchValueAt(int rowIndex, Property columnIdentifier)
getSearchValueAt
in class AbstractFilteredTableModel<Entity,Property>
rowIndex
- the row indexcolumnIdentifier
- the column identifier
protected final Criteria<Property.ColumnProperty> getQueryCriteria()
getSearchCriteria()
method
found in the underlying EntityTableSearchModelEntityTableSearchModel.getSearchCriteria()
protected void handleDelete(DeleteEvent event)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |