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.
- Create a new class called
Hello
in thecom.packtpub.e4.application.parts
package. - Add a
private
field calledlabel
of typeLabel
. - Add a
create
method annotated with@PostConstruct
that instantiates theLabel
and sets its text to"Hello"
. - Optionally, add an
onFocus
method annotated with@Focus
that sets the focus on theLabel
. - 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.