Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » e4 dynamic menu contributions not work?
e4 dynamic menu contributions not work? [message #1128400] Mon, 07 October 2013 16:51 Go to next message
Dennis Lee is currently offline Dennis LeeFriend
Messages: 32
Registered: September 2013
Member
I tried to add dynamic menu items following this article:

www.descher.at/descher-vu/2012/12/dynamic-menu-contributions

Hear is my code to add menu:
public class TestMenuHandler {
    @AboutToShow
    public void aboutToShow(List<MMenuElement> items) {
        for(int i=0 ; i< 5; i++) {
            MDirectMenuItem menuItem = MMenuFactory.INSTANCE.createDirectMenuItem();
            menuItem.setLabel("Test  menu " + i);
            menuItem.setElementId("test.dynamicmenucontribution"+ i);
            menuItem.setContributorURI("platform:/plugin/testApp.menu.test");
            menuItem.setContributionURI("bundleclass://testApp/test.TestHandler");
            items.add(menuItem);
        }
    }
}


There is nothing added to the menu. No error message.

I added DynamicMenuContribution to the menu and I tried from SWT e4 application and same code worked.

And this is handler for the menu, but I don't think it is matter at this stage:
public class TestHandler {
    @Execute
    public void canExecute(MDirectMenuItem menuItem) {
        System.out.println(menuItem.getElementId());
    }
}


Thanks in advance

[Updated on: Mon, 07 October 2013 17:17]

Report message to a moderator

Re: e4 dynamic menu contributions not work? [message #1128462 is a reply to message #1128400] Mon, 07 October 2013 18:19 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
So against which target-platform do you work? Is it
http://download.eclipse.org/efxclipse/runtime-nightly/site/ there it
should work.

Unfortunately we are currently not honoring the way it works in SWT so
I've filed https://bugs.eclipse.org/bugs/show_bug.cgi?id=418850

Tom

On 07.10.13 18:51, Dennis Lee wrote:
> I tried to add dynamic menu items following this article:
>
> www.descher.at/descher-vu/2012/12/dynamic-menu-contributions
>
>
> Hear is my code to add menu:
> public class TestMenuHandler {
> @AboutToShow
> public void aboutToShow(List<MMenuElement> items) {
> for(int i=0 ; i< 5; i++) {
> MDirectMenuItem menuItem =
> MMenuFactory.INSTANCE.createDirectMenuItem();
> menuItem.setLabel("Test menu " + i);
> menuItem.setElementId("test.dynamicmenucontribution"+ i);
>
> menuItem.setContributorURI("platform:/plugin/testApp.menu.test");
>
> menuItem.setContributionURI("bundleclass://testApp/test.TestHandler");
> items.add(menuItem);
> }
> }
> }
>
>
> There is nothing added to the menu. No error message.
>
> I added DynamicMenuContribution to the menu and I tried from SWT e4
> application and same code worked.
>
> And this is handler for the menu, but I don't think it is matter at this
> stage:
>
> public class TestHandler {
> @Execute
> public void canExecute(MDirectMenuItem menuItem) {
> System.out.println(menuItem.getElementId());
> }
> }
>
>
> Thanks in advance
Re: e4 dynamic menu contributions not work? [message #1128488 is a reply to message #1128462] Mon, 07 October 2013 18:58 Go to previous messageGo to next message
Dennis Lee is currently offline Dennis LeeFriend
Messages: 32
Registered: September 2013
Member
I was using a week old runtime but just update to the latest and it seems working but found two differences. I guess these are the ones you already mentioned as bug but just in case:

1. It only works when there is at least one other menu item. Not work if the menu has only DynamicMenuContribution.
2. @AboutToShow method is called every time access the menu - ends up multiple sets of menus.

Thanks a lot for very fast replay. Wow, it is almost like real time.
Re: e4 dynamic menu contributions not work? [message #1128514 is a reply to message #1128488] Mon, 07 October 2013 19:37 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
On 07.10.13 20:58, Dennis Lee wrote:
> I was using a week old runtime but just update to the latest and it
> seems working but found two differences. I guess these are the ones you
> already mentioned as bug but just in case:
>
> 1. It only works when there is at least one other menu item. Not work if
> the menu has only DynamicMenuContribution.

sounds interesting - need to look at it

> 2. @AboutToShow method is called every time access the menu - ends up
> multiple sets of menus.
> Thanks a lot for very fast replay. Wow, it is almost like real time.

yep - fixed with in git and i've started a new build (should be done in
a about 15 minutes). i'll look into your first comment.

Tom
Re: e4 dynamic menu contributions not work? [message #1128540 is a reply to message #1128514] Mon, 07 October 2013 20:13 Go to previous messageGo to next message
Dennis Lee is currently offline Dennis LeeFriend
Messages: 32
Registered: September 2013
Member
Wow. Already. Yes it worked. Great !!! I used work around - use flag to check menus are added - but obviously it is much better this way. Thanks
Re: e4 dynamic menu contributions not work? [message #1128546 is a reply to message #1128514] Mon, 07 October 2013 20:20 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
On 07.10.13 21:37, Tom Schindl wrote:
> On 07.10.13 20:58, Dennis Lee wrote:
>> I was using a week old runtime but just update to the latest and it
>> seems working but found two differences. I guess these are the ones you
>> already mentioned as bug but just in case:
>>
>> 1. It only works when there is at least one other menu item. Not work if
>> the menu has only DynamicMenuContribution.
>
> sounds interesting - need to look at it
>

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=418867 which fixed in
git, next buil is on its way

Tom
Re: e4 dynamic menu contributions not work? [message #1128565 is a reply to message #1128546] Mon, 07 October 2013 20:42 Go to previous messageGo to next message
Dennis Lee is currently offline Dennis LeeFriend
Messages: 32
Registered: September 2013
Member
Amazing! Yes it is fixed now with latest build. Thanks.

[Updated on: Mon, 07 October 2013 20:43]

Report message to a moderator

Re: e4 dynamic menu contributions not work? [message #1128743 is a reply to message #1128565] Tue, 08 October 2013 01:04 Go to previous messageGo to next message
Dennis Lee is currently offline Dennis LeeFriend
Messages: 32
Registered: September 2013
Member
Hi Tom,

Sorry to bothering you again but it seems it stopped working. I'm not 100% sure but I think I saw it working some time today (with one of today's build) but not anymore. I confirmed with your testcase application.

The problem is:

When accessing (top) menu ("M1") with dynamic menu contributions, it prints error message like this and clicking dynamic menu (Test menu 0 ~5) doesn't do anything:

"org.eclipse.fx.ui.workbench.renderers.base.BaseItemRenderer getContributionObject
SEVERE: No contribution uri defined"

By the way I had to commented out @CanExecute from DiHandler as all "i" are null and all menus are disabled. I guess it is not right and it may be related.

Re: e4 dynamic menu contributions not work? [message #1129021 is a reply to message #1128743] Tue, 08 October 2013 07:59 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
On 08.10.13 03:04, Dennis Lee wrote:
> Hi Tom,
>
> Sorry to bothering you again but it seems it stopped working. I'm not
> 100% sure but I think I saw it working some time today (with one of
> today's build) but not anymore. I confirmed with your testcase application.

well so do the items show up or not?

>
> The problem is:
>
> When accessing (top) menu ("M1") with dynamic menu contributions, it
> prints error message like this and clicking dynamic menu (Test menu 0
> ~5) doesn't do anything:
>
> "org.eclipse.fx.ui.workbench.renderers.base.BaseItemRenderer
> getContributionObject
> SEVERE: No contribution uri defined"
>
> By the way I had to commented out @CanExecute from DiHandler as all "i"
> are null and all menus are disabled. I guess it is not right and it may
> be related.
>

I've modified the example so that the enablement checks are succeeding
in case you toggle the "Check - H 1"-Toolitem

Tom
Re: e4 dynamic menu contributions not work? [message #1129257 is a reply to message #1129021] Tue, 08 October 2013 12:57 Go to previous messageGo to next message
Dennis Lee is currently offline Dennis LeeFriend
Messages: 32
Registered: September 2013
Member
Yes the menu items are shown. Just the menu do nothing when access. Also when accessing (top) menu that has those dynamic menu items ("M1" in testcase), it prints error message - "SEVERE: No contribution uri defined"
Re: e4 dynamic menu contributions not work? [message #1129261 is a reply to message #1129257] Tue, 08 October 2013 13:03 Go to previous messageGo to next message
Dennis Lee is currently offline Dennis LeeFriend
Messages: 32
Registered: September 2013
Member
Sorry I didn't see the bottom part. I'll check again and let's you know
Re: e4 dynamic menu contributions not work? [message #1129286 is a reply to message #1129261] Tue, 08 October 2013 13:33 Go to previous messageGo to next message
Dennis Lee is currently offline Dennis LeeFriend
Messages: 32
Registered: September 2013
Member
I just check with latest build and testcase but it seems the same.

When accessing the test menu, only thing run is ath method from DMContribution.
@AboutToHide
	public void ath(List<MMenuItem> items)


Btw, "Check - H 1"-Toolitem is working.
Re: e4 dynamic menu contributions not work? [message #1129290 is a reply to message #1129286] Tue, 08 October 2013 13:39 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
So you want to tell me that no "Test Menu 1" item is shown in M1 or Bla?

Tom

On 08.10.13 15:33, Dennis Lee wrote:
> I just check with latest build and testcase but it seems the same.
> When accessing the test menu, only thing run is ath method from
> DMContribution.
> @AboutToHide
> public void ath(List<MMenuItem> items)
>
> Btw, "Check - H 1"-Toolitem is working.
Re: e4 dynamic menu contributions not work? [message #1129326 is a reply to message #1129290] Tue, 08 October 2013 14:17 Go to previous messageGo to next message
Dennis Lee is currently offline Dennis LeeFriend
Messages: 32
Registered: September 2013
Member
No. I can see "Test Menu 1" under the M1 menu and also it is enabled/disable by "Check - H 1"-Toolitem. The problem is that "Test Menu 1" doesn't do anything when clicking.
Re: e4 dynamic menu contributions not work? [message #1129331 is a reply to message #1129326] Tue, 08 October 2013 14:21 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
You are completely right - sorry my bad! Let me see what's going on there!

Tom
On 08.10.13 16:17, Dennis Lee wrote:
> No. I can see "Test Menu 1" under the M1 menu and also it is
> enabled/disable by "Check - H 1"-Toolitem. The problem is that "Test
> Menu 1" doesn't do anything when clicking.
Re: e4 dynamic menu contributions not work? [message #1129350 is a reply to message #1129331] Tue, 08 October 2013 14:42 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Logged as https://bugs.eclipse.org/bugs/show_bug.cgi?id=418925 and fixed
with.

http://git.eclipse.org/c/efxclipse/org.eclipse.efxclipse.git/commit/?id=a35b8afb0a43318ac6b60c6e9203780c5297b1e1

Please note that there are 2 problems:
a) the execute method wanted a MToolItem which makes no sense because
this is a menu
b) for direct-menu items the CIF.invoke was wrong

You already know the procedure, a build is underway. You can naturally
also import the e4 projects from our git repo and pull the changes ;-)

Thanks for not insisting that this did NOT work!

Tom

On 08.10.13 16:21, Tom Schindl wrote:
> You are completely right - sorry my bad! Let me see what's going on there!
>
> Tom
> On 08.10.13 16:17, Dennis Lee wrote:
>> No. I can see "Test Menu 1" under the M1 menu and also it is
>> enabled/disable by "Check - H 1"-Toolitem. The problem is that "Test
>> Menu 1" doesn't do anything when clicking.
>
Re: e4 dynamic menu contributions not work? [message #1129367 is a reply to message #1129350] Tue, 08 October 2013 15:04 Go to previous messageGo to next message
Dennis Lee is currently offline Dennis LeeFriend
Messages: 32
Registered: September 2013
Member
Great. It is working now.

I failed to notice that you were using MToolItem. I was using MDirectMenuItem and it is also working but MItem seem better.

Btw, it is not a big deal and not sure it is worth to look but just let you know that whenever assessing M1 menu, the console prints some error message - SEVERE: No contribution uri defined.


Thanks a lot.
Re: e4 dynamic menu contributions not work? [message #1129380 is a reply to message #1129367] Tue, 08 October 2013 15:13 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
I think this is from MenuLifecycle which adds the first item which has
no contribution URI set - so this to expected!

Tom

On 08.10.13 17:04, Dennis Lee wrote:
> Great. It is working now.
>
> I failed to notice that you were using MToolItem. I was using
> MDirectMenuItem and it is also working but MItem seem better.
>
> Btw, it is not a big deal and not sure it is worth to look but just let
> you know that whenever assessing M1 menu, the console prints some error
> message - SEVERE: No contribution uri defined.
>
>
> Thanks a lot.
>
Re: e4 dynamic menu contributions not work? [message #1129387 is a reply to message #1129380] Tue, 08 October 2013 15:24 Go to previous message
Dennis Lee is currently offline Dennis LeeFriend
Messages: 32
Registered: September 2013
Member
Yes it's nothing.

Thanks for all your help/effort. I thought I have to re-plan dynamic menu a few weeks or more later but I'm amazed that I don't need to change the plan at all. Wonderful.
Previous Topic:ESelectionService
Next Topic:(no subject)
Goto Forum:
  


Current Time: Thu Apr 18 00:44:16 GMT 2024

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

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

Back to the top