John John - 28 days ago 4
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.


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