# Class SlavePartService

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

All Implemented Interfaces:
  `IPartService, IDisposable`

public class SlavePartService extends Object implements IPartService, IDisposable
A part service which delegates all responsibility to the parent service. The slave service is only responsible for disposing any locally activated listeners when it is disposed.

This class is not intended for use outside of the `org.eclipse.ui.workbench` plug-in.

Since:
  3.4

## Constructor Summary

Constructors
Constructor
Description
`SlavePartService(IPartService parentPartService)`
Constructs a new instance.

## Method Summary

Modifier and Type
Method
Description
`void`
`addPartListener(IPartListener listener)`
Adds the given listener for part lifecycle events.
`void`
`addPartListener(IPartListener2 listener)`
Adds the given listener for part lifecycle events.
`void`
`dispose()`
Disposes of this service.
`IWorkbenchPart`
`getActivePart()`
Returns the active part.
`IWorkbenchPartReference`
`getActivePartReference()`
Returns the active part reference.
`void`
`removePartListener(IPartListener listener)`
Removes the given part listener.
`void`
`removePartListener(IPartListener2 listener)`
Removes the given part listener.

### Methods inherited from class Object

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

## Constructor Details

### SlavePartService

public SlavePartService(IPartService parentPartService)
Constructs a new instance.

Parameters:
  `parentPartService` - The parent part service for this slave. Never `null`.

## Method Details

### addPartListener

public void addPartListener(IPartListener listener)
Description copied from interface: `IPartService`
Adds the given listener for part lifecycle events. 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.

Specified by:
  `addPartListener` in interface `IPartService`
Parameters:
  `listener` - a part listener
See Also:
  - `IPartService.removePartListener(IPartListener)`

### addPartListener

public void addPartListener(IPartListener2 listener)
Description copied from interface: `IPartService`
Adds the given listener for part lifecycle events. Has no effect if an identical listener is already registered.

As of 3.5, the IPartListener2 can also implement IPageChangedListener to be notified about any parts that implement IPageChangeProvider and post PageChangedEvents.

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.

Specified by:
  `addPartListener` in interface `IPartService`
Parameters:
  `listener` - a part listener
See Also:
  - `IPartService.removePartListener(IPartListener2)`
  - `IPageChangeProvider`
  - `IPageChangedListener`

### getActivePart

public IWorkbenchPart getActivePart()
Description copied from interface: `IPartService`
Returns the active part.

Specified by:
  `getActivePart` in interface `IPartService`
Returns:
  the active part, or `null` if no part is currently active

### getActivePartReference

public IWorkbenchPartReference getActivePartReference()
Description copied from interface: `IPartService`
Returns the active part reference.

Specified by:
  `getActivePartReference` in interface `IPartService`
Returns:
  the active part reference, or `null` if no part is currently active

### removePartListener

public void removePartListener(IPartListener listener)
Description copied from interface: `IPartService`
Removes the given part listener. Has no effect if an identical listener is not registered.

Specified by:
  `removePartListener` in interface `IPartService`
Parameters:
  `listener` - a part listener

### removePartListener

public void removePartListener(IPartListener2 listener)
Description copied from interface: `IPartService`
Removes the given part listener. Has no effect if an identical listener is not registered.

Specified by:
  `removePartListener` in interface `IPartService`
Parameters:
  `listener` - a part 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`