Example usage for com.vaadin.ui ComboBox ComboBox

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

Introduction

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

Prototype

protected ComboBox(DataCommunicator<T> dataCommunicator) 

Source Link

Document

Constructs and initializes an empty combo box.

Usage

From source file:com.terralcode.gestion.frontend.view.widgets.customer.CustomerView.java

private void buildCustomerHeader() {

    codeField = new TextField("Cdigo");
    taxCodeField = new TextField("CIF");
    nameField = new TextField("Nombre");
    //telephoneField = new TextField("Telfono");
    statusField = new ComboBox("Estado");
    statusField.setTextInputAllowed(false);
    typeField = new ComboBox("Tipo");
    typeField.setTextInputAllowed(false);

    prestigeField = new CheckBox("Imagen");
    prestigeField.setReadOnly(true);/*from  w  ww. ja  v a2  s  .  c  o  m*/
    exclusiveField = new CheckBox("Exclusividad");
    exclusiveField.setReadOnly(true);
    canGrowField = new CheckBox("Puede crecer");
    canGrowField.setReadOnly(true);
    consultingLevelField = new TextField("Nivel Asesor.");
    consultingLevelField.setReadOnly(true);
    salesLevelField = new TextField("Nivel Ventas");
    salesLevelField.setReadOnly(true);

    codeField.setReadOnly(true);
    taxCodeField.setReadOnly(true);
    nameField.setReadOnly(true);

    mainLayout.addComponent(codeField);
    mainLayout.addComponent(taxCodeField);
    mainLayout.addComponent(nameField);
    //mainLayout.addComponent(telephoneField);
    mainLayout.addComponent(statusField);
    mainLayout.addComponent(typeField);
    mainLayout.addComponent(prestigeField);
    mainLayout.addComponent(exclusiveField);
    mainLayout.addComponent(canGrowField);
    mainLayout.addComponent(consultingLevelField);
    mainLayout.addComponent(salesLevelField);
}

From source file:com.wcs.wcslib.vaadin.widget.multifileupload.WidgetTestApplication.java

License:Apache License

private void addWindowPositionSwitcher() {
    final ComboBox cb = new ComboBox("Window position");
    cb.setNullSelectionAllowed(false);/*  ww  w.j  a  v a  2  s  . co m*/
    for (UploadStateWindow.WindowPosition windowPosition : UploadStateWindow.WindowPosition.values()) {
        cb.addItem(windowPosition);
        cb.setItemCaption(windowPosition, windowPosition.name());
    }
    cb.setValue(UploadStateWindow.WindowPosition.BOTTOM_RIGHT);
    cb.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            uploadStateWindow.setWindowPosition((UploadStateWindow.WindowPosition) cb.getValue());
        }
    });
    form.addComponent(cb);
}

From source file:com.yoncabt.ebr.ui.ReportWindow.java

