package eu.etaxonomy.taxeditor.user.wizard;
import org.apache.log4j.Logger;
+import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
* @version 1.0
*/
public class UserWizardPage extends WizardPage implements ModifyListener{
+
+ public static final String NAME = "USER_WIZARD_PAGE";
+
+
private Composite composite;
private Text text_username;
private Text text_oldPassword;
private Text text_personLastName;
private Text text_userEmail;
+ private IInputValidator uniqueUserNameValidator;
+ private IInputValidator passwordRepetitionEqualityValidator;
+
/**
* @param pageName
*/
protected UserWizardPage(User user) {
- super("USER_WIZARD_PAGE");
+ super(NAME);
this.user = user;
}else{
setTitle("Edit existing user");
setDescription("Edit information for the selected user.");
-
- }
+ }
+
+ uniqueUserNameValidator = new UniqueUserNameValidator();
+ passwordRepetitionEqualityValidator = new PasswordRepetitionEqualityValidator();
}
private static final Logger logger = Logger.getLogger(UserWizardPage.class);
setControl(composite);
+ setPageComplete(false);
+
init();
}
private void createPasswordFieldsEdit(Composite parent){
CLabel label_oldPassword = new CLabel(parent, SWT.NULL);
label_oldPassword.setText("Old Password");
- text_oldPassword = new Text(parent, SWT.BORDER);
- text_oldPassword.setEchoChar('*');
+ text_oldPassword = new Text(parent, SWT.PASSWORD | SWT.BORDER);
text_oldPassword.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
text_oldPassword.addModifyListener(this);
CLabel label_password = new CLabel(parent, SWT.NULL);
label_password.setText("Password");
- text_password = new Text(parent, SWT.BORDER);
- text_password.setEchoChar('*');
+ text_password = new Text(parent, SWT.PASSWORD | SWT.BORDER);
text_password.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
text_password.addModifyListener(this);
public User getUser() {
return user;
}
+
+ private class UniqueUserNameValidator implements IInputValidator{
+
+ private static final String MESSAGE = "Username already exists";
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IInputValidator#isValid(java.lang.String)
+ */
+ public String isValid(String newText) {
+ // query for username
+ if( CdmStore.getUserService().loadUserByUsername(newText) != null){
+ return MESSAGE;
+ }
+
+ return null;
+ }
+ }
+
+ private class PasswordRepetitionEqualityValidator implements IInputValidator{
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IInputValidator#isValid(java.lang.String)
+ */
+ public String isValid(String newText) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ }
}