1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.cms.ui.widgets.auth;
17
18 import javax.security.auth.callback.CallbackHandler;
19
20 import org.eclipse.swt.SWT;
21 import org.eclipse.swt.graphics.Point;
22 import org.eclipse.swt.graphics.Rectangle;
23 import org.eclipse.swt.layout.GridData;
24 import org.eclipse.swt.layout.GridLayout;
25 import org.eclipse.swt.widgets.Composite;
26 import org.eclipse.swt.widgets.Control;
27 import org.eclipse.swt.widgets.Display;
28 import org.eclipse.swt.widgets.Shell;
29
30
31 public class DefaultLoginDialog extends AbstractLoginDialog {
32 private static final long serialVersionUID = -8551827590693035734L;
33
34 public DefaultLoginDialog() {
35 this(Display.getCurrent().getActiveShell());
36 }
37
38 public DefaultLoginDialog(Shell parentShell) {
39 super(parentShell);
40 }
41
42 protected Point getInitialSize() {
43 return new Point(350, 180);
44 }
45
46 @Override
47 protected Control createContents(Composite parent) {
48 Control control = super.createContents(parent);
49 parent.pack();
50
51
52 Rectangle shellBounds;
53 if (Display.getCurrent().getActiveShell() != null)
54 shellBounds = Display.getCurrent().getActiveShell().getBounds();
55 else
56 shellBounds = Display.getCurrent().getBounds();
57 Point dialogSize = parent.getSize();
58 int x = shellBounds.x + (shellBounds.width - dialogSize.x) / 2;
59 int y = shellBounds.y + (shellBounds.height - dialogSize.y) / 2;
60 parent.setLocation(x, y);
61 return control;
62 }
63
64 protected Control createDialogArea(Composite parent) {
65 Composite dialogarea = (Composite) super.createDialogArea(parent);
66 CompositeCallbackHandler composite = new CompositeCallbackHandler(
67 dialogarea, SWT.NONE);
68 composite.setLayout(new GridLayout(2, false));
69 composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
70 composite.createCallbackHandlers(getCallbacks());
71 return composite;
72 }
73
74 public void internalHandle() {
75 }
76 }