Example usage for org.eclipse.swt.widgets Display update

List of usage examples for org.eclipse.swt.widgets Display update

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Display update.

Prototype

public void update() 

Source Link

Document

Forces all outstanding paint requests for the display to be processed before this method returns.

Usage

From source file:org.mwc.debrief.editable.test.EditableTests.java

/**
 * Process UI input but do not return for the specified time interval.
 * //from w ww  . java  2  s  .c  o m
 * @param waitTimeMillis
 *          the number of milliseconds
 */
protected static void delay(final long waitTimeMillis) {
    final Display display = Display.getCurrent();

    // If this is the user interface thread, then process input
    if (display != null) {
        final long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
        while (System.currentTimeMillis() < endTimeMillis) {
            if (!display.readAndDispatch())
                display.sleep();
        }
        display.update();
    }

    // Otherwise perform a simple sleep
    else {
        try {
            Thread.sleep(waitTimeMillis);
        } catch (final InterruptedException e) {
            // ignored
        }
    }
}