我正在开发一个 Eclipse 产品。我定义了两种不同的视角:编辑和调试。在调试透视图的工具栏中,我放置了一组按钮来指导调试流程(例如,单步执行、单步执行等)。我使用 eclipse 命令来实现逻辑。在 pluxin.xml 片段下方,我声明了工具栏命令。
<toolbar
id=".."
label="Debug navigation command">
....
<command
commandId="org.eclipse.debug.ui.commands.Terminate"
disabledIcon="icons/16x16/stop_disabled.ico"
icon="icons/16x16/stop.ico"
label="Terminate"
style="push"
tooltip="Terminate">
<visibleWhen
checkEnabled="false">
<with
variable="activeWorkbenchWindow.activePerspective">
<equals
value="org.xvr.xvrengine.perspective.debug">
</equals>
</with>
</visibleWhen>
</command>
</toolbar>
问题是,虽然与命令 org.eclipse.debug.ui.commands.Terminate 关联的所有其他图标均由 eclipse 更新(仅当在调试 View 中选择进程时才有效),但我定义的命令是没有更新。如果我更改视角然后切换回调试视角,编辑器会更新命令图标。
如何更新命令图标?可以使用默认的eclipse图标吗?如果我将“图标”条目留空,工具栏将填充命令标签。
谢谢
最佳答案
您可以在 2 个位置控制命令的启用状态。
- 在 org.eclipse.ui.handlers 中,你可以 将您的处理程序与您的 命令并提供启用时间 核心表达。看 http://wiki.eclipse.org/Command_Core_Expressions 和 http://wiki.eclipse.org/Platform_Expression_Framework
- 当您的处理程序处于 Activity 状态时,其
启用状态反射(reflect)在
命令。大多数处理程序子类
org.eclipse.core.commands.AbstractHandler。
当您的处理程序更新其状态时
使用
org.eclipse.core.commands.AbstractHandler.setBaseEnabled(boolean)
启用状态将被反射(reflect) 在用户界面中
.
关于java - 工具栏图标不会自动更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6033389/