0

How to configure perspective in plugin/RCP to show .* resources.

Currently, it should be done manually by selecting Customize View... by every user.

In Eclipse plugin development how to show .* files in a new perspective by default?

Related How to customize eclipse perspective programmatically?

Community
  • 1
  • 1
Paul Verest
  • 60,022
  • 51
  • 208
  • 332

1 Answers1

1

I assume you want to show the *.resources in the package explorer. I do not think there is any plugin designed to do exactly that, but you still have some possibilities.

A simple way to do it, is to go to Customize View. You can just select Filters... from the view menu (the shortcut to .* resources will be shown after you modify it):

The filters menu.

But of course you still need to do that for every user. If this is still too cumbersome you need to work with the extensions that defines them. You might have luck with creating you're own plugin that tries to overwrite the extension point that defines the filter. In short you have to add this to your plugin.xml

   <extension point="org.eclipse.jdt.ui.javaElementFilters">
    <filter
          targetId="org.eclipse.jdt.ui.PackageExplorer"
          name=".* resources (new)"
          enabled="false"
          description="Hides resources with names that start with a '.'"
          pattern=".*">
    </filter>
  </extension>

There is however a hack and there is no guarantee that this will work. If you look into org.eclipse.jdt.ui.actions.CustomFiltersActionGroup.CustomFiltersActionGroup(String, StructuredViewer) you will see that it depends on the order in which the filter-extensions are loaded. According to this question this is rather arbitrary.

Another way which requires more work, but is much less hacky and (to my best knowledge) is sure to work, is to modify the original extension point. This is defined in org.eclipse.jdt.ui so you have to replace this plugin. To do this you need to:

  1. Import the plugin: Open the Plug-ins view, right click on org.eclipse.jdt.ui and select import as source
  2. Find the extension in plugin.xml (Search for name="%HideSystemFiles.label") and change enabled="true" to enabled="false"
  3. Create a "feature patch" with you plugin. Export it and install into your Eclipse. (see resources below)

One disadvantage with this approach, is that you have to maintain this every time org.eclipse.jdt.ui is updated, essentially going through all steps again.

For more info on feature patches see:

Community
  • 1
  • 1
Tobber
  • 7,211
  • 8
  • 33
  • 56
  • Great post. I should have said that the perspective in question is not JDT related. It is defined as new https://github.com/Nodeclipse/nodeclipse-1/blob/master/org.nodeclipse.ui/plugin.xml#L163-L171 (It seems like this way it ~~inherits from Resource perspective~~ shares the same setting with Resource perspective) Then there is PerspectiveFactory https://github.com/Nodeclipse/nodeclipse-1/blob/master/org.nodeclipse.ui/src/org/nodeclipse/ui/perspectives/NodePerspective.java#L25 but I don't see needed methods when I type factory. (dot and see content assist). – Paul Verest Oct 21 '13 at 08:47
  • IPerspectiveFactory is not leading to an answer... http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fui%2FIPerspectiveFactory.html Need to know exact name of attributes like in extension point="org.eclipse.jdt.ui.javaElementFilters" – Paul Verest Oct 21 '13 at 09:02
  • Oh this is close http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_ui_ide_resourceFilters.html – Paul Verest Oct 21 '13 at 09:04
  • That leads to generic Common Navigator Framework with no exact how to http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fcnf.htm&resultof=%22Common%22%20%22common%22%20%22Navigator%22%20%22navig%22%20%22Framework%22%20%22framework%22 – Paul Verest Oct 21 '13 at 09:08
  • 1
    OK. To be sure: 1. Is it the filters in `Project Explorer` view you want to change? – Tobber Oct 21 '13 at 21:34
  • Or perhaps the `Navigator` view – Tobber Oct 21 '13 at 21:42
  • It is `Project Explorer`. Just like in `Resource` perspective – Paul Verest Oct 22 '13 at 10:19
  • 1
    I *think* that `org.eclipse.ui.ide.resourceFilters` has to do with the (depricated) `Navigator` view from `org.eclipse.ui.ide`. As far as I can see `Project Explorer` and its filters are defined in `org.eclipse.ui.navigator.resources` in the insanely large extension point `org.eclipse.ui.navigator.navigatorContent` - just search for `.*` in the `plugin.xml`..... Let me know if that does the trick :) – Tobber Oct 22 '13 at 12:43