Hide Resource Management Context Menu entries from a view - eclipse

I have a custom view in my eclipse RCP and want to hide some of the actions from org.eclipse.ui.navigator.resources.ResourceMgmtActions when a user right clicks on a IProject resource. I just want to display "refresh" action and hide Close, Open, Close Unrelated projects, Build option from the context menu. Is there a way to do this declaratively via plugin.xml or pro grammatically without copying the code from ResourceMgmtActionProvider.java?

Related

Removing "Show In" menu items in Eclipse RCP application

I am developing an Eclipse RCP application, and would like to remove some of the items displayed in the "Show In" context menu. The items are placed in this menu by various plug-ins, and I would prefer to not have them there.
Adding a new entry to this menu is well documented: https://wiki.eclipse.org/FAQ_How_do_I_make_my_view_appear_in_the_Show_In_menu%3F
However, removing an existing entry seems problematic, since Views are listed in the "Show In" menu by virtue of them implementing the IShowInTarget interface. The resulting menu items do not have unique IDs that could be used to disable them via an Activity.
It seems to me like the only way to avoid listing a View defined by an existing plug-in in the "Show In" menu is to extend the plug-in class implementing this View.
The source code for the 'Show In' menu is org.eclipse.ui.internal.ShowInMenu.
This gets contributions from a number of places but I don't see anything that could be used to filter them.
'Extending the plug-in class implementing the view' is not really possible.

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?
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.

Eclipse plugin: how to modify the tab context menu

When developing Eclipse RCP application, on the view part, right click on the tab, you can see a context menu with "detached, restore, move, size, minimize, maximize" actions. I was wondering how to add a new action to that tab context menu? What's the correct keyword for this?
Most of results I found is about the general context menu, which is the one you get when right click anywhere in the viewpart. Where what I am looking for is the context menu from the tab.
Or what I should do is set some properties which make the context menu only showing when right click on the tab area.
What I am trying to do is add an option "Duplicate Tab" to context menu.

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);

In Eclipse How to Enable and Disable Main Menu Items in Run time

During menu added into the main menu of eclipse which has sub-menus. I need these sub-menus to be enabled/disabled based on a condition
which I can check programmatically.
Enabling/Disabling the items via plugin.xml is static, even if a condition can be checked it is only after we click on the menu item.
How to happen at run time when the user clicks the Menu itself rather than the sub-menu items.
Use action enablement property in plugin.xml, refer to
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_ui_actionSets.html