private void showFields(ReportDefinition definition, final Window w, final FormLayout fl)
        throws AssertionError, JSONException {
    fl.removeAllComponents();//from w  w  w .  j  ava2s  .c  o  m
    w.setCaption(definition.getCaption());
    for (ReportParam param : definition.getReportParams()) {
        AbstractField comp = null;
        if (param.getInputType() == InputType.COMBO) {
            ComboBox f = new ComboBox(param.getLabel());
            param.getLovData().forEach((k, v) -> {
                f.addItem(k);
                f.setItemCaption(k, (String) v);
            });
            comp = f;
        } else {
            switch (param.getFieldType()) {
            case STRING: {
                TextField f = new TextField(param.getLabel());
                comp = f;
                break;
            }
            case INTEGER: {
                TextField f = new TextField(param.getLabel());
                f.addValidator(new IntegerRangeValidator("Say kontrol", (Integer) param.getMin(),
                        (Integer) param.getMax()));
                comp = f;
                break;
            }
            case LONG: {
                TextField f = new TextField(param.getLabel());
                f.addValidator(new LongRangeValidator("Say kontrol", (Long) param.getMin(),
                        (Long) param.getMax()));
                comp = f;
                break;
            }
            case DOUBLE: {
                TextField f = new TextField(param.getLabel());
                f.addValidator(new DoubleRangeValidator("Say kontrol", (Double) param.getMin(),
                        (Double) param.getMax()));
                comp = f;
                break;
            }
            case DATE: {
                DateField f = new DateField(param.getLabel());
                f.setDateFormat(param.getFormat());
                comp = f;
                break;
            }
            default: {
                throw new AssertionError(param.getName() + " in tipi tannmyor :" + param.getJavaType());
            }
            }
        }
        if (param.getDefaultValue() != null) {
            comp.setValue(param.getDefaultValue());
        }
        comp.setImmediate(true);
        comp.setValidationVisible(false);
        comp.setId(param.getName());
        fl.addComponent(comp);

    }
    if (report instanceof SQLReport) {
        reportType.addItem(ReportOutputFormat.xls);
        reportType.setItemCaption(ReportOutputFormat.xls, ReportOutputFormat.xls.getTypeName());
    } else {
        for (ReportOutputFormat value : ReportOutputFormat.values()) {
            reportType.addItem(value);
            reportType.setItemCaption(value, value.getTypeName());
        }
    }
    reportType.setValue(ReportOutputFormat.xls);
    fl.addComponent(reportType);
    fl.addComponent(reportLocale);
    fl.addComponent(email);
}

From source file:de.catma.ui.analyzer.querybuilder.TagPanel.java

License:Open Source License

private void initComponents() {
    contentPanel = new VerticalLayout();
    contentPanel.setSizeFull();/*from   w ww  . j  av a  2 s.  c om*/
    addComponent(contentPanel);

    if (tagsetDefinitionDictionary.isEmpty()) {
        tagLibraryPanel = createTagLibraryPanel();
        contentPanel.addComponent(tagLibraryPanel);
    }

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

    tagsetTree = new TagsetTree(queryOptions.getRepository().getTagManager(), null, false, false, null);
    tagSearchPanel.addComponent(tagsetTree);
    tagSearchPanel.setExpandRatio(tagsetTree, 0.8f);

    tagMatchModeCombo = new ComboBox("Please choose what you consider a match:");
    tagMatchModeCombo.setImmediate(true);
    TagMatchModeItem exactMatchItem = new TagMatchModeItem("exact match", TagMatchMode.EXACT);
    tagMatchModeCombo.addItem(exactMatchItem);
    tagMatchModeCombo.addItem(new TagMatchModeItem("boundary match", TagMatchMode.BOUNDARY));
    tagMatchModeCombo.addItem(new TagMatchModeItem("overlap match", TagMatchMode.OVERLAP));
    tagMatchModeCombo.setNullSelectionAllowed(false);
    tagMatchModeCombo.setNewItemsAllowed(false);

    tagMatchModeCombo.setDescription(
            "The three different match modes influence the way tags refine" + " your search results:" + "<ul>"
                    + "<li>exact match - the tag boundaries have to match exactly to "
                    + "keep a result item in the result set</li>"
                    + "<li>boundary match - result items that should be kept in the "
                    + "result set must start and end within the boundaries of the tag</li>"
                    + "<li>overlap - the result items that should be kept in the result "
                    + "set must overlap with the range of the tag</li>" + "</ul>");
    tagMatchModeCombo.setValue(exactMatchItem);

    tagSearchPanel.addComponent(tagMatchModeCombo);
    tagSearchPanel.setExpandRatio(tagMatchModeCombo, 0.2f);

    splitPanel = new VerticalSplitPanel();
    contentPanel.addComponent(splitPanel);

    splitPanel.addComponent(tagSearchPanel);
    if (tagsetDefinitionDictionary.isEmpty()) {
        splitPanel.setVisible(false);
    } else {
        tagsetTree.addTagsetDefinition(tagsetDefinitionDictionary.values());
    }

    resultPanel = new ResultPanel(queryOptions);
    splitPanel.addComponent(resultPanel);

    initSearchPanelComponents(contentPanel);

}

