1 11 package org.eclipse.ui.internal; 12 13 import org.eclipse.core.commands.common.EventManager; 14 import org.eclipse.core.runtime.Platform; 15 import org.eclipse.jface.util.SafeRunnable; 16 import org.eclipse.ui.IPageListener; 17 import org.eclipse.ui.IWorkbenchPage; 18 import org.eclipse.ui.internal.misc.UIStats; 19 20 23 public class PageListenerList extends EventManager { 24 25 28 public PageListenerList() { 29 super(); 30 } 31 32 35 public void addPageListener(IPageListener l) { 36 addListenerObject(l); 37 } 38 39 47 private void fireEvent(SafeRunnable runnable, IPageListener listener, IWorkbenchPage page, String description) { 48 String label = null; if (UIStats.isDebugging(UIStats.NOTIFY_PAGE_LISTENERS)) { 50 label = description + page.getLabel(); 51 UIStats.start(UIStats.NOTIFY_PAGE_LISTENERS, label); 52 } 53 Platform.run(runnable); 54 if (UIStats.isDebugging(UIStats.NOTIFY_PAGE_LISTENERS)) { 55 UIStats.end(UIStats.NOTIFY_PAGE_LISTENERS, listener, label); 56 } 57 } 58 59 62 public void firePageActivated(final IWorkbenchPage page) { 63 Object [] array = getListeners(); 64 for (int i = 0; i < array.length; i++) { 65 final IPageListener l = (IPageListener) array[i]; 66 fireEvent(new SafeRunnable() { 67 public void run() { 68 l.pageActivated(page); 69 } 70 }, l, page, "activated::"); } 72 } 73 74 77 public void firePageClosed(final IWorkbenchPage page) { 78 Object [] array = getListeners(); 79 for (int i = 0; i < array.length; i++) { 80 final IPageListener l = (IPageListener) array[i]; 81 fireEvent(new SafeRunnable() { 82 public void run() { 83 l.pageClosed(page); 84 } 85 }, l, page, "closed::"); } 87 } 88 89 92 public void firePageOpened(final IWorkbenchPage page) { 93 Object [] listeners = getListeners(); 94 for (int i = 0; i < listeners.length; i++) { 95 final IPageListener l = (IPageListener) listeners[i]; 96 fireEvent(new SafeRunnable() { 97 public void run() { 98 l.pageOpened(page); 99 } 100 }, l, page, "opened::"); } 102 } 103 104 107 public void removePageListener(IPageListener l) { 108 removeListenerObject(l); 109 } 110 } 111 | Popular Tags |