Time for action – adding the view menu

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.

  1. Add a method createViewMenu in the SampleView class. Add a call to the createPartControl method so that it is called when the view is created.
  2. In the createViewMenu method, create an instance of MMenu using MMenuFactory.INSTANCE.createMenu().
  3. Add the menu to the part using part.getMenus().add(menu).
  4. To configure the menu as a view menu, add a tag ViewMenu using menu.getTags().add("ViewMenu").
  5. As with toolbar items, a menu item can either be handled or direct. A ...

Get Eclipse Plug-in Development Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.