Contributing Popup Menus for CDT Projects [message #1086161] |
Tue, 13 August 2013 22:36 |
Robert Bartlett-Schneider Messages: 2 Registered: August 2013 |
Junior Member |
|
|
I've been attempting to create a plugin that contributes an item to contextual menus in the project explorer. What I've got is this:
<extension
point="org.eclipse.ui.commands">
<category
id="org.example.myCategory"
name="Example Category">
</category>
<command
categoryId="org.exapmle.myCategory"
defaultHandler="org.example.thingHandler"
id="org.example.doTheThing"
name="Do the thing">
</command>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="true"
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<command
commandId="org.example.doTheThing"
label="Do the thing"
style="push">
<visibleWhen
checkEnabled="false">
<with
variable="selection">
<count
value="1">
</count>
<iterate>
<and>
<instanceof
value="org.eclipse.core.resources.IResource">
</instanceof>
<or>
<test
property="org.eclipse.core.resources.extension"
value="z">
</test>
<test
property="org.eclipse.core.resources.extension"
value="cc">
</test>
</or>
</and>
</iterate>
</with>
</visibleWhen>
</command>
</menuContribution>
</extension>
Ideally, the menu should only show up when files with the extension ".z" or ".cc" are selected, and then perform the associated action. However, the menu shows up only when selecting files of the aforementioned extension in Java Projects. The menu is absent in C++ projects when right clicking on a file. I can't seem to find an appropriate place for the locationURI that will get it to show up in C++ projects.
Out of curiosity, I tried the plugin in a separate install of Eclipse which lacked the JDT and the menu was nowhere to be found as well. I also used the plugin wizard for "popup menu" addition, and without making any changes, loaded it up and found that the menu contributed by the sample code only shows up in Java projects as well, and is absent from C++ projects.
I hope I'm just missing something here, possibly a different locationURI Any advice is appreciated.
Edit: One thing I tried out of curiosity was editing the .project file and removing the C nature & CC natures from the project, and replacing them with the Java nature. The project looked a tad funky, but the menu did indeed show up. It doesn't show up if I just added the Java nature and left the C/CC natures in place.
[Updated on: Thu, 15 August 2013 14:46] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03215 seconds