Example usage for com.jgoodies.binding.adapter BasicComponentFactory createPasswordField

List of usage examples for com.jgoodies.binding.adapter BasicComponentFactory createPasswordField

Introduction

In this page you can find the example usage for com.jgoodies.binding.adapter BasicComponentFactory createPasswordField.

Prototype

public static JPasswordField createPasswordField(ValueModel valueModel, boolean commitOnFocusLost) 

Source Link

Document

Creates and returns a JPasswordField with the content bound to the given ValueModel.

Usage

From source file:org.openthinclient.console.nodes.views.RealmEditor.java

License:Open Source License

public RealmEditor(final Realm realm) {
    // final PresentationModel realmModel = new PresentationModel(new
    // ValueHolder(
    // realm, true));

    final PresentationModel roPrincipalModel = new PresentationModel(
            new ValueHolder(realm.getReadOnlyPrincipal(), true));

    final DetailViewFormBuilder dfb = new DetailViewFormBuilder(new FormLayout("r:p, 3dlu, f:p:g"), //$NON-NLS-1$
            Messages.getBundle(), this);

    dfb.getPanel().setName(Messages.getString("Settings_title")); //$NON-NLS-1$

    dfb.appendI15d("User.changePassword", BasicComponentFactory //$NON-NLS-1$
            .createPasswordField(roPrincipalModel.getModel("newPassword"), //$NON-NLS-1$
                    false));// www . ja v a 2 s .c  om
    dfb.nextLine();

    dfb.appendI15d("User.verifyPassword", BasicComponentFactory //$NON-NLS-1$
            .createPasswordField(roPrincipalModel.getModel("verifyPassword"), //$NON-NLS-1$
                    false));
    dfb.nextLine();

    // HACK: forward property changes from the roPrincipal user to the realm,
    // in order to make the validation trigger.
    realm.getReadOnlyPrincipal().addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            realm.fakePropertyChange();
        }
    });
    putClientProperty(DirObjectEditor.KEY_VALIDATOR,
            new UserValidator(roPrincipalModel, realm.getReadOnlyPrincipal()));
}

From source file:org.openthinclient.console.nodes.views.UserEditor.java

License:Open Source License

public UserEditor(final User user, Realm realm) {

    if (!LDAPDirectory.isMutable(User.class)) {

        final PresentationModel model = new PresentationModel(new ValueHolder(user, true));

        final DetailViewFormBuilder dfb = new DetailViewFormBuilder(new FormLayout("r:p, 3dlu, f:p:g"),
                Messages.getBundle(), this);

        dfb.getPanel().setName(Messages.getString("Settings_title"));

        dfb.appendI15d("User.givenName", BasicComponentFactory.createLabel(model.getModel("givenName")));
        dfb.nextLine();/*from w w  w  .  ja v a  2s .c  o m*/

        dfb.appendI15d("User.surname", BasicComponentFactory.createLabel(model.getModel("sn")));
        dfb.nextLine();

        // dfb.appendI15d("User.stringLocation",
        // BasicComponentFactory.createLabel(
        // model.getModel("stringLocation")));
        // dfb.nextLine();

        dfb.appendUnrelatedComponentsGapRow();
        dfb.nextLine();

        dfb.appendI15d("User.changePassword", BasicComponentFactory.createLabel(model.getModel("newPassword")));
        dfb.nextLine();

        dfb.appendI15d("User.verifyPassword",
                BasicComponentFactory.createLabel(model.getModel("verifyPassword")));
        dfb.nextLine();

        putClientProperty(DirObjectEditor.KEY_VALIDATOR, new UserValidator(model, user));
    } else {
        final PresentationModel model = new PresentationModel(new ValueHolder(user, true));
        final DetailViewFormBuilder dfb = new DetailViewFormBuilder(new FormLayout("r:p, 3dlu, f:p:g"), //$NON-NLS-1$
                Messages.getBundle(), this);

        dfb.getPanel().setName(Messages.getString("Settings_title")); //$NON-NLS-1$

        dfb.appendI15d("User.givenName", BasicComponentFactory.createTextField( //$NON-NLS-1$
                model.getModel("givenName"), //$NON-NLS-1$
                true));
        dfb.nextLine();

        dfb.appendI15d("User.surname", BasicComponentFactory.createTextField(model //$NON-NLS-1$
                .getModel("sn"), //$NON-NLS-1$
                false));
        dfb.nextLine();

        // Set<Location> locations;
        // try {
        // locations =
        // realm.getDirectory(user.getClass().getName()).list(Location.class);
        // } catch (DirectoryException e) {
        // ErrorManager.getDefault().notify(e);
        // locations = new HashSet<Location>();
        // }

        // dfb.appendI15d("User.location", //$NON-NLS-1$
        // BasicComponentFactory.createComboBox(new SelectionInList(new ArrayList(
        // locations), model.getModel("location")))); //$NON-NLS-1$
        // dfb.nextLine();

        dfb.appendUnrelatedComponentsGapRow();
        dfb.nextLine();

        dfb.appendI15d("User.changePassword", BasicComponentFactory //$NON-NLS-1$
                .createPasswordField(model.getModel("newPassword"), //$NON-NLS-1$
                        false));
        dfb.nextLine();

        dfb.appendI15d("User.verifyPassword", BasicComponentFactory //$NON-NLS-1$
                .createPasswordField(model.getModel("verifyPassword"), //$NON-NLS-1$
                        false));
        dfb.nextLine();

        putClientProperty(DirObjectEditor.KEY_VALIDATOR, new UserValidator(model, user));
    }

}