Example usage for com.vaadin.ui TextField TextField

List of usage examples for com.vaadin.ui TextField TextField

Introduction

In this page you can find the example usage for com.vaadin.ui TextField TextField.

Prototype

public TextField() 

Source Link

Document

Constructs an empty TextField with no caption.

Usage

From source file:de.decidr.ui.view.CreateTenantComponent.java

License:Apache License

/**
 * Initializes the components for the {@link CreateTenantComponent}.
 *//* w w w  . j  av  a 2 s.  c o  m*/
private void init() {
    verticalLayout = new VerticalLayout();
    verticalLayout.setSizeFull();
    verticalLayout.setSpacing(true);

    createTenantForm = new Form();
    createTenantForm.setWriteThrough(true);
    createTenantForm.setImmediate(true);

    descriptionLabel = new Label("Create a new tenant by entering a name and description:<br/>"
            + "Further options can be set later via Tenant Settings.", Label.CONTENT_XHTML);

    tenantName = new TextField();
    tenantName.setCaption("Tenant name:");

    tenantDescription = new TextField();
    tenantDescription.setCaption("Tenant description");
    tenantDescription.setRows(5);

    createTenantForm.addField("tenantName", tenantName);
    createTenantForm.getField("tenantName").setRequired(true);
    createTenantForm.getField("tenantName").addValidator(new RegexpValidator("\\w{2,50}",
            "The tenant name must have at least " + "2 and at most 50 characters."));
    createTenantForm.addField("tenantDescription", tenantDescription);

    createTenant = new Button("Create Tenant", new CreateTenantAction(createTenantForm));

    verticalLayout.addComponent(descriptionLabel);
    verticalLayout.addComponent(createTenantForm);
    verticalLayout.addComponent(createTenant);

    this.setCompositionRoot(verticalLayout);
}

From source file:de.decidr.ui.view.InviteUserToTenantComponent.java

License:Apache License

/**
 * Initializes the components for the {@link InviteUserToTenantComponent}.
 *///  ww  w  .  j  a v a  2  s .co  m
private void init() {
    userCounter = 1;
    verticalLayout = new VerticalLayout();
    verticalLayout.setSpacing(true);
    verticalLayout.setSizeFull();

    horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSizeFull();
    horizontalLayout.setSpacing(true);

    inviteForm = new Form();
    inviteForm.setWriteThrough(true);

    descriptionLabel = new Label("Invite new users by pressing &quotAdd User&quot;"
            + " and entering either their username or email address.", Label.CONTENT_XHTML);

    inviteUser = new TextField();
    inviteUser.setCaption("Username/email address:");

    inviteForm.addField("user" + userCounter.toString(), inviteUser);
    inviteForm.getField("user" + userCounter.toString()).setRequired(true);

    addField = new Button("Add User", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(Button.ClickEvent event) {
            addUser();
        }
    });

    appointUsers = new Button("Invite Users to Tenant", new InviteUserToTenantAction(inviteForm));

    horizontalLayout.addComponent(addField);
    horizontalLayout.setComponentAlignment(addField, "left middle");
    horizontalLayout.addComponent(appointUsers);
    horizontalLayout.setComponentAlignment(appointUsers, "right middle");

    verticalLayout.addComponent(descriptionLabel);
    verticalLayout.addComponent(horizontalLayout);
    verticalLayout.addComponent(inviteForm);

    this.setCompositionRoot(verticalLayout);
}

From source file:de.decidr.ui.view.LoginComponent.java

License:Apache License

/**
 * This method initializes the components of the {@link LoginComponent}.
 *//*from  ww  w .  java 2  s.c o m*/
