Search in sources :

Example 11 with TextField

use of com.vaadin.ui.TextField in project Activiti by Activiti.

the class SelectUsersPopupWindow method initSearchField.

protected void initSearchField() {
    HorizontalLayout searchLayout = new HorizontalLayout();
    searchLayout.setSpacing(true);
    addComponent(searchLayout);
    // textfield
    searchField = new TextField();
    searchField.setInputPrompt(i18nManager.getMessage(Messages.PEOPLE_SEARCH));
    searchField.setWidth(180, UNITS_PIXELS);
    searchField.focus();
    searchField.setTextChangeEventMode(TextChangeEventMode.EAGER);
    searchLayout.addComponent(searchField);
    // Logic to change table according to input
    searchField.addListener(new TextChangeListener() {

        public void textChange(TextChangeEvent event) {
            searchPeople(event.getText());
        }
    });
    initSelectMyselfButton(searchLayout);
}
Also used : TextChangeEvent(com.vaadin.event.FieldEvents.TextChangeEvent) TextField(com.vaadin.ui.TextField) TextChangeListener(com.vaadin.event.FieldEvents.TextChangeListener) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 12 with TextField

use of com.vaadin.ui.TextField in project Activiti by Activiti.

the class GroupDetailPanel method initGroupProperties.

protected void initGroupProperties() {
    detailsGrid = new GridLayout(2, 3);
    detailsGrid.setSpacing(true);
    detailLayout.setMargin(true, true, true, false);
    detailLayout.addComponent(detailsGrid);
    // id
    Label idLabel = new Label(i18nManager.getMessage(Messages.GROUP_ID) + ": ");
    idLabel.addStyleName(ExplorerLayout.STYLE_LABEL_BOLD);
    detailsGrid.addComponent(idLabel);
    Label idValueLabel = new Label(group.getId());
    detailsGrid.addComponent(idValueLabel);
    // name
    Label nameLabel = new Label(i18nManager.getMessage(Messages.GROUP_NAME) + ": ");
    nameLabel.addStyleName(ExplorerLayout.STYLE_LABEL_BOLD);
    detailsGrid.addComponent(nameLabel);
    if (!editingDetails) {
        Label nameValueLabel = new Label(group.getName());
        detailsGrid.addComponent(nameValueLabel);
    } else {
        nameTextField = new TextField(null, group.getName());
        detailsGrid.addComponent(nameTextField);
    }
    // Type
    Label typeLabel = new Label(i18nManager.getMessage(Messages.GROUP_TYPE) + ": ");
    typeLabel.addStyleName(ExplorerLayout.STYLE_LABEL_BOLD);
    detailsGrid.addComponent(typeLabel);
    if (!editingDetails) {
        Label typeValueLabel = new Label(group.getType());
        detailsGrid.addComponent(typeValueLabel);
    } else {
        typeCombobox = new ComboBox(null, Arrays.asList("assignment", "security-role"));
        typeCombobox.setNullSelectionAllowed(false);
        typeCombobox.setInvalidAllowed(false);
        typeCombobox.select(group.getType());
        detailsGrid.addComponent(typeCombobox);
    }
}
Also used : GridLayout(com.vaadin.ui.GridLayout) ComboBox(com.vaadin.ui.ComboBox) Label(com.vaadin.ui.Label) TextField(com.vaadin.ui.TextField)

Example 13 with TextField

use of com.vaadin.ui.TextField in project Activiti by Activiti.

the class NewUserPopupWindow method initInputFields.

protected void initInputFields() {
    // Input fields
    form.addField("id", new TextField(i18nManager.getMessage(Messages.USER_ID)));
    // Set id field to required
    form.getField("id").setRequired(true);
    form.getField("id").setRequiredError(i18nManager.getMessage(Messages.USER_ID_REQUIRED));
    form.getField("id").focus();
    // Set id field to be unique
    form.getField("id").addValidator(new Validator() {

        public void validate(Object value) throws InvalidValueException {
            if (!isValid(value)) {
                throw new InvalidValueException(i18nManager.getMessage(Messages.USER_ID_UNIQUE));
            }
        }

        public boolean isValid(Object value) {
            if (value != null) {
                return identityService.createUserQuery().userId(value.toString()).singleResult() == null;
            }
            return false;
        }
    });
    // Password is required
    form.addField("password", new PasswordField(i18nManager.getMessage(Messages.USER_PASSWORD)));
    form.getField("password").setRequired(true);
    form.getField("password").setRequiredError(i18nManager.getMessage(Messages.USER_PASSWORD_REQUIRED));
    // Password must be at least 5 characters
    StringLengthValidator passwordLengthValidator = new StringLengthValidator(i18nManager.getMessage(Messages.USER_PASSWORD_MIN_LENGTH, 5), 5, -1, false);
    form.getField("password").addValidator(passwordLengthValidator);
    form.addField("firstName", new TextField(i18nManager.getMessage(Messages.USER_FIRSTNAME)));
    form.addField("lastName", new TextField(i18nManager.getMessage(Messages.USER_LASTNAME)));
    form.addField("email", new TextField(i18nManager.getMessage(Messages.USER_EMAIL)));
}
Also used : InvalidValueException(com.vaadin.data.Validator.InvalidValueException) StringLengthValidator(com.vaadin.data.validator.StringLengthValidator) TextField(com.vaadin.ui.TextField) PasswordField(com.vaadin.ui.PasswordField) StringLengthValidator(com.vaadin.data.validator.StringLengthValidator) Validator(com.vaadin.data.Validator)

