Class DataChangeLayer

All Implemented Interfaces:
ILayer, ILayerListener, IUniqueIndexLayer, IPersistable

public class DataChangeLayer extends AbstractIndexLayerTransform
ILayer that can be used to add a mechanism that highlights cells whose data has been changed.
Since:
1.6
  • Field Details

  • Constructor Details

    • DataChangeLayer

      public DataChangeLayer(IUniqueIndexLayer underlyingLayer, CellKeyHandler<?> keyHandler, boolean temporaryDataStorage)
      Create a new DataChangeLayer that does not track row structural changes and uses the default configuration.
      Parameters:
      underlyingLayer - The ILayer on top of which this DataChangeLayer should be created. Typically the DataLayer.
      keyHandler - The CellKeyHandler 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 new DataChangeLayer that uses the default configuration.
      Parameters:
      underlyingLayer - The ILayer on top of which this DataChangeLayer should be created. Typically the DataLayer.
      keyHandler - The CellKeyHandler 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 new DataChangeLayer.
      Parameters:
      underlyingLayer - The ILayer on top of which this DataChangeLayer should be created. Typically the DataLayer.
      keyHandler - The CellKeyHandler 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 class AbstractLayer
    • getConfigLabelsByPosition

      public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition)
      Description copied from interface: ILayer
      Returns the config labels for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of the IConfigRegistry.
      Specified by:
      getConfigLabelsByPosition in interface ILayer
      Overrides:
      getConfigLabelsByPosition in class AbstractIndexLayerTransform
      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

      public Object getDataValueByPosition(int columnPosition, int rowPosition)
      Description copied from interface: ILayer
      Returns the data value for the cell at the given coordinates.
      Specified by:
      getDataValueByPosition in interface ILayer
      Overrides:
      getDataValueByPosition in class AbstractIndexLayerTransform
      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

      public void handleLayerEvent(ILayerEvent event)
      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 calling super.fireLayerEvent(event) - unless you plan to eat the event yourself.
      Specified by:
      handleLayerEvent in interface ILayerListener
      Overrides:
      handleLayerEvent in class AbstractLayer
      Parameters:
      event - the event
    • registerDataChangeHandler

      public final void registerDataChangeHandler(DataChangeHandler handler)
      Registers the given DataChangeHandler to keep track of data changes.
      Parameters:
      handler - The DataChangeHandler to register.
    • unregisterDataChangeHandler

      public final void unregisterDataChangeHandler(DataChangeHandler handler)
      Unregisters the given DataChangeHandler.
      Parameters:
      handler - The DataChangeHandler to unregister.
    • getDataChangeHandler

      public final List<DataChangeHandler> getDataChangeHandler()
      Returns:
      The DataChangeHandler registered with this DataChangeLayer to keep track of data changes.
    • addDataChange

      public void addDataChange(DataChange change)
      Adds a DataChange to the list of locally tracked data changes that need to be handled on save or discard.
      Parameters:
      change - The DataChange to add.
    • getDataChanges

      public List<DataChange> 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 dedicated UpdateDataCommands.
    • 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

      public Collection<String> getProvidedLabels()
      Specified by:
      getProvidedLabels in interface ILayer
      Overrides:
      getProvidedLabels in class AbstractLayer
      Returns:
      The collection of labels that are provided by this layer.