Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 16:19 Go to next message
Stella Levin is currently offline Stella LevinFriend
Messages: 88
Registered: July 2009
Member
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 19:35 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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 04:55 Go to previous messageGo to next message
Stella Levin is currently offline Stella LevinFriend
Messages: 88
Registered: July 2009
Member
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 13:02 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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 14:06 Go to previous messageGo to next message
Stella Levin is currently offline Stella LevinFriend
Messages: 88
Registered: July 2009
Member
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 11:34 Go to previous messageGo to next message
Tanguy Mezzano is currently offline Tanguy MezzanoFriend
Messages: 24
Registered: March 2010
Junior Member
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 18:59 Go to previous messageGo to next message
Eugene  is currently offline Eugene Friend
Messages: 25
Registered: July 2009
Junior Member
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 14:30 Go to previous message
n m is currently offline n mFriend
Messages: 7
Registered: February 2012
Junior Member
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.
Previous Topic:Problem Updating Eclipse Java EE, Juno SR1
Next Topic:eclipse crashes by missing JNI_CreateJavaVM symbol windows 8
Goto Forum:
  


Current Time: Thu Nov 27 06:00:24 GMT 2014

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

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