private void init(InvitationDialogComponent invD) {
    verticalLayout = new VerticalLayout();

    invisiblePanel = new Panel();
    invisiblePanel.addActionHandler(this);

    loginLabel = new Label("<h3>Login:</h3>");
    loginLabel.setContentMode(Label.CONTENT_XHTML);

    usernameTextField = new TextField();
    usernameTextField.setCaption("Username");
    usernameTextField.setImmediate(true);
    passwordTextField = new TextField();
    passwordTextField.setCaption("Password");
    passwordTextField.setSecret(true);

    if (invD == null) {
        loginListener = new LoginAction();
        loginButton = new Button("Login", loginListener);
        usernameTextField.focus();
    } else {
        loginListener = new LoginWithInvitationAction(invD);
        loginButton = new Button("Login", loginListener);
        loginButton.focus();
    }

    forgotPasswordButton = new Button("Forgot your password?", new ShowResetPasswordAction());
    forgotPasswordButton.setStyleName(Button.STYLE_LINK);
    registerButton = new Button("Register", new ShowRegistrationAction());
    registerButton.setStyleName(Button.STYLE_LINK);

    setCompositionRoot(verticalLayout);

    ((VerticalLayout) invisiblePanel.getContent()).setSpacing(false);
    ((VerticalLayout) invisiblePanel.getContent()).setMargin(false);
    invisiblePanel.addComponent(usernameTextField);
    invisiblePanel.addComponent(passwordTextField);

    verticalLayout.setSpacing(true);
    verticalLayout.setMargin(true);
    verticalLayout.addComponent(loginLabel);
    verticalLayout.addComponent(invisiblePanel);
    verticalLayout.addComponent(loginButton);
    verticalLayout.addComponent(forgotPasswordButton);
    verticalLayout.addComponent(registerButton);
}

From source file:de.decidr.ui.view.RegisterTenantComponent.java

License:Apache License

/**
 * This method initializes the components of the
 * {@link RegisterTenantComponent}./*from  ww w .  j  a va2  s.c  om*/
 */
private void init() {
    registrationForm = new Form();
    registrationForm.setWriteThrough(true);
    registrationForm.setImmediate(true);

    descriptionLabel = new Label("Please fill out all fields to register as a new tenant:",
            Label.CONTENT_XHTML);

    tenantName = new TextField();
    tenantName.setCaption("Tenant Name:");
    tenantName.addValidator(
            new RegexpValidator("\\w{2,50}", "The tenant name must consist of 2 to 50 characters!"));
    userName = new TextField();
    userName.setCaption("User Name:");
    userName.addValidator(new RegexpValidator("\\w{3,20}", "The username must consist of 3 to 20 characters!"));
    password = new TextField();
    password.setCaption("Password:");
    password.setSecret(true);
    passwordConfirm = new TextField();
    passwordConfirm.setCaption("Confirm Password:");
    passwordConfirm.setSecret(true);
    email = new TextField();
    email.setCaption("Email:");
    email.addValidator(new EmailValidator("Please enter a valid email address."));
    firstName = new TextField();
    firstName.setCaption("First Name:");
    firstName.addValidator(new StringLengthValidator(
            "Please enter your first name. " + "It can consist of up to 50 characters.", 0, 50, false));
    lastName = new TextField();
    lastName.setCaption("Last Name:");
    lastName.addValidator(new StringLengthValidator(
            "Please enter your surname. " + "It can consist of up to 50 characters.", 0, 50, false));
    street = new TextField();
    street.setCaption("Street:");
    postalCode = new TextField();
    postalCode.setCaption("PostalCode:");
    // TODO: see previous comment about postal codes
    postalCode.addValidator(new RegexpValidator("[1-9][0-9]{4,15}", "Please enter a valid postal code"));
    city = new TextField();
    city.setCaption("City");

    completeRegistration = new Button("Finish Registration", new RegisterTenantAction());

    registrationForm.addField("tenantName", tenantName);
    registrationForm.getField("tenantName").setRequired(true);
    registrationForm.addField("userName", userName);
    registrationForm.getField("userName").setRequired(true);
    registrationForm.addField("password", password);
    registrationForm.getField("password").setRequired(true);
    registrationForm.addField("passwordConfirm", passwordConfirm);
    registrationForm.getField("passwordConfirm").setRequired(true);
    registrationForm.addField("email", email);
    registrationForm.getField("email").setRequired(true);
    registrationForm.addField("firstName", firstName);
    registrationForm.addField("lastName", lastName);
    registrationForm.addField("street", street);
    registrationForm.addField("postalCode", postalCode);
    registrationForm.addField("city", city);
    registrationForm.setSizeFull();

    verticalLayout = new VerticalLayout();
    verticalLayout.setSpacing(true);

    verticalLayout.addComponent(descriptionLabel);
    verticalLayout.addComponent(registrationForm);
    verticalLayout.addComponent(completeRegistration);
    verticalLayout.setComponentAlignment(completeRegistration, "right bottom");

    this.setCompositionRoot(verticalLayout);
}

