-
Book Overview & Buying
-
Table Of Contents
Eclipse Plug-in Development Beginner's Guide - Second Edition
By :
Although it is possible to inject an entire preference node, sometimes it is more convenient to inject just a single preference value. This can reduce the amount of code needed to extract and use a preference value. In addition, this can remove the runtime dependency on IEclipsePreferences, which can make the code more portable.
Replace the injected IEclipsePreferences node with an int launchCount field, and append value = "launchCount" to the @Preferences annotation:
@Preference(nodePath = "com.packtpub.e4.clock.ui", value = "launchCount") @Inject // IEclipsePreferences preferences; int launchCount;
Update the print message to use the launchCount value directly:
System.out.println("Launch count is: " + launchCount);Run the target Eclipse instance, and open the Time Zone Tree View. In the Console view, there should be a Launch count is: message with the same value as before.
Instead of injecting the entire preferences node...
Change the font size
Change margin width
Change background colour