org.eclipse.nebula.widgets.nattable.layer.event
Class StructuralChangeEventHelper

java.lang.Object
  extended by org.eclipse.nebula.widgets.nattable.layer.event.StructuralChangeEventHelper

public class StructuralChangeEventHelper
extends Object

Helper class providing support for modifying cached index lists for IStructuralChangeEvents.


Constructor Summary
StructuralChangeEventHelper()
           
 
Method Summary
static void handleColumnDelete(Collection<StructuralDiff> columnDiffs, ILayer underlyingLayer, Collection<Integer> cachedColumnIndexes, boolean handleNotFound)
          Will check for events that indicate that columns has been deleted.
static void handleColumnInsert(Collection<StructuralDiff> columnDiffs, ILayer underlyingLayer, Collection<Integer> cachedColumnIndexes, boolean addToCache)
          Will check for events that indicate that columns are added.
static void handleRowDelete(Collection<StructuralDiff> rowDiffs, ILayer underlyingLayer, Collection<Integer> cachedRowIndexes, boolean handleNotFound)
          Will check for events that indicate that rows has been deleted.
static void handleRowInsert(Collection<StructuralDiff> rowDiffs, ILayer underlyingLayer, Collection<Integer> cachedRowIndexes, boolean addToCache)
          Will check for events that indicate that rows are added.
static boolean isReorder(Collection<StructuralDiff> structuralDiffs)
          Method to indicate if the collection of StructuralDiffs marks a reorder event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StructuralChangeEventHelper

public StructuralChangeEventHelper()
Method Detail

handleRowDelete

public static void handleRowDelete(Collection<StructuralDiff> rowDiffs,
                                   ILayer underlyingLayer,
                                   Collection<Integer> cachedRowIndexes,
                                   boolean handleNotFound)
Will check for events that indicate that rows has been deleted. In that case the given cached indexes for the given layer need to be updated because the index of the rows might have changed. E.g. Row with index 3 is hidden in the given layer, deleting row at index 1 will cause the row at index 3 to be moved at index 2. Without transforming the index regarding the delete event, the wrong row would be hidden.

Parameters:
rowDiffs - The collection of StructuralDiffs to handle
underlyingLayer - The underlying layer of the layer who caches the indexes. Needed to translate the transported row positions to indexes, because the conversion to the layer who caches the index is done before it is fired further in the layer stack
cachedRowIndexes - The collection of indexes that is cached by the layer that needs transformation
handleNotFound - flag to tell whether the not found row indexes should be taken into account or not. Needed for last row checks

handleRowInsert

public static void handleRowInsert(Collection<StructuralDiff> rowDiffs,
                                   ILayer underlyingLayer,
                                   Collection<Integer> cachedRowIndexes,
                                   boolean addToCache)
Will check for events that indicate that rows are added. In that case the given cached indexes need to be updated because the index of the rows might have changed. E.g. Row with index 3 is hidden in the given layer, adding a row at index 1 will cause the row at index 3 to be moved to index 4. Without transforming the index regarding the add event, the wrong row would be hidden.

Parameters:
rowDiffs - The collection of StructuralDiffs to handle
underlyingLayer - The underlying layer of the layer who caches the indexes. Needed to translate the transported row positions to indexes, because the conversion to the layer who caches the index is done before it is fired further in the layer stack
cachedRowIndexes - The collection of indexes that is cached by the layer that needs transformation
addToCache - Flag to configure if the added value should be added to the cache or not. This is necessary to differ whether cachedRowIndexes are a collection of all indexes that need to be updated (e.g. row reordering) or just a collection of indexes that are applied for a specific state (e.g. row hide state)

handleColumnDelete

public static void handleColumnDelete(Collection<StructuralDiff> columnDiffs,
                                      ILayer underlyingLayer,
                                      Collection<Integer> cachedColumnIndexes,
                                      boolean handleNotFound)
Will check for events that indicate that columns has been deleted. In that case the given cached indexes for the given layer 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, deleting column at index 1 will cause the column at index 3 to be moved at index 2. Without transforming the index regarding the delete event, the wrong column would be hidden.

Parameters:
columnDiffs - The collection of StructuralDiffs to handle
underlyingLayer - The underlying layer of the layer who caches the indexes. Needed to translate the transported column positions to indexes, because the conversion to the layer who caches the index is done before it is fired further in the layer stack
cachedColumnIndexes - The collection of indexes that is cached by the layer that needs transformation
handleNotFound - flag to tell whether the not found column indexes should be taken into account or not. Needed for last column checks

handleColumnInsert

public static void handleColumnInsert(Collection<StructuralDiff> columnDiffs,
                                      ILayer underlyingLayer,
                                      Collection<Integer> cachedColumnIndexes,
                                      boolean addToCache)
Will check for events that indicate that columns are added. In that case the given cached indexes 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 of StructuralDiffs to handle
underlyingLayer - The underlying layer of the layer who caches the indexes. Needed to translate the transported column positions to indexes, because the conversion to the layer who caches the index is done before it is fired further in the layer stack
cachedColumnIndexes - The collection of indexes that is cached by the layer that needs transformation
addToCache - Flag to configure if the added value should be added to the cache or not. This is necessary to differ whether cachedColumnIndexes are a collection of all indexes that need to be updated (e.g. column reordering) or just a collection of indexes that are applied for a specific state (e.g. column hide state)

isReorder

public static boolean isReorder(Collection<StructuralDiff> structuralDiffs)
Method to indicate if the collection of StructuralDiffs marks a reorder event. This is necessary because reordering itself contains out of two diffs, one for deleting columns/rows, one for adding them at another position. As these diffs are completely separated from each other, but the handling does have impact, this check is added. Also on reordering there is no need for special handling of diffs in the layers that call this method.

Here is a small example to explain the impact on handling:

Parameters:
structuralDiffs - The collection of StructuralDiffs to check for reordering
Returns:
true if the diff indicates a reordering happened, false if if was not a reordering based on the explanation above.


Copyright © 2015. All rights reserved.