John John - 1 year ago 83
Java Question

How to programatically create a ViewMenu in Eclipse RCP 4

public Widget(MPart part)
viewMenu = MMenuFactory.INSTANCE.createMenu();

When I create a Menu or ViewMenu through the .e4xmi file and check the class of the objects, they both return the same classes. The MMenuFactory only allows me to create an MMenu object. How would I created a ViewMenu or convert an MMenu object to a ViewMenu?

NOTE: The above code does not provide me with a view menu. Though, when I create a ViewMenu through the .e4xmi file, it shows up in list returned from the getMenus() method.

Answer Source

Just add the tag ViewMenu to the menu:

viewMenu = MMenuFactory.INSTANCE.createMenu();


// TODO add menu items


Note: The view will not be shown if it does not contain some menu items

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download