如何从插件中引用图标? [英] How can I reference an icon from a plugin?

查看:168
本文介绍了如何从插件中引用图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Eclipse RCP应用程序与一些插件和一些命令。对于其中一个命令,我想使用一个附加的插件中的图标。



该插件称为 com.example.plugin.workspace ,图标的路径为 icons / workspace.png



我会喜欢在我的应用程序的plugin.xml中引用它,在那里我想将命令添加到工具栏中:

< toolbar 
id =com.example.application.displays.toolbar>
< command
commandId =com.example.application.system.command.OpenWorkspace
icon =PATH TO ICON IN PLUGIN
label =Open Workspace
style =push>
< / command>
< / toolbar>
< / menuContribution>

我可以引用插件的图标,如果是,怎么样?

解决方案

可以在XML中引用包含插件的图标,前缀为:

 平台:/plugin/Bundle-SymbolicName/path/filename.extension 

请参阅 http://www.vogella.com/tutorials/EclipseRCP/article.html#runtime_uri



所以,在问题的例子中,这将是:

 code>平台:/plugin/com.example.plugin.workspace/icons/workspace.png 

对于工具栏贡献:

 < menuContribution 
allPopups =false
locationURI =工具栏:org.eclipse.ui.main.toolbar后=添加>?
< toolbar
id =com.example.application.displays.toolbar>
< command
commandId =com.example.application.system.command.OpenWorkspace
icon =platform:/plugin/com.example.plugin.workspace/icons/workspace。 png
label =打开工作区
style =push>
< / command>
< / toolbar>
< / menuContribution>


I have an Eclipse RCP application with some plugins and some commands. For one of the commands I want to use an icon from one of the included plugins.

The plugin is called com.example.plugin.workspace and the path to the icon is icons/workspace.png.

I would like to reference it in my application's plugin.xml, where I want to add the command to a toolbar:

<menuContribution
        allPopups="false"
        locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
    <toolbar
           id="com.example.application.displays.toolbar">
        <command
             commandId="com.example.application.system.command.OpenWorkspace"
             icon="PATH TO ICON IN PLUGIN"
             label="Open Workspace"
             style="push">
        </command>
    </toolbar>
</menuContribution>

Can I reference the icon of the plugin there, and if yes, how?

解决方案

An icon from an included plugin can be referenced in the XML with the prefix:

platform:/plugin/Bundle-SymbolicName/path/filename.extension 

See http://www.vogella.com/tutorials/EclipseRCP/article.html#runtime_uri

So, in the example of the question, that would be:

platform:/plugin/com.example.plugin.workspace/icons/workspace.png 

For the toolbar contribution:

<menuContribution
        allPopups="false"
        locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
    <toolbar
           id="com.example.application.displays.toolbar">
        <command
             commandId="com.example.application.system.command.OpenWorkspace"
             icon="platform:/plugin/com.example.plugin.workspace/icons/workspace.png"
             label="Open Workspace"
             style="push">
        </command>
    </toolbar>
</menuContribution>

这篇关于如何从插件中引用图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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