From source file:de.decidr.ui.view.RegisterUserComponent.java

License:Apache License

/**
 * This method initializes the components of the
 * {@link RegisterUserComponent}.//ww  w.ja v  a  2s  .  c o m
 */
private void init() {
    registrationForm = new Form();
    registrationForm.setWriteThrough(true);
    registrationForm.setImmediate(true);

    descriptionLabel = new Label("Please fill out all fields to register as a new user:", Label.CONTENT_XHTML);

    userName = new TextField();
    userName.setCaption("User Name:");
    userName.addValidator(new RegexpValidator("\\w{3,20}", "The username must consist of 3 to 20 characters."));
    password = new TextField();
    password.setCaption("Password:");
    password.setSecret(true);
    passwordConfirm = new TextField();
    passwordConfirm.setCaption("Confirm Password:");
    passwordConfirm.setSecret(true);
    email = new TextField();
    email.setCaption("E-Mail:");
    email.addValidator(new EmailValidator("Please enter a valid email address!"));
    firstName = new TextField();
    firstName.setCaption("First Name:");
    firstName.addValidator(new StringLengthValidator(
            "Please enter your first name. " + "It may consist of up to 50 characters.", 0, 50, false));
    lastName = new TextField();
    lastName.setCaption("Last Name:");
    lastName.addValidator(new StringLengthValidator(
            "Please enter your surname. " + "It may consist of up to 50 characters.", 0, 50, false));
    street = new TextField();
    street.setCaption("Street:");
    postalCode = new TextField();
    postalCode.setCaption("PostalCode:");
    // TODO: see previous comments about postal code
    postalCode.addValidator(new RegexpValidator("[1-9][0-9]{4,15}", "Please enter a valid postal code."));
    city = new TextField();
    city.setCaption("City");

    completeRegistration = new Button("Finish Registration");

    registrationForm.addField("userName", userName);
    registrationForm.getField("userName").setRequired(true);
    registrationForm.addField("password", password);
    registrationForm.getField("password").setRequired(true);
    registrationForm.addField("passwordConfirm", passwordConfirm);
    registrationForm.getField("passwordConfirm").setRequired(true);
    registrationForm.addField("email", email);
    registrationForm.getField("email").setRequired(true);
    registrationForm.addField("firstName", firstName);
    registrationForm.addField("lastName", lastName);
    registrationForm.addField("street", street);
    registrationForm.addField("postalCode", postalCode);
    registrationForm.addField("city", city);
    registrationForm.setSizeFull();

    verticalLayout = new VerticalLayout();
    verticalLayout.setSpacing(true);

    verticalLayout.addComponent(descriptionLabel);
    verticalLayout.addComponent(registrationForm);
    verticalLayout.addComponent(completeRegistration);
    verticalLayout.setComponentAlignment(completeRegistration, "right bottom");

    this.setCompositionRoot(verticalLayout);
}

From source file:de.decidr.ui.view.TenantSettingsComponent.java

License:Apache License

/**
 * This method changes the view from basic to advanced and makes the text
 * area for the manual CSS input visible.
 *///from w w w .ja  va  2 s.c om
public void changeToAdvanced() {
    String css;
    try {
        css = retrieveCurrentCss();
    } catch (TransactionException e) {
        DecidrUI.getCurrent().getMainWindow().addWindow(new TransactionErrorDialogComponent(e));
        return;
    }

    showBasicOptionsButton = new Button("Show basic options");
    showBasicOptionsButton.addListener(new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            changeToBasic();
        }
    });
    cssTextArea = new TextField();
    cssTextArea.setRows(20);
    cssTextArea.setColumns(30);
    cssTextArea.setValue(css);
    getSchemeHorizontalLayout().removeAllComponents();
    getSchemeHorizontalLayout().addComponent(cssTextArea);
    getSchemeHorizontalLayout().addComponent(showBasicOptionsButton);

    advancedMode = true;
}

