objectContribution和command之间缺少链接 [英] Missing link between objectContribution and command

查看:139
本文介绍了objectContribution和command之间缺少链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用 objectContribution -element(它是 org.eclipse.ui.popupMenus - 扩展点),我经常(实际上总是)想委托一些命令,而不是自己实现一些动作(因为通常,我有命令和一个处理程序已经实现)。我这样做通过使用 ICommandService IHandlerService ,但感觉应该有一种方法来实现这种编程。我可以使用 viewerContribution 而不是 objectContribution ,但是我会失去显示菜单项的简单方法,对象类型。理想情况下,我想使用已经存在的处理程序的启用检查,以应用到由 objectContribution 定义的菜单项。

When using the objectContribution-element (which is part of the org.eclipse.ui.popupMenus-extension point), I often (practically always) want to delegate to some command instead of implementing some action myself (since usually, I have the command and a handler already implemented). I'm doing this by using ICommandService and IHandlerService, but it feels there should be a way to achieve this programmatically. I could use viewerContribution instead of objectContribution, but then I would lose the easy way of showing the menu entry only when certain object types are selected. Ideally, I would like to use the enablement-checks that already exist for my handlers to apply to the menu entry defined by the objectContribution.

推荐答案

好吧,这里是我缺少的:而不是使用 org.eclipse.ui.popupMenus 点,我不得不使用 org.eclipse.ui.menus - 扩展点与 menuContribution 它的 locationURI - 属性指向弹出:org.eclipse.ui.popup.any?after = additions 。这个 menuContribution 可以包括命令 -element(实现直接绑定到现有命令的目标) code>命令 -element's visibleWhen -element可以绑定到绑定命令的处理程序的激活状态通过 checkEnabled -attribute(实现只有当命令处理程序的启用满足时弹出菜单条目才可见)。

Ok, here's what I was missing: instead of using the org.eclipse.ui.popupMenus-extension point, I had to use the org.eclipse.ui.menus-extension point with a menuContribution that has its locationURI-attribute pointing to popup:org.eclipse.ui.popup.any?after=additions. This menuContribution can include a command-element (achieving the goal of binding directly to an existing command), and this command-element´s visibleWhen-element can be bound to the activation status of the bound command's handler via the checkEnabled-attribute (achieving the goal of having the popup-menu entry visible only when the enablement for the command handler is satisfied).

有什么坏处是 org.eclipse.ui.menus -extension点的文档说明 org.eclipse.ui.popupMenus -extension point被视为已弃用,但是 org.eclipse.ui.popupMenus 的文档没有提到这个事实。

What's bad is that the documentation of the org.eclipse.ui.menus-extension point states that the org.eclipse.ui.popupMenus-extension point is to be considered deprecated, but the documentation of org.eclipse.ui.popupMenus does not mention this fact.

这篇关于objectContribution和command之间缺少链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