-// $Id$
/**
* Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy
+ * European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
- *
+ *
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import eu.etaxonomy.taxeditor.l10n.Messages;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.store.CdmStore;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
/**
* TODO wrap in a LoginModule
* @version 1.0
*/
public class LoginDialog extends Dialog {
-
+
private static Text text_password;
private static Text text_username;
- private String title;
+ private final String title;
- /**
- * <p>Constructor for LoginDialog.</p>
- *
- * @param parentShell a {@link org.eclipse.swt.widgets.Shell} object.
- */
public LoginDialog(Shell parentShell) {
super(parentShell);
- title = "Login";
+ title = Messages.LoginDialog_LOGIN;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
+
/** {@inheritDoc} */
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
//add controls to composite as necessary
-
+
// Label for the heading
final CLabel titleLabel = new CLabel(composite, SWT.NONE);
- titleLabel.setText("User Login");
+ titleLabel.setText(Messages.LoginDialog_USER_LOGIN);
// Label for the username
final CLabel userNameLabel = new CLabel(composite, SWT.NONE);
- userNameLabel.setText("Username");
+ userNameLabel.setText(Messages.LoginDialog_USER_NAME);
// Textfield for the username
text_username = new Text(composite, SWT.BORDER);
// Label for the password
final CLabel passwordLabel = new CLabel(composite, SWT.NONE);
- passwordLabel.setText("Password");
+ passwordLabel.setText(Messages.LoginDialog_PASSWORD);
// Textfield for the password
text_password = new Text(composite, SWT.PASSWORD | SWT.BORDER);
text_password.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
-
+
+
return composite;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
- */
/** {@inheritDoc} */
+ @Override
protected void configureShell(Shell shell) {
super.configureShell(shell);
if (title != null) {
}
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
/** {@inheritDoc} */
@Override
protected void okPressed() {
String username = text_username.getText();
String password = text_password.getText();
-
+
boolean result = CdmStore.getLoginManager().authenticate(username, password);
-
+
if(result){
super.okPressed();
}
-
- }
-
+
+ }
+
@Override
- protected void cancelPressed() {
+ protected void cancelPressed() {
if(CdmStore.getLoginManager().getAuthenticatedUser() != null){
super.cancelPressed();
}else{
// if there is no active user and the current user chooses to cancel, we close the connection
- boolean result = MessageDialog.openConfirm(getShell(), "Do you really want to cancel", "Aborting the login procedure will close the database.");
-
+ boolean result = MessageDialog.openConfirm(getShell(), Messages.LoginDialog_REALLY_CANCEL, Messages.LoginDialog_CANCEL_MESSAGE);
+
if(result){
- CdmStore.close(StoreUtil.getMonitor());
+ CdmStore.close(AbstractUtility.getMonitor());
super.cancelPressed();
}
}