Package org.eclipse.ui.internal

# Class PartService

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

All Implemented Interfaces:
  `IPageChangedListener`, `IPartListener`, `IPartListener2`, `IPartService`

public class PartService extends Object implements IPageChangedListener, IPartListener, IPartListener2, IPartService

## Constructor Summary

Constructors
Constructor
Description
`PartService()`

## 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.
`IWorkbenchPart`
`getActivePart()`
Returns the active part.
`IWorkbenchPartReference`
`getActivePartReference()`
Returns the active part reference.
`void`
`pageChanged(PageChangedEvent event)`
Notifies that the selected page has changed.
`void`
`partActivated(IWorkbenchPart part)`
Notifies this listener that the given part has been activated.
`void`
`partActivated(IWorkbenchPartReference partRef)`
Notifies this listener that the given part has been activated.
`void`
`partBroughtToTop(IWorkbenchPart part)`
Notifies this listener that the given part has been brought to the top.
`void`
`partBroughtToTop(IWorkbenchPartReference partRef)`
Notifies this listener that the given part has been brought to the top.
`void`
`partClosed(IWorkbenchPart part)`
Notifies this listener that the given part has been closed.
`void`
`partClosed(IWorkbenchPartReference partRef)`
Notifies this listener that the given part has been closed.
`void`
`partDeactivated(IWorkbenchPart part)`
Notifies this listener that the given part has been deactivated.
`void`
`partDeactivated(IWorkbenchPartReference partRef)`
Notifies this listener that the given part has been deactivated.
`void`
`partHidden(IWorkbenchPartReference partRef)`
Notifies this listener that the given part is hidden or obscured by another part.
`void`
`partInputChanged(IWorkbenchPartReference partRef)`
Notifies this listener that the given part's input was changed.
`void`
`partOpened(IWorkbenchPart part)`
Notifies this listener that the given part has been opened.
`void`
`partOpened(IWorkbenchPartReference partRef)`
Notifies this listener that the given part has been opened.
`void`
`partVisible(IWorkbenchPartReference partRef)`
Notifies this listener that the given part is visible.
`void`
`removePartListener(IPartListener listener)`
Removes the given part listener.
`void`
`removePartListener(IPartListener2 listener)`
Removes the given part listener.

### Methods inherited from class java.lang.Object

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

## Constructor Details

### PartService

public PartService()

## 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

### partActivated

public void partActivated(IWorkbenchPart part)
Description copied from interface: `IPartListener`
Notifies this listener that the given part has been activated.

Specified by:
  `partActivated` in interface `IPartListener`
Parameters:
  `part` - the part that was activated
See Also:
  - `IWorkbenchPage.activate(org.eclipse.ui.IWorkbenchPart)`

### partBroughtToTop

public void partBroughtToTop(IWorkbenchPart part)
Description copied from interface: `IPartListener`
Notifies this listener that the given part has been brought to the top.

These events occur when an editor is brought to the top in the editor area, or when a view is brought to the top in a page book with multiple views. They are normally only sent when a part is brought to the top programmatically (via `IPerspective.bringToTop`). When a part is activated by the user clicking on it, only `partActivated` is sent.

Specified by:
  `partBroughtToTop` in interface `IPartListener`
Parameters:
  `part` - the part that was surfaced
See Also:
  - `IWorkbenchPage.bringToTop(org.eclipse.ui.IWorkbenchPart)`

### partClosed

public void partClosed(IWorkbenchPart part)
Description copied from interface: `IPartListener`
Notifies this listener that the given part has been closed.

Specified by:
  `partClosed` in interface `IPartListener`
Parameters:
  `part` - the part that was closed
See Also:
  - `IWorkbenchPage.hideView(IViewPart)`

### partDeactivated

public void partDeactivated(IWorkbenchPart part)
Description copied from interface: `IPartListener`
Notifies this listener that the given part has been deactivated.

Specified by:
  `partDeactivated` in interface `IPartListener`
Parameters:
  `part` - the part that was deactivated
