com.smartgwt.client.widgets.form.fields.PasswordItem Java Examples

The following examples show how to use com.smartgwt.client.widgets.form.fields.PasswordItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RegisterLayout.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
private void createPasswordTextInputs() {
    this.passwordItem = new PasswordItem();
    this.passwordItem.setName("password");
    this.passwordItem.setHint("<nobr>" + i18n.possibleChars() + " [0-9a-zA-Z_-]" + "</nobr>");
    this.passwordItem.setKeyPressFilter("[0-9a-zA-Z_-]");
    
    this.verifyPasswordItem = new PasswordItem();
    this.verifyPasswordItem.setName("verifyPassword");
    this.verifyPasswordItem.setTitle(i18n.passwordAgain());
    this.verifyPasswordItem.setRequired(true);
    this.verifyPasswordItem.setHint("<nobr>" + i18n.possibleChars() + " [0-9a-zA-Z_-]" + "</nobr>");
    this.verifyPasswordItem.setKeyPressFilter("[0-9a-zA-Z_-]");
    this.verifyPasswordItem.setLength(250);

    MatchesFieldValidator matchesValidator = new MatchesFieldValidator();
    matchesValidator.setOtherField("password");
    matchesValidator.setErrorMessage(i18n.passwordDoNotMatch());
    this.verifyPasswordItem.setValidators(matchesValidator);
}
 
Example #2
Source File: ItemFactory.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static PasswordItem newPasswordItem(String name, String title, String value) {
	PasswordItem password = new PasswordItem();
	password.setTitle(I18N.message(title));
	password.setName(filterItemName(name));
	if (value != null)
		password.setValue(value);
	return password;
}
 
Example #3
Source File: LoginWindow.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private DynamicForm createForm() {
    DynamicForm f = new DynamicForm();
    f.setWidth(400);
    f.setBrowserSpellCheck(false);
    f.setNumCols(1);
    f.setTitleOrientation(TitleOrientation.TOP);
    f.setSaveOnEnter(true);

    TextItem user = new TextItem(USERNAME, i18nSgwt.dialog_UserNameTitle());
    user.setRequired(true);
    user.setWidth("*");
    user.setReadOnlyDisplay(ReadOnlyDisplayAppearance.STATIC);

    PasswordItem passwd = new PasswordItem(PASSWORD, i18nSgwt.dialog_PasswordTitle());
    passwd.setRequired(true);
    passwd.setWidth("*");

    TextItem producerCode = new TextItem(PRODUCER_CODE, i18n.LoginWindow_ProducerCode());
    producerCode.setWidth("*");
    producerCode.setReadOnlyDisplay(ReadOnlyDisplayAppearance.STATIC);

    StaticTextItem error = new StaticTextItem(ERROR);
    error.setShowTitle(false);
    error.setShowErrorText(true);

    f.setItems(user, producerCode, passwd, error);
    f.addSubmitValuesHandler(new SubmitValuesHandler() {

        @Override
        public void onSubmitValues(SubmitValuesEvent event) {
            submitCredentials();
        }
    });
    return f;
}
 
Example #4
Source File: LoginLayout.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
private void initUserLogin() {
    new LoginLayoutEventBroker(this);
    TextItem userNameItem = createUserNameItem();
    PasswordItem passwordItem = createPasswordItem();
    ButtonItem loginButton = createLoginButton();
    LinkItem registerLink = createRegisterLink();
    LinkItem forgotPasswordLink = createForgotPasswordLink();
    form.setFields(headerItem, userNameItem, passwordItem, loginButton, registerLink, forgotPasswordLink);
    addMember(form);
}
 
Example #5
Source File: LoginLayout.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
private PasswordItem createPasswordItem() {
    PasswordItem passwordItem = new PasswordItem(PASSWORD_FIELD);
    passwordItem.setTitle(i18n.password());
    passwordItem.setRequired(true);
    passwordItem.setLength(20);
    passwordItem.addKeyPressHandler(new KeyPressHandler() {
        public void onKeyPress(KeyPressEvent event) {
            if ( (event.getKeyName().equals("Enter")) && (LoginLayout.this.form.validate(false))) {
                login();
            }
        }
    });
    return passwordItem;
}
 
