Filtering contents in Eclipse Common Navigator Framework view

616 Views Asked by At

I am developing a 3.x based Eclipse RCP application. In the part of application, I am implementing Common-navigator plugin of Eclipse itself, in order to display resources in the workspace. I'have created the navigator view shown below:

Custom Project Explorer

But I would like display only one tree child element. More specifically, I only want clause folder and its elements to be shown.

What is the accurate way to do it?

1

There are 1 best solutions below

0
On BEST ANSWER
  • Add dependecy of org.eclipse.ui.navigator if not exists in plugin.xml.
  • Add extension point org.eclipse.ui.navigator.navigatorContent in extension tab.
  • Create CommonFilter under that and provide your values to the properties on the right.
  • Create a class which extends 'org.eclipse.jface.viewers.ViewerFilter' and implement you logic in overridden public boolean select(Viewer viewer, Object parentElement, Object element) (Note : return true would retain the resource in Navigator otherwise it will be hidden).
  • Configure this extended class in extension for class property in CommonFilter.
  • And you are good to go for testing.

BTW, this way is adding common filter to across all the Navigator. If you need to configure for particular navigator then you need to get its view and then get viewer out of it and attach your filter to viewer. To achieve this you may need a trigger point e.g., a menu/button/startup extension!