Reputation: 1839
I am interested in using regular expressions in the NatTable filter. I have set up my code based on the following helpful links:
https://www.eclipse.org/forums/index.php/t/1069806/
From what I can gather, it basically boils down to adding the following code to your existing Filter:
FilterRowHeaderComposite<T> filterRowHeaderLayer = new
FilterRowHeaderComposite<>(filterStrategy,
sortHeaderLayer, columnHeaderDataLayer.
getDataProvider(), configRegistry);
int rowNum = 2;
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR,
new FilterRowTextCellEditor(), DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + rowNum);
configRegistry.registerConfigAttribute(FilterRowConfigAttributes.
TEXT_MATCHING_MODE, TextMatchingMode.REGULAR_EXPRESSION,
DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + rowNum);
configRegistry.registerConfigAttribute(CellConfigAttributes.
DISPLAY_CONVERTER, new FilterRowRegularExpressionConverter(),
DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + rowNum);
The filtering seems to work in certain situations and not others. For example, assume I have a cell that has the data "This is a Test". If I use the expression *t, it will find the row (which is what I expect). If I use the expression *x, it will not find the row (which is what I expect). If I use the expression ^(123) it will not find the row (which is NOT what I expect). Am I doing something incorrect?
Thanks!
Upvotes: 0
Views: 201
Reputation: 4231
I think the issue is in the regular expression. It seems that the cardinality is missing. Using [^123]* it works as you expect it.
If you for example test the _6031_GlazedListsFilterExample and insert [^abc] for the Housenumber column, you will see all entries that have only a one digit value. Adding the * all rows appear.
Upvotes: 1