KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 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.core.runtime.Platform;
14 import org.eclipse.jface.util.ListenerList;
15 import org.eclipse.jface.util.SafeRunnable;
16 import org.eclipse.ui.*;
17
18 /**
19  * Perspective listener list.
20  */

21 public class PerspectiveListenerListOld {
22     private ListenerList listeners = new ListenerList();
23 /**
24  * PerspectiveListenerList constructor comment.
25  */

26 public PerspectiveListenerListOld() {
27     super();
28 }
29 /**
30  * Adds an IPerspectiveListener to the perspective service.
31  */

32 public void addPerspectiveListener(IPerspectiveListener l) {
33     listeners.add(l);
34 }
35 /**
36  * Notifies the listener that a perspective has been activated.
37  */

38 public void firePerspectiveActivated(final IWorkbenchPage page, final IPerspectiveDescriptor perspective) {
39     Object JavaDoc [] array = listeners.getListeners();
40     for (int nX = 0; nX < array.length; nX ++) {
41         final IPerspectiveListener l = (IPerspectiveListener)array[nX];
42         Platform.run(new SafeRunnable() {
43             public void run() {
44                 l.perspectiveActivated(page, perspective);
45             }
46         });
47     }
48 }
49 /**
50  * Notifies the listener that a perspective has been changed.
51  */

52 public void firePerspectiveChanged(final IWorkbenchPage page, final IPerspectiveDescriptor perspective, final String JavaDoc changeId) {
53     Object JavaDoc [] array = listeners.getListeners();
54     for (int nX = 0; nX < array.length; nX ++) {
55         final IPerspectiveListener l = (IPerspectiveListener)array[nX];
56         Platform.run(new SafeRunnable() {
57             public void run() {
58                 l.perspectiveChanged(page, perspective, changeId);
59             }
60         });
61     }
62 }
63 /**
64  * Notifies the listener that a part has been affected
65  * in the given perspective.
66  */

67 public void firePerspectiveChanged(final IWorkbenchPage page, final IPerspectiveDescriptor perspective, final IWorkbenchPartReference partRef, final String JavaDoc changeId) {
68     Object JavaDoc [] array = listeners.getListeners();
69     for (int nX = 0; nX < array.length; nX ++) {
70         if (array[nX] instanceof IPerspectiveListener2) {
71             final IPerspectiveListener2 l2 = (IPerspectiveListener2) array[nX];
72             Platform.run(new SafeRunnable() {
73                 public void run() {
74                     l2.perspectiveChanged(page, perspective, partRef, changeId);
75                 }
76             });
77         }
78     }
79 }
80 /**
81  * Removes an IPerspectiveListener from the perspective service.
82  */

83 public void removePerspectiveListener(IPerspectiveListener l) {
84     listeners.remove(l);
85 }
86 }
87
Popular Tags