mailTextBox.setMaxLength(255);
final Label usernameLabel = new Label("Nom d'utilisateur *");
final TextBox usernameTextBox = new TextBox();
usernameTextBox.setMaxLength(255);
final Label passwordLabel = new Label("Mot de passe *");
final PasswordTextBox passwordTextBox = new PasswordTextBox();
passwordTextBox.setMaxLength(255);
final Label confirmPasswordLabel = new Label(
"Confirmation du mot de passe *");
final PasswordTextBox confirmPasswordTextBox = new PasswordTextBox();
confirmPasswordTextBox.setMaxLength(255);
final Label cellLabel = new Label("Numéro de mobile");
final TextBox cellTextBox = new TextBox();
cellTextBox.setMaxLength(16);
final HorizontalPanel buttonPanel = new HorizontalPanel();
final Button okButton = new Button("OK");
final Button logInButton = new Button("Connexion");
// Fill popup contents
popupContents.add(nameLabel);
popupContents.add(nameTextBox);
popupContents.add(mailLabel);
popupContents.add(mailTextBox);
popupContents.add(cellLabel);
popupContents.add(cellTextBox);
popupContents.add(usernameLabel);
popupContents.add(usernameTextBox);
popupContents.add(passwordLabel);
popupContents.add(passwordTextBox);
popupContents.add(confirmPasswordLabel);
popupContents.add(confirmPasswordTextBox);
buttonPanel.add(okButton);
buttonPanel.add(logInButton);
buttonPanel.setSpacing(5);
popupContents.add(buttonPanel);
loginSignupPopup.setWidget(popupContents);
// Popup ok button
okButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// Retrieve field values
String name = nameTextBox.getText().trim();
String email = mailTextBox.getText().trim();
String username = usernameTextBox.getText().trim();
String password = passwordTextBox.getText().trim();
String confirmPassword = confirmPasswordTextBox.getText()
.trim();
String cell = cellTextBox.getText().trim();
// Validate field values
try {
Validator.validateSignUp(name, email, username, password,
confirmPassword, cell);
signUp(name, email, username, confirmPassword, cell);
} catch (Exception caught) {
System.err.println(caught.getClass().getName() + " :: "
+ caught.getMessage());
// caught.printStackTrace();
if (caught instanceof RequiredFieldException) {
Window.alert(PdpScanner.REQUIRED_FIELDS_ERROR);
} else if (caught instanceof BadEmailException) {
Window.alert(PdpScanner.BAD_EMAIL_ERROR);
} else if (caught instanceof BadCellException) {
Window.alert(PdpScanner.BAD_CELL_ERROR);
} else if (caught instanceof BadPasswordLengthException) {
Window.alert(PdpScanner.BAD_PASSWORD_LENGTH_ERROR);
} else if (caught instanceof BadPasswordConfirmationException) {
Window.alert(PdpScanner.BAD_PASSWORD_CONFIRMATION_ERROR);
} else {
Window.alert(PdpScanner.SIGNUP_USER_ERROR);
}
}
}
});
// Popup confirm password textbox
confirmPasswordTextBox.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
if (event.getCharCode() == 13) {