Example #6
Source File: SetPassword.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public SetPassword(final long userId) {
	super();

	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("changepassword"));
	setWidth(300);
	setHeight(140);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setAutoSize(true);

	final ValuesManager vm = new ValuesManager();
	final DynamicForm form = new DynamicForm();
	form.setValuesManager(vm);
	form.setWidth(350);

	MatchesFieldValidator equalsValidator = new MatchesFieldValidator();
	equalsValidator.setOtherField(NEWPASSWORDAGAIN);
	equalsValidator.setErrorMessage(I18N.message("passwordnotmatch"));

	LengthRangeValidator sizeValidator = new LengthRangeValidator();
	sizeValidator.setErrorMessage(
			I18N.message("errorfieldminlenght", Integer.toString(Session.get().getUser().getPasswordMinLenght())));
	sizeValidator.setMin(Session.get().getUser().getPasswordMinLenght());

	PasswordItem newPass = new PasswordItem();
	newPass.setName(NEWPASSWORD);
	newPass.setTitle(I18N.message(NEWPASSWORD));
	newPass.setRequired(true);
	newPass.setAutoComplete(AutoComplete.NONE);
	newPass.setValidators(equalsValidator, sizeValidator);

	PasswordItem newPassAgain = new PasswordItem();
	newPassAgain.setName(NEWPASSWORDAGAIN);
	newPassAgain.setTitle(I18N.message(NEWPASSWORDAGAIN));
	newPassAgain.setAutoComplete(AutoComplete.NONE);
	newPassAgain.setWrapTitle(false);
	newPassAgain.setRequired(true);

	final CheckboxItem notify = ItemFactory.newCheckbox(NOTIFY, "notifycredentials");
	notify.setValue(false);

	final ButtonItem apply = new ButtonItem();
	apply.setTitle(I18N.message("apply"));
	apply.setAutoFit(true);
	apply.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			vm.validate();
			if (!vm.hasErrors()) {
				apply.setDisabled(true);
				SecurityService.Instance.get().changePassword(Session.get().getUser().getId(), userId, null,
						vm.getValueAsString(NEWPASSWORD), notify.getValueAsBoolean(), new AsyncCallback<Integer>() {

							@Override
							public void onFailure(Throwable caught) {
								SC.warn(caught.getMessage());
								apply.setDisabled(false);
							}

							@Override
							public void onSuccess(Integer ret) {
								apply.setDisabled(false);
								if (ret.intValue() > 0) {
									// Alert the user and maintain the popup
									// opened
									if (ret == 1)
										Log.warn(I18N.message("wrongpassword"), null);
									else if (ret == 2)
										Log.warn(I18N.message("passwdnotnotified"), null);
									else
										Log.warn(I18N.message("genericerror"), null);
								}
								SetPassword.this.destroy();
							}
						});
			}
		}
	});

	form.setFields(newPass, newPassAgain, notify, apply);

	addItem(form);
}
 
