Search in sources :

Example 6 with SWTThread

use of com.biglybt.ui.swt.mainwindow.SWTThread in project BiglyBT by BiglySoftware.

the class Utils method waitForModals.

/**
 * Waits until modal dialogs are disposed.  Assumes we are on SWT thread
 *
 * @since 3.0.1.3
 */
public static void waitForModals() {
    SWTThread swt = SWTThread.getInstance();
    Display display;
    if (swt == null) {
        display = Display.getDefault();
        if (display == null) {
            System.err.println("SWT Thread not started yet!");
            return;
        }
    } else {
        if (swt.isTerminated()) {
            return;
        }
        display = swt.getDisplay();
    }
    if (display == null || display.isDisposed()) {
        return;
    }
    Shell[] shells = display.getShells();
    Shell modalShell = null;
    for (int i = 0; i < shells.length; i++) {
        Shell shell = shells[i];
        if ((shell.getStyle() & SWT.APPLICATION_MODAL) != 0) {
            modalShell = shell;
            break;
        }
    }
    if (modalShell != null) {
        while (!modalShell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
    }
}
Also used : MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell) SWTThread(com.biglybt.ui.swt.mainwindow.SWTThread)

Aggregations

SWTThread (com.biglybt.ui.swt.mainwindow.SWTThread)6 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)2 SWTRunnable (com.biglybt.ui.swt.utils.SWTRunnable)2 ILogAlertListener (com.biglybt.core.logging.ILogAlertListener)1 MdiEntry (com.biglybt.ui.mdi.MdiEntry)1 ImageLoader (com.biglybt.ui.swt.imageloader.ImageLoader)1 BaseMdiEntry (com.biglybt.ui.swt.mdi.BaseMdiEntry)1 UISWTViewEventCancelledException (com.biglybt.ui.swt.pifimpl.UISWTViewEventCancelledException)1 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)1 MessageSlideShell (com.biglybt.ui.swt.shells.MessageSlideShell)1 SWTException (org.eclipse.swt.SWTException)1 Display (org.eclipse.swt.widgets.Display)1