EMenuService - get UI representation of menu [message #1476898] |
Mon, 17 November 2014 12:51 |
Dirk Fauth Messages: 2902 Registered: July 2012 |
Senior Member |
|
|
Hi,
I have a question on retrieving the UI representation of a menu declared in the application model programmatically.
To explain a bit more:
1. I added a popup menu to a part in the application model
2. after some investigation I've found out that with 4.4 it is possible to find the MMenu using the EModelService the following way
List<MMenu> menus = modelService.findElements(part, menuId, MMenu.class, null, EModelService.IN_PART);
Now I need to get the SWT Menu instance for the MMenu. I tried to call getWidget() on MMenu, but that returns null. I try to execute that method in @PostConstruct which should be ok from my understanding of the lifecycle.
I have seen that the SWT implementation of EMenuService contains a static helper method to get the Menu
Menu registerMenu(final Control, final MPopupMenu, IEclipseContext)
Now that method does exactly what I want. But MenuService is located in an internal package, and IMHO it is not good to rely on internal classes.
I'm currently not quite sure how to handle this correctly. Here are my questions:
1. Should MMenu#getWidget() return a valid instance if called in @PostConstruct or is there any trigger to let it be created?
2. If it is intended that it returns null, how could it be possible to get the Menu/trigger the Menu creation?
3. Since MenuService#registerMenu(Control, MPopupMenu, IEclipseContext) is public static, couldn't it be located in a place that is accessible for users? So no "internal" package.
It would be great if I could get help on this.
Greez,
Dirk
|
|
|
Re: EMenuService - get UI representation of menu [message #1477039 is a reply to message #1476898] |
Mon, 17 November 2014 15:15 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
You want EMenuService which got relocated from SWT to ui.services.
Tom
On 17.11.14 13:51, Dirk Fauth wrote:
> Hi,
>
> I have a question on retrieving the UI representation of a menu declared
> in the application model programmatically.
>
> To explain a bit more:
> 1. I added a popup menu to a part in the application model
> 2. after some investigation I've found out that with 4.4 it is possible
> to find the MMenu using the EModelService the following way
>
>
> List<MMenu> menus = modelService.findElements(part, menuId, MMenu.class,
> null, EModelService.IN_PART);
>
>
> Now I need to get the SWT Menu instance for the MMenu. I tried to call
> getWidget() on MMenu, but that returns null. I try to execute that
> method in @PostConstruct which should be ok from my understanding of the
> lifecycle.
>
> I have seen that the SWT implementation of EMenuService contains a
> static helper method to get the Menu
> Menu registerMenu(final Control, final MPopupMenu, IEclipseContext)
>
> Now that method does exactly what I want. But MenuService is located in
> an internal package, and IMHO it is not good to rely on internal classes.
>
> I'm currently not quite sure how to handle this correctly. Here are my
> questions:
>
> 1. Should MMenu#getWidget() return a valid instance if called in
> @PostConstruct or is there any trigger to let it be created?
> 2. If it is intended that it returns null, how could it be possible to
> get the Menu/trigger the Menu creation?
> 3. Since MenuService#registerMenu(Control, MPopupMenu, IEclipseContext)
> is public static, couldn't it be located in a place that is accessible
> for users? So no "internal" package.
>
> It would be great if I could get help on this.
> Greez,
> Dirk
>
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03044 seconds