Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-06-10 18:03:56 +0000
committerEike Stepper2012-06-10 18:03:56 +0000
commitc692bce3beebd46f853b63649ac309f7ed54b5bb (patch)
treef7860689c85c8d5a8b43366bb9df1d25baaa9f25 /plugins/org.eclipse.net4j.util.ui
parenta9c7fdbbf6c340fc0207f8e39f1dce45fa948376 (diff)
downloadcdo-c692bce3beebd46f853b63649ac309f7ed54b5bb.tar.gz
cdo-c692bce3beebd46f853b63649ac309f7ed54b5bb.tar.xz
cdo-c692bce3beebd46f853b63649ac309f7ed54b5bb.zip
[380629] Design a default Security model
https://bugs.eclipse.org/bugs/show_bug.cgi?id=380629
Diffstat (limited to 'plugins/org.eclipse.net4j.util.ui')
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/security/CredentialsDialog.java14
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/security/InteractiveCredentialsProvider.java119
2 files changed, 79 insertions, 54 deletions
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/security/CredentialsDialog.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/security/CredentialsDialog.java
index e7e2efd2af..57adda365b 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/security/CredentialsDialog.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/security/CredentialsDialog.java
@@ -19,6 +19,7 @@ import org.eclipse.net4j.util.ui.widgets.BaseDialog;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
@@ -35,6 +36,10 @@ public class CredentialsDialog extends BaseDialog<Viewer>
private static final String MESSAGE = Messages.getString("CredentialsDialog_1"); //$NON-NLS-1$
+ private static final int WIDTH = 300;
+
+ private static final int HEIGHT = 220;
+
private Text userIDControl;
private Text passwordControl;
@@ -50,7 +55,14 @@ public class CredentialsDialog extends BaseDialog<Viewer>
protected void configureShell(Shell newShell)
{
super.configureShell(newShell);
- newShell.setSize(300, 220);
+
+ Composite parent = newShell.getParent();
+ Rectangle bounds = parent.getBounds();
+
+ int x = bounds.x + (bounds.width >> 1) - (WIDTH >> 1);
+ int y = bounds.y + (bounds.height >> 1) - (HEIGHT >> 1);
+
+ newShell.setBounds(x, y, WIDTH, HEIGHT);
}
public IPasswordCredentials getCredentials()
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/security/InteractiveCredentialsProvider.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/security/InteractiveCredentialsProvider.java
index aefafc166e..60d94429cf 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/security/InteractiveCredentialsProvider.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/security/InteractiveCredentialsProvider.java
@@ -1,53 +1,66 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.util.ui.security;
-
-import org.eclipse.net4j.util.security.IPasswordCredentials;
-import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
-import org.eclipse.net4j.util.ui.UIUtil;
-
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- */
-public class InteractiveCredentialsProvider implements IPasswordCredentialsProvider
-{
- public InteractiveCredentialsProvider()
- {
- }
-
- public boolean isInteractive()
- {
- return true;
- }
-
- public IPasswordCredentials getCredentials()
- {
- final IPasswordCredentials[] credentials = new IPasswordCredentials[1];
- final Display display = UIUtil.getDisplay();
- display.syncExec(new Runnable()
- {
- public void run()
- {
- CredentialsDialog dialog = new CredentialsDialog(new Shell(display));
- if (dialog.open() == CredentialsDialog.OK)
- {
- credentials[0] = dialog.getCredentials();
- }
- }
- });
-
- return credentials[0];
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.util.ui.security;
+
+import org.eclipse.net4j.util.security.IPasswordCredentials;
+import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
+import org.eclipse.net4j.util.ui.UIUtil;
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public class InteractiveCredentialsProvider implements IPasswordCredentialsProvider
+{
+ public InteractiveCredentialsProvider()
+ {
+ }
+
+ public boolean isInteractive()
+ {
+ return true;
+ }
+
+ public IPasswordCredentials getCredentials()
+ {
+ final IPasswordCredentials[] credentials = new IPasswordCredentials[1];
+ final Display display = UIUtil.getDisplay();
+ display.syncExec(new Runnable()
+ {
+ public void run()
+ {
+ Shell shell;
+
+ try
+ {
+ IWorkbenchWindow window = UIUtil.getActiveWorkbenchWindow();
+ shell = window.getShell();
+ }
+ catch (Exception ex)
+ {
+ shell = new Shell(display);
+ }
+
+ CredentialsDialog dialog = new CredentialsDialog(shell);
+ if (dialog.open() == CredentialsDialog.OK)
+ {
+ credentials[0] = dialog.getCredentials();
+ }
+ }
+ });
+
+ return credentials[0];
+ }
+}

Back to the top