Class DataChangeLayer
java.lang.Object
org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
org.eclipse.nebula.widgets.nattable.layer.AbstractIndexLayerTransform
org.eclipse.nebula.widgets.nattable.datachange.DataChangeLayer
- All Implemented Interfaces:
ILayer
,ILayerListener
,IUniqueIndexLayer
,IPersistable
ILayer
that can be used to add a mechanism that highlights cells
whose data has been changed.- Since:
- 1.6
-
Field Summary
Modifier and TypeFieldDescriptionprotected final List<DataChangeHandler>
TheDataChangeHandler
registered with thisDataChangeLayer
to keep track of data changes.protected final List<DataChange>
The list ofDataChange
s that need to be handled on save or discard.static final String
Label that is applied to cells that are marked as modified/dirty in this layer.Fields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
commandHandlers, eventHandlers, eventHelperLock, layerPainter
Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR
-
Constructor Summary
ConstructorDescriptionDataChangeLayer
(IUniqueIndexLayer underlyingLayer, CellKeyHandler<?> keyHandler, boolean temporaryDataStorage) Create a newDataChangeLayer
that does not track row structural changes and uses the default configuration.DataChangeLayer
(IUniqueIndexLayer underlyingLayer, CellKeyHandler<?> keyHandler, boolean temporaryDataStorage, boolean trackRowStructuralChanges) Create a newDataChangeLayer
that uses the default configuration.DataChangeLayer
(IUniqueIndexLayer underlyingLayer, CellKeyHandler<?> keyHandler, boolean temporaryDataStorage, boolean trackRowStructuralChanges, boolean useDefaultConfiguration) Create a newDataChangeLayer
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDataChange
(DataChange change) Adds aDataChange
to the list of locally tracked data changes that need to be handled on save or discard.void
Clear the locally stored changes.void
Discards the tracked data changes.getConfigLabelsByPosition
(int columnPosition, int rowPosition) Returns the config labels for the cell at the given coordinates.final List<DataChangeHandler>
getDataValueByPosition
(int columnPosition, int rowPosition) Returns the data value for the cell at the given coordinates.void
handleLayerEvent
(ILayerEvent event) Handle layer event notification.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
isDirty()
Checks if there is a dirty state.boolean
isRowDirty
(int rowPosition) Checks if the row with the given position contains cells in a dirty state.protected void
Layers should use this method to register their command handlers and call it from their constructor.final void
Registers the givenDataChangeHandler
to keep track of data changes.void
Saves the tracked data changes.final void
Unregisters the givenDataChangeHandler
.Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractIndexLayerTransform
configure, dispose, doCommand, getCellByPosition, getCellPainter, getColumnCount, getColumnIndexByPosition, getColumnPositionByIndex, getColumnPositionByX, getColumnWidthByPosition, getDisplayModeByPosition, getHeight, getLayerPainter, getPreferredColumnCount, getPreferredHeight, getPreferredRowCount, getPreferredWidth, getRegionLabelsByXY, getRowCount, getRowHeightByPosition, getRowIndexByPosition, getRowPositionByIndex, getRowPositionByY, getStartXOfColumnPosition, getStartYOfRowPosition, getUnderlyingLayer, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, getWidth, isColumnPositionResizable, isDynamicSizeLayer, isRowPositionResizable, loadState, localToUnderlyingColumnPosition, localToUnderlyingRowPosition, saveState, setClientAreaProvider, setUnderlyingLayer, underlyingToLocalColumnPosition, underlyingToLocalColumnPositions, underlyingToLocalRowPosition, underlyingToLocalRowPositions
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
addConfiguration, addLayerListener, clearConfiguration, fireLayerEvent, getBoundsByPosition, getClientAreaProvider, getConfigLabelAccumulator, getRegionName, hasLayerListener, registerCommandHandler, registerEventHandler, registerPersistable, removeLayerListener, setConfigLabelAccumulator, setLayerPainter, setRegionName, toString, unregisterCommandHandler, unregisterEventHandler, unregisterPersistable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.nebula.widgets.nattable.layer.ILayer
addLayerListener, fireLayerEvent, getBoundsByPosition, getClientAreaProvider, hasLayerListener, registerCommandHandler, registerPersistable, removeLayerListener, unregisterCommandHandler, unregisterPersistable
-
Field Details
-
DIRTY
Label that is applied to cells that are marked as modified/dirty in this layer.- See Also:
-
dataChangeHandler
TheDataChangeHandler
registered with thisDataChangeLayer
to keep track of data changes. -
dataChanges
The list ofDataChange
s that need to be handled on save or discard.
-
-
Constructor Details
-
DataChangeLayer
public DataChangeLayer(IUniqueIndexLayer underlyingLayer, CellKeyHandler<?> keyHandler, boolean temporaryDataStorage) Create a newDataChangeLayer
that does not track row structural changes and uses the default configuration.- Parameters:
underlyingLayer
- TheILayer
on top of which thisDataChangeLayer
should be created. Typically theDataLayer
.keyHandler
- TheCellKeyHandler
that should be used to store dataChanges for a specific key.temporaryDataStorage
-true
if the data changes should be handled temporary in this layer and update the model on save,false
if the data changes should be directly applied to the underlying model and on save some additional save operations should be performed.
-
DataChangeLayer
public DataChangeLayer(IUniqueIndexLayer underlyingLayer, CellKeyHandler<?> keyHandler, boolean temporaryDataStorage, boolean trackRowStructuralChanges) Create a newDataChangeLayer
that uses the default configuration.- Parameters:
underlyingLayer
- TheILayer
on top of which thisDataChangeLayer
should be created. Typically theDataLayer
.keyHandler
- TheCellKeyHandler
that should be used to store dataChanges for a specific key.temporaryDataStorage
-true
if the data changes should be handled temporary in this layer and update the model on save,false
if the data changes should be directly applied to the underlying model and on save some additional save operations should be performed.trackRowStructuralChanges
-true
if structural changes like inserting or deleting a row should be tracked,false
if such changes should not be tracked.
-
DataChangeLayer
public DataChangeLayer(IUniqueIndexLayer underlyingLayer, CellKeyHandler<?> keyHandler, boolean temporaryDataStorage, boolean trackRowStructuralChanges, boolean useDefaultConfiguration) Create a newDataChangeLayer
.- Parameters:
underlyingLayer
- TheILayer
on top of which thisDataChangeLayer
should be created. Typically theDataLayer
.keyHandler
- TheCellKeyHandler
that should be used to store dataChanges for a specific key.temporaryDataStorage
-true
if the data changes should be handled temporary in this layer and update the model on save,false
if the data changes should be directly applied to the underlying model and on save some additional save operations should be performed.trackRowStructuralChanges
-true
if structural changes like inserting or deleting a row should be tracked,false
if such changes should not be tracked.useDefaultConfiguration
-true
if the default configuration should be applied,false
if not.
-
-
Method Details
-
registerCommandHandlers
protected void registerCommandHandlers()Description copied from class:AbstractLayer
Layers should use this method to register their command handlers and call it from their constructor. This allows easy overriding if required of command handlers- Overrides:
registerCommandHandlers
in classAbstractLayer
-
getConfigLabelsByPosition
Description copied from interface:ILayer
Returns the config labels for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of theIConfigRegistry
.- Specified by:
getConfigLabelsByPosition
in interfaceILayer
- Overrides:
getConfigLabelsByPosition
in classAbstractIndexLayerTransform
- Parameters:
columnPosition
- The column position of the cell.rowPosition
- The row position of the cell.- Returns:
- The
LabelStack
with the config labels for the cell at the given coordinates.
-
getDataValueByPosition
Description copied from interface:ILayer
Returns the data value for the cell at the given coordinates.- Specified by:
getDataValueByPosition
in interfaceILayer
- Overrides:
getDataValueByPosition
in classAbstractIndexLayerTransform
- Parameters:
columnPosition
- The column position of the cell.rowPosition
- The row position of the cell.- Returns:
- The data value for the cell at the given coordinates.
-
handleLayerEvent
Description copied from class:AbstractLayer
Handle layer event notification. Convert it to your context and propagate UP. If you override this method you MUST NOT FORGET to raise the event up the layer stack by callingsuper.fireLayerEvent(event)
- unless you plan to eat the event yourself.- Specified by:
handleLayerEvent
in interfaceILayerListener
- Overrides:
handleLayerEvent
in classAbstractLayer
- Parameters:
event
- the event
-
registerDataChangeHandler
Registers the givenDataChangeHandler
to keep track of data changes.- Parameters:
handler
- TheDataChangeHandler
to register.
-
unregisterDataChangeHandler
Unregisters the givenDataChangeHandler
.- Parameters:
handler
- TheDataChangeHandler
to unregister.
-
getDataChangeHandler
- Returns:
- The
DataChangeHandler
registered with thisDataChangeLayer
to keep track of data changes.
-
addDataChange
Adds aDataChange
to the list of locally tracked data changes that need to be handled on save or discard.- Parameters:
change
- TheDataChange
to add.
-
getDataChanges
- Returns:
- The list of
DataChange
s that need to be handled on save or discard.
-
discardDataChanges
public void discardDataChanges()Discards the tracked data changes. In case temporary data storage is disabled, the applied changes are undone by restoring the previous values via dedicatedUpdateDataCommand
s. -
saveDataChanges
public void saveDataChanges()Saves the tracked data changes. In case temporary data storage is enabled this means the underlying data model is updated. Otherwise the stored data changes are simply cleared.Note: In case temporary data storage is disabled and a custom save operation should be performed on save, a custom
SaveDataChangesCommandHandler
should be registered that first performs a custom action and afterwards calls this method to ensure a clear state in this layer. -
clearDataChanges
public void clearDataChanges()Clear the locally stored changes. -
isColumnDirty
public boolean isColumnDirty(int columnPosition) 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) 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) 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.
-
isDirty
public boolean isDirty()Checks if there is a dirty state.- Returns:
true
if there is a dirty state (data has changed and not saved yet),false
if not.- Since:
- 2.4
-
getProvidedLabels
- Specified by:
getProvidedLabels
in interfaceILayer
- Overrides:
getProvidedLabels
in classAbstractLayer
- Returns:
- The collection of labels that are provided by this layer.
-