Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Custom FILTER_COMPARATOR not called
Custom FILTER_COMPARATOR not called [message #1472389] Thu, 13 November 2014 21:03 Go to next message
Thomas Kernstock is currently offline Thomas KernstockFriend
Messages: 29
Registered: July 2009
Location: Vienna
Junior Member
Hi,

I'm trying to implement my own filtercomparator but it seems that is never gets called.
When I debug the Example "FilterRowGridExample" at line 94 the getIngnorecaseComparator() is called so it should be registered - shouldn't it?
........
// Configure custom comparator on the rating column
configRegistry.registerConfigAttribute(FilterRowConfigAttributes.FILTER_COMPARATOR,
getIngnorecaseComparator(),
DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 2);
..........

private static Comparator<?> getIngnorecaseComparator() {
return new Comparator<String>() {
public int compare(String o1, String o2) {
System.out.println(o1+"/"+o2);
return o1.compareToIgnoreCase(o2);
}
};
};

Now I would expect that the compare Method ist called everytime I enter a value in the filterrow for rating and press enter. But it isn't.

Even if I completly remove the lines for configRegistry.registerConfigAttribute(... the row gets filtered correctly. So it seems that the FilterComparator isn't used at all.

Is this a bug or do I simply missunderstand the concept?
How can I implement a CustomFilter for one of the rows?

Thanx
Thomas

PS: I'm using Nattable Version 1.2.0.201410270901, GlazedList 1.9.0, Java 1.8.0_25
Re: Custom FILTER_COMPARATOR not called [message #1472408 is a reply to message #1472389] Thu, 13 November 2014 21:22 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
from looking into the code it seems the comparator is not used because a TextMatcherEditor is used since a simple text matching is performed.
Using another match mode that accepts matchers like >, < etc. would create a ThresholdMatcherEditor that makes use of the comparator.

So if you want to name it a bug then it is a bug in the example.
Re: Custom FILTER_COMPARATOR not called [message #1472417 is a reply to message #1472408] Thu, 13 November 2014 21:30 Go to previous messageGo to next message
Thomas Kernstock is currently offline Thomas KernstockFriend
Messages: 29
Registered: July 2009
Location: Vienna
Junior Member
thank you for the quick answer.

What I would like to achive is a CustomFilter that gets a value from a Dropdown and compares it to the fieldvalue.
The Dropdown contains ("IET","DO","D","O","I","E","T")
=> if I choose "IET" all rows containig either I,E or T in the column should show up. If I choose "I" only the rows with "I" should show up.....

Unfortunately I can't find any example or documentation on that topic and since the FILTER_COMPARATOR isn't used I have no clue how to do that.
br
Thomas
Re: Custom FILTER_COMPARATOR not called [message #1472796 is a reply to message #1472417] Fri, 14 November 2014 05:08 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
A comparator is used for sorting in Java. So the filter comparator is intended to sort the filter result and has nothing to do with filtering itself.

What you are looking for is an excel like filter, since there should be a dropdown with multi selection. If you want to use that have a look at the corresponding examples in the Tutorial examples section.
Re: Custom FILTER_COMPARATOR not called [message #1472801 is a reply to message #1472796] Fri, 14 November 2014 05:11 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Oh, just saw you don't want multi selection. In that case I guess you need to implement a custom IFilterStrategy that transforms the value into several single values on apply. Extending the default might be worth a look.
Re: Custom FILTER_COMPARATOR not called [message #1472930 is a reply to message #1472796] Fri, 14 November 2014 07:49 Go to previous messageGo to next message
Thomas Kernstock is currently offline Thomas KernstockFriend
Messages: 29
Registered: July 2009
Location: Vienna
Junior Member
Dirk Fauth wrote on Fri, 14 November 2014 00:08

What you are looking for is an excel like filter, since there should be a dropdown with multi selection. If you want to use that have a look at the corresponding examples in the Tutorial examples section.

Indeed I would have liked that for this particular column only, but what I saw I have to use Excelfilters on all columns which is not what I want.
Re: Custom FILTER_COMPARATOR not called [message #1472935 is a reply to message #1472801] Fri, 14 November 2014 07:51 Go to previous messageGo to next message
Thomas Kernstock is currently offline Thomas KernstockFriend
Messages: 29
Registered: July 2009
Location: Vienna
Junior Member
Dirk Fauth wrote on Fri, 14 November 2014 00:11
Extending the default might be worth a look.

Thank you for the hint. Do you know if there is an example for that?
Re: Custom FILTER_COMPARATOR not called [message #1472952 is a reply to message #1472935] Fri, 14 November 2014 08:08 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
No there is no example for that. But there are internal classes that extend DefaultGlazedListsFilterStrategy for the combo boxes or for adding static filters
Re: Custom FILTER_COMPARATOR not called [message #1472962 is a reply to message #1472952] Fri, 14 November 2014 08:17 Go to previous message
Thomas Kernstock is currently offline Thomas KernstockFriend
Messages: 29
Registered: July 2009
Location: Vienna
Junior Member
Great. I will have a look at these classes.
Thanx und schönen Tag noch
Thomas
Previous Topic:Image not exported to Excel sheet
Next Topic:Highlighting specific cells on a paste operation
Goto Forum:
  


Current Time: Fri Apr 19 20:31:53 GMT 2024

Powered by FUDForum. Page generated in 0.03804 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top