1 11 package org.eclipse.help.ui.internal; 12 import org.eclipse.help.internal.base.*; 13 import org.eclipse.swt.widgets.*; 14 public class HelpUIEventLoop { 15 18 private static boolean started = false; 19 22 private static boolean running = false; 23 private static Display display; 24 27 public static void run() { 28 try { 29 if (display == null) 30 display = Display.getCurrent(); 31 if (display == null) 32 display = new Display(); 33 } finally { 34 started = true; 35 } 36 try { 37 running = true; 38 while (HelpApplication.isRunning()) { 39 try { 40 if (!display.readAndDispatch()) { 41 display.sleep(); 42 } 43 } catch (Throwable t) { 44 HelpBasePlugin.logError(t.getMessage(), t); 45 } 46 } 47 display.dispose(); 48 display = null; 49 } finally { 50 running = false; 51 } 52 } 53 public static void wakeup() { 54 Display d = display; 55 if (d != null) 56 try { 57 d.wake(); 58 } catch (Exception e) { 59 } 60 } 61 64 public static void waitFor() { 65 while (!started && HelpApplication.isRunning()) { 66 try { 67 Thread.sleep(100); 68 } catch (InterruptedException ie) { 69 } 70 } 71 } 72 75 public static boolean isRunning() { 76 return running; 77 } 78 } 79 | Popular Tags |