T
- The type of the objects shown within the NatTable. Needed to access the data columnwise.public class FilterRowComboBoxDataProvider<T> extends Object implements IComboBoxDataProvider, ILayerListener
On creating this IComboBoxDataProvider, the possible values for all columns will be calculated taking the whole data provided by the body IDataProvider into account. Therefore you shouldn't use this one if you show huge datasets at once.
As the values are cached in here, this IComboBoxDataProvider registers itself as ILayerListener to the body DataLayer. If values are updated or rows get added/deleted, it will update the cache accordingly.
Constructor and Description |
---|
FilterRowComboBoxDataProvider(ILayer bodyLayer,
Collection<T> baseCollection,
IColumnAccessor<T> columnAccessor) |
Modifier and Type | Method and Description |
---|---|
void |
addCacheUpdateListener(IFilterRowComboUpdateListener listener)
Adds the given listener to the list of listeners for value cache updates.
|
protected FilterRowComboUpdateEvent |
buildUpdateEvent(int columnIndex,
List<?> cacheBefore,
List<?> cacheAfter)
Creates a FilterRowComboUpdateEvent for the given column index.
|
protected void |
buildValueCache()
Builds the local value cache for all columns.
|
protected List<?> |
collectValues(int columnIndex)
Iterates over all rows of the local body IDataProvider and collects the unique
values for the given column index.
|
protected void |
fireCacheUpdateEvent(FilterRowComboUpdateEvent event)
Fire the given event to all registered listeners.
|
Collection<Integer> |
getCachedColumnIndexes()
This method returns the column indexes of the columns for which values
was cached.
|
List<?> |
getValues(int columnIndex,
int rowIndex)
Will determine the values for the cell at the specified position.
|
void |
handleLayerEvent(ILayerEvent event)
Handle an event notification from an
ILayer |
void |
removeCacheUdpateListener(IFilterRowComboUpdateListener listener)
Removes the given listener from the list of listeners for value cache updates.
|
public FilterRowComboBoxDataProvider(ILayer bodyLayer, Collection<T> baseCollection, IColumnAccessor<T> columnAccessor)
bodyLayer
- A layer in the body region. Usually the DataLayer or a layer that is responsible for list event handling.
Needed to register ourself as listener for data changes.baseCollection
- The base collection used to collect the unique values from. This need to be a collection that
is not filtered, otherwise after modifications the content of the filter row combo boxes will only
contain the current visible (not filtered) elements.columnAccessor
- The IColumnAccessor to be able to read the values out of the base collection objects.public List<?> getValues(int columnIndex, int rowIndex)
IComboBoxDataProvider
IDisplayConverter
will handle
the conversion to display values when the ComboBoxCellEditor
is filled
with the selectable items. There is no need to convert within this method.getValues
in interface IComboBoxDataProvider
columnIndex
- The column index of the cell whose ComboBoxCellEditor
should be filled.rowIndex
- The row index of the cell whose ComboBoxCellEditor
should
be filled.ComboBoxCellEditor
protected void buildValueCache()
public Collection<Integer> getCachedColumnIndexes()
protected List<?> collectValues(int columnIndex)
columnIndex
- The column index for which the values should be collectedpublic void handleLayerEvent(ILayerEvent event)
ILayerListener
ILayer
handleLayerEvent
in interface ILayerListener
event
- the eventprotected FilterRowComboUpdateEvent buildUpdateEvent(int columnIndex, List<?> cacheBefore, List<?> cacheAfter)
columnIndex
- The column index for which the value cache was updated.cacheBefore
- The value cache for the column before the change. Needed to determine which values
where removed by the update.cacheAfter
- The value cache for the column after the change. Needed to determine which values
where added by the update.protected void fireCacheUpdateEvent(FilterRowComboUpdateEvent event)
event
- The event to handle.public void addCacheUpdateListener(IFilterRowComboUpdateListener listener)
listener
- The listener to add.public void removeCacheUdpateListener(IFilterRowComboUpdateListener listener)
listener
- The listener to remove.Copyright © 2013. All Rights Reserved.