From source file:de.decidr.ui.view.TenantSettingsComponent.java

License:Apache License

/**
 * This method initializes the components for the tenant settings component.
 *///  w ww .  j a v  a  2 s .c o  m
private void init() {
    verticalLayout = new VerticalLayout();
    browseHorizontalLayout = new HorizontalLayout();
    buttonHorizontalLayout = new HorizontalLayout();
    schemeHorizontalLayout = new HorizontalLayout();

    browsePanel = new Panel();
    schemePanel = new Panel();
    schemePanel.setCaption("Color Scheme");
    buttonPanel = new Panel();

    tenantSettingsLabel = new Label("Tenant Settings for " + tenant.getName());

    textArea = new TextField();
    textArea.setRows(10);
    textArea.setColumns(30);
    textArea.setCaption("Description");
    textArea.setValue(tenant.getDescription());

    logoUpload = new UploadComponent(tenant.getLogo().getId(), new UploadAction());

    saveButton = new Button("Save", new SaveTenantSettingsAction());
    restoreDefaultSettingsButton = new Button("Restore Default Settings",
            new RestoreDefaultTenantSettingsAction());

    logoEmbedded = new Embedded("",
            new FileResource(UIConventions.getLogoFile(tenant.getId()), DecidrUI.getCurrent()));
    logoEmbedded.setCaption("Logo");
    logoEmbedded.setImmediate(true);

    setCompositionRoot(verticalLayout);

    verticalLayout.setSpacing(true);
    verticalLayout.addComponent(tenantSettingsLabel);
    verticalLayout.addComponent(textArea);
    verticalLayout.addComponent(logoEmbedded);
    verticalLayout.addComponent(browsePanel);

    browsePanel.addComponent(browseHorizontalLayout);
    browseHorizontalLayout.setSpacing(true);
    browseHorizontalLayout.addComponent(logoUpload);

    verticalLayout.addComponent(schemePanel);

    schemePanel.addComponent(schemeHorizontalLayout);
    schemeHorizontalLayout.setSpacing(true);

    changeToBasic();

    verticalLayout.addComponent(buttonPanel);

    buttonPanel.addComponent(buttonHorizontalLayout);
    buttonHorizontalLayout.setSpacing(true);
    buttonHorizontalLayout.addComponent(saveButton);
    buttonHorizontalLayout.addComponent(restoreDefaultSettingsButton);
}

From source file:de.decidr.ui.view.windows.ChangeEmailWindow.java

License:Apache License

/**
 * Initializes the components for the {@link ChangeEmailWindow}.
 *///from ww  w  .jav a  2s . com
private void init() {
    emailForm = new Form();
    emailForm.setWriteThrough(false);

    verticalLayout = new VerticalLayout();
    verticalLayout.setSpacing(true);
    verticalLayout.setMargin(true);
    verticalLayout.setSizeUndefined();

    horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSpacing(true);
    horizontalLayout.setMargin(false);
    horizontalLayout.setSizeUndefined();

    infoLabel = new Label("To change your email address, enter your new email address and click"
            + " &quot;Change Email&quot;.<br/>" + "A confirmation email will be send to the new address.",
            Label.CONTENT_XHTML);
    infoLabel.setWidth(350, Sizeable.UNITS_PIXELS);

    newEmailText = new TextField();
    newEmailText.setCaption("New Email Address");
    newEmailText.setColumns(20);

    submitButton = new Button("Change Email", new ChangeEmailAction());
    cancelButton = new Button("Cancel", new HideDialogWindowAction());

    emailForm.setWidth(370, Sizeable.UNITS_PIXELS);
    // emailForm.setSizeUndefined();
    emailForm.addField("newEmail", newEmailText);
    emailForm.getField("newEmail").addValidator(new EmailValidator("Please enter a valid email adress"));

    verticalLayout.addComponent(infoLabel);
    verticalLayout.addComponent(emailForm);
    horizontalLayout.addComponent(submitButton);
    horizontalLayout.addComponent(cancelButton);
    verticalLayout.addComponent(horizontalLayout);

    horizontalLayout.setComponentAlignment(cancelButton, "right bottom");
    horizontalLayout.setComponentAlignment(submitButton, "right bottom");

    verticalLayout.setComponentAlignment(horizontalLayout, "right bottom");

    this.setModal(true);
    this.setResizable(false);
    this.setCaption("Change E-mail Address");
    this.setContent(verticalLayout);
}

