| Creating a parameter controlled ViewerFilter for CommonNavigator [message #511895] |
Wed, 03 February 2010 06:00  |
hjembaek Messages: 5 Registered: February 2010 |
Junior Member |
|
|
I have created a nice working ViewerFilter for my CommonNavigator.
The problem is that my implementation is very specific because the filter uses a String to determine whether the resource should be filtered or not.
Example:
public boolean select(Viewer viewer, Object parentElement, Object element) {
String filter = "CAT";
...
}
Now I would like to make the exact same filter with DOG, HORSE and so on. It would violate the DRY principle to duplicate the implementation and change the hardcoded filter string.
I would rather like to specify the filter string as a parameter (filterExpression ???) in some extension point and look this up within the ViewerFilter.
Any solutions with code examples are greatly appreciated.
|
|
|
| Re: Creating a parameter controlled ViewerFilter for CommonNavigator [message #511947 is a reply to message #511895] |
Wed, 03 February 2010 08:58  |
hjembaek Messages: 5 Registered: February 2010 |
Junior Member |
|
|
It seems to be almost impossible to do this without having to do a ton of work. So I guess I am better of violating the DRY principle - Grrrr!
The main problem being that the ViewerFilter instance is only known at runtime by the CommonFilterDescriptorManager.
This class binds the ViewerFilter instances to a CommonFilterDescriptor (contains the info from plugin.xml).
public class CommonFilterDescriptorManager {
private static final CommonFilterDescriptorManager INSTANCE = new CommonFilterDescriptorManager();
private static final CommonFilterDescriptor[] NO_FILTER_DESCRIPTORS = new CommonFilterDescriptor[0];
private final Set filters = new HashSet();
However everything about this class is private.
What I need is a getViewerFilter(CommonFilterDescriptor) method - or an alternative way to this.
I already spent to much time on this - so I am off to duplicating my filter code.
[Updated on: Wed, 03 February 2010 08:59] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.06032 seconds