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