Time for action – contributing commands to pop-up menus

It's useful to be able to add contributions to pop-up menus so that they can be used by different places. Fortunately this can be done fairly easily with the menuContribution fragment and a combination of enablement tests. However, to implement this in E4, the view must be moved into the fragment.e4xmi file in order to attach a PopupMenu.

  1. Add the org.eclipse.ui.services package as a dependency to the plugin.xml in the Dependencies tab, if it's not already added.
  2. Open the TimeZoneTableView class and add the following to the end of the createPartControl method:
    private void createPartControl(Composite parent, EMenuService menuService) { menuService.registerContextMenu(tableViewer.getControl(), ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.