Eclipse 4 dynamic menu: direct menu item or handler are not executed [message #1790045] |
Mon, 04 June 2018 04:05  |
Eclipse User |
|
|
|
Hello,
I am migrating an Eclipse RAP application to Eclipse 4 and I am facing an issue with the Dynamic Menu Contributions: I can dynamically add Direct Menu Items or Handled Menu Items, but they don't get executed when clicked.
This is basically the issue described here:
https://stackoverflow.com/questions/42627768/eclipse-rap-why-are-my-dynamic-handled-menu-items-able-to-call-canexecute-but
Just like in this post, the @CanExecute methods work (that is, the menu items are properly enabled or disabled), but the @Execute methods never get executed.
I have searched this forum and Bugzilla but did not find this issue mentioned.
Is it a known problem?
Should I book a proper bug report?
Below is some test code, so that you can check whether I am doing something wrong.
Thanks in advance for your advice!
Mathieu
@AboutToShow
public void aboutToShow(List<MMenuElement> items, MApplication app, EModelService modelService) {
System.out.println("aboutToShow: " + items);
// Direct menu item
MDirectMenuItem dynamicItem = modelService.createModelElement(MDirectMenuItem.class);
dynamicItem.setLabel("Dynamic Menu Item (" + new Date() + ")");
// dynamicItem.setContributorURI("platform:/plugin/org.argeo.suite.e4");
dynamicItem.setContributorURI("platform:/plugin/org.argeo.connect.e4");
dynamicItem.setContributionURI(
"bundleclass://org.argeo.connect.e4/org.argeo.documents.e4.parts.TestDirectMenuItem");
dynamicItem.setIconURI("platform:/plugin/org.argeo.theme.argeo2/icons/types/folder.png");
// dynamicItem.setObject(new TestDirectMenuItem());
items.add(dynamicItem);
// Handled menu item
MHandledMenuItem handledItem = modelService.createModelElement(MHandledMenuItem.class);
handledItem.setContributorURI("platform:/plugin/org.argeo.suite.e4");
List<MCommand> cmds = modelService.findElements(app, null, MCommand.class, null);
for (MCommand cmd : cmds) {
if (cmd.getElementId().equals("org.argeo.suite.e4.command.closeAll")) {
handledItem.setCommand(cmd);
break;
}
}
items.add(handledItem);
}
|
|
|
|
|
Re: Eclipse 4 dynamic menu: direct menu item or handler are not executed [message #1791309 is a reply to message #1790162] |
Wed, 27 June 2018 23:52  |
Eclipse User |
|
|
|
Hi Ivan & Mathieu,
I faced the same issue and after debugging I noticed that the code of MenuManagerHideProcessor class in org.eclipse.e4.ui.workbench.renderers.swt RAP bundle was not synchronised with the latest e4 code.
Bugs have been fixed in e4 since the class has been copied to RAP repository, main changes are in the processDynamicElements() method. I actually posted about this synchronisation issue (not only for this class, but for all e4 classes in general) some time ago and I believe this is still a pending task:
https://www.eclipse.org/forums/index.php?t=msg&th=1079714&goto=1739266&#msg_1739266
Mathieu if that can help you meanwhile, what I did is that I got the org.eclipse.e4.ui.workbench.renderers.swt RAP bundle in my workspace and changed the MenuManagerHideProcessor code by the latest one in e4 git repository. I then reference my workspace bundle instead of the RAP target one in my run configuration and that works for me...
Fabrice
|
|
|
Powered by
FUDForum. Page generated in 0.03860 seconds