Example usage for com.vaadin.ui ComboBox setTextInputAllowed

List of usage examples for com.vaadin.ui ComboBox setTextInputAllowed

Introduction

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

Prototype

public void setTextInputAllowed(boolean textInputAllowed) 

Source Link

Document

Sets whether it is possible to input text into the field or whether the field area of the component is just used to show what is selected.

Usage

From source file:management.limbr.ui.entity.EntityEditorViewImpl.java

License:Open Source License

private Field<?> getUIField(java.lang.reflect.Field field) {
    String label = messages.get(field.getName() + "FieldLabel");
    Password passwordAnnotation = field.getAnnotation(Password.class);
    if (passwordAnnotation != null) {
        return new PasswordField(label);
    } else if (field.getType().isEnum()) {
        ComboBox comboBox = new ComboBox(label);
        comboBox.setTextInputAllowed(false);
        comboBox.addItems(field.getType().getEnumConstants());
        return comboBox;
    }/*from   w w  w.j a  va2s  .  c  o  m*/
    return new TextField(label);
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.admin.AdminScreenProvider.java

License:Apache License

private Component getConfigurableTab() {
    VerticalLayout vl = new VerticalLayout();
    ComboBox options = new ComboBox();
    options.addItem(ISSUE_TYPE);//  w  ww . jav  a 2  s  .  co  m
    options.setItemCaption(ISSUE_TYPE, TRANSLATOR.translate(ISSUE_TYPE));
    options.addItem(ISSUE_RESOLUTION);
    options.setItemCaption(ISSUE_RESOLUTION, TRANSLATOR.translate(ISSUE_RESOLUTION));
    options.addItem(REQUIREMENT_TYPE);
    options.setItemCaption(REQUIREMENT_TYPE, TRANSLATOR.translate(REQUIREMENT_TYPE));
    options.setTextInputAllowed(false);
    options.addValueChangeListener((Property.ValueChangeEvent event) -> {
        Component nextComp = null;
        if (options.getValue() != null) {
            switch ((String) options.getValue()) {
            case ISSUE_TYPE:
                nextComp = displayIssueTypes();
                break;
            case ISSUE_RESOLUTION:
                nextComp = displayIssueResolutions();
                break;
            case REQUIREMENT_TYPE:
                nextComp = displayRequirementTypes();
                break;
            default:
                //Do nothing
            }
        }
        if (nextComp != null) {
            vl.removeAllComponents();
            vl.addComponent(options);
            vl.addComponent(nextComp);
        }
    });
    vl.addComponent(options);
    vl.setSizeFull();
    return vl;
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.StepComponent.java

License:Apache License

private void init() {
    FormLayout layout = new FormLayout();
    setContent(layout);//from  w  ww.  j  a  va  2 s  .  c  o m
    addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    BeanFieldGroup binder = new BeanFieldGroup(s.getClass());
    binder.setItemDataSource(s);
    Field<?> sequence = binder.buildAndBind(TRANSLATOR.translate("general.sequence"), "stepSequence");
    layout.addComponent(sequence);
    TextArea text = new TextArea(TRANSLATOR.translate("general.text"));
    text.setConverter(new ByteToStringConverter());
    binder.bind(text, "text");
    layout.addComponent(text);
    TextArea result = new TextArea(TRANSLATOR.translate("expected.result"));
    result.setConverter(new ByteToStringConverter());
    binder.bind(result, "expectedResult");
    layout.addComponent(result);
    Field notes = binder.buildAndBind(TRANSLATOR.translate("general.notes"), "notes", TextArea.class);
    notes.setSizeFull();
    layout.addComponent(notes);
    if (!s.getRequirementList().isEmpty() && !edit) {
        layout.addComponent(((ValidationManagerUI) UI.getCurrent()).getDisplayRequirementList(
                TRANSLATOR.translate("related.requirements"), s.getRequirementList()));
    } else {
        AbstractSelect requirements = ((ValidationManagerUI) UI.getCurrent())
                .getRequirementSelectionComponent();
        //Select the exisitng ones.
        if (s.getRequirementList() != null) {
            s.getRequirementList().forEach((r) -> {
                requirements.select(r);
            });
        }
        requirements.addValueChangeListener(event -> {
            Set<Requirement> selected = (Set<Requirement>) event.getProperty().getValue();
            s.getRequirementList().clear();
            selected.forEach(r -> {
                s.getRequirementList().add(r);
            });
        });
        layout.addComponent(requirements);
    }
    DataEntryComponent fields = new DataEntryComponent(edit);
    binder.bind(fields, "dataEntryList");
    layout.addComponent(fields);
    binder.setReadOnly(edit);
    Button cancel = new Button(TRANSLATOR.translate("general.cancel"));
    cancel.addClickListener((Button.ClickEvent event) -> {
        binder.discard();
        if (s.getStepPK() == null) {
            ((ValidationManagerUI) UI.getCurrent())
                    .displayObject(((ValidationManagerUI) UI.getCurrent()).getTree().getValue());
        } else {
            ((ValidationManagerUI) UI.getCurrent()).displayObject(s, false);
        }
    });
    if (edit) {
        Button add = new Button(TRANSLATOR.translate("add.field"));
        add.addClickListener(listener -> {
            VMWindow w = new VMWindow();
            FormLayout fl = new FormLayout();
            ComboBox newType = new ComboBox(TRANSLATOR.translate("general.type"));
            newType.setNewItemsAllowed(false);
            newType.setTextInputAllowed(false);
            newType.addValidator(new NullValidator(TRANSLATOR.translate("message.required.field.missing")
                    .replaceAll("%f", TRANSLATOR.translate("general.type")), false));
            BeanItemContainer<DataEntryType> container = new BeanItemContainer<>(DataEntryType.class,
                    new DataEntryTypeJpaController(DataBaseManager.getEntityManagerFactory())
                            .findDataEntryTypeEntities());
            newType.setContainerDataSource(container);
            newType.getItemIds().forEach(id -> {
                DataEntryType temp = ((DataEntryType) id);
                newType.setItemCaption(id, TRANSLATOR.translate(temp.getTypeName()));
            });
            fl.addComponent(newType);
            TextField tf = new TextField(TRANSLATOR.translate("general.name"));
            fl.addComponent(tf);
            HorizontalLayout hl = new HorizontalLayout();
            Button a = new Button(TRANSLATOR.translate("general.add"));
            a.addClickListener(l -> {
                DataEntryType det = (DataEntryType) newType.getValue();
                DataEntry de = null;
                switch (det.getId()) {
                case 1:
                    de = DataEntryServer.getStringField(tf.getValue());
                    break;
                case 2:
                    de = DataEntryServer.getNumericField(tf.getValue(), null, null);
                    break;
                case 3:
                    de = DataEntryServer.getBooleanField(tf.getValue());
                    break;
                case 4:
                    de = DataEntryServer.getAttachmentField(tf.getValue());
                    break;
                }
                if (de != null) {
                    s.getDataEntryList().add(de);
                    ((ValidationManagerUI) UI.getCurrent()).displayObject(s);
                }
                UI.getCurrent().removeWindow(w);
            });
            hl.addComponent(a);
            Button c = new Button(TRANSLATOR.translate("general.cancel"));
            c.addClickListener(l -> {
                UI.getCurrent().removeWindow(w);
            });
            hl.addComponent(c);
            fl.addComponent(hl);
            w.setContent(fl);
            UI.getCurrent().addWindow(w);
        });
        if (s.getStepPK() == null) {
            //Creating a new one
            Button save = new Button(TRANSLATOR.translate("general.save"));
            save.addClickListener(listener -> {
                try {
                    s.setExpectedResult(((TextArea) result).getValue().getBytes(encoding));
                    s.setNotes(notes.getValue() == null ? "" : notes.getValue().toString());
                    s.setStepSequence(Integer.parseInt(sequence.getValue().toString()));
                    s.setTestCase((TestCase) ((ValidationManagerUI) UI.getCurrent()).getTree().getValue());
                    s.setText(text.getValue().getBytes(encoding));
                    if (s.getRequirementList() == null) {
                        s.setRequirementList(new ArrayList<>());
                    }
                    new StepJpaController(DataBaseManager.getEntityManagerFactory()).create(s);
                    setVisible(false);
                    //Recreate the tree to show the addition
                    ((ValidationManagerUI) UI.getCurrent()).updateProjectList();
                    ((ValidationManagerUI) UI.getCurrent()).updateScreen();
                    ((ValidationManagerUI) UI.getCurrent()).displayObject(s);
                    ((ValidationManagerUI) UI.getCurrent()).buildProjectTree(s);
                } catch (Exception ex) {
                    LOG.log(Level.SEVERE, null, ex);
                    Notification.show(TRANSLATOR.translate("general.error.record.creation"),
                            ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                }
            });
            HorizontalLayout hl = new HorizontalLayout();
            hl.addComponent(save);
            hl.addComponent(add);
            hl.addComponent(cancel);
            layout.addComponent(hl);
        } else {
            //Editing existing one
            Button update = new Button(TRANSLATOR.translate("general.update"));
            update.addClickListener((Button.ClickEvent event) -> {
                try {
                    s.setExpectedResult(((TextArea) result).getValue().getBytes(encoding));
                    s.setNotes(notes.getValue().toString());
                    s.setStepSequence(Integer.parseInt(sequence.getValue().toString()));
                    s.setText(text.getValue().getBytes(encoding));
                    if (s.getRequirementList() == null) {
                        s.setRequirementList(new ArrayList<>());
                    }
                    ((ValidationManagerUI) UI.getCurrent()).handleVersioning(s, () -> {
                        try {
                            new StepJpaController(DataBaseManager.getEntityManagerFactory()).edit(s);
                        } catch (NonexistentEntityException ex) {
                            LOG.log(Level.SEVERE, null, ex);
                            Notification.show(TRANSLATOR.translate("general.error.record.update"),
                                    ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                        } catch (Exception ex) {
                            LOG.log(Level.SEVERE, null, ex);
                            Notification.show(TRANSLATOR.translate("general.error.record.update"),
                                    ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                        }
                    });
                    ((ValidationManagerUI) UI.getCurrent()).displayObject(s);
                } catch (UnsupportedEncodingException | NumberFormatException ex) {
                    LOG.log(Level.SEVERE, null, ex);
                    Notification.show(TRANSLATOR.translate("general.error.record.creation"),
                            ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
                }
            });
            HorizontalLayout hl = new HorizontalLayout();
            hl.addComponent(update);
            hl.addComponent(add);
            hl.addComponent(cancel);
            layout.addComponent(hl);
        }
    }
    binder.setReadOnly(!edit);
    binder.bindMemberFields(this);
    layout.setSizeFull();
    setSizeFull();
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.UserComponent.java

License:Apache License

private void init() {
    FormLayout layout = new FormLayout();
    setContent(layout);//from  w  ww.j  av  a 2s. c om
    addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    BeanFieldGroup binder = new BeanFieldGroup(user.getClass());
    binder.setItemDataSource(user);
    Field<?> fn = binder.buildAndBind(TRANSLATOR.translate("general.first.name"), "firstName", TextField.class);
    layout.addComponent(fn);
    Field<?> ln = binder.buildAndBind(TRANSLATOR.translate("general.last.name"), "lastName", TextField.class);
    layout.addComponent(ln);
    Field<?> username = binder.buildAndBind(TRANSLATOR.translate("general.username"), "username",
            TextField.class);
    layout.addComponent(username);
    PasswordField pw = (PasswordField) binder.buildAndBind(TRANSLATOR.translate("general.password"), "password",
            PasswordField.class);
    PasswordChangeListener listener = new PasswordChangeListener();
    pw.addTextChangeListener(listener);
    pw.setConverter(new UserPasswordConverter());
    layout.addComponent(pw);
    Field<?> email = binder.buildAndBind(TRANSLATOR.translate("general.email"), "email", TextField.class);
    layout.addComponent(email);
    ComboBox locale = new ComboBox(TRANSLATOR.translate("general.locale"));
    locale.setTextInputAllowed(false);
    ValidationManagerUI.getAvailableLocales().forEach(l -> {
        locale.addItem(l.toString());
    });
    if (user.getLocale() != null) {
        locale.setValue(user.getLocale());
    }
    binder.bind(locale, "locale");
    layout.addComponent(locale);
    //Status
    ComboBox status = new ComboBox(TRANSLATOR.translate("general.status"));
    new UserStatusJpaController(DataBaseManager.getEntityManagerFactory()).findUserStatusEntities()
            .forEach(us -> {
                status.addItem(us);
                status.setItemCaption(us, TRANSLATOR.translate(us.getStatus()));
            });
    binder.bind(status, "userStatusId");
    status.setTextInputAllowed(false);
    layout.addComponent(status);
    List<UserHasRole> userRoles = new ArrayList<>();
    //Project specific roles
    if (!user.getUserHasRoleList().isEmpty()) {
        Tree roles = new Tree(TRANSLATOR.translate("project.specific.role"));
        user.getUserHasRoleList().forEach(uhr -> {
            if (uhr.getProjectId() != null) {
                Project p = uhr.getProjectId();
                if (!roles.containsId(p)) {
                    roles.addItem(p);
                    roles.setItemCaption(p, p.getName());
                    roles.setItemIcon(p, VMUI.PROJECT_ICON);
                }
                roles.addItem(uhr);
                roles.setItemCaption(uhr, TRANSLATOR.translate(uhr.getRole().getRoleName()));
                roles.setChildrenAllowed(uhr, false);
                roles.setItemIcon(uhr, VaadinIcons.USER_CARD);
                roles.setParent(uhr, p);
            }
        });
        if (!roles.getItemIds().isEmpty()) {
            layout.addComponent(roles);
        }
    }
    //Roles
    if (edit && ((VMUI) UI.getCurrent()).checkRight("system.configuration")) {
        Button projectRole = new Button(TRANSLATOR.translate("manage.project.role"));
        projectRole.addClickListener(l -> {
            VMWindow w = new VMWindow(TRANSLATOR.translate("manage.project.role"));
            w.setContent(getProjectRoleManager());
            ((VMUI) UI.getCurrent()).addWindow(w);
        });
        layout.addComponent(projectRole);
        List<Role> list = new RoleJpaController(DataBaseManager.getEntityManagerFactory()).findRoleEntities();
        Collections.sort(list, (Role r1, Role r2) -> TRANSLATOR.translate(r1.getRoleName())
                .compareTo(TRANSLATOR.translate(r2.getRoleName())));
        BeanItemContainer<Role> roleContainer = new BeanItemContainer<>(Role.class, list);
        TwinColSelect roles = new TwinColSelect(TRANSLATOR.translate("general.role"));
        roles.setContainerDataSource(roleContainer);
        roles.setRows(5);
        roles.setLeftColumnCaption(TRANSLATOR.translate("available.roles"));
        roles.setRightColumnCaption(TRANSLATOR.translate("current.roles"));
        roles.setImmediate(true);
        list.forEach(r -> {
            roles.setItemCaption(r, TRANSLATOR.translate(r.getDescription()));
        });
        if (user.getUserHasRoleList() != null) {
            Set<Role> rs = new HashSet<>();
            user.getUserHasRoleList().forEach(uhr -> {
                if (uhr.getProjectId() == null) {
                    rs.add(uhr.getRole());
                }
            });
            roles.setValue(rs);
        }
        roles.addValueChangeListener(event -> {
            Set<Role> selected = (Set<Role>) event.getProperty().getValue();
            selected.forEach(r -> {
                UserHasRole temp = new UserHasRole();
                temp.setRole(r);
                temp.setVmUser(user);
                userRoles.add(temp);
            });
        });
        layout.addComponent(roles);
    } else {
        if (!user.getUserHasRoleList().isEmpty()) {
            Table roles = new Table(TRANSLATOR.translate("general.role"));
            user.getUserHasRoleList().forEach(role -> {
                roles.addItem(role.getRole());
                roles.setItemCaption(role.getRole(), TRANSLATOR.translate(role.getRole().getRoleName()));
                roles.setItemIcon(role.getRole(), VaadinIcons.USER_STAR);
            });
            layout.addComponent(roles);
        }
    }
    Button update = new Button(user.getId() == null ? TRANSLATOR.translate("general.create")
            : TRANSLATOR.translate("general.update"));
    update.addClickListener((Button.ClickEvent event) -> {
        try {
            VMUserServer us;
            String password = (String) pw.getValue();
            if (user.getId() == null) {
                us = new VMUserServer((String) username.getValue(), password, (String) fn.getValue(),
                        (String) ln.getValue(), (String) email.getValue());
            } else {
                us = new VMUserServer(user);
                us.setFirstName((String) fn.getValue());
                us.setLastName((String) ln.getValue());
                us.setEmail((String) email.getValue());
                us.setUsername((String) username.getValue());
            }
            us.setLocale((String) locale.getValue());
            if (user.getUserHasRoleList() == null) {
                user.setUserHasRoleList(new ArrayList<>());
            }
            user.getUserHasRoleList().clear();
            userRoles.forEach(uhr -> {
                UserHasRoleJpaController c = new UserHasRoleJpaController(
                        DataBaseManager.getEntityManagerFactory());
                try {
                    c.create(uhr);
                    user.getUserHasRoleList().add(uhr);
                } catch (Exception ex) {
                    LOG.log(Level.SEVERE, null, ex);
                }
            });
            if (listener.isChanged() && !password.equals(user.getPassword())) {
                //Different password. Prompt for confirmation
                MessageBox mb = MessageBox.create();
                VerticalLayout vl = new VerticalLayout();
                Label l = new Label(TRANSLATOR.translate("password.confirm.pw.message"));
                vl.addComponent(l);
                PasswordField np = new PasswordField(Lookup.getDefault()
                        .lookup(InternationalizationProvider.class).translate("general.password"));
                vl.addComponent(np);
                mb.asModal(true)
                        .withCaption(Lookup.getDefault().lookup(InternationalizationProvider.class)
                                .translate("password.confirm.pw"))
                        .withMessage(vl).withButtonAlignment(Alignment.MIDDLE_CENTER).withOkButton(() -> {
                            try {
                                if (password.equals(MD5.encrypt(np.getValue()))) {
                                    us.setHashPassword(true);
                                    us.setPassword(np.getValue());
                                    us.write2DB();
                                    Notification.show(
                                            TRANSLATOR.translate("audit.user.account.password.change"),
                                            Notification.Type.ASSISTIVE_NOTIFICATION);
                                    ((VMUI) UI.getCurrent()).updateScreen();
                                } else {
                                    Notification.show(TRANSLATOR.translate("password.does.not.match"),
                                            Notification.Type.WARNING_MESSAGE);
                                }
                                mb.close();
                            } catch (VMException ex) {
                                Exceptions.printStackTrace(ex);
                            }
                        }, ButtonOption.focus(), ButtonOption.closeOnClick(false),
                                ButtonOption.icon(VaadinIcons.CHECK))
                        .withCancelButton(ButtonOption.icon(VaadinIcons.CLOSE)).getWindow()
                        .setIcon(ValidationManagerUI.SMALL_APP_ICON);
                mb.open();
            } else {
                us.write2DB();
            }
            ((VMUI) UI.getCurrent()).getUser().update();
            ((VMUI) UI.getCurrent()).setLocale(new Locale(us.getLocale()));
            ((VMUI) UI.getCurrent()).updateScreen();
        } catch (Exception ex) {
            LOG.log(Level.SEVERE, null, ex);
            Notification.show(TRANSLATOR.translate("general.error.record.update"), ex.getLocalizedMessage(),
                    Notification.Type.ERROR_MESSAGE);
        }
    });
    Button cancel = new Button(
            Lookup.getDefault().lookup(InternationalizationProvider.class).translate("general.cancel"));
    cancel.addClickListener((Button.ClickEvent event) -> {
        binder.discard();
        ((VMUI) UI.getCurrent()).updateScreen();
    });
    binder.setReadOnly(!edit);
    binder.setBuffered(true);
    HorizontalLayout hl = new HorizontalLayout();
    hl.addComponent(update);
    hl.addComponent(cancel);
    layout.addComponent(hl);
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.traceability.TraceMatrix.java

License:Apache License

public Component getMenu() {
    HorizontalLayout hl = new HorizontalLayout();
    ComboBox baseline = new ComboBox(TRANSLATOR.translate("baseline.filter"));
    baseline.setTextInputAllowed(false);
    baseline.setNewItemsAllowed(false);//from  w w w .  j  a v a 2s  .c  o  m
    Tool.extractRequirements(p).forEach(r -> {
        r.getHistoryList().forEach(h -> {
            h.getBaselineList().forEach(b -> {
                if (!baseline.containsId(b)) {
                    baseline.addItem(b);
                    baseline.setItemCaption(b, b.getBaselineName());
                }
            });
        });
    });
    baseline.addValueChangeListener(event -> {
        removeAllItems();
        Baseline b = (Baseline) baseline.getValue();
        if (b == null) {
            //None selected, no filtering
            Tool.extractRequirements(p).forEach((r) -> {
                if (r.getParentRequirementId() == null) {
                    addRequirement(r);
                }
            });
        } else {
            b.getHistoryList().forEach(h -> {
                addRequirement(h.getRequirementId());
            });
        }
    });
    hl.addComponent(baseline);
    Button export = new Button(TRANSLATOR.translate("general.export"));
    export.addClickListener(listener -> {
        //Create the Excel file
        ExcelExport excelExport = new ExcelExport(this);
        excelExport.excludeCollapsedColumns();
        excelExport.setReportTitle(TRANSLATOR.translate("trace.matrix"));
        excelExport.setDisplayTotals(false);
        excelExport.export();
    });
    hl.addComponent(export);
    return hl;
}

From source file:nl.kpmg.lcm.ui.view.administration.components.UserCreateWindow.java

License:Apache License

private ComboBox initRolesListComboBox() {
    ComboBox rolesListComboBox = new ComboBox("Role");

    rolesListComboBox.addItem(Roles.ADMINISTRATOR);
    rolesListComboBox.setItemCaption(Roles.ADMINISTRATOR, "Administrator");

    rolesListComboBox.addItem(Roles.REMOTE_USER);
    rolesListComboBox.setItemCaption(Roles.REMOTE_USER, "Remote user");

    rolesListComboBox.addItem(Roles.API_USER);
    rolesListComboBox.setItemCaption(Roles.API_USER, "API user");

    rolesListComboBox.setTextInputAllowed(false);
    rolesListComboBox.setRequired(true);
    rolesListComboBox.setNullSelectionAllowed(false);
    rolesListComboBox.setInputPrompt("Please select one");
    rolesListComboBox.addListener(this);

    return rolesListComboBox;
}

From source file:nl.kpmg.lcm.ui.view.transfer.SchedulePanel.java

License:Apache License

private ComboBox initRemoteLcmListComboBox() throws UnsupportedOperationException {
    ComboBox remoteLcmListComboBox = new ComboBox("Remote LCMs");
    RemoteLcmsRepresentation remoteLcms;
    try {//from   www . j av a  2s  .c o  m
        remoteLcms = restClientService.getRemoteLcm();
        remoteLcmListComboBox.addItem("all");
        remoteLcmListComboBox.setItemCaption("all", "All");

        for (RemoteLcmRepresentation item : remoteLcms.getItems()) {
            RemoteLcm remoteLcm = item.getItem();
            String template = "%s://%s:%s";
            String url = String.format(template, remoteLcm.getProtocol(), remoteLcm.getDomain(),
                    remoteLcm.getPort().toString());

            remoteLcmUrlMap.put(remoteLcm.getId(), remoteLcm.getName() + " : " + url);
            remoteLcmListComboBox.addItem(remoteLcm.getId());
            remoteLcmListComboBox.setItemCaption(remoteLcm.getId(), remoteLcm.getName() + " : " + url);
            remoteLcmListComboBox.setTextInputAllowed(false);
        }
    } catch (ServerException ex) {
        LOGGER.error("Unable to load remote LCMs! Message:" + ex.getMessage());
    } catch (AuthenticationException | LcmBadRequestException ex) {
        LOGGER.error("Unable to reload remote LCMs." + ex.getMessage());
        Notification.show("Unable to reload the remote LCMs! Message: " + ex.getMessage());
    }

    remoteLcmListComboBox.addStyleName("margin-right-20");
    remoteLcmListComboBox.addStyleName("width-wide-search-field");
    remoteLcmListComboBox.setRequired(true);
    remoteLcmListComboBox.setInputPrompt("Please select one");

    return remoteLcmListComboBox;
}

From source file:org.abstractform.vaadin.VaadinFormToolkit.java

License:Apache License

protected AbstractComponent internalBuildField(Field field, Map<String, Object> extraObjects) {
    AbstractComponent ret = null;/*from ww  w  . ja  va2 s.  c  om*/
    if (field.getType().equals(Field.TYPE_BOOL)) {
        CheckBox cb = new CheckBox(field.getName());
        cb.setImmediate(true);
        ret = cb;
    } else if (field.getType().equals(Field.TYPE_DATETIME)) {
        DateField dt = new DateField(field.getName());
        dt.setResolution(DateField.RESOLUTION_DAY);
        dt.setDescription(field.getDescription());
        dt.setRequired(field.isRequired());
        dt.setImmediate(true);
        dt.setReadOnly(field.isReadOnly());
        ret = dt;
    } else if (field.getType().equals(Field.TYPE_TEXT) || field.getType().equals(Field.TYPE_NUMERIC)
            || field.getType().equals(Field.TYPE_PASSWORD)) {
        AbstractTextField textField;
        if (field.getType().equals(Field.TYPE_PASSWORD)) {
            textField = new PasswordField(field.getName());
        } else {
            textField = new TextField(field.getName());
        }
        //textField.setColumns(field.getDisplayWidth());
        if (field.getMaxLength() != 0) {
            textField.setMaxLength(field.getMaxLength());
        }
        textField.setDescription(field.getDescription());
        textField.setReadOnly(field.isReadOnly());
        textField.setNullRepresentation("".intern());
        textField.setNullSettingAllowed(true);
        textField.setRequired(field.isRequired());
        textField.setImmediate(true);
        textField.setWidth("100%");
        ret = textField;
    } else if (field.getType().equals(SelectorConstants.TYPE_SELECTOR)) {
        ComboBox comboBox = new ComboBox(field.getName());
        comboBox.setTextInputAllowed(false);
        comboBox.setNullSelectionAllowed(!field.isRequired());
        comboBox.setDescription(field.getDescription());
        comboBox.setReadOnly(field.isReadOnly());
        comboBox.setRequired(field.isRequired());
        comboBox.setImmediate(true);
        comboBox.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_PROPERTY);
        comboBox.setItemCaptionPropertyId(VaadinSelectorContainer.PROPERTY_CAPTION);
        comboBox.setWidth("100%");
        ret = comboBox;
    } else if (field.getType().equals(TableConstants.TYPE_TABLE)) {
        ret = buildTableField(field, extraObjects);
    }
    return ret;
}

From source file:org.apache.usergrid.chop.webapp.view.util.UIUtil.java

License:Apache License

public static ComboBox createCombo(String caption, Object values[]) {

    ComboBox combo = new ComboBox(caption);
    combo.setTextInputAllowed(false);
    combo.setNullSelectionAllowed(false);

    populateCombo(combo, values);//from www .jav a  2  s  . com

    return combo;
}

From source file:org.apache.usergrid.chop.webapp.view.util.UIUtil.java

License:Apache License

public static ComboBox addCombo(AbsoluteLayout layout, String caption, String position, String width,
        Object values[]) {/*from w w w.  j  a v a  2  s.  c o  m*/

    ComboBox combo = new ComboBox(caption);
    combo.setTextInputAllowed(false);
    combo.setNullSelectionAllowed(false);
    combo.setWidth(width);

    layout.addComponent(combo, position);
    populateCombo(combo, values);

    return combo;
}