The e4view
extension point allows a view to be loaded into an Eclipse 4.x application without the need of a specific superclass. This allows existing Eclipse 3.x views to be upgraded to an Eclipse 4.x view as follows.
Open the
SampleView
class and remove theextends ViewPart
superclass definition. This will introduce some errors in the code, which will be fixed shortly.Add a
@PostConstruct
annotation to thecreatePartControl
method. Use Cmd + Shift + O on macOS or Ctrl + Shift + O on other platforms to automatically add theimport javax.annotation.PostConstruct
statement.Add a
@Focus
annotation to thesetFocus
method. This time, the automatic import won't work, but a quick fix will suggest adding the dependency. Alternatively open theMANIFEST.MF
file, go to the Dependencies tab, and addorg.eclipse.e4.ui.di
bundle as a dependency. Now switch back to theSampleView
class, perform the organize imports with the previous keystroke, andimport org.eclipse...