Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Rendering an SWT Menu from MMenu?(Is it possible to use platform renderers to render an SWT Menu from MMenu?)
Rendering an SWT Menu from MMenu? [message #1216596] Thu, 28 November 2013 14:52 Go to next message
Alex Kipling is currently offline Alex Kipling
Messages: 253
Registered: July 2012
Senior Member
My Plugin contributes a MMenu hierarchy through a Model-Fragment.
is there any chance to use a use platform renderers to generate a Menu from the MMenu hierarchy?

What I have already tried:

        MenuManager invisibleRootNodeMm = new MenuManager("Root");

        // append menus to the main manager
        Menu invisibleParent = invisibleRootNodeMm .createContextMenu(treeViewer.getControl());
        treeViewer.getControl().setMenu(invisibleParent);

        // get ModuleCOntextCOntributions
        MMenuContribution moduleContextContribution = null;
        for (MMenuContribution mmc : mApplication.getMenuContributions()) {
            if (mmc.getElementId().equals(idModuleContextContribution)) {
                moduleContextContribution = mmc;
                break;
            }
        }

        // get all Menus from the Contribution
        List<MMenu> menus = modelService.findElements(moduleContextContribution, null, MMenu.class, null);
        MMenu menu = menus.get(0);

        // Switch to the SWT API
        IRendererFactory fac = eclipseContext.get(IRendererFactory.class);
        AbstractPartRenderer r = fac.getRenderer(menu, parent.getShell());

        // does not generate a hierarchy, but an empty menu
        Menu swtMenu = (Menu) r.createWidget(menu, parent.getShell());

[Updated on: Thu, 28 November 2013 14:53]

Report message to a moderator

Re: Rendering an SWT Menu from MMenu? [message #1220065 is a reply to message #1216596] Mon, 09 December 2013 12:59 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

I'm not sure I understand. Normally the rendering should be done automatically, so why do you want to trigger it yourself?
Re: Rendering an SWT Menu from MMenu? [message #1220554 is a reply to message #1220065] Thu, 12 December 2013 14:24 Go to previous messageGo to next message
Alex Kipling is currently offline Alex Kipling
Messages: 253
Registered: July 2012
Senior Member
Hello Sopot!
I want to render the Menus myselfe, for the follwoing reason.

- I have a system of multiple plugins. Every Plugin contributes a fragment of the E4Model.
- There is a central application, which collects all plugins.
- Every plugin should contribute some menuitems to the menu in the central applicaiton.

My Idea was - to use the E4-Model to implement menuitem contribution. Every plugin adds the MenuItems to the fragment - the central applicaiton collects all the Menuitems and displays the whole menu.

IMPORTANT: the menu should be displayed on click inside of the part, not on places predefined by the E4 platform. So I can not just add the Menuitems using the e4Model. I have to convert it to SWT meu items. (I am using SWT inside of my parts)

So the question is again: how would I turn the E4 MMenu into SWT widget Menu?
I mean the whole hierarchy of the Menus and Menu items. The platform does this somehow..
Re: Rendering an SWT Menu from MMenu? [message #1220592 is a reply to message #1220554] Thu, 12 December 2013 16:16 Go to previous message
Eclipse User
On 12/12/2013 03:24 PM, Alex Kipling wrote:
>
> - I have a system of multiple plugins. Every Plugin contributes a
> fragment of the E4Model.
> - There is a central application, which collects all plugins. - Every
> plugin should contribute some menuitems to the menu in the central
> applicaiton.
> My Idea was - to use the E4-Model to implement menuitem contribution.
> Every plugin adds the MenuItems to the fragment - the central
> applicaiton collects all the Menuitems and displays the whole menu.
>
> IMPORTANT: the menu should be displayed on click inside of the part, not
> on places predefined by the E4 platform. So I can not just add the
> Menuitems using the e4Model. I have to convert it to SWT meu items. (I
> am using SWT inside of my parts)
>
> So the question is again: how would I turn the E4 MMenu into SWT widget
> Menu?
> I mean the whole hierarchy of the Menus and Menu items. The platform
> does this somehow..

Hi Alex,

you don't have to deal with the e4 model or how your plugins contribute
to it via fragments. That should all work out-of-the-box for you.
What you wanna do instead is to lookup (findElements) the model menus
with the EModelService in your part(s) (as described in your initial
post) and renderer them according to your custom needs. Unfortunately
the build-in SWT renderer isn't implemented in a away to be reusable for
such use cases. But then remember, the renderer's (logical)
responsibility is to convert the e4 model into a visual representation.
If you are not satisfied with the visual rep, you just have to roll it
yourself.

HTH
M.
Previous Topic:Support for Xulrunner 25
Next Topic:Eclipse 4.2 GUI is very slow
Goto Forum:
  


Current Time: Fri Sep 19 15:59:34 GMT 2014

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

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