Time for action – injecting preferences

The top-level preferences store can be injected into the object by using standard dependency injection techniques, using the IEclipsePreferences interface. The underlying nodes can also be injected by using an @Preferences annotation, specifying the node path of interest.

  1. Add the org.eclipse.e4.core.di.extensions package to the manifest of the com.packtpub.e4.clock.ui project, which contains the @Preferences annotation.
  2. In the TimeZoneTreeView class, add a new field of type IEclipsePreferences called preferences. Annotate it with @Inject and @Preferences(nodePath = "com.packtpub.e4.clock.ui"):
    @Preference(nodePath = "com.packtpub.e4.clock.ui")
    @Inject
    IEclipsePreferences preferences;

    Note

    The IEclipsePreferences ...

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.