Interface EntityTableModel<E extends EntityEditModel>

    • Field Detail

      • QUERY_HIDDEN_COLUMNS

        static final PropertyValue<Boolean> QUERY_HIDDEN_COLUMNS
        Specifies whether the values of hidden columns are included in the underlying query
        Value type: Boolean
        Default value: true
      • ORDER_QUERY_BY_SORT_ORDER

        static final PropertyValue<Boolean> ORDER_QUERY_BY_SORT_ORDER
        Specifies whether the table model sort order is used as a basis for the query order by clause. Note that this only applies to column properties. Value type: Boolean
        Default value: false
    • Method Detail

      • entityType

        EntityType entityType()
        Returns:
        the type of the entity this table model is based on
      • connectionProvider

        EntityConnectionProvider connectionProvider()
        Returns:
        the connection provider used by this table model
      • entities

        Entities entities()
        Returns:
        the underlying domain entities
      • entityDefinition

        EntityDefinition entityDefinition()
        Returns:
        the definition of the underlying entity
      • editModel

        E editModel()
        Returns the EntityEditModel associated with this table model
        Returns:
        the edit model associated with this table model
      • setForeignKeyConditionValues

        void setForeignKeyConditionValues​(ForeignKey foreignKey,
                                          Collection<Entity> foreignKeyValues)
        Sets foreignKeyValues as the search condition values for the given foreign key and refreshes this table model.
        Parameters:
        foreignKey - the foreign key
        foreignKeyValues - the entities to use as condition values
      • replaceForeignKeyValues

        void replaceForeignKeyValues​(EntityType foreignKeyEntityType,
                                     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.
        Parameters:
        foreignKeyEntityType - the entityType of the foreign key values
        foreignKeyValues - the foreign key entities
      • addEntities

        void addEntities​(Collection<Entity> entities)
        Adds the given entities to the bottom of 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.
        Parameters:
        entities - the entities to add
      • addEntitiesSorted

        void addEntitiesSorted​(Collection<Entity> entities)
        Adds the given entities to the bottom of this table model and then, if sorting is enabled, sorts 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.
        Parameters:
        entities - the entities to add
      • addEntitiesAt

        void addEntitiesAt​(int index,
                           Collection<Entity> entities)
        Adds the given entities to the top of 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.
        Parameters:
        index - the index at which to add
        entities - the entities to add
      • addEntitiesAtSorted

        void addEntitiesAtSorted​(int index,
                                 Collection<Entity> entities)
        Adds the given entities to the top of this table model and then, if sorting is enabled, sorts 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.
        Parameters:
        index - the index at which to add
        entities - the entities to add
      • replaceEntities

        void replaceEntities​(Collection<Entity> entities)
        Replaces the given entities in this table model
        Parameters:
        entities - the entities to replace
      • refreshEntities

        void refreshEntities​(List<Key> keys)
        Refreshes the entities with the given keys by re-selecting them from the underlying database.
        Parameters:
        keys - the keys of the entities to refresh
      • isEditable

        boolean isEditable()
        Returns:
        true if this table model is editable
      • setEditable

        void setEditable​(boolean editable)
        Parameters:
        editable - true if this table model should be editable
      • isDeleteEnabled

        boolean isDeleteEnabled()
        Returns:
        true if the underlying edit model allows deletion of records
      • isReadOnly

        boolean isReadOnly()
        Returns:
        true if the underlying edit model is read only
      • isUpdateEnabled

        boolean isUpdateEnabled()
        Returns:
        true if the underlying edit model allows updating of records
      • isBatchUpdateEnabled

        boolean isBatchUpdateEnabled()
        Returns:
        true if multiple entities can be updated at a time
      • setBatchUpdateEnabled

        void setBatchUpdateEnabled​(boolean batchUpdateEnabled)
        Parameters:
        batchUpdateEnabled - true if this model should enable multiple entities to be updated at a time
      • backgroundColor

        Object backgroundColor​(int row,
                               Attribute<?> attribute)
        Parameters:
        row - the row for which to retrieve the background color
        attribute - the attribute for which to retrieve the background color
        Returns:
        an Object representing the background color for this row and attribute, specified by the row entity
        See Also:
        EntityDefinition.Builder.backgroundColorProvider(ColorProvider)
      • foregroundColor

        Object foregroundColor​(int row,
                               Attribute<?> attribute)
        Parameters:
        row - the row for which to retrieve the foreground color
        attribute - the attribute for which to retrieve the foreground color
        Returns:
        an Object representing the foreground color for this row and attribute, specified by the row entity
        See Also:
        EntityDefinition.Builder.foregroundColorProvider(ColorProvider)
      • getLimit

        int getLimit()
        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
        Returns:
        the fetch count
      • setLimit

        void setLimit​(int limit)
        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
        Parameters:
        limit - the fetch count
      • isQueryHiddenColumns

        boolean isQueryHiddenColumns()
        Returns whether the values of hidden columns are included when querying data
        Returns:
        true if the values of hidden columns are included when querying data
      • setQueryHiddenColumns

        void setQueryHiddenColumns​(boolean queryHiddenColumns)
        Parameters:
        queryHiddenColumns - true if the values of hidden columns should be included when querying data
        See Also:
        QUERY_HIDDEN_COLUMNS
      • isOrderQueryBySortOrder

        boolean isOrderQueryBySortOrder()
        Specifies whether the current sort order is used as a basis for the query order by clause. Note that this only applies to column properties.
        Returns:
        true if the current sort order should be used as a basis for the query order by clause
      • setOrderQueryBySortOrder

        void setOrderQueryBySortOrder​(boolean orderQueryBySortOrder)
        Specifies whether the current sort order is used as a basis for the query order by clause. Note that this only applies to column properties.
        Parameters:
        orderQueryBySortOrder - true if the current sort order should be used as a basis for the query order by clause
      • queryConditionRequiredState

        State queryConditionRequiredState()
        Returns a State controlling whether this table model should display all underlying entities when no query condition has been set. Setting this value to 'true' prevents all records from being fetched by accident, when no condition has been set, which is recommended for tables with a large underlying dataset.
        Returns:
        a State specifying whether this table model requires a query condition
      • isRemoveDeletedEntities

        boolean isRemoveDeletedEntities()
        Returns:
        true if entities that are deleted via the associated edit model should be automatically removed from this table model
      • setRemoveDeletedEntities

        void setRemoveDeletedEntities​(boolean removeDeletedEntities)
        Parameters:
        removeDeletedEntities - true if entities that are deleted via the associated edit model should be automatically removed from this table model
      • getInsertAction

        EntityTableModel.InsertAction getInsertAction()
        Returns:
        the action performed when entities are inserted via the associated edit model
      • setInsertAction

        void setInsertAction​(EntityTableModel.InsertAction insertAction)
        Parameters:
        insertAction - the action to perform when entities are inserted via the associated edit model
      • entitiesByKey

        Collection<Entity> entitiesByKey​(Collection<Key> keys)
        Finds entities according to the values in keys
        Parameters:
        keys - the primary key values to use as condition
        Returns:
        the entities having the primary key values as in keys
      • selectByKey

        void selectByKey​(Collection<Key> keys)
        Sets the selected entities according to the primary keys in primaryKeys
        Parameters:
        keys - the primary keys of the entities to select
      • selectedEntitiesIterator

        Iterator<Entity> selectedEntitiesIterator()
        Returns an Iterator which iterates through the selected entities
        Returns:
        the iterator used when generating reports
      • entityByKey

        Entity entityByKey​(Key primaryKey)
        Parameters:
        primaryKey - the primary key to search by
        Returns:
        the entity with the given primary key from the table model, null if it's not found
      • indexOf

        int indexOf​(Key primaryKey)
        Parameters:
        primaryKey - the primary key
        Returns:
        the row index of the entity with the given primary key, -1 if not found
      • savePreferences

        void savePreferences()
        Saves any user preferences
      • setVisibleColumns

        void setVisibleColumns​(Attribute<?>... attributes)
        Arranges the column model so that only the given columns are visible and in the given order
        Parameters:
        attributes - the column attributes
      • setVisibleColumns

        void setVisibleColumns​(List<Attribute<?>> attributes)
        Arranges the column model so that only the given columns are visible and in the given order
        Parameters:
        attributes - the column attributes
      • tableDataAsDelimitedString

        String tableDataAsDelimitedString​(char delimiter)
        Parameters:
        delimiter - the delimiter
        Returns:
        the table data as a tab delimited string, with column names as a header
      • clear

        void clear()
        Clears all items from this table model
      • getRowCount

        int getRowCount()
        Returns:
        the number of visible rows in this table model
      • conditionChangedObserver

        StateObserver conditionChangedObserver()
        Returns:
        a StateObserver indicating if the search condition has changed since last refresh
      • addSelectionChangedListener

        void addSelectionChangedListener​(EventListener listener)
        Parameters:
        listener - notified when the selection changes in the underlying selection model
      • setRefreshOnForeignKeyConditionValuesSet

        void setRefreshOnForeignKeyConditionValuesSet​(boolean refreshOnForeignKeyConditionValuesSet)
        Parameters:
        refreshOnForeignKeyConditionValuesSet - true if this table model should automatically refresh when foreign key condition values are set
        See Also:
        setForeignKeyConditionValues(ForeignKey, Collection)