2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.cms
.ui
.widgets
.auth
;
18 import javax
.security
.auth
.callback
.CallbackHandler
;
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
;
30 /** Default authentication dialog, to be used as {@link CallbackHandler}. */
31 public class DefaultLoginDialog
extends AbstractLoginDialog
{
32 private static final long serialVersionUID
= -8551827590693035734L;
34 public DefaultLoginDialog() {
35 this(Display
.getCurrent().getActiveShell());
38 public DefaultLoginDialog(Shell parentShell
) {
42 protected Point
getInitialSize() {
43 return new Point(350, 180);
47 protected Control
createContents(Composite parent
) {
48 Control control
= super.createContents(parent
);
51 // Move the dialog to the center of the top level shell.
52 Rectangle shellBounds
;
53 if (Display
.getCurrent().getActiveShell() != null) // RCP
54 shellBounds
= Display
.getCurrent().getActiveShell().getBounds();
56 shellBounds
= Display
.getCurrent().getBounds();// RAP
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
);
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());
74 public void internalHandle() {