Time for action – adding the pop-up

A pop-up menu is very similar to creating a toolbar or view menu; however, there are a few extra steps required to hook it up to the viewer and to ensure that the right pop-up menu is connected to the right part. As with the view menu, a tag is required; but instead of being a generic hard-coded value, the pop-up tag requires a tight binding with the pop-up menu.

  1. Create a method called createPopupMenu in the SampleView class. It will need to take an SWT Control parameter, which will be the one that is used to trigger the menu.
  2. Ensure that the createPopupMenu is called from the end of the createPartControl method, passing in the control from the viewer as the argument:
    createPopupMenu(viewer.getControl());
  3. First, ...

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.