Time for action – getting the window

In an Eclipse 3.x application, the main window is typically accessed via a static accessor such as Display.getDisplay() or workbench.getWorkbenchWindows(). Both of these assume that there is a way of getting to this global list in the first place, often through tightly coupled code references. As well as OSGi services, E4 can also be used to inject references to GUI components. However, rather than accessing the GUI components directly, models are used instead. As a result, components in E4 tend to start with M (for Model)—such as MPart, MWindow, and MPerspective.

  1. To obtain the reference to the window, add a private field MWindow window to the Hello class, along with an @Inject annotation.
  2. Modify the create

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.