Example #7
Source File: ChangePassword.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ChangePassword() {
	super();

	GUIUser user = Session.get().getUser();

	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("changepassword"));
	setWidth(300);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setAutoSize(true);

	final ValuesManager vm = new ValuesManager();
	final DynamicForm form = new DynamicForm();
	form.setValuesManager(vm);
	form.setWidth(350);
	form.setMargin(5);

	PasswordItem password = new PasswordItem();
	password.setName(PASSWORD);
	password.setTitle(I18N.message(PASSWORD));
	password.setRequired(true);

	MatchesFieldValidator equalsValidator = new MatchesFieldValidator();
	equalsValidator.setOtherField(NEWPASSWORDAGAIN);
	equalsValidator.setErrorMessage(I18N.message("passwordnotmatch"));

	LengthRangeValidator sizeValidator = new LengthRangeValidator();
	sizeValidator
			.setErrorMessage(I18N.message("errorfieldminlenght", Integer.toString(user.getPasswordMinLenght())));
	sizeValidator.setMin(user.getPasswordMinLenght());

	PasswordItem newPass = new PasswordItem();
	newPass.setName(NEWPASSWORD);
	newPass.setTitle(I18N.message(NEWPASSWORD));
	newPass.setRequired(true);
	newPass.setValidators(equalsValidator, sizeValidator);

	PasswordItem newPassAgain = new PasswordItem();
	newPassAgain.setName(NEWPASSWORDAGAIN);
	newPassAgain.setTitle(I18N.message(NEWPASSWORDAGAIN));
	newPassAgain.setWrapTitle(false);
	newPassAgain.setRequired(true);

	final ButtonItem apply = new ButtonItem();
	apply.setTitle(I18N.message("apply"));
	apply.setAutoFit(true);
	apply.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			vm.validate();
			if (!vm.hasErrors()) {
				if (vm.getValueAsString(PASSWORD).equals(vm.getValueAsString(NEWPASSWORD))) {
					Map<String, String> errors = new HashMap<String, String>();
					errors.put(NEWPASSWORD, I18N.message("useanotherpassword"));
					vm.setErrors(errors, true);
					return;
				}

				apply.setDisabled(true);

				SecurityService.Instance.get().changePassword(user.getId(), user.getId(),
						vm.getValueAsString(PASSWORD), vm.getValueAsString(NEWPASSWORD), false,
						new AsyncCallback<Integer>() {

							@Override
							public void onFailure(Throwable caught) {
								apply.setDisabled(false);
								SC.warn(caught.getMessage());
							}

							@Override
							public void onSuccess(Integer ret) {
								apply.setDisabled(false);
								if (ret.intValue() > 0) {
									// Alert the user and maintain the popup
									// opened
									if (ret == 1)
										SC.warn(I18N.message("wrongpassword"));
									else if (ret == 2)
										SC.warn(I18N.message("passwdnotnotified"));
									else
										SC.warn(I18N.message("genericerror"));
								} else {
									SC.say(I18N.message("yourpasswordhaschanged"));
									Log.info(I18N.message("event.user.passwordchanged"), null);
								}

								// Close the popup
								ChangePassword.this.destroy();
							}
						});
			}
		}
	});

	form.setFields(password, newPass, newPassAgain, apply);

	addItem(form);
}
 
Example #8
Source File: SetAdminPassword.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public SetAdminPassword(final String tenantName) {
	super();

	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("changepassword"));
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setAutoSize(true);

	final ValuesManager vm = new ValuesManager();
	final DynamicForm form = new DynamicForm();
	form.setValuesManager(vm);

	MatchesFieldValidator equalsValidator = new MatchesFieldValidator();
	equalsValidator.setOtherField(NEWPASSWORDAGAIN);
	equalsValidator.setErrorMessage(I18N.message("passwordnotmatch"));

	LengthRangeValidator sizeValidator = new LengthRangeValidator();
	sizeValidator.setErrorMessage(I18N.message("errorfieldminlenght",
			Integer.toString(Session.get().getUser().getPasswordMinLenght())));
	sizeValidator.setMin(Session.get().getUser().getPasswordMinLenght());

	PasswordItem newPass = new PasswordItem();
	newPass.setName(NEWPASSWORD);
	newPass.setTitle(I18N.message(NEWPASSWORD));
	newPass.setRequired(true);
	newPass.setValidators(equalsValidator, sizeValidator);

	PasswordItem newPassAgain = new PasswordItem();
	newPassAgain.setName(NEWPASSWORDAGAIN);
	newPassAgain.setTitle(I18N.message(NEWPASSWORDAGAIN));
	newPassAgain.setWrapTitle(false);
	newPassAgain.setRequired(true);

	final ButtonItem apply = new ButtonItem();
	apply.setTitle(I18N.message("apply"));
	apply.setAutoFit(true);
	apply.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			vm.validate();
			if (!vm.hasErrors()) {
				apply.setDisabled(true);
				TenantService.Instance.get().changeAdminPassword(vm.getValueAsString(NEWPASSWORD).trim(),
						tenantName, new AsyncCallback<Void>() {

							@Override
							public void onFailure(Throwable caught) {
								SC.warn(caught.getMessage());
								apply.setDisabled(false);
							}

							@Override
							public void onSuccess(Void arg) {
								apply.setDisabled(false);
								SetAdminPassword.this.destroy();
								Log.info(I18N.message("event.user.passwordchanged"), null);
							}
						});
			}
		}
	});

	form.setFields(newPass, newPassAgain, apply);
	addItem(form);
}
 
Example #9
Source File: LoginLayout.java    From SensorWebClient with GNU General Public License v2.0 4 votes vote down vote up
private PasswordItem getPasswordField() {
    return (PasswordItem) form.getField(PASSWORD_FIELD);
}