In order to react when preferences are changed, it is necessary to inject the preference value as part of a method call. When the preference value is changed, the method will be invoked again with the new value.
Remove the annotations associated with the
launchCount
instance field.Create a
setLaunchCount
method that takes anint
argument and assigns it to thelaunchCount
instance field.Add the
@Inject
annotation to thesetLaunchCount
method.Add the
@Preference(nodePath = "com.packtpub.e4.clock.ui", value = "launchCount")
annotation to the method argument. The resulting method will look like this:int launchCount; @Inject public void setLaunchCount( @Preference(nodePath = "com.packtpub.e4.clock.ui", value = "launchCount") int launchCount) { this.launchCount = launchCount; }
Run the target Eclipse instance, and open the Time Zone Tree View. In the Console...