How to add handler to MDirectMenuItem created at runtime? [message #1782416] |
Thu, 22 February 2018 20:44 |
Pinaki Poddar Messages: 1 Registered: February 2018 |
Junior Member |
|
|
Using e4 to build a plugin that creates its menu dynamically.
The menu items shows up with its child items -- however, the handler does not get executed.
New to Eclipse e4 -- any help is much appreciated.
The code creates a menu instance by MMenuFacory and adds direct menu item to the newly created menu
MMenu menu = MMenuFactory.INSTANCE.createMenu();
addMenuItem(menu, "Do #1", new OneHandler());
addMenuItem(menu, "Do #2", new TwoHandler());
// add to created menu to main menu of the workbench
The addMenuItem() function creates MDirectMenuItem and sets the handler instance
public void addMenuItem(MMenu menu, String label,, Object handler) {
MDirectMenuItem menuItem = MMenuFactory.INSTANCE.createDirectMenuItem();
menuItem.setElementId("x.y.z." + System.currentTimeMillis());
menuItem.setType(ItemType.PUSH);
menuItem.setLabel(label);
menuItem.setContributionURI("bundleclass://" + Plugin.ID + "/" + handler.getClass().getName());
The created menu appears and so its menu items.
However, the menu items do not invoke the handler that has been set with setContributionURI(...).
What else needs to be set on dynamically created MDirectMenuItem to invoke a handler function?
The handler class is declared in Application.e4xmi.
|
|
|
Powered by
FUDForum. Page generated in 0.06958 seconds