Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Creating a parameter controlled ViewerFilter for CommonNavigator(Creating a parameter controlled ViewerFilter for CommonNavigator)
Creating a parameter controlled ViewerFilter for CommonNavigator [message #511895] Wed, 03 February 2010 11:00 Go to next message
hjembaek is currently offline hjembaekFriend
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 13:58 Go to previous message
hjembaek is currently offline hjembaekFriend
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 13:59]

Report message to a moderator

Previous Topic:RCP + jws multiplatform
Next Topic:status bar injected into DAO
Goto Forum:
  


Current Time: Tue Mar 19 11:35:06 GMT 2024

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

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

Back to the top