0

Add Custom File Filters to the Eclipse Explorer

Ugh, they don't make this easy to do nor is it easy to find an answer online. Maybe I can improve on the latter experience.

The Situation

Using Eclipse, I have a project with beaucoup files pleasantly organized into not-quite-so-beaucoup directories. As a Subversion user, I also have the requisite .svn directories for every single one of my not-quite-so-beaucoup directories. I got tired of looking at all of these in the Eclipse Project Explorer so I hid them by using the built-in Filter option. To do this, simply click the down-facing triangle at the upper right of the Project Explorer view and select the Filters... option. Check the .* entry, click OK and all of those pesky .svn directories magically disappear.

But wait a minute. Along with the .svn directories, .project and .DS_store files, I also lost my .htaccess file. Crap. I need that one.

The Problem

I need to customize my list of filters so I could block some .* files and leave others. I really need access to that .htaccess file.

The Solution

Customizing the list of filters isn't an obvious action, but nor is it difficult if you're comfortable with text editors (and Eclipse users certainly should be). There may be other ways, but this is what I did:

  1. Locate the directory of the Eclipse plugin being used for editing. This is usually something like eclipse/plugins/[plugin name]_[version]. I spend most of my time in Aptana, so my plugin directory is eclipse/plugins/com.aptana.ide.scripting_0.2.9.16696.
  2. Open the plugin.xml file in a text editor.
  3. Find the extension element whose point attribute has a value of org.eclipse.ui.ide.resourceFilters.
  4. Create a new filter element like any others that already exist, but containing the needed file pattern. If no extension element is found for resourceFilters, see below.
  5. Restart Eclipse using the -clean switch.

Being an Aptana user, I found that the plugin.xml file I had to edit didn't contain any resource filters so I just created one by adding the following code to the bottom of plugin.xml:

<extension point="org.eclipse.ui.ide.resourceFilters">
   <filter selected="false" pattern=".svn"></filter>
   <filter selected="false" pattern=".project"></filter>
</extension>

After restarting Eclipse with the -clean switch, my custom file patterns appeared in the Filters... list and I was able to hide my .svn directories (and my .project file) without losing my .htaccess files.

I hope this helps someone else.

tags:
HowTo
Rémi Prévost said:
 
It helps me for sure! I was looking for something like this for a long time and couldn't find an easy way to do it.

Thank you very much!
 
posted 364 days ago
Add Comment Reply to: this comment OR this thread
 
padam said:
 
Hi
the modification you suggested seems to work only for navigator and not for project explorer.

tell me how to hide some files in project explorer.
 
posted 91 days ago
View Replies (1) || Add Comment Reply to: this comment OR this thread
 
.: HIDE REPLIES :.
Rob said:
 
padam -

I'm not sure I can help, but I'll try if you can provide more information. What perspective are you using? In the PHP Explorer, I can customize a filter directly within the "Filters..." menu (using Europa)
 
posted 91 days ago
Add Comment Reply to: this comment OR this thread
 
padam said:
 
Thanks for te promt reply Rob.

well fyi i am using C Perspective.(CDT 5.0)
eclipse 3.4(Ganymede)
I can add my own custom filter in the navigator , after extending "org.eclipse.ui.ide.resourceFilters" as you mentioned.
My question is how can i created my own filter on the project explorer. Basically i have some *.XXX files in my project workspace.And i want to hide them in project explorer.

 
posted 91 days ago
View Replies (1) || Add Comment Reply to: this comment OR this thread
 
.: HIDE REPLIES :.
Rob said:
 
I guess what I'm not clear about is the difference between the project explorer and the navigator. Are they two different views? This post was a long time ago, so I'm not sure what my workbench looked like at that time and that leaves me with no frame of reference.

What's the name of the view that you're trying to add the filters to?
 
posted 91 days ago
Add Comment Reply to: this comment OR this thread
 

Search

Rob  Wilkerson