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>
Related
I am trying to add a new command to "compare with" menu present in context menu of Package Explorer and Project Explorer.
Command is getting displayed only in Package Explorer. I am not getting any command in Project Explorer. I want the command to be present only in these two views.
Below is my code.
<menuContribution
allPopups="false"
locationURI="popup:org.eclipse.jdt.ui.PackageExplorer?after=additions">
<menu
id="compareWithMenu"
label="Compare With">
<separator
name="compareWithGroup">
</separator>
</menu>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="popup:org.eclipse.ui.navigator.ProjectExplorer?after=additions">
<menu
id="compareWithMenu"
label="Compare With">
<separator
name="compareWithGroup">
</separator>
</menu>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="popup:compareWithMenu?after=additions">
<command
commandId="com.test.compareWithEachOther"
label="Compare with each other"
style="push">
<visibleWhen
checkEnabled="true">
</visibleWhen>
</command>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="popup:compareWithMenu?after=additions">
<command
commandId="com.test.compareWithEachOther"
label="Compare with each other"
style="push">
<visibleWhen
checkEnabled="true">
</visibleWhen>
</command>
</menuContribution>
I tried changing my id menu contribution also. But then in Package Explorer a new compare with option is coming. I think this is expected.
I want the command to be present only in these two views.
Am i missing something?
The popup menu id for Project Explorer appears to be
org.eclipse.ui.navigator.ProjectExplorer#PopupMenu
Alternatively the PDE plugin uses:
<menuContribution
allPopups="false"
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
to add its 'Compare With > API Baseline' menu item.
In Eclipse plugin.xml,how to make a submenuItem from New Menu to be visible not only in project explorer but also in package explorer.
My source code is ...
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="true"
locationURI="popup:common.new.menu?after=additions">
<command
commandId="org.eclipse.ui.newWizard"
icon="icons/schema-file_16x16.png"
label="%schemaFile.command.label"
style="push">
</command>
</menu>
</extension>
But this submenu is only visible in ProjectExplorer, but not in PackageExplorer.
How to do to be visible in both package and project. If someone know the code please share to me.
I am writing an Eclipse plugin for which I want to re-use the File > New... menu leading to the wizard to include my start menu's. For this, I have the following simple code:
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="menu:file">
<menu label="New">
<command
commandId="org.eclipse.ui.file.newQuickMenu">
</command>
</menu>
</menuContribution>
</extension>
My expectation is that I should see File > New... But no such menu appears. What am I missing?
We're developing an eclipse-plugin and have some contributions for the context-menu in the package-explorer. Using the old org.eclipse.ui.popupMenus, we could specify a name-filter in the contribution, so the menu-entry is only shown if the selected file has a specific name:
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
adaptable="false"
id="..."
nameFilter="file.xml"
objectClass="org.eclipse.core.resources.IFile">
...
</objectContribution>
</extension>
Now, we want to use the new way to create that context-menu and can also disable the entry, if it's no file:
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="popup:org.eclipse.jdt.ui.PackageExplorer">
<command
commandId="..."
label="..."
style="push">
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="..."
name="...">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="..."
commandId="...">
<activeWhen>
<with
variable="selection">
<iterate
ifEmpty="false"
operator="and">
<adapt
type="org.eclipse.core.resources.IFile">
</adapt>
</iterate>
</with>
</activeWhen>
</handler>
</extension>
(Also compare: Enable/disable menu item in Eclipse plugin)
However, we not only want to disable the entry, when there's no file selected, but also, when the file isn't an xml-file. We tried to hack something in the <activeWhen>-tag, but we couldn't find a solution to let it watch the filename, too.
Is there a possibility to do this? And if: How?
There is an Eclipse wiki page about Menu Contributions/IFile objectContribution which might help. I haven't tested it myself, but it seems the nameFilter attribute of the action-based extension can be replaced with a call to a predefined property tester with id org.eclipse.core.resources.name when using the command framework.
I am developing an eclipse plugin and trying to extend the source menu (mainMenubar/Source - visible when editing in the java-editor) in Eclipse 3.7.
The documentation says to rely on the org.eclipse.ui.menus-extension point since the older extension points are deprecated. It is a complete secret to me where to obtain reliable locationURIs, but I finally managed to find some plausible URI with the Plugin Spy (following an advice here).
So the following should be the extension snippet for the plugin.xml:
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.jdt.ui.source.menu">
<command
commandId="some.command.id"
label="Some label"
style="push">
</command>
</menuContribution>
</extension>
Unfortunately, when running the plugin for my development IDE no command appears, and also no error message. Just nothing happens. When I set the locationURI to "menu:help", the new command appears in the help menu, so the problem seems to be really the locationURI.
This thread reports having added an entry in the main Source menu:
<!-- main menu -->
<extension point="org.eclipse.ui.actionSets">
<actionSet label="Java Coding"
description="Action set containing coding related Java actions"
visible="true"
id="org.eclipse.jdt.ui.CodingActionSet2">
<menu label="&Source"
path="edit"
id="org.eclipse.jdt.ui.source.menu">
</menu>
<action class="org.gsoc.eclipse.tostringgenerator.actions.GenerateToStringActionDelegate "
id="org.gsoc.eclipse.tostringgenerator.action"
label="Generate to&String()..."
menubarPath="org.eclipse.jdt.ui.source.menu/generateGroup">
</action>
</actionSet>
</extension>
I ran into the same problem. I finally figured out that extending the Source menu using the (recommended) extension point org.eclipse.ui.menus is not possible.
The reason is that a menu defined in an old style actionSet (like the Source menu) is created after the processing of org.eclipse.ui.menus-extensions. The way it is, these extensions can only contribute to already existing menus.
So sticking to the old API (as suggested by VonC) is probably the best option until the jdt plugin is migrated to the new approach...
You can use the popup: space instead of the menu: space. Here is a working example:
<extension point="org.eclipse.ui.commands">
<command defaultHandler="com.igenox.plugin.dpbuilder.rcp.handler.CreateBuilderHandler"
id="com.igenox.plugin.DPBuilder.CreateBuilderPattern" name="CreateBuilderPattern">
</command>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.jdt.ui.source.menu?after=DPSeparator">
<command commandId="com.igenox.plugin.DPBuilder.CreateBuilderPattern"
id="createBuilder" label="Create Builder Pattern">
</command>
</menuContribution>
<menuContribution
locationURI="popup:org.eclipse.jdt.ui.source.menu?after=additions">
<separator name="DPSeparator" visible="true">
</separator>
</menuContribution>
</extension>