When the user selects an item in a viewer component, any registered selection listeners will be notified. In order to forward changes to the E4 selection service, a listener needs to be created to forward the selection to the ESelectionService
.
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.workbench.modeling
as well asorg.eclipse.e4.core.di.annotations
.In order to forward selection changes to the E4 selection service, it must be injected into the view. Add a field
ESelectionService selectionService
annotated with@Inject
and@Optional
. When the part is created, the field will be filled with a selection service instance ornull
as appropriate:@Inject @Optional private ESelectionService selectionService...