Class FilterRowDataProvider<T>

java.lang.Object
org.eclipse.nebula.widgets.nattable.filterrow.FilterRowDataProvider<T>
All Implemented Interfaces:
IDataProvider, IPersistable

public class FilterRowDataProvider<T> extends Object implements IDataProvider, IPersistable
Data provider for the filter row
  • Stores filter strings
  • Applies them to the ca.odell.glazedlists.matchers.MatcherEditor on the ca.odell.glazedlists.FilterList
  • Field Details

    • PIPE_REPLACEMENT

      public static final String PIPE_REPLACEMENT
      Replacement for the pipe character | that is used for persistence. If regular expressions are used for filtering, the pipe character can be used in the regular expression to specify alternations. As the persistence mechanism in NatTable uses the pipe character for separation of values, the persistence breaks for such cases. By replacing the pipe in the regular expression with some silly uncommon value specified here, we ensure to be able to also persist pipes in the regular expressions, as well as being backwards compatible with already saved filter row states.
      See Also:
    • COMMA_REPLACEMENT

      public static final String COMMA_REPLACEMENT
      Replacement for the comma character , that is used for persisting collection values in case of combobox filters.
      Since:
      2.1
      See Also:
    • NULL_REPLACEMENT

      public static final String NULL_REPLACEMENT
      Replacement for the null value that is used for persisting collection values in case of combobox filters. Needed for the inverted persistence in case there are null values in the collection that need to be persisted.
      Since:
      2.1
      See Also:
    • EMPTY_REPLACEMENT

      public static final String EMPTY_REPLACEMENT
      Replacement for an empty String value that is used for persisting collection values in case of combobox filters. Needed for the inverted persistence in case there are empty String values in the collection that need to be persisted.
      Since:
      2.1
      See Also:
    • FILTER_COLLECTION_PREFIX

      public static final String FILTER_COLLECTION_PREFIX
      The prefix String that will be used to mark that the following filter value in the persisted state is a collection.
      See Also:
  • Constructor Details

    • FilterRowDataProvider

      public FilterRowDataProvider(IFilterStrategy<T> filterStrategy, ILayer columnHeaderLayer, IDataProvider columnHeaderDataProvider, IConfigRegistry configRegistry)
      Parameters:
      filterStrategy - The IFilterStrategy to which the set filter value should be applied.
      columnHeaderLayer - The column header layer where this IDataProvider is used for filtering needed for retrieval of column indexes and firing according filter events..
      columnHeaderDataProvider - The IDataProvider of the column header needed to retrieve the real column count of the column header and not a transformed one.
      configRegistry - The IConfigRegistry needed to retrieve the IDisplayConverter for converting the values on state save/load operations.
  • Method Details

    • getFilterIndexToObjectMap

      public Map<Integer,Object> getFilterIndexToObjectMap()
      Returns the map that contains the filter objects mapped to the column index. It is the data storage for the inserted filters into the filter row by the user.

      Note: Usually it is not intended to modify this Map directly. You should rather call setDataValue(int, int, Object) or clearAllFilters() to modify this Map to ensure consistency in other framework code. It is made visible because there might be code that needs to modify the Map without index transformations or firing events.

      Returns:
      Map that contains the filter objects mapped to the column index.
    • setFilterIndexToObjectMap

      public void setFilterIndexToObjectMap(Map<Integer,Object> filterIndexToObjectMap)
      Set the map that contains the filter objects mapped to the column index to be the data storage for the inserted filters into the filter row by the user.

      Note: Usually it is not intended to set this Map from the outside as it is created in the constructor. But there might be use cases where you e.g. need to connect filter rows to each other. In this case it might be useful to override the local Map with the one form another FilterRowDataProvider. This is not a typical use case, therefore you should use this method carefully!

      Parameters:
      filterIndexToObjectMap - Map that contains the filter objects mapped to the column index.
    • getColumnCount

      public int getColumnCount()
      Specified by:
      getColumnCount in interface IDataProvider
      Returns:
      The number of columns this IDataProvider handles.
    • getDataValue

      public Object getDataValue(int columnIndex, int rowIndex)
      Description copied from interface: IDataProvider
      Gets the value at the given column and row index.
      Specified by:
      getDataValue in interface IDataProvider
      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.
    • getRowCount

      public int getRowCount()
      Specified by:
      getRowCount in interface IDataProvider
      Returns:
      The number of rows this IDataProvider handles.
    • setDataValue

      public void setDataValue(int columnIndex, int rowIndex, Object newValue)
      Description copied from interface: IDataProvider
      Sets the value at the given column and row index. Optional operation. Should throw UnsupportedOperationException if this operation is not supported.
      Specified by:
      setDataValue in interface IDataProvider
      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.
    • saveState

      public void saveState(String prefix, Properties properties)
      Description copied from interface: IPersistable
      Saves the state to the given Properties using the specified prefix. Note: The prefix must be prepended to the property key to support multiple states within one Properties instance.
      Specified by:
      saveState in interface IPersistable
      Parameters:
      prefix - The prefix to use for the state keys. Is also used as the state configuration name.
      properties - The Properties instance to save the state to.
    • loadState

      public void loadState(String prefix, Properties properties)
      Description copied from interface: IPersistable
      Restore the state out of the given Properties identified by the specified prefix. Note: The prefix must be prepended to the property key to support multiple states within one Properties instance.
      Specified by:
      loadState in interface IPersistable
      Parameters:
      prefix - The prefix to use for the state keys. Is also used as the state configuration name.
      properties - The Properties instance to load the state from.
    • clearAllFilters

      public void clearAllFilters()
      Clear all filters that are currently applied.
    • getFilterStrategy

      public IFilterStrategy<T> getFilterStrategy()
      Returns:
      The IFilterStrategy to which the set filter value should be applied.
      Since:
      2.1
    • setFilterRowComboBoxDataProvider

      public void setFilterRowComboBoxDataProvider(FilterRowComboBoxDataProvider<T> comboBoxDataProvider)
      Parameters:
      comboBoxDataProvider - The FilterRowComboBoxDataProvider that should be used to support inverted persistence of filter collections. By default the values in the collection are persisted as is. In case of Excel like filters, it can be more feasible to store which values are NOT selected, to be able to load the filter even for different values in the filter list. Passing null will result in the default persistence.
      Since:
      2.1