# Class SlaveSelectionService

java.lang.Object
org.eclipse.ui.internal.SlaveSelectionService

All Implemented Interfaces:
  `ISelectionService, IDisposable`

public class SlaveSelectionService extends Object implements ISelectionService, IDisposable

Since:
  3.4

## Constructor Summary

Constructors
Constructor
Description
`SlaveSelectionService(ISelectionService parentSelectionService)`

## Method Summary

Modifier and Type
Method
Description
`void`
`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.
`void`
`dispose()`
Disposes of this service.
`ISelection`
`getSelection()`
Returns the current selection in the active part.
`ISelection`
`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`
`removePostSelectionListener(ISelectionListener listener)`
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.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SlaveSelectionService

public SlaveSelectionService(ISelectionService parentSelectionService)

## Method Details

### addPostSelectionListener

public void addPostSelectionListener(ISelectionListener listener)
Description copied from interface: `ISelectionService`
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.

Specified by:
  `addPostSelectionListener` in interface `ISelectionService`
Parameters:
  `listener` - a selection listener
See Also:
  - `ISelectionService.removePostSelectionListener(ISelectionListener)`
  - `SelectionListenerFactory.createVisibleListener(IWorkbenchPart, ISelectionListener)`
  - `SelectionListenerFactory.createVisibleSelfMutedListener(IWorkbenchPart, ISelectionListener)`

### addPostSelectionListener

public void addPostSelectionListener(String partId, ISelectionListener listener)
Description copied from interface: `ISelectionService`
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 implements `INullSelectionListener`.

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.

Specified by:
  `addPostSelectionListener` in interface `ISelectionService`
Parameters:
  `partId` - the id of the part to track
  `listener` - a selection listener
See Also:
  - `ISelectionService.removePostSelectionListener(String, ISelectionListener)`
  - `SelectionListenerFactory.createVisibleListener(IWorkbenchPart, ISelectionListener)`
  - `SelectionListenerFactory.createVisibleSelfMutedListener(IWorkbenchPart, ISelectionListener)`

### addSelectionListener

public void addSelectionListener(ISelectionListener listener)
Description copied from interface: `ISelectionService`
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.

Specified by:
  `addSelectionListener` in interface `ISelectionService`
Parameters:
  `listener` - a selection listener
See Also:
  - `ISelectionService.removeSelectionListener(ISelectionListener)`
  - `SelectionListenerFactory.createVisibleListener(IWorkbenchPart, ISelectionListener)`
  - `SelectionListenerFactory.createVisibleSelfMutedListener(IWorkbenchPart, ISelectionListener)`

### addSelectionListener

public void addSelectionListener(String partId, ISelectionListener listener)
Description copied from interface: `ISelectionService`
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 implements `INullSelectionListener`.

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.

Specified by:
  `addSelectionListener` in interface `ISelectionService`
Parameters:
  `partId` - the id of the part to track
  `listener` - a selection listener
See Also:
  - `ISelectionService.removeSelectionListener(String, ISelectionListener)`
  - `SelectionListenerFactory.createVisibleListener(IWorkbenchPart, ISelectionListener)`
  - `SelectionListenerFactory.createVisibleSelfMutedListener(IWorkbenchPart, ISelectionListener)`

### getSelection

public ISelection getSelection()
Description copied from interface: `ISelectionService`
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 be `null`.

Specified by:
  `getSelection` in interface `ISelectionService`
Returns:
  the current selection, or `null` if undefined

### getSelection

public ISelection getSelection(String partId)
Description copied from interface: `ISelectionService`
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 be `null`.

Specified by:
  `getSelection` in interface `ISelectionService`
Parameters:
  `partId` - the id of the part
Returns:
  the current selection, or `null` if undefined

### removePostSelectionListener

public void removePostSelectionListener(ISelectionListener listener)
Description copied from interface: `ISelectionService`
Removes the given post selection listener. Has no effect if an identical listener is not registered.

Specified by:
  `removePostSelectionListener` in interface `ISelectionService`
Parameters:
  `listener` - a selection listener

### removePostSelectionListener

public void removePostSelectionListener(String partId, ISelectionListener listener)
Description copied from interface: `ISelectionService`
Removes the given part-specific post selection listener. Has no effect if an identical listener is not registered for the given part id.

Specified by:
  `removePostSelectionListener` in interface `ISelectionService`
Parameters:
  `partId` - the id of the part to track
  `listener` - a selection listener

### removeSelectionListener

public void removeSelectionListener(ISelectionListener listener)
Description copied from interface: `ISelectionService`
Removes the given selection listener. Has no effect if an identical listener is not registered.

Specified by:
  `removeSelectionListener` in interface `ISelectionService`
Parameters:
  `listener` - a selection listener

### removeSelectionListener

public void removeSelectionListener(String partId, ISelectionListener listener)
Description copied from interface: `ISelectionService`
Removes the given part-specific selection listener. Has no effect if an identical listener is not registered for the given part id.

Specified by:
  `removeSelectionListener` in interface `ISelectionService`
Parameters:
  `partId` - the id of the part to track
  `listener` - a selection listener

### dispose

public void dispose()
Description copied from interface: `IDisposable`
Disposes of this service. All resources must be freed. All listeners must be detached. Dispose will only be called once during the life cycle of a service.

Specified by:
  `dispose` in interface `IDisposable`