Class DefaultGlazedListsFilterStrategy<T>
- All Implemented Interfaces:
IFilterStrategy<T>
- Direct Known Subclasses:
DefaultGlazedListsStaticFilterStrategy
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassTextFilteratorimplementation that extracts the cell value for a column as String by using anIDisplayConverter. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final IColumnAccessor<T>protected final IConfigRegistryprotected 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 TypeMethodDescriptionvoidapplyFilter(Map<Integer, Object> filterIndexToObjectMap) Create GlazedLists matcher editors and apply them to facilitate filtering.protected booleancontainsMatcherEditor(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 IDisplayConvertergetFilterContentDisplayConverter(int columnIndex) Retrieves theIDisplayConverterthat should be used for converting the body content to string for text match filter operations.intgetGlazedListsTextMatcherEditorMode(TextMatchingMode textMatchingMode) ca.odell.glazedlists.matchers.CompositeMatcherEditor<T>Returns theCompositeMatcherEditorthat is created and used by thisIFilterStrategy.protected StringgetStringFromColumnObject(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 booleanmatcherEditorEqual(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:
applyFilterin interfaceIFilterStrategy<T>- Parameters:
filterIndexToObjectMap- A Map of column indexes to filter text Strings.
-
getFilterContentDisplayConverter
Retrieves theIDisplayConverterthat 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_CONVERTERwhich 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
IDisplayConverterto 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-Comparatorthat is used to determine how objects compare with the threshold valuecolumnValueProvider-FunctionList.Functionthat exposes the content of the given column index from a row objectmatchOperation- The NatTableParseResult.MatchTypeused to determine the GlazedLists ThresholdMatcherEditor#MatchOperation- Returns:
- A
ThresholdMatcherEditorthat 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.Functionwhich 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 NatTableTextMatchingModethat should be usedconverter- TheIDisplayConverterused for converting the cell value to a StringfilterText- text entered by the user in the filter row- Returns:
- A
TextMatcherEditorbased 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- TheIDisplayConverterused for converting the cell value to a String- Returns:
TextFilteratorwhich exposes the contents of the column as aString
-
getGlazedListsTextMatcherEditorMode
- Parameters:
textMatchingMode- The NatTable TextMatchingMode for which the GlazedListsTextMatcherEditormode is requested- Returns:
- The GlazedLists
TextMatcherEditormode 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:
trueif the matcher editor is already existing in the list of matcher editors,falseotherwise.- 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:
trueif the matcher editors are equals,falseotherwise.- Since:
- 1.5
-
getMatcherEditor
Returns theCompositeMatcherEditorthat is created and used by thisIFilterStrategy. In prior versions it was necessary to create theCompositeMatcherEditoroutside 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
CompositeMatcherEditorinstead of creating one outside. For static filtering additional to the filter row you might want to consider using theDefaultGlazedListsStaticFilterStrategy.- Returns:
- The
CompositeMatcherEditorthat is created and used by thisIFilterStrategy.
-