Class 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 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:
    IColumnPropertyResolver
    • 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 interface IDataProvider
        Overrides:
        getRowCount in class ListDataProvider<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 interface IDataProvider
        Overrides:
        getDataValue in class ListDataProvider<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 interface IDataProvider
        Overrides:
        setDataValue in class ListDataProvider<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 interface IRowDataProvider<T>
        Overrides:
        getRowObject in class ListDataProvider<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 interface IRowDataProvider<T>
        Overrides:
        indexOfRowObject in class ListDataProvider<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