Search in sources :

Example 46 with Display

use of org.eclipse.swt.widgets.Display in project yyl_example by Relucent.

the class ScreenCenter method main.

public static void main(String[] arg) {
    Dimension di = Toolkit.getDefaultToolkit().getScreenSize();
    System.out.println(di.height + " " + di.width);
    final Display display = Display.getDefault();
    final Shell shell = new Shell();
    Rectangle r = display.getClientArea();
    System.out.println(r);
    shell.layout();
    shell.setLocation(di.width / 2 - shell.getSize().x / 2, di.height / 2 - shell.getSize().y / 2);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Rectangle(org.eclipse.swt.graphics.Rectangle) Dimension(java.awt.Dimension) Display(org.eclipse.swt.widgets.Display)

Example 47 with Display

use of org.eclipse.swt.widgets.Display in project tdi-studio-se by Talend.

the class Application method stop.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.equinox.app.IApplication#stop()
     */
public void stop() {
    final IWorkbench workbench = PlatformUI.getWorkbench();
    if (workbench == null) {
        return;
    }
    final Display display = workbench.getDisplay();
    display.syncExec(new Runnable() {

        public void run() {
            if (!display.isDisposed()) {
                workbench.close();
            }
        }
    });
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) Display(org.eclipse.swt.widgets.Display)

Example 48 with Display

use of org.eclipse.swt.widgets.Display in project tdi-studio-se by Talend.

the class CodeGeneratorProgressMonitor method runEventLoop.

/**
     * Runs an event loop.
     */
private void runEventLoop() {
    // Only run the event loop so often, as it is expensive on some platforms
    // (namely Motif).
    final long t = System.currentTimeMillis();
    if (t - lastTime < tTHRESH) {
        return;
    }
    lastTime = t;
    // Run the event loop.
    if (CommonUIPlugin.isFullyHeadless()) {
        return;
    }
    final Display disp = DisplayUtils.getDisplay();
    if (disp == null) {
        return;
    }
    disp.syncExec(new Runnable() {

        @Override
        public void run() {
            for (; ; ) {
                try {
                    if (!disp.readAndDispatch()) {
                        break;
                    }
                } catch (SWTException se) {
                // do nothing;
                }
                // constantly generating events.
                if (System.currentTimeMillis() - t > tMAX) {
                    break;
                }
            }
        }
    });
}
Also used : SWTException(org.eclipse.swt.SWTException) Display(org.eclipse.swt.widgets.Display)

Example 49 with Display

use of org.eclipse.swt.widgets.Display in project tdi-studio-se by Talend.

the class CodeGeneratorProgressMonitor method setBlocked.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.core.runtime.IProgressMonitorWithBlocking#setBlocked(org.eclipse.core.runtime.IStatus)
     */
@Override
public void setBlocked(final IStatus reason) {
    // Run the event loop.
    if (CommonUIPlugin.isFullyHeadless()) {
        ExceptionHandler.process(reason.getException());
        return;
    }
    final Display disp = DisplayUtils.getDisplay();
    disp.syncExec(new Runnable() {

        @Override
        public void run() {
            Dialog.getBlockedHandler().showBlocked(CodeGeneratorProgressMonitor.this, reason, taskName);
        }
    });
}
Also used : Display(org.eclipse.swt.widgets.Display)

Example 50 with Display

use of org.eclipse.swt.widgets.Display in project tdi-studio-se by Talend.

the class CodeGeneratorProgressMonitor method clearBlocked.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.core.runtime.IProgressMonitorWithBlocking#clearBlocked()
     */
@Override
public void clearBlocked() {
    // Run the event loop.
    if (CommonUIPlugin.isFullyHeadless()) {
        return;
    }
    final Display disp = DisplayUtils.getDisplay();
    disp.syncExec(new Runnable() {

        @Override
        public void run() {
            Dialog.getBlockedHandler().clearBlocked();
        }
    });
}
Also used : Display(org.eclipse.swt.widgets.Display)

Aggregations

Display (org.eclipse.swt.widgets.Display)485 Shell (org.eclipse.swt.widgets.Shell)184 Point (org.eclipse.swt.graphics.Point)76 Test (org.junit.Test)63 FillLayout (org.eclipse.swt.layout.FillLayout)62 Color (org.eclipse.swt.graphics.Color)52 Button (org.eclipse.swt.widgets.Button)50 Rectangle (org.eclipse.swt.graphics.Rectangle)48 GridLayout (org.eclipse.swt.layout.GridLayout)43 Composite (org.eclipse.swt.widgets.Composite)43 GridData (org.eclipse.swt.layout.GridData)39 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)32 Image (org.eclipse.swt.graphics.Image)32 Label (org.eclipse.swt.widgets.Label)32 SWT (org.eclipse.swt.SWT)29 InvocationTargetException (java.lang.reflect.InvocationTargetException)28 StyledText (org.eclipse.swt.custom.StyledText)24 Text (org.eclipse.swt.widgets.Text)24 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)23 Font (org.eclipse.swt.graphics.Font)23