Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Create extendable PopupMenu for an SWT Component via EMenuService((in my case NatTable))
Create extendable PopupMenu for an SWT Component via EMenuService [message #1220010] Mon, 09 December 2013 07:19 Go to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
Hello,

i'm trying to add a (Popup)Menu for an SWT component (NatTable).
it should be possible to add an menu item to it via extensions.

afaik i have to create a menu via EMenuService and register an SWT component with an given ID (then the service should create the menu and return it to me)

here is the code i use:
Quote:
Create a menu for this control and hook it up with the MPopupMenu.

does it mean it creates the menu itself or must it already exist?
e4popupMenu = menuService.registerContextMenu(natTable, menuId);

i checked for nullpointers:
menuService is not null
natTable is not null
menuId is not null
but the resulting e4popupMenu is null

can anyone explain me why this happens?

before i switched to e4 i did it with MenuManager, and this worked fine :-/
i was even able to gain direct access to an Menu (no more possible as i get an MPopupMenu? or can i get from this one to my 'classic' Menu)

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

Report message to a moderator

Re: Create extendable PopupMenu for an SWT Component via EMenuService [message #1220069 is a reply to message #1220010] Mon, 09 December 2013 13:10 Go to previous messageGo to next message
Eclipse UserFriend
Your menu is a part menu right?
Re: Create extendable PopupMenu for an SWT Component via EMenuService [message #1220144 is a reply to message #1220069] Tue, 10 December 2013 06:04 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
nope, its a popup menu on an swt component
Re: Create extendable PopupMenu for an SWT Component via EMenuService [message #1220174 is a reply to message #1220010] Tue, 10 December 2013 08:39 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
So does the Part-Model hold a Menu with this ID? Did you debug into the
code?

Tom

On 09.12.13 08:19, Ludwig Moser wrote:
> Hello,
>
> i'm trying to add a (Popup)Menu for an SWT component (NatTable).
> it should be possible to add an menu item to it via extensions.
>
> afaik i have to create a menu via EMenuService and register an SWT
> component with an given ID (then the service should create the menu and
> return it to me)
>
> here is the code i use:
>
> e4popupMenu = menuService.registerContextMenu(natTable, menuId);
>
> i checked for nullpointers:
> menuService is not null
> natTable is not null
> menuId is not null
> but the resulting e4popupMenu is null
>
> can anyone explain me why this happens?
>
> before i switched to e4 i did it with MenuManager, and this worked fine :-/
> i was even able to gain direct access to an Menu (no more possible as i
> get an MPopupMenu? or can i get from this one to my 'classic' Menu)
Re: Create extendable PopupMenu for an SWT Component via EMenuService [message #1220177 is a reply to message #1220174] Tue, 10 December 2013 09:01 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
tom i hope i understand your question right:
Quote:
So does the Part-Model hold a Menu with this ID?

in my manifest.mf i got an extension
org.eclipse.ui.menus
with location URI menu:xxx.views.site.listview.menu
(this extension contains a command - which i expect to show up in the menu)

Quote:
Did you debug into the code?

i did debug/search for mistakes in my code but not in eclipse code.
Re: Create extendable PopupMenu for an SWT Component via EMenuService [message #1220189 is a reply to message #1220177] Tue, 10 December 2013 10:02 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
So you are running the compat layer? You did not say this in your first
post!

I'd suggest to bring up the live application model editor to find out if
the MPopupMenu is there and with what ID.

Tom

On 10.12.13 10:01, Ludwig Moser wrote:
> tom i hope i understand your question right:
> Quote:
>> So does the Part-Model hold a Menu with this ID?
>
> in my manifest.mf i got an extension
> org.eclipse.ui.menus
> with location URI menu:xxx.views.site.listview.menu
> (this extension contains a command - which i expect to show up in the menu)
>
> Quote:
>> Did you debug into the code?
>
> i did debug/search for mistakes in my code but not in eclipse code.
Re: Create extendable PopupMenu for an SWT Component via EMenuService [message #1220197 is a reply to message #1220189] Tue, 10 December 2013 10:44 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
yes, i am using the compatibility layer (sorry forgot to mention this)
when running the liveeditor it did not show me an menu contribution.

so i added one in my plugin.xml

<menuContribution
            allPopups="false"
            locationURI="menu:xxx.views.site.listview.menu">
         <command
               commandId="xxx.views.site.commands.doSomething"
               icon="icons/icon.png"
               label="%doSomething"
               style="push">
         </command>
     </menuContribution>

after launching the app again, the only entry i can find which is connected to my specified view id is this:

id: org.eclipse.core.internal.registry.ConfigurationElementHandle@10e
parent-id: xxx.views.site.listview.menu


it seems i am missing the menu itself (specified parent-id)
how do i do so?
Re: Create extendable PopupMenu for an SWT Component via EMenuService [message #1220199 is a reply to message #1220197] Tue, 10 December 2013 10:57 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Well you are using "menu:" as the protocol which contradicts what you
are argueing about (Context/Pop-Menus). Are you sure you don't want
"popup:"?

Tom

On 10.12.13 11:44, Ludwig Moser wrote:
> yes, i am using the compatibility layer (sorry forgot to mention this)
> when running the liveeditor it did not show me an menu contribution.
>
> so i added one in my plugin.xml
>
> <menuContribution
> allPopups="false"
> locationURI="menu:xxx.views.site.listview.menu">
> <command
> commandId="xxx.views.site.commands.doSomething"
> icon="icons/icon.png"
> label="%doSomething"
> style="push">
> </command>
> </menuContribution>
> after launching the app again, the only entry i can find which is
> connected to my specified view id is this:
>
> id: org.eclipse.core.internal.registry.ConfigurationElementHandle@10e
> parent-id: xxx.views.site.listview.menu
>
> it seems i am missing the menu itself (specified parent-id)
> how do i do so?
Re: Create extendable PopupMenu for an SWT Component via EMenuService [message #1220204 is a reply to message #1220199] Tue, 10 December 2013 11:20 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
do you mean simply change it to:
NOTE: this is extension point org.eclipse.ui.menus
<menuContribution
            allPopups="false"
            locationURI="popup:xxx.views.site.listview.menu">
         <command
               commandId="xxx.views.site.commands.doSomething"
               icon="icons/icon.png"
               label="%doSomething"
               style="push">
         </command>
     </menuContribution>


or do i need to move it to extension point org.eclipse.ui.popupMenus?
if so, what do i specify as id and parent id? (as the viewer which gets created by my gui has no id)

sorry if those questions are kind of dumb, but most tutorials handle e3 version or e4 versions, was not able to find a 'mixture' with compatibility layer, as i do use it.
Re: Create extendable PopupMenu for an SWT Component via EMenuService [message #1220206 is a reply to message #1220204] Tue, 10 December 2013 11:28 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
http://wiki.eclipse.org/Menu_Contributions#popup. I'm not sure how this
stuff is handled in the compat layer but IIRC you need to register
context menus getSite().registerContextMenu(....) in your ViewPart, not?

Tom

On 10.12.13 12:20, Ludwig Moser wrote:
> do you mean simply change it to:
> NOTE: this is extension point org.eclipse.ui.menus
> <menuContribution
> allPopups="false"
> locationURI="popup:xxx.views.site.listview.menu">
> <command
> commandId="xxx.views.site.commands.doSomething"
> icon="icons/icon.png"
> label="%doSomething"
> style="push">
> </command>
> </menuContribution>
>
> or do i need to move it to extension point org.eclipse.ui.popupMenus?
> if so, what do i specify as id and parent id? (as the viewer which gets
> created by my gui has no id)
>
> sorry if those questions are kind of dumb, but most tutorials handle e3
> version or e4 versions, was not able to find a 'mixture' with
> compatibility layer, as i do use it.
Re: Create extendable PopupMenu for an SWT Component via EMenuService [message #1220207 is a reply to message #1220206] Tue, 10 December 2013 11:42 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
exactly this is what i try to do (but i do not register through the getSite() because i have none - i register through the EMenuService - or is this the Wrong service?).
but the returned MPopupMenu is null.
Re: Create extendable PopupMenu for an SWT Component via EMenuService [message #1220209 is a reply to message #1220207] Tue, 10 December 2013 11:50 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
You can not register through EMenuService, there you can only retrieve
an already register MPopupMenu. So if you are on the compat layer why
don't use getSite()? What you need is a MPopupMenu in your views
Menu-List. Who is contributing the MPart instance?

Tom

On 10.12.13 12:42, Ludwig Moser wrote:
> exactly this is what i try to do (but i do not register through the
> getSite() because i have none - i register through the EMenuService - or
> is this the Wrong service?).
> but the returned MPopupMenu is null.
Re: Create extendable PopupMenu for an SWT Component via EMenuService [message #1220318 is a reply to message #1220209] Wed, 11 December 2013 06:22 Go to previous message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
i am on the compatibility layer because i was not able to do everything needed in pure E4 (due bugs, which are already reported in bugzilla)
so some things are from e3 code.

i got a PojoListView
public class PojoListView extends E4TableViewPartTemplate<Site> {
	public static final String ID = "xxx.views.site.listview".intern(); //$NON-NLS-1$

	@Inject
	public PojoListView(Composite parent, EMenuService menuService) {
		// all needed swt code here...
	}
}



and the E4-version of it:
public class E4ListView extends DIViewPart<PojoListView> {
	public E4ListView() {
		super(PojoListView.class);
	}
}


so i need to do getSite() from the E4ListView and pass the site() to super.getcomponent() etc...?

[Updated on: Wed, 11 December 2013 06:44]

Report message to a moderator

Previous Topic:Help system in e4
Next Topic:Stacking parts vertically without using PartSashContainer
Goto Forum:
  


Current Time: Fri Mar 29 06:43:21 GMT 2024

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

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

Back to the top