From source file:de.catma.ui.repository.wizard.FileTypePanel.java

License:Open Source License

private void initComponents() {
    setSpacing(true);//from w  w  w . j  a  v  a  2  s.  c  o  m
    setSizeFull();
    setMargin(true, false, false, false);

    cbFileType = new ComboBox("File type");
    for (FileType ft : FileType.values()) {
        cbFileType.addItem(ft);
    }
    cbFileType.setNullSelectionAllowed(false);
    cbFileType.setImmediate(true);

    addComponent(cbFileType, 0, 0);

    fileEncodingTree = new Tree("File encoding");
    fileEncodingTree.setImmediate(true);

    Map<String, Map<String, List<Charset>>> regionLanguageCharsetMapping = CharsetLanguageInfo.SINGLETON
            .getRegionLanguageCharsetMapping();

    for (String region : regionLanguageCharsetMapping.keySet()) {
        fileEncodingTree.addItem(region);
        Map<String, List<Charset>> languages = regionLanguageCharsetMapping.get(region);
        for (String language : languages.keySet()) {
            fileEncodingTree.addItem(language);
            fileEncodingTree.setParent(language, region);
            for (Charset charset : languages.get(language)) {
                fileEncodingTree.addItem(charset);
                fileEncodingTree.setParent(charset, language);
                fileEncodingTree.setChildrenAllowed(charset, false);
            }
        }
    }

    Map<String, List<Charset>> categoryCharsetMapping = CharsetLanguageInfo.SINGLETON
            .getCategoryCharsetMapping();

    for (String category : categoryCharsetMapping.keySet()) {
        fileEncodingTree.addItem(category);
        for (Charset charset : categoryCharsetMapping.get(category)) {
            fileEncodingTree.addItem(charset);
            fileEncodingTree.setParent(charset, category);
            fileEncodingTree.setChildrenAllowed(charset, false);
        }
    }

    previewPanel = new Panel("Preview");
    previewPanel.getContent().setSizeUndefined();
    previewPanel.setHeight("300px");

    this.taPreview = new Label();
    this.taPreview.setContentMode(Label.CONTENT_XHTML);
    previewPanel.addComponent(taPreview);

    addComponent(fileEncodingTree, 0, 1);
    addComponent(previewPanel, 1, 1);

    this.uploadLabel = new Label("Upload the corresponding XSLT file:");
    this.uploadPanel = new UploadPanel();
    addComponent(uploadLabel, 0, 2, 1, 2);
    addComponent(uploadPanel, 0, 3, 1, 3);

    progressIndicator = new ProgressIndicator();
    progressIndicator.setEnabled(false);
    progressIndicator.setIndeterminate(true);
    progressIndicator.setWidth("100%");
    progressIndicator.setPollingInterval(500);

    addComponent(progressIndicator, 1, 0);
    setColumnExpandRatio(1, 1);

}

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

License:Apache License

