1 11 package org.eclipse.debug.ui.contexts; 12 13 import org.eclipse.core.runtime.ISafeRunnable; 14 import org.eclipse.core.runtime.ListenerList; 15 import org.eclipse.core.runtime.SafeRunner; 16 import org.eclipse.debug.internal.ui.DebugUIPlugin; 17 import org.eclipse.ui.IWorkbenchPart; 18 19 26 public abstract class AbstractDebugContextProvider implements IDebugContextProvider { 27 28 31 private ListenerList fListeners = new ListenerList(); 32 33 36 private IWorkbenchPart fPart; 37 38 43 public AbstractDebugContextProvider(IWorkbenchPart part) { 44 fPart = part; 45 } 46 47 50 public void addDebugContextListener(IDebugContextListener listener) { 51 fListeners.add(listener); 52 } 53 54 57 public IWorkbenchPart getPart() { 58 return fPart; 59 } 60 61 64 public void removeDebugContextListener(IDebugContextListener listener) { 65 fListeners.remove(listener); 66 } 67 68 73 protected void fire(final DebugContextEvent event) { 74 Object [] listeners = fListeners.getListeners(); 75 for (int i = 0; i < listeners.length; i++) { 76 final IDebugContextListener listener = (IDebugContextListener) listeners[i]; 77 SafeRunner.run(new ISafeRunnable() { 78 public void run() throws Exception { 79 listener.debugContextChanged(event); 80 } 81 public void handleException(Throwable exception) { 82 DebugUIPlugin.log(exception); 83 } 84 }); 85 86 } 87 } 88 } 89 | Popular Tags |