]> git.argeo.org Git - gpl/argeo-slc.git/blob - workbench/DefaultLoginDialog.java
Prepare next development cycle
[gpl/argeo-slc.git] / workbench / DefaultLoginDialog.java
1 package org.argeo.cms.ui.workbench;
2
3 import javax.security.auth.callback.CallbackHandler;
4
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;
15
16 /** Default authentication dialog, to be used as {@link CallbackHandler}. */
17 @Deprecated
18 public class DefaultLoginDialog extends AbstractLoginDialog {
19 private static final long serialVersionUID = -8551827590693035734L;
20
21 public DefaultLoginDialog() {
22 this(Display.getCurrent().getActiveShell());
23 }
24
25 public DefaultLoginDialog(Shell parentShell) {
26 super(parentShell);
27 }
28
29 protected Point getInitialSize() {
30 return new Point(350, 180);
31 }
32
33 @Override
34 protected Control createContents(Composite parent) {
35 Control control = super.createContents(parent);
36 parent.pack();
37
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();
42 else
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);
48 return control;
49 }
50
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());
58 return composite;
59 }
60
61 public void internalHandle() {
62 }
63 }