Adding a filter in Project Explorer in Eclipse

I want to add a new filter in Project Explorer to hide from the user some projects created automatically in the RCP Eclipse application.

So far I have found two extension points:

org.eclipse.ui.ide.resourceFilters

Allows filtering navigation

org.eclipse.jdt.ui.javaElementFilters

Lets me filter Java Viewers

I expect there is a similar extension point for Project Explorer, but so far I have not been able to get it.

I tried importing org.eclipse.ui.navigator and org.eclipse.ui.navigator.resources, but I could not find an interesting perspective extension point either

I am using Eclipse 3.3.2 as the basis for this RCP application

Thanks!

+6
java eclipse eclipse-rcp
source share
3 answers

I found the correct set of extension points. This is a big pain that I expected, because Project Explorer is a specialization of a conventional navigator.

This is a two-step process:

  • expand org.eclipse.ui.navigator.navigatorContent

    • Add a common filter to this extension point.
    • Set filter name and id
    • Implement a filter viewer with the required logic
  • expand org.eclipse.ui.navigator.viewer

    • Add viewerContentBinding
    • Set content identifier for org.eclipse.ui.navigator.ProjectExplorer
    • Add two includes
    • In the first inclusion, add a pattern that matches the identifier of the common filter
    • In the second case add id org.eclipse.ui.navigator.resourceContent

And then the filter is connected to the general Project Explorer

+7
source share

There you go:

<extension point="org.eclipse.ui.navigator.navigatorContent"> <commonFilter description="Hides *.pj resources" id="com.xyz.commonFilter.hidePj" name="*.pj resources" activeByDefault="true"> <filterExpression> <and> <adapt type="org.eclipse.core.resources.IResource"> <test property="org.eclipse.core.resources.name" value="*.pj"/> </adapt> </and> </filterExpression> </commonFilter> </extension> <extension point="org.eclipse.ui.navigator.viewer"> <viewerContentBinding viewerId="org.eclipse.ui.navigator.ProjectExplorer"> <includes> <contentExtension pattern="com.xyz.commonFilter.hidePj"/> </includes> </viewerContentBinding> </extension> 

Remember to import the org.eclipse.ui.navigator package

+8
source share

Filters ... to represent Project Explorer?

There are some lasting errors on this:

This may require some development (as suggested in this thread )

perhaps you could do this by creating a class that extends ViewFilter and associates your class with the project explorer.

(Note: FilterViewer were corrupted in Eclipse3.3.1 , some of which use 3.3.2, this is a good idea)

+2
source share

All Articles