1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.ui.auth;
\r
14 import org.eclipse.jface.dialogs.IDialogSettings;
\r
15 import org.eclipse.jface.dialogs.TrayDialog;
\r
16 import org.eclipse.jface.layout.GridDataFactory;
\r
17 import org.eclipse.swt.SWT;
\r
18 import org.eclipse.swt.graphics.Point;
\r
19 import org.eclipse.swt.widgets.Composite;
\r
20 import org.eclipse.swt.widgets.Control;
\r
21 import org.eclipse.swt.widgets.Shell;
\r
22 import org.simantics.ui.auth.model.LoginModel;
\r
25 * @author Tuukka Lehtonen
\r
27 public class LoginDialog extends TrayDialog {
\r
29 private static final String LOGIN_DIALOG = "LoginDialog"; //$NON-NLS-1$
\r
31 private IDialogSettings dialogBoundsSettings;
\r
33 private LoginComposite c;
\r
35 private final LoginModel model;
\r
37 protected LoginDialog(Shell parentShell, IDialogSettings settings, LoginModel model) {
\r
41 dialogBoundsSettings = settings.getSection(LOGIN_DIALOG);
\r
42 if (dialogBoundsSettings == null)
\r
43 dialogBoundsSettings = settings.addNewSection(LOGIN_DIALOG);
\r
47 protected int getShellStyle() {
\r
48 return super.getShellStyle() /*| SWT.RESIZE */;
\r
52 protected void configureShell(Shell newShell) {
\r
53 newShell.setText("Login - " + model.getServer().getName());
\r
54 super.configureShell(newShell);
\r
58 protected Control createDialogArea(Composite parent) {
\r
59 Composite composite = (Composite) super.createDialogArea(parent);
\r
61 c = new LoginComposite(composite, SWT.NONE, model);
\r
63 GridDataFactory.fillDefaults().grab(true, false).applyTo(c);
\r
65 applyDialogFont(composite);
\r
71 protected IDialogSettings getDialogBoundsSettings() {
\r
72 return dialogBoundsSettings;
\r
76 protected Point getInitialSize() {
\r
77 Point defaultSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
\r
78 Point result = super.getInitialSize();
\r
79 if (defaultSize.equals(result))
\r
80 return new Point(400, 220);
\r
85 protected void createButtonsForButtonBar(Composite parent) {
\r
86 super.createButtonsForButtonBar(parent);
\r