Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Contributing Popup Menus for CDT Projects
Contributing Popup Menus for CDT Projects [message #1086161] Tue, 13 August 2013 22:36 Go to next message
Robert Bartlett-Schneider is currently offline Robert Bartlett-SchneiderFriend
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:

            name="Example Category">
            name="Do the thing">

               label="Do the thing"

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 Smile 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

Re: Contributing Popup Menus for CDT Projects [message #1087587 is a reply to message #1086161] Thu, 15 August 2013 21:52 Go to previous message
Robert Bartlett-Schneider is currently offline Robert Bartlett-SchneiderFriend
Messages: 2
Registered: August 2013
Junior Member
After a bit more digging I figured it out...

It looks like .cc/.cpp files in the project viewer in C/CC nature projects are actually objects of type ITranslationUnit, not IFile. As such they don't directly inherit from IResource, and the property tester for IResource extension doesn't even want to consider them. I ended up writing my own as there didn't seem to be any property testers for ITranslationUnit (or related files) in any of the cdt source. Everything seems to work for the time being now though.

I did also find out that the other files I had that I wanted it to activate for (.z) did seem to be IFile objects, so it worked on those.
Previous Topic:[TreeViewer] How to bring a not yet visible object in view
Next Topic:How to launch a run/debug configuration using a keyboard shortcut?
Goto Forum:

Current Time: Mon Nov 24 16:37:28 GMT 2014

Powered by FUDForum. Page generated in 0.16061 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software