After my execute method I want to set the current selection null
. I got this far but it won't work. After that, selection
still holds the a value, which is not null.
@Inject
private ESelectionService selection;
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION) Foo foo, Shell shell) {
if (true) {
//do something!
final Object NULL_OBJECT = new Object();
selection.setSelection(NULL_OBJECT);
}
}
There are multiple selection services, one per context (IEclipseContext
). You may be setting the selection in the wrong context.
Injecting the ESelectionService
as a field of your class may mean you end up with the wrong service. Always inject this as a parameter of the execute
method.
... no field injection
@Execute
public void execute(ESelectionService selection, @Named(IServiceConstants.ACTIVE_SELECTION) Foo foo, Shell shell) {