Time for action – creating a part

Having created a sample application, the next step is to create a view, known as a part in E4. Parts are the generic name for views, editors, and other grouping components in an E4 application. Unlike views in Eclipse 3, the view class doesn't have to have any references to the Eclipse APIs. This makes it particularly easy to build and test in isolation.

  1. Create a new class called Hello in the com.packtpub.e4.application.parts package.
  2. Add a private field called label of type Label.
  3. Add a create method annotated with @PostConstruct that instantiates the Label and sets its text to "Hello".
  4. Optionally, add an onFocus method annotated with @Focus that sets the focus on the Label.
  5. The class will look like:
    package com.packtpub.e4.application.parts; ...

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.