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>
public abstract class AbstractFilterListDataProvider<T> extends ListDataProvider<T>
Enables the use of aList
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. AIColumnPropertyResolver
is used to retrieve column data from the bean properties. By implementing filter logic withinshow(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:
IColumnPropertyResolver
-
-
Field Summary
-
Fields inherited from class org.eclipse.nebula.widgets.nattable.data.ListDataProvider
columnAccessor, list
-
-
Constructor Summary
Constructors Constructor Description AbstractFilterListDataProvider(List<T> list, IColumnAccessor<T> columnAccessor)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Object
getDataValue(int columnIndex, int rowIndex)
Get the data value for the columnIndex and the visible rowIndex.int
getRowCount()
Iterates over the whole list of data objects and checks the visibility for every object.T
getRowObject(int rowIndex)
Returns the object for the visible rowIndex.int
indexOfRowObject(T rowObject)
Returns the visible rowIndex for the given object.void
setDataValue(int columnIndex, int rowIndex, Object newValue)
Set the data value for the columnIndex and the visible rowIndex.protected abstract boolean
show(T object)
Within this method the filter logic should be applied.-
Methods inherited from class org.eclipse.nebula.widgets.nattable.data.ListDataProvider
getColumnCount, getList
-
-
-
-
Constructor Detail
-
AbstractFilterListDataProvider
public AbstractFilterListDataProvider(List<T> list, IColumnAccessor<T> columnAccessor)
-
-
Method Detail
-
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:
getRowCount
in interfaceIDataProvider
- Overrides:
getRowCount
in classListDataProvider<T>
- Returns:
- The number of rows this
IDataProvider
handles.
-
getDataValue
public Object getDataValue(int columnIndex, int rowIndex)
Get the data value for the columnIndex and the visible rowIndex.- Specified by:
getDataValue
in interfaceIDataProvider
- Overrides:
getDataValue
in 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
public void setDataValue(int columnIndex, int rowIndex, Object newValue)
Set the data value for the columnIndex and the visible rowIndex.- Specified by:
setDataValue
in interfaceIDataProvider
- Overrides:
setDataValue
in 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
public T getRowObject(int rowIndex)
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:
getRowObject
in interfaceIRowDataProvider<T>
- Overrides:
getRowObject
in classListDataProvider<T>
-
indexOfRowObject
public int indexOfRowObject(T rowObject)
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:
indexOfRowObject
in interfaceIRowDataProvider<T>
- Overrides:
indexOfRowObject
in classListDataProvider<T>
-
show
protected abstract boolean show(T object)
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
-
-