Class DefaultGlazedListsFilterStrategy<T>
- All Implemented Interfaces:
IFilterStrategy<T>
- Direct Known Subclasses:
DefaultGlazedListsStaticFilterStrategy
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
TextFilterator
implementation that extracts the cell value for a column as String by using anIDisplayConverter
. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final IColumnAccessor<T>
protected final IConfigRegistry
protected ca.odell.glazedlists.FilterList<T>
protected ca.odell.glazedlists.util.concurrent.ReadWriteLock
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultGlazedListsFilterStrategy
(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.DefaultGlazedListsFilterStrategy
(ca.odell.glazedlists.FilterList<T> filterList, IColumnAccessor<T> columnAccessor, IConfigRegistry configRegistry) Create a new DefaultGlazedListsFilterStrategy on top of the given FilterList. -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyFilter
(Map<Integer, Object> filterIndexToObjectMap) Create GlazedLists matcher editors and apply them to facilitate filtering.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.getColumnValueProvider
(int columnIndex) protected IDisplayConverter
getFilterContentDisplayConverter
(int columnIndex) Retrieves theIDisplayConverter
that should be used for converting the body content to string for text match filter operations.int
getGlazedListsTextMatcherEditorMode
(TextMatchingMode textMatchingMode) ca.odell.glazedlists.matchers.CompositeMatcherEditor<T>
Returns theCompositeMatcherEditor
that is created and used by thisIFilterStrategy
.protected String
getStringFromColumnObject
(int columnIndex, Object object) Converts the object inserted to the filter cell at the given column position to the corresponding String.protected ca.odell.glazedlists.TextFilterator<T>
getTextFilterator
(Integer columnIndex, IDisplayConverter converter) protected ca.odell.glazedlists.matchers.TextMatcherEditor<T>
getTextMatcherEditor
(Integer columnIndex, TextMatchingMode textMatchingMode, IDisplayConverter converter, String filterText) Sets up a text matcher editor for String tokensgetThresholdMatcherEditor
(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.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 equal.
-
Field Details
-
columnAccessor
-
configRegistry
-
filterList
-
filterLock
protected ca.odell.glazedlists.util.concurrent.ReadWriteLock filterLock
-
-
Constructor Details
-
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 Details
-
applyFilter
Create GlazedLists matcher editors and apply them to facilitate filtering.- Specified by:
applyFilter
in interfaceIFilterStrategy<T>
- Parameters:
filterIndexToObjectMap
- A Map of column indexes to filter text Strings.
-
getFilterContentDisplayConverter
Retrieves theIDisplayConverter
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 forFilterRowConfigAttributes.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
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 upthreshold
- the threshold value used for comparisoncomparator
-Comparator
that is used to determine how objects compare with the threshold valuecolumnValueProvider
-FunctionList.Function
that exposes the content of the given column index from a row objectmatchOperation
- The NatTableParseResult.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 uptextMatchingMode
- The NatTableTextMatchingMode
that should be usedconverter
- TheIDisplayConverter
used for converting the cell value to a StringfilterText
- 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 Stringsconverter
- TheIDisplayConverter
used for converting the cell value to a String- Returns:
TextFilterator
which exposes the contents of the column as aString
-
getGlazedListsTextMatcherEditorMode
- Parameters:
textMatchingMode
- The NatTable TextMatchingMode for which the GlazedListsTextMatcherEditor
mode is requested- Returns:
- The GlazedLists
TextMatcherEditor
mode for the given NatTableTextMatchingMode
-
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 ofCompositeMatcherEditor
.- 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 equal.- 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
Returns theCompositeMatcherEditor
that is created and used by thisIFilterStrategy
. In prior versions it was necessary to create theCompositeMatcherEditor
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 theDefaultGlazedListsStaticFilterStrategy
.- Returns:
- The
CompositeMatcherEditor
that is created and used by thisIFilterStrategy
.
-