See Also:
  - `IWorkbenchPage.activate(IWorkbenchPart)`

### partOpened

public void partOpened(IWorkbenchPart part)
Description copied from interface: `IPartListener`
Notifies this listener that the given part has been opened.

Specified by:
  `partOpened` in interface `IPartListener`
Parameters:
  `part` - the part that was opened
See Also:
  - `IWorkbenchPage.showView(String)`

### partActivated

public void partActivated(IWorkbenchPartReference partRef)
Description copied from interface: `IPartListener2`
Notifies this listener that the given part has been activated.

Specified by:
  `partActivated` in interface `IPartListener2`
Parameters:
  `partRef` - the part that was activated
See Also:
  - `IWorkbenchPage.activate(org.eclipse.ui.IWorkbenchPart)`

### partBroughtToTop

public void partBroughtToTop(IWorkbenchPartReference partRef)
Description copied from interface: `IPartListener2`
Notifies this listener that the given part has been brought to the top.

These events occur when an editor is brought to the top in the editor area, or when a view is brought to the top in a page book with multiple views. They are normally only sent when a part is brought to the top programmatically (via `IPerspective.bringToTop`). When a part is activated by the user clicking on it, only `partActivated` is sent.

Specified by:
  `partBroughtToTop` in interface `IPartListener2`
Parameters:
  `partRef` - the part that was surfaced
See Also:
  - `IWorkbenchPage.bringToTop(org.eclipse.ui.IWorkbenchPart)`

### partClosed

public void partClosed(IWorkbenchPartReference partRef)
Description copied from interface: `IPartListener2`
Notifies this listener that the given part has been closed.

Note that if other perspectives in the same page share the view, this notification is not sent. It is only sent when the view is being removed from the page entirely (it is being disposed).

Specified by:
  `partClosed` in interface `IPartListener2`
Parameters:
  `partRef` - the part that was closed
See Also:
  - `IWorkbenchPage.hideView(org.eclipse.ui.IViewPart)`

### partDeactivated

public void partDeactivated(IWorkbenchPartReference partRef)
Description copied from interface: `IPartListener2`
Notifies this listener that the given part has been deactivated.

Specified by:
  `partDeactivated` in interface `IPartListener2`
Parameters:
  `partRef` - the part that was deactivated
See Also:
  - `IWorkbenchPage.activate(org.eclipse.ui.IWorkbenchPart)`

### partOpened

public void partOpened(IWorkbenchPartReference partRef)
Description copied from interface: `IPartListener2`
Notifies this listener that the given part has been opened.

Note that if other perspectives in the same page share the view, this notification is not sent. It is only sent when the view is being newly opened in the page (it is being created).

Specified by:
  `partOpened` in interface `IPartListener2`
Parameters:
  `partRef` - the part that was opened
See Also:
  - `IWorkbenchPage.showView(java.lang.String)`

### partHidden

public void partHidden(IWorkbenchPartReference partRef)
Description copied from interface: `IPartListener2`
Notifies this listener that the given part is hidden or obscured by another part.

Specified by:
  `partHidden` in interface `IPartListener2`
Parameters:
  `partRef` - the part that is hidden or obscured by another part

### partVisible

public void partVisible(IWorkbenchPartReference partRef)
Description copied from interface: `IPartListener2`
Notifies this listener that the given part is visible.

Specified by:
  `partVisible` in interface `IPartListener2`
Parameters:
  `partRef` - the part that is visible

### partInputChanged

public void partInputChanged(IWorkbenchPartReference partRef)
Description copied from interface: `IPartListener2`
Notifies this listener that the given part's input was changed.

Specified by:
  `partInputChanged` in interface `IPartListener2`
Parameters:
  `partRef` - the part whose input was changed

### pageChanged

public void pageChanged(PageChangedEvent event)
Description copied from interface: `IPageChangedListener`
Notifies that the selected page has changed.

Specified by:
  `pageChanged` in interface `IPageChangedListener`
Parameters:
  `event` - event object describing the change