private void init(TRoles roles) {
    userTable = new Table();
    userTable.addContainerProperty("Username", String.class, "");
    userTable.setWriteThrough(true);// w w w.  ja  v  a 2  s. com
    userTable.setImmediate(true);
    userTable.setHeight(5.0f, UNITS_CM);
    userTable.setWidth(100.0f, UNITS_PERCENTAGE);

    ComboBox chooseRoles = new ComboBox("Role: ");
    chooseRoles.setNewItemsAllowed(false);
    chooseRoles.setNullSelectionAllowed(false);
    chooseRoles.setImmediate(true);
    chooseRoles.setWriteThrough(true);
    for (TRole role : roles.getRole()) {
        chooseRoles.addItem(role.getLabel());
        IndexedContainer co = new IndexedContainer();
        co.addContainerProperty("Username", String.class, "");
        roleTables.put(role.getLabel(), co);
        roleNames.put(role.getLabel(), role);

    }
    // As a workaround, since the value change events tends to be fired very
    // late
    chooseRoles.addListener(new BlurListener() {
        private static final long serialVersionUID = 1727886677015952723L;

        @Override
        public void blur(BlurEvent event) {
            userTable.setContainerDataSource(roleTables.get(((ComboBox) event.getSource()).getValue()));

        }
    });
    chooseRoles.addListener(new ValueChangeListener() {
        private static final long serialVersionUID = 3539972189878693446L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            userTable.setContainerDataSource(roleTables.get(event.getProperty().getValue()));
            userTable.requestRepaintAll();
        }
    });

    chooseUser = new ComboBox();
    List<User> userList;
    try {
        userList = ModelFacades.getTenantFacade().getUsersOfTenant(DecidrUI.getCurrent().getCurrentTenantId(),
                null);
    } catch (TransactionException e) {
        DecidrUI.getCurrent().getMainWindow().addWindow(new TransactionErrorDialogComponent(e));
        userList = new ArrayList<User>(0);
    }
    for (User u : userList) {
        chooseUser.addItem(u.getUserProfile().getUsername());
        userNames.put(u.getUserProfile().getUsername(), u);
    }
    chooseUser.setNewItemsAllowed(true);

    userTable.addListener(new ItemClickListener() {
        private static final long serialVersionUID = 2064501225684227835L;

        @Override
        public void itemClick(ItemClickEvent event) {
            chooseUser.setValue(event.getItem().getItemProperty("Username"));
        }
    });

    Button addUser = new Button("add", new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            Item newItem = userTable.getContainerDataSource().addItem(chooseUser.getValue());
            newItem.getItemProperty("Username").setValue(chooseUser.getValue());

            userTable.requestRepaintAll();
        }
    });

    Button delUser = new Button("remove", new ClickListener() {
        private static final long serialVersionUID = -5312856358004084337L;

        @Override
        public void buttonClick(ClickEvent event) {
            userTable.getContainerDataSource().removeItem(chooseUser.getValue());
            userTable.requestRepaintAll();
        }
    });

    this.addComponent(chooseRoles);
    this.addComponent(userTable);
    HorizontalLayout hLayout = new HorizontalLayout();
    hLayout.addComponent(chooseUser);
    hLayout.addComponent(addUser);
    hLayout.addComponent(delUser);
    this.addComponent(hLayout);

}

From source file:de.fatalix.bookery.view.admin.BatchJobCard.java

private FormLayout createContent() {
    batchJobTypeCombo = new ComboBox("Batch Type");
    for (BatchJobType type : BatchJobType.values()) {
        batchJobTypeCombo.addItem(type);
    }/*w  w  w . j  a v  a 2s.  c o  m*/
    batchJobTypeCombo.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (!noUpdate) {
                BatchJobType newType = ((BatchJobType) batchJobTypeCombo.getValue());

                batchJobConfiguration.setValue(newType.getDefaultConfig());

                updateBean();
                setFields();
            }
        }
    });

    description = new Label("description");
    nextRuntime = new Label("---");
    batchJobActive = new CheckBox("active", false);
    cronjobExpression = new TextField("Cronjob", "*******");
    status = new TextField("Status", "-");
    batchJobConfiguration = new TextArea("Configuration");

    Button updateButton = new Button("update", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            updateBean();
            jobConfig = presenter.updateBatchJob(jobConfig);
            setFields();
            logger.debug("Updated Batch Job...");
        }
    });
    updateButton.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    FormLayout batchJobCardContent = new FormLayout(batchJobTypeCombo, description, cronjobExpression,
            batchJobActive, batchJobConfiguration, nextRuntime, status, updateButton);
    batchJobCardContent.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    batchJobCardContent.setMargin(true);
    return batchJobCardContent;
}

From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultFormView.java

