+1

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 719 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 445 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 445 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 445 days ago
View Replies (2) || 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 445 days ago
Add Comment Reply to: this comment OR this thread
 
manju said:
 
hi m making database explorer plugin, m a novice nd dont knw how to hide .project file from my database explorer view so that only data source folders and tables are visible, plz help me thanx
 
posted 254 days ago
Add Comment Reply to: this comment OR this thread
 
James said:
 
Hey, the problem/solution you have listed here is EXACTLY what I am experiencing, but I have been unable to resolve it, even following your steps. I typically code in PHPclipse so I attempted to add the extension code to the PHPclipse files with no success. I'm running Eclipse 3.4.2. Any other suggestions on how to accomplish this?
 
posted 248 days ago
Add Comment Reply to: this comment OR this thread
 
scrasnups said:
 
it's the second time that a post from you helps me, dude
Thanks a lot
 
posted 108 days ago
Add Comment Reply to: this comment OR this thread
 
scrasnups said:
 
However, i modify the plugin.xml but i had to repackage the directory in a jar file and then delete this directory and restart eclipse with the -clean option
 
posted 108 days ago
Add Comment Reply to: this comment OR this thread
 

Search

Rob  Wilkerson