Revision 8aac42d2
Added by Patrick Plitzner over 8 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/LoginDialog.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
20 | 20 |
import org.eclipse.swt.widgets.Shell; |
21 | 21 |
import org.eclipse.swt.widgets.Text; |
22 | 22 |
|
23 |
import eu.etaxonomy.taxeditor.Messages; |
|
24 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
23 | 25 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
24 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
|
25 | 26 |
|
26 | 27 |
/** |
27 | 28 |
* TODO wrap in a LoginModule |
... | ... | |
32 | 33 |
* @version 1.0 |
33 | 34 |
*/ |
34 | 35 |
public class LoginDialog extends Dialog { |
35 |
|
|
36 |
|
|
36 | 37 |
private static Text text_password; |
37 | 38 |
private static Text text_username; |
38 | 39 |
|
39 |
private String title; |
|
40 |
private final String title;
|
|
40 | 41 |
|
41 |
/** |
|
42 |
* <p>Constructor for LoginDialog.</p> |
|
43 |
* |
|
44 |
* @param parentShell a {@link org.eclipse.swt.widgets.Shell} object. |
|
45 |
*/ |
|
46 | 42 |
public LoginDialog(Shell parentShell) { |
47 | 43 |
super(parentShell); |
48 |
title = "Login";
|
|
44 |
title = Messages.LoginDialog_LOGIN;
|
|
49 | 45 |
} |
50 |
|
|
51 | 46 |
|
52 |
/* (non-Javadoc) |
|
53 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
|
54 |
*/ |
|
47 |
|
|
55 | 48 |
/** {@inheritDoc} */ |
56 | 49 |
@Override |
57 | 50 |
protected Control createDialogArea(Composite parent) { |
58 | 51 |
Composite composite = (Composite) super.createDialogArea(parent); |
59 | 52 |
//add controls to composite as necessary |
60 |
|
|
53 |
|
|
61 | 54 |
|
62 | 55 |
// Label for the heading |
63 | 56 |
final CLabel titleLabel = new CLabel(composite, SWT.NONE); |
64 |
titleLabel.setText("User Login");
|
|
57 |
titleLabel.setText(Messages.LoginDialog_USER_LOGIN);
|
|
65 | 58 |
|
66 | 59 |
// Label for the username |
67 | 60 |
final CLabel userNameLabel = new CLabel(composite, SWT.NONE); |
68 |
userNameLabel.setText("Username");
|
|
61 |
userNameLabel.setText(Messages.LoginDialog_USER_NAME);
|
|
69 | 62 |
|
70 | 63 |
// Textfield for the username |
71 | 64 |
text_username = new Text(composite, SWT.BORDER); |
... | ... | |
73 | 66 |
|
74 | 67 |
// Label for the password |
75 | 68 |
final CLabel passwordLabel = new CLabel(composite, SWT.NONE); |
76 |
passwordLabel.setText("Password");
|
|
69 |
passwordLabel.setText(Messages.LoginDialog_PASSWORD);
|
|
77 | 70 |
|
78 | 71 |
// Textfield for the password |
79 | 72 |
text_password = new Text(composite, SWT.PASSWORD | SWT.BORDER); |
80 | 73 |
text_password.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
81 |
|
|
82 |
|
|
74 |
|
|
75 |
|
|
83 | 76 |
return composite; |
84 | 77 |
} |
85 | 78 |
|
86 |
/* |
|
87 |
* (non-Javadoc) |
|
88 |
* |
|
89 |
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) |
|
90 |
*/ |
|
91 | 79 |
/** {@inheritDoc} */ |
80 |
@Override |
|
92 | 81 |
protected void configureShell(Shell shell) { |
93 | 82 |
super.configureShell(shell); |
94 | 83 |
if (title != null) { |
... | ... | |
96 | 85 |
} |
97 | 86 |
} |
98 | 87 |
|
99 |
/* (non-Javadoc) |
|
100 |
* @see org.eclipse.jface.dialogs.Dialog#okPressed() |
|
101 |
*/ |
|
102 | 88 |
/** {@inheritDoc} */ |
103 | 89 |
@Override |
104 | 90 |
protected void okPressed() { |
105 | 91 |
String username = text_username.getText(); |
106 | 92 |
String password = text_password.getText(); |
107 |
|
|
93 |
|
|
108 | 94 |
boolean result = CdmStore.getLoginManager().authenticate(username, password); |
109 |
|
|
95 |
|
|
110 | 96 |
if(result){ |
111 | 97 |
super.okPressed(); |
112 | 98 |
} |
113 |
|
|
114 |
}
|
|
115 |
|
|
99 |
|
|
100 |
} |
|
101 |
|
|
116 | 102 |
@Override |
117 |
protected void cancelPressed() {
|
|
103 |
protected void cancelPressed() { |
|
118 | 104 |
if(CdmStore.getLoginManager().getAuthenticatedUser() != null){ |
119 | 105 |
super.cancelPressed(); |
120 | 106 |
}else{ |
121 | 107 |
// if there is no active user and the current user chooses to cancel, we close the connection |
122 |
boolean result = MessageDialog.openConfirm(getShell(), "Do you really want to cancel", "Aborting the login procedure will close the database.");
|
|
123 |
|
|
108 |
boolean result = MessageDialog.openConfirm(getShell(), Messages.LoginDialog_REALLY_CANCEL, Messages.LoginDialog_CANCEL_MESSAGE);
|
|
109 |
|
|
124 | 110 |
if(result){ |
125 |
CdmStore.close(StoreUtil.getMonitor());
|
|
111 |
CdmStore.close(AbstractUtility.getMonitor());
|
|
126 | 112 |
super.cancelPressed(); |
127 | 113 |
} |
128 | 114 |
} |
Also available in: Unified diff
I18n of login and data source view