1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.ui.dialogs;
|
12
|
|
13
|
import org.eclipse.jface.dialogs.Dialog;
|
14
|
import org.eclipse.swt.SWT;
|
15
|
import org.eclipse.swt.custom.CLabel;
|
16
|
import org.eclipse.swt.layout.GridData;
|
17
|
import org.eclipse.swt.widgets.Composite;
|
18
|
import org.eclipse.swt.widgets.Control;
|
19
|
import org.eclipse.swt.widgets.Shell;
|
20
|
import org.eclipse.swt.widgets.Text;
|
21
|
|
22
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
23
|
|
24
|
/**
|
25
|
* TODO wrap in a LoginModule
|
26
|
* see: http://java.sun.com/j2se/1.5.0/docs/api/javax/security/auth/spi/LoginModule.html
|
27
|
*
|
28
|
* @author n.hoffmann
|
29
|
* @created 16.06.2009
|
30
|
* @version 1.0
|
31
|
*/
|
32
|
public class LoginDialog extends Dialog {
|
33
|
|
34
|
private static Text text_password;
|
35
|
private static Text text_username;
|
36
|
|
37
|
private String title;
|
38
|
|
39
|
/**
|
40
|
* <p>Constructor for LoginDialog.</p>
|
41
|
*
|
42
|
* @param parentShell a {@link org.eclipse.swt.widgets.Shell} object.
|
43
|
*/
|
44
|
public LoginDialog(Shell parentShell) {
|
45
|
super(parentShell);
|
46
|
title = "Login";
|
47
|
}
|
48
|
|
49
|
|
50
|
/* (non-Javadoc)
|
51
|
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
52
|
*/
|
53
|
/** {@inheritDoc} */
|
54
|
@Override
|
55
|
protected Control createDialogArea(Composite parent) {
|
56
|
Composite composite = (Composite) super.createDialogArea(parent);
|
57
|
//add controls to composite as necessary
|
58
|
|
59
|
|
60
|
// Label for the heading
|
61
|
final CLabel titleLabel = new CLabel(composite, SWT.NONE);
|
62
|
titleLabel.setText("User Login");
|
63
|
|
64
|
// Label for the username
|
65
|
final CLabel userNameLabel = new CLabel(composite, SWT.NONE);
|
66
|
userNameLabel.setText("Username");
|
67
|
|
68
|
// Textfield for the username
|
69
|
text_username = new Text(composite, SWT.BORDER);
|
70
|
text_username.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
71
|
|
72
|
// Label for the password
|
73
|
final CLabel passwordLabel = new CLabel(composite, SWT.NONE);
|
74
|
passwordLabel.setText("Password");
|
75
|
|
76
|
// Textfield for the password
|
77
|
text_password = new Text(composite, SWT.PASSWORD | SWT.BORDER);
|
78
|
text_password.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
79
|
|
80
|
|
81
|
return composite;
|
82
|
}
|
83
|
|
84
|
/*
|
85
|
* (non-Javadoc)
|
86
|
*
|
87
|
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
|
88
|
*/
|
89
|
/** {@inheritDoc} */
|
90
|
protected void configureShell(Shell shell) {
|
91
|
super.configureShell(shell);
|
92
|
if (title != null) {
|
93
|
shell.setText(title);
|
94
|
}
|
95
|
}
|
96
|
|
97
|
/* (non-Javadoc)
|
98
|
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
|
99
|
*/
|
100
|
/** {@inheritDoc} */
|
101
|
@Override
|
102
|
protected void okPressed() {
|
103
|
String username = text_username.getText().trim();
|
104
|
String password = text_password.getText().trim();
|
105
|
|
106
|
CdmStore.getLoginManager().authenticate(username, password);
|
107
|
|
108
|
super.okPressed();
|
109
|
}
|
110
|
|
111
|
|
112
|
}
|