Dependency injection for Eclipse 3.x views available for Eclipse 4.7 M3

You can now use dependency injection (di) in your Eclipse 3.x. views.You can enable this for a view via the new inject flag in the org.eclipse.ui.views extension.


public class SampleView extends ViewPart {

@Inject IWorkbench workbench;

private TableViewer viewer;

public void createPartControl(Composite parent) {
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);

viewer.setInput(new String[] { "One", "Two", "Three" });
viewer.setLabelProvider(new ViewLabelProvider());

// Create the help context id for the viewer's control
workbench.getHelpSystem().setHelp(viewer.getControl(), "test7.viewer");
// more stuff

I hope that this will help Eclipse IDE extenders to move towards the Eclipse 4.x programming approach.

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, He is the primary author of With more than one million visitors per month this website is one of the central sources for Java, Eclipse and Android programming information.
This entry was posted in Eclipse, Lars Vogel. Bookmark the permalink.