@UiHandler("usernameTextBox") void usernameTextBoxOnFocus(FocusEvent event) { active.setVisible(true); int x = getTooltipPosition(usernameTextBox)[0]; int y = getTooltipPosition(usernameTextBox)[1]; active.setGray(); setTooltipPosition(x, y); setTooltipText("Optional Field. Enter username if you wish to create a superuser."); }
@UiHandler("emailTextBox") void emailTextBoxOnFocus(FocusEvent event) { if (!emailTextBox.getStyleName().equals(deployer.redBorder())) { active.setVisible(true); int x = getTooltipPosition(emailTextBox)[0]; int y = getTooltipPosition(emailTextBox)[1]; active.setGray(); setTooltipPosition(x, y); setTooltipText("Enter your email address."); } }
@UiHandler("passwordConfirmTextBox") void passwordConfirmTextBoxOnFocus(FocusEvent event) { if (!passwordTextBox.getStyleName().equals(deployer.redBorder())) { active.setVisible(true); int x = getTooltipPosition(passwordConfirmTextBox)[0]; int y = getTooltipPosition(passwordConfirmTextBox)[1]; active.setGray(); setTooltipPosition(x, y); setTooltipText("Confirm the previous password."); } }
@UiHandler("passwordTextBox") void passwordTextBoxOnFocus(FocusEvent event) { if (!passwordTextBox.getStyleName().equals(deployer.redBorder())) { active.setVisible(true); int x = getTooltipPosition(passwordTextBox)[0]; int y = getTooltipPosition(passwordTextBox)[1]; active.setGray(); setTooltipPosition(x, y); setTooltipText("Must be entered if your wish to create a superuser."); } }
@UiHandler("emailTextBox") void emailTextBoxOnChange(KeyUpEvent event) { if (!usernameTextBox.getText().isEmpty()) { if (!isEmailValid()) { active.hide(); emailError.setText("Enter a valid email address"); emailTextBox.setStyleName(deployer.redBorder()); } else { emailError.setText(""); emailTextBox.setStyleName(deployer.greyBorder()); } } else { } }
@UiHandler("passwordConfirmTextBox") void passwordConfirmTextBoxOnChange(KeyUpEvent event) { if (!usernameTextBox.getText().isEmpty()) { if (!isPasswordValid()) { active.hide(); passwordError.setText("Passwords do not match"); passwordTextBox.setStyleName(deployer.redBorder()); passwordConfirmTextBox.setStyleName(deployer.redBorder()); } else { passwordError.setText(""); passwordTextBox.setStyleName(deployer.greyBorder()); passwordConfirmTextBox.setStyleName(deployer.greyBorder()); } } else { } }
/** * Set the text of a tooltip * * @param text the text to set */ private void setTooltipText(String text) { active.hide(); active.setText(text); active.show(); }
/** * Set the position of a tooltip relative to the browser window * * @param x the x coordinate * @param y the y coordinate */ private void setTooltipPosition(int x, int y) { active.setPopupPosition(x, y); }
/** Set the tooltips initial state on page load */ private void setTooltipInitialState() { active.setVisible(false); }