Class DefaultGlazedListsFilterStrategy<T>

    • Field Detail

      • filterList

        protected ca.odell.glazedlists.FilterList<T> filterList
      • filterLock

        protected ca.odell.glazedlists.util.concurrent.ReadWriteLock filterLock
    • Constructor Detail

      • DefaultGlazedListsFilterStrategy

        public DefaultGlazedListsFilterStrategy​(ca.odell.glazedlists.FilterList<T> filterList,
                                                IColumnAccessor<T> columnAccessor,
                                                IConfigRegistry configRegistry)
        Create a new DefaultGlazedListsFilterStrategy on top of the given FilterList.

        Note: Using this constructor you don't need to create and set the CompositeMatcherEditor as MatcherEditor on the FilterList yourself! The necessary steps to get it working is done within this constructor.

        Parameters:
        filterList - The FilterList that is used within the GlazedLists based NatTable for filtering.
        columnAccessor - The IColumnAccessor necessary to access the column data of the row objects in the FilterList.
        configRegistry - The IConfigRegistry necessary to retrieve filter specific configurations.
      • DefaultGlazedListsFilterStrategy

        public DefaultGlazedListsFilterStrategy​(ca.odell.glazedlists.FilterList<T> filterList,
                                                ca.odell.glazedlists.matchers.CompositeMatcherEditor<T> matcherEditor,
                                                IColumnAccessor<T> columnAccessor,
                                                IConfigRegistry configRegistry)
        Create a new DefaultGlazedListsFilterStrategy on top of the given FilterList using the given CompositeMatcherEditor. This is necessary to support connection of multiple filter rows.

        Note: Using this constructor you need to create the CompositeMatcherEditor yourself. It will be added automatically to the given FilterList, so you can skip that step.

        Parameters:
        filterList - The FilterList that is used within the GlazedLists based NatTable for filtering.
        matcherEditor - The CompositeMatcherEditor that should be used by this DefaultGlazedListsFilterStrategy.
        columnAccessor - The IColumnAccessor necessary to access the column data of the row objects in the FilterList.
        configRegistry - The IConfigRegistry necessary to retrieve filter specific configurations.
    • Method Detail

      • applyFilter

        public void applyFilter​(Map<Integer,​Object> filterIndexToObjectMap)
        Create GlazedLists matcher editors and apply them to facilitate filtering.
        Specified by:
        applyFilter in interface IFilterStrategy<T>
        Parameters:
        filterIndexToObjectMap - A Map of column indexes to filter text Strings.
      • getFilterContentDisplayConverter

        protected IDisplayConverter getFilterContentDisplayConverter​(int columnIndex)
        Retrieves the IDisplayConverter that should be used for converting the body content to string for text match filter operations.

        First checks if there is a converter registered for FilterRowConfigAttributes.FILTER_CONTENT_DISPLAY_CONVERTER which should be the same converter that is also registered in the body region. For backwards compatibility if no value is registered for that configuration attribute it will check for FilterRowConfigAttributes.FILTER_DISPLAY_CONVERTER.

        Parameters:
        columnIndex - The column index of the column for which a filter should be applied.
        Returns:
        The IDisplayConverter to be used for converting the body content to string for text match filter operations.
        Since:
        2.0
      • getStringFromColumnObject

        protected String getStringFromColumnObject​(int columnIndex,
                                                   Object object)
        Converts the object inserted to the filter cell at the given column position to the corresponding String.
        Parameters:
        columnIndex - The column index of the filter cell that should be processed.
        object - The value set to the filter cell that needs to be converted
        Returns:
        The String value for the given filter value.
      • getThresholdMatcherEditor

        protected ca.odell.glazedlists.matchers.ThresholdMatcherEditor<T,​Object> getThresholdMatcherEditor​(Integer columnIndex,
                                                                                                                 Object threshold,
                                                                                                                 Comparator<Object> comparator,
                                                                                                                 ca.odell.glazedlists.FunctionList.Function<T,​Object> columnValueProvider,
                                                                                                                 ParseResult.MatchType matchOperation)
        Set up a threshold matcher for tokens like '>20', '<=10' etc.
        Parameters:
        columnIndex - the column index of the column for which the matcher editor is being set up
        threshold - the threshold value used for comparison
        comparator - Comparator that is used to determine how objects compare with the threshold value
        columnValueProvider - FunctionList.Function that exposes the content of the given column index from a row object
        matchOperation - The NatTable ParseResult.MatchType used to determine the GlazedLists ThresholdMatcherEditor#MatchOperation
        Returns:
        A ThresholdMatcherEditor that filters elements based on whether they are greater than or less than a threshold.
      • getColumnValueProvider

        protected ca.odell.glazedlists.FunctionList.Function<T,​Object> getColumnValueProvider​(int columnIndex)
        Parameters:
        columnIndex - The column index of the column whose contents should be exposed.
        Returns:
        FunctionList.Function which exposes the content of the given column index from a row object
      • getTextMatcherEditor

        protected ca.odell.glazedlists.matchers.TextMatcherEditor<T> getTextMatcherEditor​(Integer columnIndex,
                                                                                          TextMatchingMode textMatchingMode,
                                                                                          IDisplayConverter converter,
                                                                                          String filterText)
        Sets up a text matcher editor for String tokens
        Parameters:
        columnIndex - the column index of the column for which the matcher editor is being set up
        textMatchingMode - The NatTable TextMatchingMode that should be used
        converter - The IDisplayConverter used for converting the cell value to a String
        filterText - text entered by the user in the filter row
        Returns:
        A TextMatcherEditor based on the given information.
      • getTextFilterator

        protected ca.odell.glazedlists.TextFilterator<T> getTextFilterator​(Integer columnIndex,
                                                                           IDisplayConverter converter)
        Parameters:
        columnIndex - The column index of the column whose contents should be collected as Strings
        converter - The IDisplayConverter used for converting the cell value to a String
        Returns:
        TextFilterator which exposes the contents of the column as a String
      • getGlazedListsTextMatcherEditorMode

        public int getGlazedListsTextMatcherEditorMode​(TextMatchingMode textMatchingMode)
        Parameters:
        textMatchingMode - The NatTable TextMatchingMode for which the GlazedLists TextMatcherEditor mode is requested
        Returns:
        The GlazedLists TextMatcherEditor mode for the given NatTable TextMatchingMode
      • containsMatcherEditor

        protected boolean containsMatcherEditor​(List<ca.odell.glazedlists.matchers.MatcherEditor<T>> existingMatcherEditors,
                                                ca.odell.glazedlists.matchers.MatcherEditor<T> matcherEditor)
        This allows to determinate if the matcher editor in parameter is already existing in the list of matcher editors as first parameter. This function takes care of CompositeMatcherEditor.
        Parameters:
        existingMatcherEditors - The list of existing matcher editors.
        matcherEditor - The matcher editor to search.
        Returns:
        true if the matcher editor is already existing in the list of matcher editors, false otherwise.
        Since:
        1.5
      • matcherEditorEqual

        protected boolean matcherEditorEqual​(ca.odell.glazedlists.matchers.MatcherEditor<T> first,
                                             ca.odell.glazedlists.matchers.MatcherEditor<T> second)
        This allows to determinate if two matcher editors are equals.
        Parameters:
        first - The first matcher editor to compare.
        second - The second matcher editor to compare.
        Returns:
        true if the matcher editors are equals, false otherwise.
        Since:
        1.5
      • getMatcherEditor

        public ca.odell.glazedlists.matchers.CompositeMatcherEditor<T> getMatcherEditor()
        Returns the CompositeMatcherEditor that is created and used by this IFilterStrategy. In prior versions it was necessary to create the CompositeMatcherEditor outside this class and use it as constructor parameter. We changed this to hide that implementation from users and to ensure that filter operations and possible listeners are executed thread safe. Otherwise there might be concurrency issues while filtering.

        If you want to use additional filtering you should now use this method to work on the created CompositeMatcherEditor instead of creating one outside. For static filtering additional to the filter row you might want to consider using the DefaultGlazedListsStaticFilterStrategy.

        Returns:
        The CompositeMatcherEditor that is created and used by this IFilterStrategy.