57

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 file mask is *.ooj).

Is it possible to add a custom filter by file mask into Customize View? Or maybe there is anther way to hide files in Project Explorer?

rmflow
  • 4,445
  • 4
  • 27
  • 41

4 Answers4

108

Here's how to do it on Eclipse Indigo/Luna/Neon (as of 2018-05-22):

  • Open the "project properties"
    • pull down menu --> Project --> Properties
    • A new dialog window named "Properties" will appear
  • Create a "Resource Filter"
    • Select Resource --> Resource Filters -> Add Filter...
    • A new dialog window named "Add Resource Filter for project" will appear
    • In the new dialog select the following
      • Filter Type: Exclude All
      • Applies to: Files
      • Make sure to click the checkbox for "All children (recusive)"
      • File and Folder Attributes
        • select: Name
        • select: Matches
        • fill in: *.ooj
      • Click OK
      • Dialog closes
  • Apply the new filter
    • Click Apply
    • You should see a change in your "Navigator" View
  • Close the "Project Properties"
    • Click OK
  • Done
Trevor Boyd Smith
  • 18,164
  • 32
  • 127
  • 177
Colm Ryan
  • 1,208
  • 2
  • 14
  • 12
  • 1
    When I do this, my folder get hidden but immediately it appears again. What can I do? – John Alexander Betts Aug 08 '13 at 13:52
  • If you'd like to do that for all projects you can click on the pointing-down triangle in the package explorer bar (next to the minimize icon), and select Filters from there. Then just add your filter (you can use regex) to the top textarea. – ceiroa Oct 31 '13 at 17:44
  • Does not work on Indigo. Seemed to work once. But now it doesn't. – Duck Dodgers Jul 10 '18 at 09:18
4

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

emmzett
  • 41
  • 3
  • Cool! Exactly what I was looking for to hide `*.orig` files (from hg/git merges): this worked: ` ` for `plugin.xml` and ... – Andreas Covidiot Jun 01 '16 at 12:29
  • ... (continued my previous comment) `filters.origFiles.name=*.orig resources filters.origFiles.description=Hides resources that end with ".orig", e.g. generated on versioning system merges (e.g. Mercurial/HG, GIT) ` for `plugins.properties`. after `eclipse -clean` everything was available in Eclipse Kepler :) – Andreas Covidiot Jun 01 '16 at 12:30
  • with the ***Remote Systems* plugin** (maybe already available in your Eclipse distro) this is **quite easy to setup without extra apps ((un)packer, file navigator etc.)**: 1. go to (or *Window -> Show View -> Remote Systems*), 2. *Local -> ... -> org.eclipse.ui.navigator.resources_.jar -> plugins.xml / plugins.properties -> double click*, 3. edit/insert desired content in both files, 4. *Remote Systems -> ... -> plugins.xml / plugins.properties -> right click -> Synchronize Cache* :) – Andreas Covidiot Jun 01 '16 at 12:40
3

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.

Kai
  • 38,985
  • 14
  • 88
  • 103
  • 3
    View Menu has no `Filters` option. I need to click Customize View to access `Filters`. But there are only predefined filters, such as "Archive Files", "Java Files" etc, and no option to add/edit those filters – rmflow May 26 '11 at 12:24
  • Which Eclipse version do you use? – Kai May 26 '11 at 12:40
  • 2
    Eclipse 3.7(Indigo) has a customizable filter named "Name filter patterns" in the menu he mentioned, but Juno has removed it as far as I can see. Don't know why either. – fwonce Jan 08 '13 at 02:47
  • 1
    @rmflowless Newer versions use "Project Explorer" by default. You want the "Package Explorer" for that filter. – lilalinux Jan 29 '14 at 10:35
2

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.

  1. Firstly go in eclipse file then plugins->org.eclipse.ui.navigator.resources_(your eclipse version).jar
  2. Right click to .jar file and open with winrar
  3. Find the plugin.xml open with an editor(notepad,Notepad++ etc) the plugin.xml file
  4. Find the point="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>
  5. Change SpecifyAnIdForYourFileType with a unique name for id Change "your specific file" with your specific file suffix like *.pdf or desktop.ini etc.
  6. Save the plugin.xml and exit
  7. Find the plugin.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
  8. Save plugin.properties and exit
  9. Restart the eclipse and clear cache than go to Project Explorer at the left side
  10. Click the View Menu icon at the top right corner
  11. Click the Filters and Customization...
  12. Tick your new filter in the Filters menu.

That's all I want to thanks again to emmzett.

Regards.

omerbguclu
  • 69
  • 6