Hi all,
I encountered an unexpected behavior when developing an e4-Application (no compatibility layer) and hope someone can help me understand where I didnt get the concept yet.
There are Objects reacting to changes to the "Workbench Selection" the following way...
@Inject
public void selectionChanged(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) final Object sel)
{
System.err.println("---> selChange(injection) --->" + sel);
}
But there are also Objects that are not under the control of EclipseContexts and they react to changes this way...
public MyObject(final ESelectionService selectionService)
{
selectionService.addSelectionListener(this);
}
@Override
public void selectionChanged(final MPart part, final Object objSelection)
{
System.err.println("---> selChange(listener) --->" + sel);
}
The strange thing here is, that when I now open two Editors that provide a Selection, the injection-variant automatically gets called when I switch between the Editors (=when the active part changes) but the listener-variant does not get called.
I expected them to behave the exact same way.
Addition: When I call ESelectionService.setSelection(anySelection) both variants get called
Addition: We use Eclipse 2021_12
[Updated on: Wed, 11 May 2022 11:50]
Report message to a moderator