When the selection is changed in the E4 selection service, parts can be notified that a new selection is available through injection. Although an @Inject
field could be used, there would be no trigger that could be used to update the view. Instead, a method with an injected parameter will be used to trigger the update.
Add the required packages to the bundle's package imports, by right-clicking on the
com.packtpub.e4.clock.ui
project and navigating to Plug-in Tools | Open Manifest to open the bundle's manifest. On the Dependencies tab, click on Add under the Imported Packages section and enterorg.eclipse.e4.ui.services
.In the
TimeZoneTableView
class, create a method calledsetTimeZone
. The method name isn't specifically important, but the method needs to be annotated with@Inject
and@Optional
, and the argument needs to be annotated with@Named(IServiceConstants.ACTIVE_SELECTION)
. It should look like:@Inject @Optional public void setTimeZone...