IMprove centering of defualt login dialog in RCP
authorMathieu Baudier <mbaudier@argeo.org>
Thu, 25 Oct 2012 09:37:53 +0000 (09:37 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Thu, 25 Oct 2012 09:37:53 +0000 (09:37 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@5644 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

security/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/dialogs/DefaultLoginDialog.java

index c07e8a9dfc0060a7963d0e4d9e72bfec1b760a1d..dc7c09a990dd9c445e1765564381b3c56100f70f 100644 (file)
@@ -54,8 +54,13 @@ public class DefaultLoginDialog extends AbstractLoginDialog {
        protected Control createContents(Composite parent) {
                Control control = super.createContents(parent);
                parent.pack();
+
                // Move the dialog to the center of the top level shell.
-               Rectangle shellBounds = Display.getCurrent().getBounds();
+               Rectangle shellBounds;
+               if (Display.getCurrent().getActiveShell() != null) // RCP
+                       shellBounds = Display.getCurrent().getActiveShell().getBounds();
+               else
+                       shellBounds = Display.getCurrent().getBounds();// RAP
                Point dialogSize = parent.getSize();
                int x = shellBounds.x + (shellBounds.width - dialogSize.x) / 2;
                int y = shellBounds.y + (shellBounds.height - dialogSize.y) / 2;