Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Adding a context menu in NatTable Eclipse 3 RCP Application
Adding a context menu in NatTable Eclipse 3 RCP Application [message #1693022] Tue, 21 April 2015 09:44 Go to next message
Ines El Euch is currently offline Ines El EuchFriend
Messages: 35
Registered: March 2015
Member
Hello,

I want to add a context menu to a NatTable in an RCP Eclipse 3 application. I am following the tutorial posted in the blog of Lars Vogel http://blog.vogella.com/2015/02/03/nattable-context-menus-with-eclipse-menus/?utm_medium=twitter&utm_source=twitterfeed
I am using the "Combination with Eclipse 3.x menus" part of the tutorial.

The problem that I found using this method, is when I run the application and I right click on the nattable, the contribution that I added is displayed, however when I right click again it disappears. And then, I am left with only the debug information menu Item (that I want to delete by the way). I am really stuck with this issue and any help is welcome.

Thanks in advance

Inès


PS : I corrected my message Dirk Fauth

[Updated on: Tue, 21 April 2015 13:28]

Report message to a moderator

Re: Adding a context menu in NatTable Eclipse 3 RCP Application [message #1693034 is a reply to message #1693022] Tue, 21 April 2015 11:21 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Quote:
I am following the tutorial of Lars Vogella


First, his name is Lars Vogel, not Vogella. The later is the company name.
Second, if you have a look at the author you will notice that he didn't wrote the blog post. Wink

Quote:
when I right click again it disappears


Sounds like there is an issue with your MenuManager. But without seeing your code and knowing which NatTable version you use, I can't tell you what you are doing wrong. I'm pretty sure I tested this back when I wrote the blog post.

Quote:
I am left with only the debug information menu Item (that I want to delete by the way)


If you don't want to show the debug information menu item, why do you use the DebugMenuConfiguration? It is just used as an example. For a custom menu you should create a custom AbstractUiBindingConfiguration, similar to the showed DebugMenuConfiguration.
Re: Adding a context menu in NatTable Eclipse 3 RCP Application [message #1693058 is a reply to message #1693034] Tue, 21 April 2015 13:24 Go to previous messageGo to next message
Ines El Euch is currently offline Ines El EuchFriend
Messages: 35
Registered: March 2015
Member
Hello,

First of all thanks for your reply Smile . Second of all, I am using the latest version of nattable wich is 1.3.0. As for the debug configuration, I created a class extending the AbstractUiBindingConfiguration.
For further information here is my code

This is the class that extends AbstractUiBindingConfiguration
public class DebugMenuConfiguration extends AbstractUiBindingConfiguration {
	
	private final Menu debugMenu;
	private final NatTable natTable;
	@Override
	public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
		uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE,																		 GridRegion.BODY,																	 MouseEventMatcher.RIGHT_BUTTON), new PopupMenuAction(this.debugMenu));

	}
	
	public DebugMenuConfiguration(NatTable natTable,MenuManager mgr) {
	    // extend the declarative menu provided by the MenuManager
		this.natTable = natTable;		
	    this.debugMenu = new PopupMenuBuilder(this.natTable,mgr)
	                .withInspectLabelsMenuItem()
	                .build();	   
	   
	}

}



Then I call it in the nattable.addConfiguration() like so :

 nattable.addConfiguration(new DebugMenuConfiguration(nattable,mgr)); // nattable is the instance of NatTable that I am working with



Then in my view in I instanciate the MenuManager :

 public void createPartControl(Composite parent) {		
			
		MenuManager mgr = new MenuManager();			
		getSite().registerContextMenu("nattableContextMenu",mgr,null);	


Finally, nattableContextMenu is declared under org.eclipse.ui.menus like so :

popup:nattableContextMenu => the I created a command under it, I gave it a label, an id and a command.

I hope now my question si more clear.

Thanks for your help.

Inès

[Updated on: Tue, 21 April 2015 13:30]

Report message to a moderator

Re: Adding a context menu in NatTable Eclipse 3 RCP Application [message #1693110 is a reply to message #1693058] Tue, 21 April 2015 19:36 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Please open a ticket. I tried to search for this quickly, but it seems there is an issue regarding the MenuManager and contribution items with Eclipse 3 API. Or the compat layer. With Eclipse 4 everything works fine.

Which Eclipse version do you use in the target?
Re: Adding a context menu in NatTable Eclipse 3 RCP Application [message #1693180 is a reply to message #1693110] Wed, 22 April 2015 09:41 Go to previous messageGo to next message
Ines El Euch is currently offline Ines El EuchFriend
Messages: 35
Registered: March 2015
Member
Hi,

I am using Eclipse SDK Luna 4.4 with Build id : I20140606-1215. For the ticket could you show me how I can make one I haven't did that before. Thanks

Inès
Re: Adding a context menu in NatTable Eclipse 3 RCP Application [message #1693203 is a reply to message #1693180] Wed, 22 April 2015 11:47 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Create an Eclipse user, log in to Bugzilla and file a ticket for NatTable Core 1.3.0

https://bugs.eclipse.org/bugs/enter_bug.cgi?product=NatTable

http://www.vogella.com/tutorials/EclipsePlatformDevelopment/article.html#contributingtotheproject_bugreports
Re: Adding a context menu in NatTable Eclipse 3 RCP Application [message #1693360 is a reply to message #1693203] Thu, 23 April 2015 13:43 Go to previous message
Ines El Euch is currently offline Ines El EuchFriend
Messages: 35
Registered: March 2015
Member
Ok, Thank you Smile
Previous Topic:FileOutputStreamProvider - Error Written to Log
Next Topic:RowPostSelectionProvider doesn't fire if selection is programmatically executed
Goto Forum:
  


Current Time: Thu Apr 25 23:36:28 GMT 2024

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

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

Back to the top