]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.ui/src/org/simantics/ui/auth/LoginDialog.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.ui / src / org / simantics / ui / auth / LoginDialog.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.ui.auth;
13
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;
23
24 /**
25  * @author Tuukka Lehtonen
26  */
27 public class LoginDialog extends TrayDialog {
28
29     private static final String LOGIN_DIALOG = "LoginDialog"; //$NON-NLS-1$
30
31     private IDialogSettings     dialogBoundsSettings;
32
33     private LoginComposite      c;
34
35     private final LoginModel          model;
36
37     protected LoginDialog(Shell parentShell, IDialogSettings settings, LoginModel model) {
38         super(parentShell);
39         this.model = model;
40
41         dialogBoundsSettings = settings.getSection(LOGIN_DIALOG);
42         if (dialogBoundsSettings == null)
43             dialogBoundsSettings = settings.addNewSection(LOGIN_DIALOG);
44     }
45
46     @Override
47     protected int getShellStyle() {
48         return super.getShellStyle() /*| SWT.RESIZE */;
49     }
50
51     @Override
52     protected void configureShell(Shell newShell) {
53         newShell.setText("Login - " + model.getServer().getName());
54         super.configureShell(newShell);
55     }
56
57     @Override
58     protected Control createDialogArea(Composite parent) {
59         Composite composite = (Composite) super.createDialogArea(parent);
60
61         c = new LoginComposite(composite, SWT.NONE, model);
62
63         GridDataFactory.fillDefaults().grab(true, false).applyTo(c);
64
65         applyDialogFont(composite);
66
67         return composite;
68     }
69
70     @Override
71     protected IDialogSettings getDialogBoundsSettings() {
72         return dialogBoundsSettings;
73     }
74
75     @Override
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);
81         return result;
82     }
83
84     @Override
85     protected void createButtonsForButtonBar(Composite parent) {
86         super.createButtonsForButtonBar(parent);
87     }
88
89 }