Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Dynamic menu contributions(How to create dynamic menu contribution as done in Eclipse 3.x)
Dynamic menu contributions [message #908970] Thu, 06 September 2012 10:19 Go to next message
Marco Descher is currently offline Marco Descher
Messages: 84
Registered: October 2010
Location: Austria
Member
I want to realize a dynamic menu contribution to the menu of a handler located in a view toolbar. In Eclipse 3 it was possible to add "dynamic" as org.eclipse.ui.menus contribution to a Menu!

I already found out about www.vogella.com/blog/2010/10/26/processors-e4-model explaining on how to dynamically contribute to menus by means of processor model extensions.

But to set it into specific questions:

  • Why is it not possible to use the dynamic contribution element in the e4 tooling on an element of MMenu as it was possible to contribute in Eclipse 3.x, where you had to implement a class that extends org.eclipse.jface.action.ContributionItem?
  • Am I required to contribute such elements by means of processor contributions or
  • is support for it only not yet implemented!
  • What is the purpose of MMenuContribution, as it's not possible to execute something like MMenu.getChildren().add(MMenuContribution).


Thanks a lot for your comments!
Re: Dynamic menu contributions [message #909029 is a reply to message #908970] Thu, 06 September 2012 12:44 Go to previous messageGo to next message
Joseph Carroll is currently offline Joseph Carroll
Messages: 174
Registered: May 2012
Location: Milwaukee, WI
Senior Member

Quote:
Why is it not possible to use the dynamic contribution element in the e4 tooling on an element of MMenu as it was possible to contribute in Eclipse 3.x, where you had to implement a class that extends org.eclipse.jface.action.ContributionItem?


Eclipse4 introduced a whole new paradigm, the same functionality exists just not through the same methods.

Quote:
Am I required to contribute such elements by means of processor contributions


No, you can supply it through any application or fragment model.

Quote:
or is support for it only not yet implemented!


Support exists.

Quote:
What is the purpose of MMenuContribution, as it's not possible to execute something like MMenu.getChildren().add(MMenuContribution).


You can, you just cannot use a MMenuContribution because a menu contribution is a menu contribution and not a menu item. Menu contributions are meant to hold menu elements which are UIElements and the MMenuContribution is also a UIElement. Thus to dynamically show/hide a MMenuContribution you can use the toBeRendered flag.

http://www.vogella.com/articles/EclipseRCP/article.html

Take care,

JD
Re: Dynamic menu contributions [message #909048 is a reply to message #909029] Thu, 06 September 2012 13:08 Go to previous messageGo to next message
Marco Descher is currently offline Marco Descher
Messages: 84
Registered: October 2010
Location: Austria
Member
Thanks for your answer, yet I am still confused, please let me explain the scenario:

I am placing a button at the toolbar of a contact selector which aims to implement a filter, where the dropdown of the filter symbol allows me to check the filter on


  • persons
  • organizations
  • ...


These are all SWT.CHECK elements which should directly lead to the re-configuration of the respective filter implementation class. And on click of the menu the elements show the resp. state of the filter class. This was no problem to realize in Eclipse 3.x via the dynamic menu contribution and the set of isDynamic() to true.

So it is about a completely dynamic menu implementation which changes on every call of the resp. submenu.

I still do not understand what is the correct way to realize this in Eclipse 4. What is the correct way to realize this within the application model?

Please find the following image to describe the usage within the Eclipse 3.x implementation which I am currently trying to port to Eclipse 4 (unfortunately I can't post the image .... the forum blocks me to do so):

https: dl.dropbox.com/u/72943400/dynamic%20toolbar%20command.png

[Updated on: Thu, 06 September 2012 13:11]

Report message to a moderator

Re: Dynamic menu contributions [message #909626 is a reply to message #909048] Fri, 07 September 2012 12:46 Go to previous messageGo to next message
Marco Descher is currently offline Marco Descher
Messages: 84
Registered: October 2010
Location: Austria
Member
To keep this thread up to date I moved the topic to stackoverflow, as I am allow to paste pictures and links there Sad

See the link stackoverflow.com/questions/12315749/e4-dynamic-menu-contributions
Re: Dynamic menu contributions [message #909633 is a reply to message #909626] Fri, 07 September 2012 12:53 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5422
Registered: July 2009
Senior Member
Like replied to Markus in the other thread one should be able modify the
MMenus children at runtime.

To me it looks like a bug in the MenuRenderer which are only that
complex because it also holds a lot of code needed by the compat story.
Writing a clean room implementation targeted towards pure e4
applications might be quite easy.

Tom

Am 07.09.12 14:46, schrieb Marco Descher:
> To keep this thread up to date I moved the topic to stackoverflow, as I
> am allow to paste pictures and links there :(
>
> See the link
> stackoverflow.com/questions/12315749/e4-dynamic-menu-contributions
Re: Dynamic menu contributions [message #909634 is a reply to message #909633] Fri, 07 September 2012 12:58 Go to previous messageGo to next message
Marco Descher is currently offline Marco Descher
Messages: 84
Registered: October 2010
Location: Austria
Member
Hey Thomas, please see the update on stackoverflow, I tried a dynamic modification already ---> ConcurrentModificationException ..
Re: Dynamic menu contributions [message #909648 is a reply to message #909634] Fri, 07 September 2012 13:35 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5422
Registered: July 2009
Senior Member
Like said it is a bug - and you are able to roll your own renderers
which don't have such a problem and please file a bug. We should
certainly not fail with a CCE in any case but do a defensive copy for
the iteration.

My vote would be for 4.3 to roll a simplified e4 Menu/ToolBar-Renderer
but you can easily roll your own in 4.2 or even better develop one and
contribute it back to e4.

Tom

Am 07.09.12 14:58, schrieb Marco Descher:
> Hey Thomas, please see the update on stackoverflow, I tried a dynamic
> modification already ---> ConcurrentModificationException ..
Re: Dynamic menu contributions [message #909650 is a reply to message #909648] Fri, 07 September 2012 13:49 Go to previous messageGo to next message
Marco Descher is currently offline Marco Descher
Messages: 84
Registered: October 2010
Location: Austria
Member
Thank you very much for your comment, but I have one more question please:

The problem itself is the lack of a contribution possibility to a menu, like it was done in Eclipse 3 with a dynamic contribution for a menu. Don't you think that this feature should be available in E4, my hack is very dirty and yet buggy with the renderer, and the only option I have is to interfere with the menu using @canExecute!

I was trying to access the widget and to intefere with menuAboutToBeOpened or whatever, but was not successful! In Eclipse 3 I can use fill(Menu) to execute exactly that when the menu is needed (lazy!!).

Hence: I am really missing this feature for E4! Or am i completely "standing on the tube" Wink when it comes on how to realize this in E4?! *g*
Re: Dynamic menu contributions [message #909664 is a reply to message #909650] Fri, 07 September 2012 14:20 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5422
Registered: July 2009
Senior Member
We have NOT ported all and everything 1:1 from 3.x to e4. I have not
looked in detail into the code but haven't found something that will
help you get this feature currently.

In e4 things like this should be done by making the renderer send an
event that it is about to show the menu and you can subscribe to this
event and add/remove elements.

So:
a) file a bug that adding/removing items at runtime does not work
b) file a feature request that you want to get informed about menu
display
c) think about writing your own menu renderer until then


Tom


Am 07.09.12 15:49, schrieb Marco Descher:
> Thank you very much for your comment, but I have one more question please:
>
> The problem itself is the lack of a contribution possibility to a menu,
> like it was done in Eclipse 3 with a dynamic contribution for a menu.
> Don't you think that this feature should be available in E4, my hack is
> very dirty and yet buggy with the renderer, and the only option I have
> is to interfere with the menu using @canExecute!
>
> I was trying to access the widget and to intefere with
> menuAboutToBeOpened or whatever, but was not successful! In Eclipse 3 I
> can use fill(Menu) to execute exactly that when the menu is needed
> (lazy!!).
>
> Hence: I am really missing this feature for E4! Or am i completely
> "standing on the tube" ;) when it comes on how to realize this in E4?! *g*
Re: Dynamic menu contributions [message #909681 is a reply to message #909664] Fri, 07 September 2012 15:09 Go to previous messageGo to next message
Marco Descher is currently offline Marco Descher
Messages: 84
Registered: October 2010
Location: Austria
Member
Thanks a lot Thomas, bug created in https://bugs.eclipse.org/bugs/show_bug.cgi?id=389063 maybe I will find the time somehow, would be very interesting Smile
Re: Dynamic menu contributions [message #926008 is a reply to message #908970] Fri, 28 September 2012 08:11 Go to previous messageGo to next message
Marco Descher is currently offline Marco Descher
Messages: 84
Registered: October 2010
Location: Austria
Member
I'm trying to start developing a possible solution, I have however a hard time to create a functioning development environment. I checked out the current master from git.eclipse.org for platorm and ui, however:

  • I did not find the the org.eclipse.e4.ui.workbench.renderers.swt in any git, so I used "Import Plug-Ins and Fragments". So i get the resp. plugins in my workspace!
  • If I create an e4 product now, starting with my TARGET LOCATED (but the rest is from my workspace) org.eclipse.e4.ui.workbench.renderers.swt and org.eclipse.e4.ui.workbench.renderers.swt.cocoa everything works fine.
  • If I however use these both plug-ins from my workspace I get the enclosed exceptions.

What am I doing wrong here??


Re: Dynamic menu contributions [message #926024 is a reply to message #926008] Fri, 28 September 2012 08:32 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=389651#c22 and substitute e4.tools with the platform ui repo. The instructions there (and other comments) should get you started.
Re: Dynamic menu contributions [message #926025 is a reply to message #926024] Fri, 28 September 2012 08:34 Go to previous message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

You may not want to import all projects in the git repo as it is considerably big. Import just the relevant (maybe o.e.e4.* ) ones.
Previous Topic:Abbort close operation on MPart
Next Topic:From where can I contribute model processor
Goto Forum:
  


Current Time: Sat Oct 25 10:19:07 GMT 2014

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

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