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; import javax.annotation.PostConstruct; import org.eclipse.e4.ui.di.Focus; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; public class Hello { private Label label...