命令图像

org.eclipse.ui.commandImages

3.2

图像扩展点用来将不同类型的图像和图标链接到特定命令。可以在用户界面中任何显示该命令的位置适当地使用这些图像。为了适应某些边界情况(例如,工具栏下拉项),可以将特定命令的图像分组成“样式”。然后,可以在显示命令时明确地请求使用这些样式。

<!ELEMENT extension (image*)>

<!ATTLIST extension

point CDATA #REQUIRED

id    CDATA #IMPLIED

name  CDATA #IMPLIED>


<!ELEMENT image EMPTY>

<!ATTLIST image

commandId    CDATA #REQUIRED

icon         CDATA #REQUIRED

disabledIcon CDATA #IMPLIED

hoverIcon    CDATA #IMPLIED

style        CDATA #IMPLIED>

要与特定命令相关联的图像。



<extension point=

"org.eclipse.ui.commandsImages"

>

<image commandId=

"ProfileLast"

hoverIcon=

"icons/full/etool16/profile.gif"

disabledIcon=

"icons/full/dtool16/profile.gif"

icon=

"icons/full/etool16/profile.gif"

/>

<image commandId=

"ProfileLast"

hoverIcon=

"icons/full/etool16/history.gif"

disabledIcon=

"icons/full/dtool16/history.gif"

icon=

"icons/full/etool16/history.gif"

imageStyle=

"toolbar"

/>

</extension>

在工作台中,可以使用 org.eclipse.ui.handlers.ICommandImageService 接口来获取命令的图像。可以从支持工作台对象(例如 IWorkbench 本身)检索此接口。要检索该服务,可以进行类似于 IWorkbench.getAdapter(ICommandImageService.class) 的调用。