The next step is to add the view menu, which is the drop-down menu shown by the triangle in the top-right of the original view. Adding this takes the same pattern as before, but the drop-down menu requires an additional tag to be shown as a view menu.
Add a method
createViewMenu
in theSampleView
class. Add a call to thecreatePartControl
method so that it is called when the view is created.In the
createViewMenu
method, create an instance ofMMenu
usingMMenuFactory.INSTANCE.createMenu()
.Add the
menu
to thepart
usingpart.getMenus().add(menu)
.To configure the
menu
as a view menu, add a tagViewMenu
usingmenu.getTags().add("ViewMenu")
.As with toolbar items, a menu item can either be handled or direct. A direct menu item is associated directly with a handler implementation class. Create a direct menu item with
MMenuFactory.INSTANCE.createDirectMenuItem()
and store it in a local fieldone
. Set the tooltip and label appropriately, and use the same icon...