1 11 package org.eclipse.debug.internal.ui.sourcelookup; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.core.runtime.IStatus; 15 import org.eclipse.core.runtime.Status; 16 import org.eclipse.debug.core.DebugPlugin; 17 import org.eclipse.debug.core.IStatusHandler; 18 import org.eclipse.debug.internal.ui.DebugUIPlugin; 19 import org.eclipse.debug.ui.IDebugUIConstants; 20 import org.eclipse.swt.widgets.Display; 21 22 31 public class Prompter implements IStatusHandler { 32 42 public Object handleStatus(final IStatus status, final Object source) throws CoreException { 43 DebugPlugin dp = DebugPlugin.getDefault(); 44 if (dp == null) { 46 throw new CoreException(new Status(IStatus.INFO, 47 IDebugUIConstants.PLUGIN_ID, 48 IStatus.OK, 49 SourceLookupUIMessages.Prompter_0, 50 null)); 51 } 52 final IStatusHandler handler = dp.getStatusHandler(status); 53 if (handler == null) { 54 throw new CoreException(new Status(IStatus.ERROR, 55 IDebugUIConstants.PLUGIN_ID, 56 IStatus.OK, 57 SourceLookupUIMessages.Prompter_0, 58 null)); 59 } 60 Display display = DebugUIPlugin.getStandardDisplay(); 61 if (display.getThread().equals(Thread.currentThread())) { 62 return handler.handleStatus(status, source); 63 } 64 final Object [] result = new Object [1]; 65 final CoreException[] exception = new CoreException[1]; 66 final Object lock = this; 67 Runnable r = new Runnable () { 68 public void run() { 69 try { 70 result[0] = handler.handleStatus(status, source); 71 } catch (CoreException e) { 72 exception[0] = e; 73 } 74 synchronized (lock) { 75 lock.notifyAll(); 76 } 77 } 78 }; 79 DebugUIPlugin.getStandardDisplay().syncExec(r); 80 81 if (exception[0] != null ) { 82 throw exception[0]; 83 } 84 return result[0]; 85 } 86 } 87 | Popular Tags |