Package org.eclipse.ui.internal
Class PartSelectionListener
java.lang.Object
org.eclipse.ui.internal.PartSelectionListener
- All Implemented Interfaces:
EventListener
,INullSelectionListener
,ISelectionListener
public class PartSelectionListener
extends Object
implements ISelectionListener, INullSelectionListener
An intermediate selection listener that filters selection change events based
on one or more predicates and forwards it to the functional selection
listener.
Instances of this class can be obtained via the
SelectionListenerFactory
class.-
Constructor Summary
ConstructorDescriptionPartSelectionListener
(IWorkbenchPart part, ISelectionListener callbackListener, Predicate<SelectionListenerFactory.ISelectionModel> predicate) Constructs the intermediate selection listener to filter selections before they are passed on the the callback listener. -
Method Summary
Modifier and TypeMethodDescriptionAnd-chains this predicate to the already existing predicate.void
selectionChanged
(IWorkbenchPart part, ISelection selection) Notifies this listener that the selection has changed.
-
Constructor Details
-
PartSelectionListener
public PartSelectionListener(IWorkbenchPart part, ISelectionListener callbackListener, Predicate<SelectionListenerFactory.ISelectionModel> predicate) Constructs the intermediate selection listener to filter selections before they are passed on the the callback listener.- Parameters:
part
- the part which may not be null.callbackListener
- the callback listener which may not be null.predicate
- the predicate which may not be null.
-
-
Method Details
-
selectionChanged
Description copied from interface:ISelectionListener
Notifies this listener that the selection has changed.Note: it is important that this method returns as quickly as possible to avoid UI freezes. For example, do not update the UI if the UI is not visible. See the
SelectionListenerFactory
for listeners that are build for this purpose.This method is called when the selection changes to a
non-null
value, but not when the selection changes tonull
. If there is a requirement to be notified in the latter scenario, implementINullSelectionListener
. The event will be posted through this method.- Specified by:
selectionChanged
in interfaceISelectionListener
- Parameters:
part
- the workbench part containing the selectionselection
- the current selection. This may benull
ifINullSelectionListener
is implemented.- See Also:
-
addPredicate
public PartSelectionListener addPredicate(Predicate<SelectionListenerFactory.ISelectionModel> predicate) And-chains this predicate to the already existing predicate. Nothing happens if the passed predicate is null.- Parameters:
predicate
- the non-null predicate to and-chain to the existing predicate- Returns:
- this
-