Search code examples
eclipseeclipse-plugineclipse-cdt

How to programmatically (or via eclipse plugin.xml) enable context menu which is disabled by eclipse IDE?


In CDT, How can I programmatically (or via eclipse plugin.xml) enable the context menu of a project "Build Project" when It is right clicked. So that I can make the Build Action enabled in order to solve this problem.

Please Check this forum link for more information:

https://www.eclipse.org/forums/index.php/m/1709440/#msg_1709440

I have tried MenuManager but it returns the top menu? I want to access the pop-up menu when it is right clicked on a project.

What I experienced so far is I can programatically get the flow of program when I right-click a project via CommonActionProvider by defining a class at org.eclipse.ui.navigator.navigatorContent at plugin.xml under which I have a defined actionProvider. Now at this ActionProvider I can halt at debug when I right click the project first at setContext method via ActionContext parameter. And this is the point where I want to get access to the right-click menu of selection.

I can acess the selection I get it from context at this point and because I right-clicked at it the context menu will hapen but how I get the access to this right click menu programatically ? When I right click the project after selecting it via control button I get now the access to method fillContextMenu with parameter IMenuManager menu but the bug is not at this part so I dont need to do anything at this method. I need the access to right click menu when I right click an unselected project (via holding control button). Any idea?


Solution

  • I solved the bug via an actionProvider (enablement for a instanceof IProject.) Here in the class that I extended from CommonActionProvider at the method setContext I got the command via commandService and getCommand method. Then calling buildCommand.isEnabled(); solved the bug.