Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I reference an icon from a plugin?

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?

like image 572
Terry Avatar asked Oct 27 '14 12:10

Terry


1 Answers

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>
like image 151
Terry Avatar answered Oct 25 '22 09:10

Terry