如何从 Eclipse-RCP 中的导入向导中删除类别?
我需要将导入向导添加到我的 eclipse-rcp 应用程序中。为此,我想使用现有的向导,仅包含我的类别。我在互联网上找到了几个例子,但它们没有多大帮助。
我的问题是我不仅有我的类别,还有常规类别。如果可能的话,我想删除它。实际上我已经找到了一个解决方案这里,但看起来,它不工作。我尝试将提供的代码片段放入 WorkbrenchWindowAdvisor 和 ActionBarAdvisor 中,甚至在创建向导之前执行它,但具有 5 个可能向导的常规类别仍然存在。有什么建议,如何删除它或至少隐藏它?
BR, 亚历克斯·G.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用
org.eclipse.ui.activities
扩展点与适当的activityPatternBinding
(尽管他们在页面上说链接)。使用此扩展点,您可以使用与除您自己的贡献之外的任何内容相匹配的模式定义一项活动(例如
pattern="[^\.]++\.(?!myplugin).*"
与贡献匹配ID-s 不以 com.myplugin 开头)。如果未启用此活动,将排除 UI 中除您自己的贡献之外的所有贡献。通过另一个活动,您将定义一个模式,其中包括您希望从其他插件中包含的贡献(例如
pattern=".*file\.import"
与中的 Import... 菜单项匹配文件菜单)。这是您将在WorkbenchAdvisor
使用请注意,此特定解决方案将禁用(几乎)所有 Eclipse 贡献,除了 File > >导入...如果您想启用大量功能而仅禁用一小部分功能,则需要进行大量的挖掘。但最有可能找出正确的模式来实现这一目标。
You can choose which contributions are visible in your RCP application by using
org.eclipse.ui.activities
extension point with appropriateactivityPatternBinding
(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 yourWorkbenchAdvisor
usingPlease 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.
听起来这与您的 RCP 运行配置和包含的插件有关。
常规类别(及其向导首选项、文件系统、现有项目、存档文件)由
org.eclipse.ui.ide
插件提供。您的 RCP 应用程序需要此插件吗?
查看 这个与 RCP 中的帮助菜单相关的问题 因为它描述了如何检查和更改所使用的插件。
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.
您指出的解决方案的问题在于它使用 NewWizardRegistry 来检索向导的类别。相反,如果您想删除导入向导,您应该轮询工作台中的 ImportWizardRegistry:
AbstractExtensionWizardRegistry importWizardRegistry = (AbstractExtensionWizardRegistry) PlatformUI.getWorkbench().getImportWizardRegistry();
其他一切都好。
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.