Reputation: 2281
In my RCP project, I would like to programmatically hide the folders that starts with dot in the Project Explorer (when the user browse to open a file).
I have used the below extensions to achieve this, but sadly it did not work. Can someone help? Thank You.
<extension point="org.eclipse.ui.navigator.navigatorContent">
<commonFilter
description="Hides .* resources"
id="com.xyz.commonFilter.hidePj"
name=".* resources"
activeByDefault="true">
<filterExpression>
<and>
<adapt type="org.eclipse.core.resources.IResource">
<test property="org.eclipse.core.resources.name" value=".*"/>
</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>
Note: I am using eclipse Ganymede.
Upvotes: 3
Views: 405
Reputation: 15113
Change the generic IResource
type:
<adapt type="org.eclipse.core.resources.IResource">
and use the most specific IFolder
type:
<adapt type="org.eclipse.core.resources.IFolder">
The relevant source code follows, standard Eclipse plugin project created with the wizard (Ganymede), I just changed the id
name attribute:
plugin.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.navigator.navigatorContent">
<commonFilter
id="com.stackoverflow.commonFilter.hideFolders"
name=".* folders"
description="Hides .* folders"
activeByDefault="true">
<filterExpression>
<and>
<adapt type="org.eclipse.core.resources.IFolder">
<test property="org.eclipse.core.resources.name" value=".*"/>
</adapt>
</and>
</filterExpression>
</commonFilter>
</extension>
<extension point="org.eclipse.ui.navigator.viewer">
<viewerContentBinding viewerId="org.eclipse.ui.navigator.ProjectExplorer">
<includes>
<contentExtension pattern="com.stackoverflow.commonFilter.hideFolders" />
</includes>
</viewerContentBinding>
</extension>
</plugin>
MANIFEST.MF:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Filter_dot Plug-in
Bundle-SymbolicName: filter_dot;singleton:=true
Bundle-Version: 1.0.0
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.ui.navigator,org.eclipse.core.resources
build.properties:
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml
In the following images the "Project Explorer" displays a ".test" folder, if the filter is enabled, using the "Arrow in the top right corner > Customize View..." option, then the folder is hidden.
Upvotes: 2