From source file:de.decidr.ui.view.windows.ChangePasswordWindow.java

License:Apache License

/**
 * Initializes the components for the {@link ChangePasswordWindow}.
 *//*from w ww .j a v a 2s .c om*/
private void init() {
    passwordForm = new Form();
    passwordForm.setWriteThrough(false);

    verticalLayout = new VerticalLayout();
    verticalLayout.setSpacing(true);
    verticalLayout.setMargin(true);
    verticalLayout.setSizeUndefined();

    horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSpacing(true);
    horizontalLayout.setMargin(false);
    horizontalLayout.setSizeUndefined();

    newPasswordText = new TextField();
    newPasswordText.setCaption("New Password");
    newPasswordText.setSecret(true);
    newPasswordText.setColumns(21);

    newPasswordConfirmText = new TextField();
    newPasswordConfirmText.setCaption("Confirm New Password");
    newPasswordConfirmText.setSecret(true);
    newPasswordConfirmText.setColumns(21);

    oldPasswordText = new TextField();
    oldPasswordText.setCaption("Old Password");
    oldPasswordText.setSecret(true);
    oldPasswordText.setColumns(21);

    submitButton = new Button("Change Password", new ChangePasswordAction());
    cancelButton = new Button("Cancel", new HideDialogWindowAction());

    passwordForm.setWidth(400, Sizeable.UNITS_PIXELS);
    passwordForm.addField("oldPassword", oldPasswordText);
    passwordForm.addField("newPassword", newPasswordText);
    passwordForm.addField("newPasswordConfirm", newPasswordConfirmText);

    verticalLayout.addComponent(passwordForm);
    horizontalLayout.addComponent(submitButton);
    horizontalLayout.addComponent(cancelButton);
    verticalLayout.addComponent(horizontalLayout);

    horizontalLayout.setComponentAlignment(cancelButton, "right bottom");
    horizontalLayout.setComponentAlignment(submitButton, "right bottom");

    verticalLayout.setComponentAlignment(horizontalLayout, "right bottom");

    this.setModal(true);
    this.setResizable(false);
    this.setCaption("Change Password");
    this.setContent(verticalLayout);
}

From source file:de.decidr.ui.view.windows.ResetPasswordWindow.java

License:Apache License

/**
 * This method initializes the components of the reset password component.
 * //w w w.j  a v a 2 s.co  m
 */
private void init() {
    requestForm = new Form();
    requestForm.setWriteThrough(false);

    verticalLayout = new VerticalLayout();
    verticalLayout.setSpacing(true);
    verticalLayout.setMargin(true);
    verticalLayout.setSizeUndefined();

    horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSpacing(true);
    horizontalLayout.setMargin(false);
    horizontalLayout.setSizeUndefined();

    email = new TextField();
    email.setCaption("User Name or E-Mail:");
    email.setColumns(21);

    submitButton = new Button("Reset Password", new ResetPasswordAction());
    cancelButton = new Button("Cancel", new HideDialogWindowAction());

    requestForm.setWidth(400, Sizeable.UNITS_PIXELS);
    requestForm.addField("email", email);

    verticalLayout.addComponent(requestForm);
    horizontalLayout.addComponent(submitButton);
    horizontalLayout.addComponent(cancelButton);
    verticalLayout.addComponent(horizontalLayout);

    horizontalLayout.setComponentAlignment(cancelButton, "right bottom");
    horizontalLayout.setComponentAlignment(submitButton, "right bottom");

    verticalLayout.setComponentAlignment(horizontalLayout, "right bottom");

    this.setModal(true);
    this.setResizable(false);
    this.setCaption("Reset Password");
    this.setContent(verticalLayout);
}