Epicurus
Epicurus

Reputation: 2133

Showing hidden directories in Project Explorer view

My Eclipse RCP application includes the Project Explorer view, which by default hides all directories whose name starts with the dot (".") character.

Is it possible to customize the Project Explorer view so that these directories are no longer hidden?

EDIT: I would like to do this programmatically.

Upvotes: 1

Views: 782

Answers (1)

Epicurus
Epicurus

Reputation: 2133

I found a way to do this by looking at the code behind the Customize View dialog (accessing the dialog is described here).

The INavigatorFilterService interface provides the activateFilterIdsAndUpdateViewer method, which allows callers to activate certain filters and deactivate all others. The org.eclipse.ui.navigator.resources plugin defines the org.eclipse.ui.navigator.resources.filters.startsWithDot filter, which is used to remove all files and directories whose name starts with a dot character from the Project Explorer view.

The following code snippet can be used:

      ProjectExplorer projectExpl = ... // get project explorer
      INavigatorContentService contentServ = projectExpl.getNavigatorContentService();
      INavigatorFilterService filterServ = contentServ.getFilterService();
      String[] enabledFilters = new String[0]; // this will clear all filters
      filterServ.activateFilterIdsAndUpdateViewer(enabledFilters);

Upvotes: 1

Related Questions