Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Create Body Context Menu in E4 with NatTable
Create Body Context Menu in E4 with NatTable [message #1220045] Mon, 09 December 2013 05:50 Go to next message
Ludwig Moser is currently offline Ludwig Moser
Messages: 328
Registered: July 2009
Senior Member
I'm trying to register a Context Menu for NatTable.

therefore i use the EMenuService, NatTable and a MenuID.

e4popupMenu = menuService.registerContextMenu(natTable, menuId);


this returns me null.
so i thought i do need an existing menu on NatTable:

popupMenu = new Menu(natTable.getShell(), SWT.POP_UP);
natTable.setMenu(popupMenu);


now i can access my menu from code, but via extension its not visible by using the MenuID

what am i doing wrong here?
any help wellcome! thanks in advance!
Re: Create Body Context Menu in E4 with NatTable [message #1220050 is a reply to message #1220045] Mon, 09 December 2013 06:12 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1263
Registered: July 2012
Senior Member
I'm not sure. NatTable itself has no dependency to the Eclipse framework. Maybe that is why it is not possible via extension point.

Why don't you use the popup menus in NatTable itself? This will give you access to the context like the current cell the click is performed on.
Re: Create Body Context Menu in E4 with NatTable [message #1220052 is a reply to message #1220050] Mon, 09 December 2013 06:34 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig Moser
Messages: 328
Registered: July 2009
Senior Member
i need to be able to add menu items by extensions (commands)
eg. i add an command which exports my data to a specific format (eg. csv or something else)
one command exports the selection; the other exports all items in table, another one deletes the items selected;
etc...

i already had this stuff working with E3 (there i used the MenuManager)

to the function registerContextMenu i can find anything which shows that the swt component needs any dependencies to the eclipse framework. from what i read it just has to be a swt component which can hold an Menu...
Re: Create Body Context Menu in E4 with NatTable [message #1220054 is a reply to message #1220052] Mon, 09 December 2013 06:44 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1263
Registered: July 2012
Senior Member
Would need to investigate on this myself.

Could it be related to not performed injections?
Re: Create Body Context Menu in E4 with NatTable [message #1220058 is a reply to message #1220054] Mon, 09 December 2013 06:56 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig Moser
Messages: 328
Registered: July 2009
Senior Member
nope. the only thing i get injected is the EMenuService, and this one is not null.
i checked this like 10 times, before posting here. all parameters are filled and not null.

eg:
		public EclipsePopupMenuBuilder(EMenuService menuService, NatTable natTable,
			String menuId) {
		System.out.println("building an PopupMenu for NatTable:");
		System.out.println("\tmenuId: " + menuId);
		System.out.println("\tmenuService: " + menuService);
		System.out.println("\tnatTable: " + natTable);

		if (menuService != null) {
			popupMenu = new Menu(natTable.getShell(), SWT.POP_UP); // testing
			natTable.setMenu(popupMenu);// testing

			e4popupMenu = menuService.registerContextMenu(natTable, menuId);
			System.out.println("\te4popupMenu : "
					+ e4popupMenu);
			System.out.println("\tswt menu : "
					+ popupMenu);

		}
	}


and the output:
building an PopupMenu for NatTable:
	menuId: at.biooffice.views.site.listview.menu
	menuService: org.eclipse.e4.ui.workbench.swt.modeling.MenuService@146e54c
	natTable: NatTable {}
	e4popupMenu : null
	swt menu : Menu {}


hope this helps

[Updated on: Mon, 09 December 2013 07:03]

Report message to a moderator

Re: Create Body Context Menu in E4 with NatTable [message #1220126 is a reply to message #1220058] Mon, 09 December 2013 16:22 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1263
Registered: July 2012
Senior Member
Did you add a Popup Menu in the Application Model for your Part?

Debugging into MenuService you will notice that it will return null if there can be no menu found for the given ID for the current Part.
Re: Create Body Context Menu in E4 with NatTable [message #1220146 is a reply to message #1220126] Tue, 10 December 2013 01:18 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig Moser
Messages: 328
Registered: July 2009
Senior Member
FYI i am not creating the app by using Application.e4xmi. i launch my app with an .product.
i added a extension point
org.eclipse.ui.menus
menu:xxx.views.listview.menu

xxx.views.listview.menu is the MenuID i pass in the register function
Re: Create Body Context Menu in E4 with NatTable [message #1220164 is a reply to message #1220146] Tue, 10 December 2013 02:26 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1263
Registered: July 2012
Senior Member
You also have a .product when working with an Application.e4xmi

I don't think your issue is related to NatTable. It sounds more like an issue with E4, compatibility layer and context menus in general. Maybe you want to ask you question in the E4 forum.
Re: Create Body Context Menu in E4 with NatTable [message #1220167 is a reply to message #1220164] Tue, 10 December 2013 02:53 Go to previous message
Ludwig Moser is currently offline Ludwig Moser
Messages: 328
Registered: July 2009
Senior Member
will do so, thanks!
Previous Topic:Frozen Columns - Drawing error
Next Topic:Collapse All Rows in TreeLayer
Goto Forum:
  


Current Time: Fri Aug 29 06:32:14 EDT 2014

Powered by FUDForum. Page generated in 0.01945 seconds