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 ofDataChangeHandler
to handle data updates.- Since:
- 1.6
-
-
Field Summary
Fields Modifier and Type Field Description protected Set<Integer>
changedColumns
The column indexes of columns that contain dirty cells.protected Set<Integer>
changedRows
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
Constructors Constructor Description UpdateDataChangeHandler(DataChangeLayer layer, CellKeyHandler<?> keyHandler, Map<Object,T> dataChanges)
Creates anPersistenceUpdateDataChangeHandler
to handleDataUpdateEvent
s to be able to track and revert data changes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearDataChanges()
Clear the locally stored changes.void
handleColumnDelete(Collection<StructuralDiff> columnDiffs)
Will check for events that indicate that columns have been deleted.void
handleColumnInsert(Collection<StructuralDiff> columnDiffs)
Will check for events that indicate that columns are added.void
handleStructuralChange(IStructuralChangeEvent structuralChangeEvent)
Trigger handling ofIStructuralChangeEvent
s to update locally stored changes, e.g.boolean
isCellDirty(int columnPosition, int rowPosition)
Checks if the cell at the given position is dirty.boolean
isColumnDirty(int columnPosition)
Checks if the column with the given position contains cells in a dirty state.boolean
isRowDirty(int rowPosition)
Checks if the row with the given position contains cells in a dirty state.protected void
rebuildPositionCollections()
Rebuilds thechangedColumns
andchangedRows
collections based on the updatedAbstractDataChangeHandler.dataChanges
map.protected void
removeChangesForDeletedColumnObjects()
Iterates over the locally stored data changes and checks if the referenced object does still exist.protected void
removeChangesForDeletedRowObjects()
void
setUpdateOnHorizontalChanges(boolean update)
Configure if the changes tracked by theDataChangeLayer
should also be updated on a horizontal/column structural changes.void
setUpdateOnVerticalChanges(boolean update)
Configure if the changes tracked by theDataChangeLayer
should also be updated on a vertical/row structural changes.-
Methods inherited from class org.eclipse.nebula.widgets.nattable.datachange.AbstractDataChangeHandler
disableTracking, enableTracking, getDataChanges, getKeyHandler
-
-
-
-
Constructor Detail
-
UpdateDataChangeHandler
public UpdateDataChangeHandler(DataChangeLayer layer, CellKeyHandler<?> keyHandler, Map<Object,T> dataChanges)
Creates anPersistenceUpdateDataChangeHandler
to handleDataUpdateEvent
s to be able to track and revert data changes.- Parameters:
layer
- TheDataChangeLayer
this handler should be assigned to.keyHandler
- TheCellKeyHandler
that is used to store data changes for a specific key.dataChanges
- The map to track the data changes locally.
-
-
Method Detail
-
handleStructuralChange
public void handleStructuralChange(IStructuralChangeEvent structuralChangeEvent)
Description copied from interface:DataChangeHandler
Trigger handling ofIStructuralChangeEvent
s 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
public void handleColumnDelete(Collection<StructuralDiff> columnDiffs)
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 ofStructuralDiff
s to handle.
-
handleColumnInsert
public void handleColumnInsert(Collection<StructuralDiff> columnDiffs)
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 ofStructuralDiff
s to handle.
-
clearDataChanges
public void clearDataChanges()
Clear the locally stored changes.- Specified by:
clearDataChanges
in interfaceDataChangeHandler
- Overrides:
clearDataChanges
in 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
CellKeyHandler
implementations 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 thechangedColumns
andchangedRows
collections based on the updatedAbstractDataChangeHandler.dataChanges
map.
-
isColumnDirty
public boolean isColumnDirty(int columnPosition)
Description copied from interface:DataChangeHandler
Checks 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:
true
if the column contains cells that are marked as dirty (data has changed and not saved yet),false
if not.
-
isRowDirty
public boolean isRowDirty(int rowPosition)
Description copied from interface:DataChangeHandler
Checks 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:
true
if the row contains cells that are marked as dirty (data has changed and not saved yet),false
if not.
-
isCellDirty
public boolean isCellDirty(int columnPosition, int rowPosition)
Description copied from interface:DataChangeHandler
Checks 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:
true
if the cell is dirty (data has changed and not saved yet),false
if not.
-
setUpdateOnHorizontalChanges
public void setUpdateOnHorizontalChanges(boolean update)
Configure if the changes tracked by theDataChangeLayer
should also be updated on a horizontal/column structural changes. The update is needed in case the change does not cause aDataChange
that is created by some other handler and performed in the correct order.- Parameters:
update
-true
if the changes tracked by theDataChangeLayer
should be updated,false
if not.
-
setUpdateOnVerticalChanges
public void setUpdateOnVerticalChanges(boolean update)
Configure if the changes tracked by theDataChangeLayer
should also be updated on a vertical/row structural changes. The update is needed in case the change does not cause aDataChange
that is created by some other handler and performed in the correct order.- Parameters:
update
-true
if the changes tracked by theDataChangeLayer
should be updated,false
if not.
-
-