License:Apache License

private Field<?> createSelect(OptionListFormField field) {
    AbstractSelect select;//from  w ww. j a v  a  2 s. c  o  m
    if (field.getVisibleRows() <= 1) {
        select = new ComboBox(field.getTitle());
    } else {
        select = new ListSelect(field.getTitle());
        ((ListSelect) select).setRows(field.getVisibleRows());
    }

    fillOptions(field.getOptionList(), select, new FormSelectionContext(field));
    // addOptionListChangeListener(field, select, new FormSelectionContext(
    // field));

    select.setPropertyDataSource(field.getProperty());
    select.setInvalidAllowed(false);
    select.setImmediate(true);
    select.setMultiSelect(false);
    select.addStyleName(field.getName());

    return select;
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.ChangeExperimentMetadataComponent.java

License:Open Source License

private void buildFormLayout() {
    final FieldGroup fieldGroup = new FieldGroup();
    final FormLayout form2 = new FormLayout();

    Map<String, PropertyBean> controlledVocabularies = getControlledVocabularies();
    Map<String, PropertyBean> properties = getProperties();
    List<Property> xmlProps = getXMLProperties();

    for (Property f : xmlProps) {
        PropertyType type = f.getType();

        String label = f.getLabel();
        if (f.hasUnit())
            label += " in " + f.getUnit();
        TextField tf = new TextField(label);
        tf.setData(type);// save property type for later, when it is written back
        fieldGroup.bind(tf, label);/* w w  w. j a  va 2  s. c om*/
        tf.setCaption(label);
        tf.setDescription("Q_PROPERTIES");
        tf.setValue((String) f.getValue());
        form2.addComponent(tf);
    }

    for (String key : properties.keySet()) {
        if (controlledVocabularies.keySet().contains(key)) {
            ComboBox select = new ComboBox(controlledVocabularies.get(key).getLabel());
            fieldGroup.bind(select, key);

            // Add items with given item IDs
            select.addItems(controlledVocabularies.get(key).getVocabularyValues());

            select.setDescription(controlledVocabularies.get(key).getCode());
            select.setValue(properties.get(key).getValue());

            form2.addComponent(select);

        } else {
            TextField tf = new TextField(key);
            fieldGroup.bind(tf, key);
            tf.setCaption(properties.get(key).getLabel());
            tf.setDescription(properties.get(key).getCode());
            tf.setValue((String) properties.get(key).getValue());
            form2.addComponent(tf);
        }
    }
    this.fieldGroup = fieldGroup;
    this.form = form2;
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.ChangeMetadataComponent.java

License:Open Source License

private void buildFormLayout(SampleBean sample) {
    final FieldGroup fieldGroup = new FieldGroup();
    final FormLayout form2 = new FormLayout();

    Map<String, PropertyBean> controlledVocabularies = getControlledVocabularies(sample);
    Map<String, PropertyBean> properties = getProperties(sample);

    for (String key : properties.keySet()) {
        if (controlledVocabularies.keySet().contains(key)) {
            ComboBox select = new ComboBox(controlledVocabularies.get(key).getLabel());
            fieldGroup.bind(select, key);

            // Add items with given item IDs
            select.addItems(controlledVocabularies.get(key).getVocabularyValues());

            /*/*from  w ww . j  av  a 2s  .  c  o  m*/
             * for(Object itemID: select.getItemIds()) { System.out.println(itemID); }
             */
            select.setDescription(controlledVocabularies.get(key).getCode());
            select.setValue(properties.get(key).getValue());

            form2.addComponent(select);

        } else {
            TextField tf = new TextField(key);
            fieldGroup.bind(tf, key);
            tf.setCaption(properties.get(key).getLabel());
            tf.setDescription(properties.get(key).getCode());
            tf.setValue((String) properties.get(key).getValue());
            form2.addComponent(tf);
        }
    }
    this.fieldGroup = fieldGroup;
    this.form = form2;
}