2

The Eclipse folder properties dialog allows you to edit the resource filters ( see eclipse 3.5 filter .git folder) . I would like to do the same programmatically. My current solution is to use internal code as shown below to include only file that match 'xml'. Does anyone know how to do this without the use of internal code?

Thanks in advance

folder.createFilter(
    IResourceFilterDescription.FILES | IResourceFilterDescription.INCLUDE_ONLY,
        new FileInfoMatcherDescription("NameofFolder",  
            "1.0-name-matches-false-false-xml"), 0, null);
Community
  • 1
  • 1

1 Answers1

4

The solution is:

folder.createFilter( 
   IResourceFilterDescription.EXCLUDE_ALL | IResourceFilterDescription.FOLDERS, 
       new FileInfoMatcherDescription("org.eclipse.core.resources.regexFilterMatcher",
           "xml"), IResource.BACKGROUND_REFRESH, monitor);
Dominic Weiser
  • 1,446
  • 1
  • 20
  • 32
  • 1
    I believe to make it recursive you would OR-ing IResourceFilterDescription.INHERITABLE – Oliver Jan 02 '14 at 21:35
  • regex must match the whole filename so `xml` match only a file with exactly "xml" as name. If you want everything with "xml" extension, you must use a regex like the following `.*\\.xml` (it's a real regex, not just a string with * and ? wildcards) – 6pi May 23 '19 at 10:16