KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > WWinPerspectiveService


1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal;
12
13 import org.eclipse.ui.*;
14
15 /**
16  * A perspective service for the workbench window.
17  */

18 public class WWinPerspectiveService implements IPerspectiveService {
19     private WorkbenchWindow workbenchWindow;
20     private PerspectiveListenerList perspectiveListeners = new PerspectiveListenerList();
21 /**
22  * WWinPerspectiveService constructor comment.
23  */

24 public WWinPerspectiveService(WorkbenchWindow window) {
25     super();
26     this.workbenchWindow = window;
27 }
28 /**
29  * Adds the given listener for a page's perspective lifecycle events.
30  * Has no effect if an identical listener is already registered.
31  *
32  * @param listener a perspective listener
33  */

34 public void addPerspectiveListener(IInternalPerspectiveListener listener) {
35     perspectiveListeners.addPerspectiveListener(listener);
36 }
37 /**
38  * Fires perspective activated
39  */

40 protected void firePerspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
41     perspectiveListeners.firePerspectiveActivated(page, perspective);
42 }
43 /**
44  * Fires perspective changed
45  */

46 protected void firePerspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String JavaDoc changeId) {
47     perspectiveListeners.firePerspectiveChanged(page, perspective, changeId);
48 }
49 /**
50  * Fires perspective reset
51  */

52 protected void firePerspectiveClosed(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
53     perspectiveListeners.firePerspectiveClosed(page, perspective);
54 }
55 /**
56  * Fires perspective reset
57  */

58 protected void firePerspectiveOpened(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
59     perspectiveListeners.firePerspectiveOpened(page, perspective);
60 }
61 /**
62  * Returns the active perspective descriptor in the active workbench page.
63  *
64  * @return the active perspective descriptor, or <code>null</code> if no perspective is currently active
65  */

66 public IPerspectiveDescriptor getActivePerspective() {
67     IWorkbenchPage page = workbenchWindow.getActivePage();
68     if (page == null)
69         return null;
70     else
71         return page.getPerspective();
72 }
73 /**
74  * Removes the given page's perspective listener.
75  * Has no affect if an identical listener is not registered.
76  *
77  * @param listener a perspective listener
78  */

79 public void removePerspectiveListener(IInternalPerspectiveListener listener) {
80     perspectiveListeners.removePerspectiveListener(listener);
81 }
82 }
83
Popular Tags