Interface ISelectionService
- All Known Subinterfaces:
IWorkbenchPage
- All Known Implementing Classes:
SlaveSelectionService
,WorkbenchPage
A listener that wants to be notified when the selection becomes
null
must implement the INullSelectionListener
interface.
This service can be acquired from your service locator:
ISelectionService service = (ISelectionService) getSite().getService(ISelectionService.class);This service is not available globally, only from the workbench window level down.
- See Also:
- Restriction:
- This interface is not intended to be implemented by clients.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPostSelectionListener
(String partId, ISelectionListener listener) Adds a part-specific selection listener which is notified when selection changes in the part with the given id.void
addPostSelectionListener
(ISelectionListener listener) Adds the given post selection listener.It is equivalent to selection changed if the selection was triggered by the mouse but it has a delay if the selection is triggered by the keyboard arrows.void
addSelectionListener
(String partId, ISelectionListener listener) Adds a part-specific selection listener which is notified when selection changes in the part with the given id.void
addSelectionListener
(ISelectionListener listener) Adds the given selection listener.Returns the current selection in the active part.getSelection
(String partId) Returns the current selection in the part with the given id.void
removePostSelectionListener
(String partId, ISelectionListener listener) Removes the given part-specific post selection listener.void
Removes the given post selection listener.void
removeSelectionListener
(String partId, ISelectionListener listener) Removes the given part-specific selection listener.void
removeSelectionListener
(ISelectionListener listener) Removes the given selection listener.
-
Method Details
-
addSelectionListener
Adds the given selection listener. Has no effect if an identical listener is already registered.Note: listeners should be removed when no longer necessary. If not, they will be removed when the IServiceLocator used to acquire this service is disposed.
Note: only update the UI when the UI is visible. See the
SelectionListenerFactory
for listeners that will only be called when the UI is visible to the user.- Parameters:
listener
- a selection listener- See Also:
-
addSelectionListener
Adds a part-specific selection listener which is notified when selection changes in the part with the given id. This is independent of part activation - the part need not be active for notification to be sent.When the part is created, the listener is passed the part's initial selection. When the part is disposed, the listener is passed a
null
selection, but only if the listener implementsINullSelectionListener
.Note: this will not correctly track editor parts as each editor does not have a unique partId.
Note: listeners should be removed when no longer necessary. If not, they will be removed when the IServiceLocator used to acquire this service is disposed.
Note: only update the UI when the UI is visible. See the
SelectionListenerFactory
for listeners that will only be called when the UI is visible to the user.- Parameters:
partId
- the id of the part to tracklistener
- a selection listener- Since:
- 2.0
- See Also:
-
addPostSelectionListener
Adds the given post selection listener.It is equivalent to selection changed if the selection was triggered by the mouse but it has a delay if the selection is triggered by the keyboard arrows. Has no effect if an identical listener is already registered. Note: Works only for StructuredViewer(s).Note: listeners should be removed when no longer necessary. If not, they will be removed when the IServiceLocator used to acquire this service is disposed.
Note: only update the UI when the UI is visible. See the
SelectionListenerFactory
for listeners that will only be called when the UI is visible to the user.- Parameters:
listener
- a selection listener- See Also:
-
addPostSelectionListener
Adds a part-specific selection listener which is notified when selection changes in the part with the given id. This is independent of part activation - the part need not be active for notification to be sent.When the part is created, the listener is passed the part's initial selection. When the part is disposed, the listener is passed a
null
selection, but only if the listener implementsINullSelectionListener
.Note: this will not correctly track editor parts as each editor does not have a unique partId.
Note: listeners should be removed when no longer necessary. If not, they will be removed when the IServiceLocator used to acquire this service is disposed.
Note: only update the UI when the UI is visible. See the
SelectionListenerFactory
for listeners that will only be called when the UI is visible to the user.- Parameters:
partId
- the id of the part to tracklistener
- a selection listener- Since:
- 2.0
- See Also:
-
getSelection
ISelection getSelection()Returns the current selection in the active part. If the selection in the active part is undefined (the active part has no selection provider) the result will benull
.- Returns:
- the current selection, or
null
if undefined
-
getSelection
Returns the current selection in the part with the given id. If the part is not open, or if the selection in the active part is undefined (the active part has no selection provider) the result will benull
.- Parameters:
partId
- the id of the part- Returns:
- the current selection, or
null
if undefined - Since:
- 2.0
-
removeSelectionListener
Removes the given selection listener. Has no effect if an identical listener is not registered.- Parameters:
listener
- a selection listener
-
removeSelectionListener
Removes the given part-specific selection listener. Has no effect if an identical listener is not registered for the given part id.- Parameters:
partId
- the id of the part to tracklistener
- a selection listener- Since:
- 2.0
-
removePostSelectionListener
Removes the given post selection listener. Has no effect if an identical listener is not registered.- Parameters:
listener
- a selection listener
-
removePostSelectionListener
Removes the given part-specific post selection listener. Has no effect if an identical listener is not registered for the given part id.- Parameters:
partId
- the id of the part to tracklistener
- a selection listener- Since:
- 2.0
-