1 package org
.argeo
.cms
.ui
.widgets
.auth
;
3 import javax
.security
.auth
.callback
.CallbackHandler
;
5 import org
.eclipse
.swt
.SWT
;
6 import org
.eclipse
.swt
.graphics
.Point
;
7 import org
.eclipse
.swt
.graphics
.Rectangle
;
8 import org
.eclipse
.swt
.layout
.GridData
;
9 import org
.eclipse
.swt
.layout
.GridLayout
;
10 import org
.eclipse
.swt
.widgets
.Composite
;
11 import org
.eclipse
.swt
.widgets
.Control
;
12 import org
.eclipse
.swt
.widgets
.Display
;
13 import org
.eclipse
.swt
.widgets
.Shell
;
15 /** Default authentication dialog, to be used as {@link CallbackHandler}. */
16 public class DefaultLoginDialog
extends AbstractLoginDialog
{
17 private static final long serialVersionUID
= -8551827590693035734L;
19 public DefaultLoginDialog() {
20 this(Display
.getCurrent().getActiveShell());
23 public DefaultLoginDialog(Shell parentShell
) {
27 protected Point
getInitialSize() {
28 return new Point(350, 180);
32 protected Control
createContents(Composite parent
) {
33 Control control
= super.createContents(parent
);
36 // Move the dialog to the center of the top level shell.
37 Rectangle shellBounds
;
38 if (Display
.getCurrent().getActiveShell() != null) // RCP
39 shellBounds
= Display
.getCurrent().getActiveShell().getBounds();
41 shellBounds
= Display
.getCurrent().getBounds();// RAP
42 Point dialogSize
= parent
.getSize();
43 int x
= shellBounds
.x
+ (shellBounds
.width
- dialogSize
.x
) / 2;
44 int y
= shellBounds
.y
+ (shellBounds
.height
- dialogSize
.y
) / 2;
45 parent
.setLocation(x
, y
);
49 protected Control
createDialogArea(Composite parent
) {
50 Composite dialogarea
= (Composite
) super.createDialogArea(parent
);
51 CompositeCallbackHandler composite
= new CompositeCallbackHandler(
52 dialogarea
, SWT
.NONE
);
53 composite
.setLayout(new GridLayout(2, false));
54 composite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false));
55 composite
.createCallbackHandlers(getCallbacks());
59 public void internalHandle() {