Class UpdateDataChangeHandler<T extends UpdateDataChange>
java.lang.Object
org.eclipse.nebula.widgets.nattable.datachange.AbstractDataChangeHandler<T>
org.eclipse.nebula.widgets.nattable.datachange.UpdateDataChangeHandler<T>
- All Implemented Interfaces:
DataChangeHandler
- Direct Known Subclasses:
PersistenceUpdateDataChangeHandler,TemporaryUpdateDataChangeHandler
public abstract class UpdateDataChangeHandler<T extends UpdateDataChange>
extends AbstractDataChangeHandler<T>
Abstract implementation of
DataChangeHandler to handle data updates.- Since:
- 1.6
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe column indexes of columns that contain dirty cells.The row indexes of rows that contain dirty cells.Fields inherited from class org.eclipse.nebula.widgets.nattable.datachange.AbstractDataChangeHandler
dataChanges, handleDataUpdate, keyHandler, layer -
Constructor Summary
ConstructorsConstructorDescriptionUpdateDataChangeHandler(DataChangeLayer layer, CellKeyHandler<?> keyHandler, Map<Object, T> dataChanges) Creates anPersistenceUpdateDataChangeHandlerto handleDataUpdateEvents to be able to track and revert data changes. -
Method Summary
Modifier and TypeMethodDescriptionvoidClear the locally stored changes.voidhandleColumnDelete(Collection<StructuralDiff> columnDiffs) Will check for events that indicate that columns have been deleted.voidhandleColumnInsert(Collection<StructuralDiff> columnDiffs) Will check for events that indicate that columns are added.voidhandleStructuralChange(IStructuralChangeEvent structuralChangeEvent) Trigger handling ofIStructuralChangeEvents to update locally stored changes, e.g.booleanisCellDirty(int columnPosition, int rowPosition) Checks if the cell at the given position is dirty.booleanisColumnDirty(int columnPosition) Checks if the column with the given position contains cells in a dirty state.booleanisDirty()Checks if there is a dirty state tracked by this handler.booleanisRowDirty(int rowPosition) Checks if the row with the given position contains cells in a dirty state.protected voidRebuilds thechangedColumnsandchangedRowscollections based on the updatedAbstractDataChangeHandler.dataChangesmap.protected voidIterates over the locally stored data changes and checks if the referenced object does still exist.protected voidvoidsetUpdateOnHorizontalChanges(boolean update) Configure if the changes tracked by theDataChangeLayershould also be updated on a horizontal/column structural changes.voidsetUpdateOnVerticalChanges(boolean update) Configure if the changes tracked by theDataChangeLayershould also be updated on a vertical/row structural changes.Methods inherited from class org.eclipse.nebula.widgets.nattable.datachange.AbstractDataChangeHandler
disableTracking, enableTracking, getDataChanges, getKeyHandler
-
Field Details
-
changedColumns
The column indexes of columns that contain dirty cells. -
changedRows
The row indexes of rows that contain dirty cells.
-
-
Constructor Details
-
UpdateDataChangeHandler
public UpdateDataChangeHandler(DataChangeLayer layer, CellKeyHandler<?> keyHandler, Map<Object, T> dataChanges) Creates anPersistenceUpdateDataChangeHandlerto handleDataUpdateEvents to be able to track and revert data changes.- Parameters:
layer- TheDataChangeLayerthis handler should be assigned to.keyHandler- TheCellKeyHandlerthat is used to store data changes for a specific key.dataChanges- The map to track the data changes locally.
-
-
Method Details
-
handleStructuralChange
Description copied from interface:DataChangeHandlerTrigger handling ofIStructuralChangeEvents to update locally stored changes, e.g. update the row index of a key in case a row above was inserted or deleted.- Parameters:
structuralChangeEvent- The event to handle.
-
handleColumnDelete
Will check for events that indicate that columns have been deleted. In that case the cached dataChanges need to be updated because the index of the columns might have changed. E.g. cell with column at index 3 is changed in the given layer, deleting column at index 1 will cause the column at index 3 to be moved to index 2. Without transforming the index regarding the delete event, the wrong cell at the incorrect column would be shown as changed.- Parameters:
columnDiffs- The collection ofStructuralDiffs to handle.
-
handleColumnInsert
Will check for events that indicate that columns are added. In that case the cached dataChanges need to be updated because the index of the columns might have changed. E.g. column with index 3 is hidden in the given layer, adding a column at index 1 will cause the column at index 3 to be moved to index 4. Without transforming the index regarding the add event, the wrong column would be hidden.- Parameters:
columnDiffs- The collection ofStructuralDiffs to handle.
-
clearDataChanges
public void clearDataChanges()Clear the locally stored changes.- Specified by:
clearDataChangesin interfaceDataChangeHandler- Overrides:
clearDataChangesin classAbstractDataChangeHandler<T extends UpdateDataChange>
-
removeChangesForDeletedColumnObjects
protected void removeChangesForDeletedColumnObjects()Iterates over the locally stored data changes and checks if the referenced object does still exist. If not the data change is removed.This method is intended to be used with
CellKeyHandlerimplementations whose created keys do not need to be updated on structural changes as they update automatically, e.g. via unique identifier. -
removeChangesForDeletedRowObjects
protected void removeChangesForDeletedRowObjects() -
rebuildPositionCollections
protected void rebuildPositionCollections()Rebuilds thechangedColumnsandchangedRowscollections based on the updatedAbstractDataChangeHandler.dataChangesmap. -
isColumnDirty
public boolean isColumnDirty(int columnPosition) Description copied from interface:DataChangeHandlerChecks if the column with the given position contains cells in a dirty state.- Parameters:
columnPosition- The position of the column whose dirty state should be checked.- Returns:
trueif the column contains cells that are marked as dirty (data has changed and not saved yet),falseif not.
-
isRowDirty
public boolean isRowDirty(int rowPosition) Description copied from interface:DataChangeHandlerChecks if the row with the given position contains cells in a dirty state.- Parameters:
rowPosition- The position of the row whose dirty state should be checked.- Returns:
trueif the row contains cells that are marked as dirty (data has changed and not saved yet),falseif not.
-
isCellDirty
public boolean isCellDirty(int columnPosition, int rowPosition) Description copied from interface:DataChangeHandlerChecks if the cell at the given position is dirty.- Parameters:
columnPosition- The column position of the cell whose dirty state should be checked.rowPosition- The row position of the cell whose dirty state should be checked.- Returns:
trueif the cell is dirty (data has changed and not saved yet),falseif not.
-
isDirty
public boolean isDirty()Description copied from interface:DataChangeHandlerChecks if there is a dirty state tracked by this handler.- Returns:
trueif there is a dirty state (data has changed and not saved yet),falseif not.
-
setUpdateOnHorizontalChanges
public void setUpdateOnHorizontalChanges(boolean update) Configure if the changes tracked by theDataChangeLayershould also be updated on a horizontal/column structural changes. The update is needed in case the change does not cause aDataChangethat is created by some other handler and performed in the correct order.- Parameters:
update-trueif the changes tracked by theDataChangeLayershould be updated,falseif not.
-
setUpdateOnVerticalChanges
public void setUpdateOnVerticalChanges(boolean update) Configure if the changes tracked by theDataChangeLayershould also be updated on a vertical/row structural changes. The update is needed in case the change does not cause aDataChangethat is created by some other handler and performed in the correct order.- Parameters:
update-trueif the changes tracked by theDataChangeLayershould be updated,falseif not.
-