Class AbstractFilterListDataProvider<T>
java.lang.Object
org.eclipse.nebula.widgets.nattable.data.ListDataProvider<T>
org.eclipse.nebula.widgets.nattable.data.AbstractFilterListDataProvider<T>
- Type Parameters:
T- type of the Objects in the backing list.
- All Implemented Interfaces:
IDataProvider,IRowDataProvider<T>
Enables the use of a
List containing POJO(s) as a backing data
source.
By default a bean at position 'X' in the list is displayed in row 'X' in the
table. The properties of the bean are used to populate the columns. A
IColumnPropertyResolver is used to retrieve column data from the bean
properties.
By implementing filter logic within
show(Object) it is possible to create
a static filter. All data access methods will skip invisible items within the
wrapped list and delegate access to the visible items.
NOTE: This way of static filtering can cause performance issues for huge data
sets where a lot of items are filtered, because data access will always
calculate the visible row position. Trying to use a caching mechanism would
create some issues for deleting or inserting new data to the wrapped list.
TODO add caching that reacts on insert/delete actions on the wrapped list- See Also:
-
Field Summary
Fields inherited from class org.eclipse.nebula.widgets.nattable.data.ListDataProvider
columnAccessor, list -
Constructor Summary
ConstructorsConstructorDescriptionAbstractFilterListDataProvider(List<T> list, IColumnAccessor<T> columnAccessor) -
Method Summary
Modifier and TypeMethodDescriptiongetDataValue(int columnIndex, int rowIndex) Get the data value for the columnIndex and the visible rowIndex.intIterates over the whole list of data objects and checks the visibility for every object.getRowObject(int rowIndex) Returns the object for the visible rowIndex.intindexOfRowObject(T rowObject) Returns the visible rowIndex for the given object.voidsetDataValue(int columnIndex, int rowIndex, Object newValue) Set the data value for the columnIndex and the visible rowIndex.protected abstract booleanWithin this method the filter logic should be applied.Methods inherited from class org.eclipse.nebula.widgets.nattable.data.ListDataProvider
getColumnCount, getList
-
Constructor Details
-
AbstractFilterListDataProvider
-
-
Method Details
-
getRowCount
public int getRowCount()Iterates over the whole list of data objects and checks the visibility for every object. The number of non visible items will be subtracted from the size of the wrapped list to return the number of visible items.- Specified by:
getRowCountin interfaceIDataProvider- Overrides:
getRowCountin classListDataProvider<T>- Returns:
- The number of rows this
IDataProviderhandles.
-
getDataValue
Get the data value for the columnIndex and the visible rowIndex.- Specified by:
getDataValuein interfaceIDataProvider- Overrides:
getDataValuein classListDataProvider<T>- Parameters:
columnIndex- The column index of the cell whose value is requested.rowIndex- The row index of the cell whose value is requested.- Returns:
- The data value associated with the specified cell coordintates.
-
setDataValue
Set the data value for the columnIndex and the visible rowIndex.- Specified by:
setDataValuein interfaceIDataProvider- Overrides:
setDataValuein classListDataProvider<T>- Parameters:
columnIndex- The column index of the cell whose value should be changed.rowIndex- The row index of the cell whose value should be changed.newValue- The new value that should be set.
-
getRowObject
Returns the object for the visible rowIndex. To do this it is iterated over the wrapped list, taking the invisible items into account, so the real row index for the given visible row index is calculated.- Specified by:
getRowObjectin interfaceIRowDataProvider<T>- Overrides:
getRowObjectin classListDataProvider<T>
-
indexOfRowObject
Returns the visible rowIndex for the given object. To do this the real row index for the object within the wrapped list is searched and then all invisible items are subtracted from the real row index to calculate the visible row index.- Specified by:
indexOfRowObjectin interfaceIRowDataProvider<T>- Overrides:
indexOfRowObjectin classListDataProvider<T>
-
show
Within this method the filter logic should be applied. Return false if the object should not be visible within the grid. Return true if it should be visible.- Parameters:
object- The object that should be checked.- Returns:
- true if the object should be visible, false if not
-