3

I need to add an import wizard into my eclipse-rcp app. For that I would like to use existing wizard with only my categories. I found couple of examples in the Internet, but they didn't help much.

My problem is that I have not only my category, but also the General category. I would like to remove it, if possible. Actually I have found one solution here, but it seems, that it is not working. I've tried to put provided code snippet in WorkbrenchWindowAdvisor and in ActionBarAdvisor and even execute it before my wizard is created, but General category with 5 possible wizards is still there. Any suggestions, how to remove it or at least hide?

BR, AlexG.

Alex K.
  • 3,294
  • 4
  • 29
  • 41

3 Answers3

3

You can choose which contributions are visible in your RCP application by using org.eclipse.ui.activities extension point with appropriate activityPatternBinding (despite of what they say at the page that you linked).

Using this extension point you can define one activity with a pattern that matches anything but your own contributions (e.g. pattern="[^\.]++\.(?!myplugin).*" matches contributions wiht ID-s not starting with com.myplugin). This activity, when not being enabled, will exclude all the contributions from UI except your own.

With another acitvity you will define a pattern that includes the contributions that you'd like to include from other plugins (e.g. pattern=".*file\.import" matches the Import... menu item in File menu). This is the activity that you will enable in your WorkbenchAdvisor using

PlatformUI.getWorkbench().getActivitySupport().setEnabledActivityIds(...);

Please note that this particular solution will disable (almost) all of the Eclipse contributions except File > Import... It will take quite a bit of digging if you want to have a lot of functionality enabled and only small parts disabled. But it's mostly possible to figure out correct patterns to achieve this.

Martti Käärik
  • 3,601
  • 18
  • 28
  • Thank you for your answer, I think this is the only proper solution, thou for some reason I can't make it working. When I am defining an activity to match only my contributions, I can still see some other contributions. – Alex K. Nov 18 '11 at 14:09
  • @AlexanderGavrilov Indeed, some of the UI elements will still be visible for different reasons that depend on the situation. For example, you can't disable primary wizards like "Java Project" wizard. Or if you are reusing some action builders than those might ignore activities. Or sometimes there are bugs in Eclipse... – Martti Käärik Nov 29 '11 at 08:20
  • @MarttiKäärik: Excellent solution, using regex! – s.d Apr 02 '12 at 19:38
0

The problem with the solution you point out is that it is using the NewWizardRegistry to retrieve the categories of the wizards. Instead, if you want to remove the import wizards you should poll the Workbench for the ImportWizardRegistry:

AbstractExtensionWizardRegistry importWizardRegistry = (AbstractExtensionWizardRegistry) PlatformUI.getWorkbench().getImportWizardRegistry();

Everything else is OK.

0

It sounds like it's related to your RCP run configuration and the plug-ins included.

The General category (with it's wizards Preferences, File System, Existing Projects, Archive File) is contributed by the org.eclipse.ui.ide plug-in.

Is this plug-in required by your RCP application?

Have a look at this question related to the Help Menu in an RCP as it describes how to check and change the plug-ins used.

Community
  • 1
  • 1
mecsco
  • 2,250
  • 1
  • 15
  • 28
  • Thank you for your answer, but unfortunately I can not remove org.eclipse.ui.ide plugin, because it is required by some other plugins. – Alex K. Nov 18 '11 at 14:06