3

我需要在我的 eclipse-rcp 应用程序中添加一个导入向导。为此,我想仅将现有向导与我的类别一起使用。我在互联网上找到了几个例子,但它们并没有太大帮助。

我的问题是我不仅有我的类别,还有一般类别。如果可能的话,我想删除它。实际上我在这里找到了一种解决方案,但似乎它不起作用。我尝试将提供的代码片段放在 WorkbrenchWindowAdvisor 和 ActionBarAdvisor 中,甚至在创建我的向导之前执行它,但是具有 5 个可能向导的通用类别仍然存在。任何建议,如何删除或至少隐藏?

BR,亚历克斯G。

4

3 回答 3

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.

于 2011-11-17T08:29:23.770 回答
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.

于 2011-11-15T17:39:10.097 回答
0

您指出的解决方案的问题是它使用 NewWizardRegistry 来检索向导的类别。相反,如果您想删除导入向导,您应该轮询 Workbench 以获取 ImportWizardRegistry:

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

其他一切都很好。

于 2013-10-22T15:36:49.910 回答