I have an eclipse plugin which has multiple classes which make some UI contributions.
The contribution is done through the deprecated org.eclipse.ui.actionSets
and the classes implement the IWorkbenchWindowActionDelegate
which require an implementation of the selectionChanged(IAction action, ISelection selection)
.
The selectionChanged
method is triggered on any selection change (another file opened, another item selected in Project Explorer, some text is selected in the editor(this one triggers several calls of the method)).
Is there a filtering or something which I can do to limit the selectionChanged
observed objects. For example, for class A
, trigger the selectionChanged
only if the opened file in editor changes)?
No, there is no way to filter that.
Selections coming from text editors with be instances of ITextSelection
, other selections will usually be instances of IStructuredSelection
so you can check for those instances to do simple filtering in your code.