【发布时间】:2013-06-13 12:34:58
【问题描述】:
上下文
我正在为 eclipse 3.4 及更多版本构建一个插件。
我有一个 ID 为 mrp.view 的视图,其中 menuContribution 设置为 toolbar:mrp.view。
这个 menuContribution 有一些命令,我有这个:
<handler
class="mrp.handlers.export"
commandId="mrp.commands.export">
</handler>
<command
commandId="mrp.commands.export"
label="My command"
style="push">
</command>
我的处理程序mrp.handlers.export 有一个动态ìsEnabled()` 方法,看起来像这样:
@Override
public boolean isEnabled() {
return !getMySelection().isEmpty();
}
问题
如何在数据更改时刷新工具栏上的按钮? (如果我单击工具栏的另一个按钮,则会自动完成刷新,但如果我不...)
我试过了..
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
service.refreshElements("mrp.commands.export", null);
但它似乎没有做任何事情。
还有这个:
public class Export extends AbstractHandler implements PropertyChangeListener {
@Override
public void propertyChange(PropertyChangeEvent evt) {
setBaseEnabled(!getSelection().isEmpty());
}
// ....
}
它被调用,但我的视图菜单上的图标没有刷新(在 eclipse 3.7 上)。 我是不是做错了什么?
【问题讨论】:
-
好吧,这很奇怪,它在 Eclipse 4.2 上开箱即用......但在 3.4-3.7 上仍然不能工作
标签: java eclipse eclipse-plugin