Time for action – adding items to the tray

Most operating systems have a concept of tray, as a set of icons visible from the main window that can provide quick access components. On macOS, these are represented as icons across the top menu bar, and on Windows, as icons on the bottom-right near the clock. Linux systems have various approaches that do similar things, and some operating systems have none. Since there is only one tray, it is necessary to add the item only once. The Activator class can be used to ensure that the TrayItem is created at startup and removed at shutdown.

  1. Open the Activator class, and add two private fields:
    private TrayItem trayItem;
    private Image image;
  2. Add the following to the start method:
    final Display display = Display.getDefault(); ...

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.