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