Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » remove items from contex menu(cannot remove "Team","Show In","Compare With","Replace With" items from context menu)
remove items from contex menu [message #526997] Tue, 13 April 2010 12:19 Go to next message
Eclipse UserFriend
Hi,
my rcp application has it's own editor inherited from TextEditor. I add actions to context menu. But I cannot remove the items like: "Team","Show In","Compare With","Replace With". I tried to do it with "org.eclipse.ui.activities" but without success.
What is wrong? Thanks, Stella
<extension
	point="org.eclipse.ui.activities">
	<category
    	name="Filter GUI Category"
    	id="category.excludeFromGUI">
	</category>
	<categoryActivityBinding
   		activityId="activity.excludeFromGUI"
   		categoryId="category.excludeFromGUI">
	</categoryActivityBinding>
	<activity
		name = "Exclude GUI"
		description="Exclude GUI"
		id="activity.excludeFromGUI">
	</activity>			
				
	<activityPatternBinding
		activityId="activity.excludeFromGUI"
		pattern="org\.eclipse\..*update">
	</activityPatternBinding>
	<activityPatternBinding
		activityId="activity.excludeFromGUI"
		pattern="org\.eclipse\.compare.*">
	</activityPatternBinding>
	<activityPatternBinding
		activityId="activity.excludeFromGUI"
		pattern="org\.eclipse\.team\.ui\.showLocalHistory">
	</activityPatternBinding>	
	<activityPatternBinding
		activityId="activity.excludeFromGUI"
		pattern="org\.eclipse\.team\.ui.*">
	</activityPatternBinding>
	<activityPatternBinding
		activityId="activity.excludeFromGUI"
		pattern="org\.eclipse\.team\.cvs\.ui.*">
	</activityPatternBinding>		
 </extension>
Re: remove items from contex menu [message #527045 is a reply to message #526997] Tue, 13 April 2010 15:35 Go to previous messageGo to next message
Eclipse UserFriend
AFAIK org.eclipse.ui.popupMenus don't support activities. I couldn't
find any reference from
org.eclipse.ui.activities.WorkbenchActivityHelper in the
ObjectContributionManager code.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm
Re: remove items from contex menu [message #527102 is a reply to message #527045] Wed, 14 April 2010 00:55 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for response. What is the right way to remove context menu items?
Re: remove items from contex menu [message #527198 is a reply to message #527102] Wed, 14 April 2010 09:02 Go to previous messageGo to next message
Eclipse UserFriend
Stella wrote:
> Thanks for response. What is the right way to remove context menu items?

My guess is if you can't do it with activities, then you won't be able
to do it at all. If you create the view yourself then you control the
context menu. If your menu has no MB_ADDITIONS group marker then
popupMenus won't add objectContributions.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm
Re: remove items from contex menu [message #527219 is a reply to message #526997] Wed, 14 April 2010 10:06 Go to previous messageGo to next message
Eclipse UserFriend
My application editor is inherited from TextEditor. I try to clean a context menu items of the application editor, that I don't need in my rcp application.
Re: remove items from contex menu [message #642446 is a reply to message #526997] Wed, 01 December 2010 06:34 Go to previous messageGo to next message
Eclipse UserFriend
Hello,

A solution is to subclass:

protected String[] collectContextMenuPreferencePages()

Regards,

Tanguy
Re: remove items from contex menu [message #644687 is a reply to message #526997] Mon, 13 December 2010 13:59 Go to previous messageGo to next message
Eclipse UserFriend
another option would be to simply register another Menu with the site.
Re: remove items from contex menu [message #1057881 is a reply to message #526997] Thu, 09 May 2013 10:30 Go to previous messageGo to next message
Eclipse UserFriend
I couldn't find any clean way to do this, but I was able to remove the Show in context menu item in the following way.

In your own Editor class, override the
editorContextMenuAboutToShow(IMenuManager menu)
method. I added the following code to my Editor's method and it removed the Show in menu.

 @Override
	protected void editorContextMenuAboutToShow(IMenuManager menu)
	{   	
		super.editorContextMenuAboutToShow(menu);
		
		//Look for show ins menu
		IContributionItem[] items = menu.getItems();
		for (int i = 0; i < items.length; i++)
		{
			if (items[i] instanceof IMenuManager)
			{
				IMenuManager submenu = (IMenuManager)items[i];
				IContributionItem testShowIn = submenu.find(ContributionItemFactory.VIEWS_SHOW_IN.getId());
				//If menu is found then remove this submenu from the context menu
				if (testShowIn != null)
					menu.remove(submenu);
			}
		}
	}


It works fine and so far I haven't come across any repercussions but it is not a very clean fix.
Re: remove items from contex menu [message #1733182 is a reply to message #1057881] Wed, 25 May 2016 03:50 Go to previous message
Eclipse UserFriend
In Luna (4.4) I managed to remove the items by adding this line at the end of my editor's menuAboutToShow method:

ObjectActionContributorManager.getManager().unregisterAllContributors();
Previous Topic:how to add coolbar in eclipse rcp3
Next Topic:How to refresh decorations of the files in Package Explorer view
Goto Forum:
  


Current Time: Wed Mar 26 11:56:02 EDT 2025

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

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

Back to the top