IMprove centering of defualt login dialog in RCP
[lgpl/argeo-commons.git] / 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;