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();
}
}
}
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();
}
}
});
}
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;
}
}
}
});
}
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);
}
});
}
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();
}
});
}
Aggregations