Example 14 with TextField

use of com.vaadin.ui.TextField in project Activiti by Activiti.

the class UserDetailPanel method loadUserDetails.

protected void loadUserDetails() {
    // Grid of details
    GridLayout detailGrid = new GridLayout();
    detailGrid.setColumns(2);
    detailGrid.setSpacing(true);
    detailGrid.setMargin(true, true, false, true);
    userDetailsLayout.addComponent(detailGrid);
    // Details
    // details are non-editable
    addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_ID), new Label(user.getId()));
    if (!editingDetails) {
        addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_FIRSTNAME), new Label(user.getFirstName()));
        addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_LASTNAME), new Label(user.getLastName()));
        addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_EMAIL), new Label(user.getEmail()));
    } else {
        firstNameField = new TextField(null, user.getFirstName() != null ? user.getFirstName() : "");
        addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_FIRSTNAME), firstNameField);
        firstNameField.focus();
        lastNameField = new TextField(null, user.getLastName() != null ? user.getLastName() : "");
        addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_LASTNAME), lastNameField);
        emailField = new TextField(null, user.getEmail() != null ? user.getEmail() : "");
        addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_EMAIL), emailField);
        passwordField = new PasswordField();
        Label cautionLabel = new Label(i18nManager.getMessage(Messages.USER_RESET_PASSWORD));
        cautionLabel.addStyleName(Reindeer.LABEL_SMALL);
        HorizontalLayout passwordLayout = new HorizontalLayout();
        passwordLayout.setSpacing(true);
        passwordLayout.addComponent(passwordField);
        passwordLayout.addComponent(cautionLabel);
        passwordLayout.setComponentAlignment(cautionLabel, Alignment.MIDDLE_LEFT);
        addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_PASSWORD), passwordLayout);
    }
}
Also used : GridLayout(com.vaadin.ui.GridLayout) Label(com.vaadin.ui.Label) TextField(com.vaadin.ui.TextField) PasswordField(com.vaadin.ui.PasswordField) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 15 with TextField

use of com.vaadin.ui.TextField in project opennms by OpenNMS.

the class NameEditForm method initFields.

private void initFields() {
    nonEditableField = new TextField();
    nonEditableField.setWidth(400, Unit.PIXELS);
    nonEditableField.setReadOnly(true);
    nonEditableField.setEnabled(false);
    editableField = new TextField();
    editableField.setWidth(400, Unit.PIXELS);
    editableField.setRequired(true);
    editableField.setRequiredError("You must provide a value.");
    editableField.setValidationVisible(false);
    editableField.setBuffered(false);
    editableField.setImmediate(true);
    editableField.addValidator(nameValidator);
    editableField.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (!blockListenerOrValidators) {
                controller.validateCurrentSelection();
            }
        }
    });
    editableField.setTextChangeTimeout(200);
    editableField.addTextChangeListener(new FieldEvents.TextChangeListener() {

        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            editableField.setComponentError(null);
            editableField.setValue(event.getText());
            editableField.validate();
        }
    });
    selectedField = new CheckBox();
    selectedField.setCaption("selected");
    selectedField.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            updateEnabledState();
            if (!selectedField.getValue()) {
                editableField.discard();
            }
            if (!blockListenerOrValidators) {
                try {
                    blockListenerOrValidators = true;
                    controller.fireSelectionValueChanged(getData(), getItemId(), selectedField.getValue());
                } finally {
                    blockListenerOrValidators = false;
                }
            }
        }
    });
    contentLayout.addComponent(selectedField);
    contentLayout.addComponent(editableField);
    contentLayout.addComponent(nonEditableField);
}
Also used : FieldEvents(com.vaadin.event.FieldEvents) CheckBox(com.vaadin.ui.CheckBox) TextField(com.vaadin.ui.TextField) Property(com.vaadin.data.Property)

Aggregations

TextField (com.vaadin.ui.TextField)79 Test (org.junit.Test)22 Button (com.vaadin.ui.Button)15 Label (com.vaadin.ui.Label)15 HorizontalLayout (com.vaadin.ui.HorizontalLayout)12 VerticalLayout (com.vaadin.ui.VerticalLayout)10 ClickListener (com.vaadin.ui.Button.ClickListener)7 ComboBox (com.vaadin.ui.ComboBox)7 GridLayout (com.vaadin.ui.GridLayout)7 SplitTextField (au.com.vaadinutils.crud.splitFields.SplitTextField)6 InvalidValueException (com.vaadin.data.Validator.InvalidValueException)6 ClickEvent (com.vaadin.ui.Button.ClickEvent)6 PasswordField (com.vaadin.ui.PasswordField)6 CheckBox (com.vaadin.ui.CheckBox)4 Form (com.vaadin.ui.Form)4 TextArea (com.vaadin.ui.TextArea)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4 Property (com.vaadin.data.Property)3 Validator (com.vaadin.data.Validator)3