private Shell backgroundShell;
private Shell foregoundShell;
+ private Display display;
+
private Integer returnCode = null;
private boolean block = true;
private String title;
/** Tries to find a display */
- private static Display getDisplay() {
+ static Display findDisplay() {
try {
Display display = Display.getCurrent();
if (display != null)
}
public int open() {
+ display = findDisplay();
if (foregoundShell != null)
throw new EclipseUiException("There is already a shell");
backgroundShell = new Shell(parentShell, SWT.ON_TOP);
// } else
// backgroundShell.setMaximized(true);
backgroundShell.setAlpha(128);
- backgroundShell.setBackground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ backgroundShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
foregoundShell = new Shell(backgroundShell, SWT.NO_TRIM | SWT.ON_TOP);
if (title != null)
setTitle(title);
// shell.pack();
// shell.layout();
- Rectangle shellBounds = parentShell != null ? parentShell.getBounds() : Display.getCurrent().getBounds();// RAP
+ Rectangle shellBounds = parentShell != null ? parentShell.getBounds() : display.getBounds();// RAP
Point dialogSize = foregoundShell.getSize();
int x = shellBounds.x + (shellBounds.width - dialogSize.x) / 2;
int y = shellBounds.y + (shellBounds.height - dialogSize.y) / 2;
closeShell(CANCEL);
}
});
+ backgroundShell.addDisposeListener((event) -> onClose());
if (block) {
block();
return foregoundShell.getShells().length != 0;
}
+ protected void onClose() {
+
+ }
+
// public synchronized int openAndWait() {
// open();
// while (returnCode == null)
}
protected Point getInitialSize() {
- // if (exception != null)
- // return new Point(800, 600);
- // else
return new Point(600, 400);
}
return returnCode;
}
+ Display getDisplay() {
+ return display;
+ }
+
}
\ No newline at end of file