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:
- 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.
- Open the plugin.xml file in a text editor.
- Find the extension element whose point attribute has a value of org.eclipse.ui.ide.resourceFilters.
- 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.
- 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.





Loading....