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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With