I have a custom builder in CDT, which adds alot of files into project directory. I want those files to be filtered out from Project Explorer, but cannot figure out how (the
Here's how to do it on Eclipse Indigo/Luna/Neon (as of 2018-05-22):
How to add global user defined resource filters to the Eclipse Project Explorer view:
Modifying and switching filters on a project level needs a lot of clicks and can be tedious if you have many projects in your workspace. If you need to apply or switch the same filter settings on all projects again and again you might prefer a quicker and global solution for all projects and all workspaces.
Modify the files plugin.xml
and plugin.properties
in plugins/org.eclipse.ui.navigator.resources_{version}.jar
(extract, modify and re-add the modified files).
For example, add a file only filter in plugin.xml
to the element /plugin/extension @point="org.eclipse.ui.navigator.navigatorContent"
:
<commonFilter id="org.eclipse.ui.navigator.resources.filters.{unique-id-a}" name="%filters.{unique-id-a}.name" description="%filters.{unique-id-a}.description" activeByDefault="true|false">
<filterExpression>
<and>
<instanceof value="org.eclipse.core.resources.IFile"/>
<test property="org.eclipse.core.resources.name" value="{file-wildcard-pattern-a}"/>
</and>
</filterExpression>
</commonFilter>
As another example, add a file and directory filter in plugin.xml
to the same element:
<commonFilter id="org.eclipse.ui.navigator.resources.filters.{unique-id-b}" name="%filters.{unique-id-b}.name" description="%filters.{unique-id-b}.description" activeByDefault="true|false">
<filterExpression>
<and>
<adapt type="org.eclipse.core.resources.IResource">
<test property="org.eclipse.core.resources.name" value="{file-wildcard-pattern-b}"/>
</adapt>
</and>
</filterExpression>
</commonFilter>
Provide filter names and descriptions for all added filters in plugin.properties
. Filter display order in Project Explorer view is by this filter name regardless of filter type:
filters.{unique-id-a}.name={file-wildcard-pattern-a} files
filters.{unique-id-a}.description=Hides files that match "{file-wildcard-pattern-a}"
filters.{unique-id-b}.name={file-wildcard-pattern-b} files and folders
filters.{unique-id-b}.description=Hides files and folders that match "{file-wildcard-pattern-b}"
Restart Eclipse and reset its caches: eclipse.exe -clean
You can define a filter for that. Open the view menu in the Package Explorer and then choose "Filters..." Here you can define a pattern to hide files.
Firstly thanks to @emmzett Just wanna explain in a verbose mode of emmzett's answer because I didn't know anything editing plugin files and I spent 2 hours on this. Maybe I can save your time with this clarified expression.
plugin.xml
open with an editor(notepad,Notepad++ etc) the
plugin.xml
filepoint="org.eclipse.ui.navigator.navigatorContent"
and paste code below
<commonFilter id="org.eclipse.ui.navigator.resources.filters.SpecifyAnIdForYourFileType"
name="%filters.SpecifyAnIdForYourFileType.name"
description="%filters.SpecifyAnIdForYourFileType.description"
activeByDefault="true">
<filterExpression>
<and>
<instanceof value="org.eclipse.core.resources.IFile"/>
<test property="org.eclipse.core.resources.name" value="your specific file"/>
</and>
</filterExpression>
</commonFilter>
SpecifyAnIdForYourFileType
with a unique name for id
Change "your specific file"
with your specific file suffix like *.pdf
or desktop.ini
etc.plugin.xml
and exitplugin.properties
open with an editor same as 3.step
Paste this code filters.SpecifyAnIdForYourFileType.name=your specific file files
filters.SpecifyAnIdForYourFileType.description=Hides files that match your specific file
plugin.properties
and exitProject Explorer
at
the left sideView Menu
icon at the top right cornerFilters and Customization...
Filters
menu.That's all I want to thanks again to emmzett.
Regards.