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

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?

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.

Related

How to add a context menu entry to the eclipse editor context menu

I'm trying to create a plugin for eclipse and for the one of the requirements is to add an entry to the context menu for all text editors so that on right click I get an option corresponding to the action I want to perform. I've tried to find relevant resources for it but most of the use cases are focused on adding a context menu to a view etc and not to the context menu for the eclipse editor. So far, I tried to implement this using the eclipse context in the activator but as is perhaps obvious, the workspace is not created when the activator's start method executes. Any help would be appreciated!

Eclipse RCP - remove command from the popup

I am working on a tool (which is built over Eclipse). In that there is a popup menu called "Edit Properties" if a object is right clicked. I need to hide this menu command. Provided that it should not be gets hided from the standard menu, should only be hide from the popup.
How to do this? Can anyone suggest me?

Updating Eclipse context menu contributions on right click

In my Eclipse RCP application, I have created a context menu in a tree viewer with some contributions that are added depending on the results of various property testers. Those property testers evaluate attributes of the model object which is selected with right click when opening the context menu.
When debugging, I noticed that the property testers are only executed when the selection in the tree viewer changes, but not on right clicking when opening the context menu. How do I get the property testers called when right clicking?
I need the property testers executed when right clicking because some actions change the underlying model objects and therefore should result in a different context menu. And the user might execute such an action and and open the context menu right after without changing the selection.
Have a look at IEvaluationService.requestEvaluation(String propertyName)... It does exactly what you need. You get the evaluation service from the site like all the other services:
IEvaluationService es = (IEvaluationService)getSite().getService(IEvaluationService.class);

Adding menu listener for Paste option in SWT Browser

I have a org.eclipse.swt.browser.Browser instance created in a composite. I would like to know when some content is pasted in the browser using the (platform specific) right click context menu and selecting the paste option.
In the menuDetected() of MenuDetectListener, I get a notification when the context menu is detected in the browser.
How can I know if the Paste option is selected from the context menu?
Regards,
Noopur
No you can't access the selected context menu item. There is no direct provision for that. At least not in eclipse 3.7. Although, you could try different combinations of events for determining the menu item. For example, in windows the internet explorer populates the status bar with 'inserts the clipboard...' when your mouse pointer hovers over the Paste menu item, you can capture this using StatusTextListener event.
Note: The hack is not an elegant solution, even if you get it working, there is still some possibility that it may break with new or older releases of SWT or in fact its behavior may vary with operating systems !!

Eclipse plug-in: How to create a new menu for eclipse plugin with key combination?

I've been looking about this question but I couldn't find it. I need to create a new "popup menu" and assign a key pressed (in other words, I need press "F3+right-click" (for example) and this action will be appear a new popup menu, with my actions in my workbench). I don't need a submenu for my right-click... i need a new and alone menu
Example, in eclipse, when i right-click with my mouse over workbench I see a popmenu with: "undo, revert file, save, cut, copy..." and more, but i need create a new menu instead of eclipse menu, so, when I press "F3+right-click" (example) i need see my popup-menu with my actions... this is my problem, i need to create a new menu and call it with key/mouse combination...
I've been reading the forums but i don't know where to post this question and I don't know where to search (maybe i write a wrong question in the search... i think...).
I hope someone can help me.
Thank you very much;)
I assume that you would like to see this menu in an editor (rather than in a view because that would be slightly different). Most of what you need to do here is to extend eclipse extension points through declaring them in the plugin.xml for your plugin.
Thankfully, Eclipse ships with a few extension point wizards to help you get started with this. To get there, do the following
Open the plugin.xml for your plugin
Go to the extensions page
Click on Add...
Click on Extension Wizards
The "Popup Menu" wizard
After filling in all the details, there are still a few more pieces that you need to do.
The wizard creates an Object contribution, that will add the new popup menu to an object of a specified type in all views. You can change this to being an editor contribution, so that the menu item will show in editors instead.
The final step is to connect this menu item with a key-binding. For that, you need to create a new Command extension.
Start with the Command extension point wizard.
After filling in the details, you get a command, a handler, and a binding. You can remove the handler, since you will connect your action created previously to the command you just created.
From here, you need to fill in all of the stub Java classes created by the wizards and you should be in business.
This is a very rough set of steps you need to do to implement the keybindinds (and, yes, it is way more complicated than it needs to be). For more detail, you can go here:
http://www.vogella.de/articles/EclipseCommands/article.html