Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Context Menu on my TreeViewer
Context Menu on my TreeViewer [message #668049] Tue, 03 May 2011 14:15 Go to next message
Remo Blaser is currently offline Remo BlaserFriend
Messages: 9
Registered: August 2010
Junior Member
Hello dear Eclipse Community

Im working with a TreeViewer which holds several Files in it.
Now im wondering if i could get the Eclipse standart Context Menu on my TreeElement?

For a Example:

I got a .java File in my Tree and would like to see on a Right Click the Context Menu for Java Files provided by eclipse.

Is there any way to do this?

Re: Context Menu on my TreeViewer [message #671236 is a reply to message #668049] Tue, 17 May 2011 08:41 Go to previous messageGo to next message
Chaitannya  is currently offline Chaitannya Friend
Messages: 14
Registered: May 2010
Junior Member
	// creating the Menu and registering it
		MenuManager menuMgr = new MenuManager("#PopupMenu");
		Menu menu = menuMgr.createContextMenu(treeViewer.getControl());
		getSite().registerContextMenu(menuMgr, treeViewer);

		Action action1 = new Action() { 
			public void run() {
			// Code for handling action goes here. 
		} ; 
		action1.setText("Action 1");

Try out this code.. Let me know if it works.

[Updated on: Tue, 17 May 2011 08:42]

Report message to a moderator

Re: Context Menu on my TreeViewer [message #671420 is a reply to message #671236] Tue, 17 May 2011 19:46 Go to previous message
Catalin Gerea is currently offline Catalin GereaFriend
Messages: 89
Registered: July 2009
Location: Bucharest, Romania

Using the Plug-in Spy (ALT+SHIFT+F1) on the PackageExplorer I could see that the class where the menu is shown is PackageExplorerPart --> menuAboutToShow() method. After that you can check if that implementation could be used by you easily or not.
That class is from JDT internal package so probably asking on the JDT forum will give you back more answers.

Time is what you make of it.
Previous Topic:How to open correct XML editor for different XML documents
Next Topic:Simple Question: Making a button open a tab
Goto Forum:

Current Time: Wed May 23 11:28:14 GMT 2018

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

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

Back to the top