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
FieldsModifier and TypeFieldDescriptionprotected final List<DataChangeHandler>TheDataChangeHandlerregistered with thisDataChangeLayerto keep track of data changes.protected final List<DataChange>The list ofDataChanges that need to be handled on save or discard.static final StringLabel 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, layerPainterFields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR -
Constructor Summary
ConstructorsConstructorDescriptionDataChangeLayer(IUniqueIndexLayer underlyingLayer, CellKeyHandler<?> keyHandler, boolean temporaryDataStorage) Create a newDataChangeLayerthat does not track row structural changes and uses the default configuration.DataChangeLayer(IUniqueIndexLayer underlyingLayer, CellKeyHandler<?> keyHandler, boolean temporaryDataStorage, boolean trackRowStructuralChanges) Create a newDataChangeLayerthat uses the default configuration.DataChangeLayer(IUniqueIndexLayer underlyingLayer, CellKeyHandler<?> keyHandler, boolean temporaryDataStorage, boolean trackRowStructuralChanges, boolean useDefaultConfiguration) Create a newDataChangeLayer. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDataChange(DataChange change) Adds aDataChangeto the list of locally tracked data changes that need to be handled on save or discard.voidClear the locally stored changes.voidDiscards 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.voidhandleLayerEvent(ILayerEvent event) Handle layer event notification.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.booleanisRowDirty(int rowPosition) Checks if the row with the given position contains cells in a dirty state.protected voidLayers should use this method to register their command handlers and call it from their constructor.final voidRegisters the givenDataChangeHandlerto keep track of data changes.voidSaves the tracked data changes.final voidUnregisters 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, underlyingToLocalRowPositionsMethods 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, unregisterPersistableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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
TheDataChangeHandlerregistered with thisDataChangeLayerto keep track of data changes. -
dataChanges
The list ofDataChanges that need to be handled on save or discard.
-
-
Constructor Details
-
DataChangeLayer
public DataChangeLayer(IUniqueIndexLayer underlyingLayer, CellKeyHandler<?> keyHandler, boolean temporaryDataStorage) Create a newDataChangeLayerthat does not track row structural changes and uses the default configuration.- Parameters:
underlyingLayer- TheILayeron top of which thisDataChangeLayershould be created. Typically theDataLayer.keyHandler- TheCellKeyHandlerthat should be used to store dataChanges for a specific key.temporaryDataStorage-trueif the data changes should be handled temporary in this layer and update the model on save,falseif 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 newDataChangeLayerthat uses the default configuration.- Parameters:
underlyingLayer- TheILayeron top of which thisDataChangeLayershould be created. Typically theDataLayer.keyHandler- TheCellKeyHandlerthat should be used to store dataChanges for a specific key.temporaryDataStorage-trueif the data changes should be handled temporary in this layer and update the model on save,falseif the data changes should be directly applied to the underlying model and on save some additional save operations should be performed.trackRowStructuralChanges-trueif structural changes like inserting or deleting a row should be tracked,falseif such changes should not be tracked.
-
DataChangeLayer
public DataChangeLayer(IUniqueIndexLayer underlyingLayer, CellKeyHandler<?> keyHandler, boolean temporaryDataStorage, boolean trackRowStructuralChanges, boolean useDefaultConfiguration) Create a newDataChangeLayer.- Parameters:
underlyingLayer- TheILayeron top of which thisDataChangeLayershould be created. Typically theDataLayer.keyHandler- TheCellKeyHandlerthat should be used to store dataChanges for a specific key.temporaryDataStorage-trueif the data changes should be handled temporary in this layer and update the model on save,falseif the data changes should be directly applied to the underlying model and on save some additional save operations should be performed.trackRowStructuralChanges-trueif structural changes like inserting or deleting a row should be tracked,falseif such changes should not be tracked.useDefaultConfiguration-trueif the default configuration should be applied,falseif not.
-
-
Method Details
-
registerCommandHandlers
protected void registerCommandHandlers()Description copied from class:AbstractLayerLayers 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:
registerCommandHandlersin classAbstractLayer
-
getConfigLabelsByPosition
Description copied from interface:ILayerReturns the config labels for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of theIConfigRegistry.- Specified by:
getConfigLabelsByPositionin interfaceILayer- Overrides:
getConfigLabelsByPositionin classAbstractIndexLayerTransform- Parameters:
columnPosition- The column position of the cell.rowPosition- The row position of the cell.- Returns:
- The
LabelStackwith the config labels for the cell at the given coordinates.
-
getDataValueByPosition
Description copied from interface:ILayerReturns the data value for the cell at the given coordinates.- Specified by:
getDataValueByPositionin interfaceILayer- Overrides:
getDataValueByPositionin 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:AbstractLayerHandle 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:
handleLayerEventin interfaceILayerListener- Overrides:
handleLayerEventin classAbstractLayer- Parameters:
event- the event
-
registerDataChangeHandler
Registers the givenDataChangeHandlerto keep track of data changes.- Parameters:
handler- TheDataChangeHandlerto register.
-
unregisterDataChangeHandler
Unregisters the givenDataChangeHandler.- Parameters:
handler- TheDataChangeHandlerto unregister.
-
getDataChangeHandler
- Returns:
- The
DataChangeHandlerregistered with thisDataChangeLayerto keep track of data changes.
-
addDataChange
Adds aDataChangeto the list of locally tracked data changes that need to be handled on save or discard.- Parameters:
change- TheDataChangeto add.
-
getDataChanges
- Returns:
- The list of
DataChanges 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 dedicatedUpdateDataCommands. -
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
SaveDataChangesCommandHandlershould 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:
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) 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:
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) 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:
trueif the cell is dirty (data has changed and not saved yet),falseif not.
-
isDirty
public boolean isDirty()Checks if there is a dirty state.- Returns:
trueif there is a dirty state (data has changed and not saved yet),falseif not.- Since:
- 2.4
-
getProvidedLabels
- Specified by:
getProvidedLabelsin interfaceILayer- Overrides:
getProvidedLabelsin classAbstractLayer- Returns:
- The collection of labels that are provided by this layer.
-