Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » How to add handler to MDirectMenuItem created at runtime?(binding handler function to dynamic DirectMenuItem )
How to add handler to MDirectMenuItem created at runtime? [message #1782416] Thu, 22 February 2018 20:44
Pinaki Poddar is currently offline Pinaki PoddarFriend
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.






Previous Topic:Regex Restrictions on Eclipse Schema file (.exsd)
Next Topic:Test cases are not running due to TestNG exception.
Goto Forum:
  


Current Time: Tue Jun 19 11:02:03 GMT 2018

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

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

Back to the top