List of usage examples for com.vaadin.ui ComboBox setItems
@Override public void setItems(T... items)
Filtering will use a case insensitive match to show all items where the filter text is a substring of the caption displayed for that item.
From source file:com.github.carljmosca.MainLayout.java
private void init() { setSizeFull();// w ww . ja va 2 s .com addStyleName("menylayout"); Responsive.makeResponsive(this); ComboBox<Person> cmbPerson = new ComboBox<>(); cmbPerson.setItems(personProcessor.findAll()); cmbPerson.setItemCaptionGenerator(c -> c.getTitle() + " " + c.getFirstName() + " " + c.getLastName()); cmbPerson.addValueChangeListener((HasValue.ValueChangeEvent<Person> event) -> { binder.setBean(cmbPerson.getValue()); }); title = new ComboBox("Title", Arrays.asList(titles)); firstName = new TextField("First"); middleName = new TextField("Middle"); lastName = new TextField("Last"); Button btnNew = new Button("New"); btnNew.addClickListener((Button.ClickEvent event) -> { person = new Person(); binder.setBean(person); }); Button btnSave = new Button("Save"); btnSave.addClickListener((Button.ClickEvent event) -> { personProcessor.addPerson(person); cmbPerson.setItems(personProcessor.findAll()); }); personLayout.setWidth(null); personLayout.setSpacing(true); personLayout.addStyleName("menu"); personLayout.addComponent(title); personLayout.addComponent(firstName); personLayout.addComponent(middleName); personLayout.addComponent(lastName); personLayout.addComponent(btnNew); addComponent(btnSave); addComponent(cmbPerson); addComponent(personLayout); //addComponent(buttonLayout); doBinding(); }
From source file:de.symeda.sormas.ui.configuration.DevModeView.java
License:Open Source License
public DevModeView() { super(VIEW_NAME); contentLayout = new VerticalLayout(); contentLayout.setMargin(true);/*from ww w. j a va 2 s. c o m*/ contentLayout.setSpacing(true); contentLayout.setSizeFull(); contentLayout.setStyleName("crud-main-layout"); HorizontalLayout caseGeneratorLayout = new HorizontalLayout(); TextField caseCountField = new TextField(); caseCountField.setCaption(I18nProperties.getCaption(Captions.devModeCaseCount)); caseGeneratorConfigBinder.forField(caseCountField) .withConverter(new StringToIntegerConverter("Must be a number")) .bind(CaseGenerationConfig::getCaseCount, CaseGenerationConfig::setCaseCount); caseGeneratorLayout.addComponent(caseCountField); DateField startDateField = new DateField(); startDateField.setCaption(I18nProperties.getCaption(Captions.devModeStartDate)); startDateField.setDateFormat(DateHelper.getLocalDatePattern()); startDateField.setLenient(true); caseGeneratorConfigBinder.bind(startDateField, CaseGenerationConfig::getStartDate, CaseGenerationConfig::setStartDate); caseGeneratorLayout.addComponent(startDateField); DateField endDateField = new DateField(); endDateField.setCaption(I18nProperties.getCaption(Captions.devModeEndDate)); endDateField.setDateFormat(DateHelper.getLocalDatePattern()); endDateField.setLenient(true); caseGeneratorConfigBinder.bind(endDateField, CaseGenerationConfig::getEndDate, CaseGenerationConfig::setEndDate); caseGeneratorLayout.addComponent(endDateField); ComboBox<Disease> diseaseField = new ComboBox<>(null, FacadeProvider.getDiseaseConfigurationFacade().getAllActivePrimaryDiseases()); diseaseField.setCaption(I18nProperties.getCaption(Captions.devModeDisease)); caseGeneratorConfigBinder.bind(diseaseField, CaseGenerationConfig::getDisease, CaseGenerationConfig::setDisease); caseGeneratorLayout.addComponent(diseaseField); List<RegionReferenceDto> regions = FacadeProvider.getRegionFacade().getAllAsReference(); ComboBox<RegionReferenceDto> regionField = new ComboBox<RegionReferenceDto>(null, regions); regionField.setCaption(I18nProperties.getCaption(Captions.devModeRegion)); caseGeneratorConfigBinder.bind(regionField, CaseGenerationConfig::getRegion, CaseGenerationConfig::setRegion); caseGeneratorLayout.addComponent(regionField); ComboBox<DistrictReferenceDto> districtField = new ComboBox<DistrictReferenceDto>(); districtField.setCaption(I18nProperties.getCaption(Captions.devModeDistrict)); caseGeneratorConfigBinder.bind(districtField, CaseGenerationConfig::getDistrict, CaseGenerationConfig::setDistrict); caseGeneratorLayout.addComponent(districtField); regionField.addValueChangeListener(event -> { RegionReferenceDto region = event.getValue(); if (region != null) { districtField.setItems(FacadeProvider.getDistrictFacade().getAllByRegion(region.getUuid())); } else { districtField.setItems(new ArrayList<DistrictReferenceDto>()); } }); Button generateButton = new Button("generate cases"); CssStyles.style(generateButton, CssStyles.FORCE_CAPTION); generateButton.addClickListener(e -> generateCases()); caseGeneratorLayout.addComponent(generateButton); contentLayout.addComponent(caseGeneratorLayout); CaseGenerationConfig config = new CaseGenerationConfig(); config.setRegion(regions.get(0)); caseGeneratorConfigBinder.setBean(config); addComponent(contentLayout); }
From source file:dhbw.clippinggorilla.userinterface.views.ClippingView.java
public ClippingView(Clipping clipping) { User user = UserUtils.getCurrent();/* w ww. java 2s . c om*/ clippingArticlesLayout = new VerticalLayout(); clippingArticlesLayout.setSpacing(true); clippingArticlesLayout.setMargin(false); clippingArticlesLayout.setSizeFull(); HorizontalLayout clippingOptionsLayout = new HorizontalLayout(); clippingOptionsLayout.setSpacing(true); clippingOptionsLayout.setMargin(false); clippingOptionsLayout.setWidth("100%"); ComboBox<SortOptions> comboBoxSortOptions = new ComboBox<>(Language.get(Word.SORT_BY)); Language.setCustom(Word.SORT_BY, s -> { comboBoxSortOptions.setCaption(s); comboBoxSortOptions.getDataProvider().refreshAll(); }); comboBoxSortOptions.setItems(EnumSet.allOf(SortOptions.class)); comboBoxSortOptions.setItemCaptionGenerator(s -> s.getName()); comboBoxSortOptions.setItemIconGenerator(s -> s.getIcon()); comboBoxSortOptions.setValue(SortOptions.BYPROFILE); comboBoxSortOptions.setTextInputAllowed(false); comboBoxSortOptions.setEmptySelectionAllowed(false); comboBoxSortOptions.addStyleName("comboboxsort"); comboBoxSortOptions.addValueChangeListener(e -> { switch (e.getValue()) { case BYDATE: createClippingViewByDate(clipping); break; case BYPROFILE: createClippingViewByProfile(clipping); break; case BYSOURCE: createClippingViewBySource(clipping); break; } }); Button buttonRegenerateClipping = new Button(VaadinIcons.REFRESH); buttonRegenerateClipping.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonRegenerateClipping.addClickListener(ce -> { user.setLastClipping(ClippingUtils.generateClipping(user, false)); ClippingGorillaUI.getCurrent().setMainContent(ClippingView.getCurrent()); }); clippingOptionsLayout.addComponents(comboBoxSortOptions, buttonRegenerateClipping); clippingOptionsLayout.setExpandRatio(comboBoxSortOptions, 5); clippingOptionsLayout.setComponentAlignment(buttonRegenerateClipping, Alignment.BOTTOM_CENTER); addComponents(clippingOptionsLayout, clippingArticlesLayout); createClippingViewByProfile(clipping); if (clipping.getArticles().keySet().isEmpty() && clipping.getArticlesFromGroup().keySet().isEmpty()) { Label labelNoProfile = new Label(); Language.setCustom(Word.NO_PROFILE_PRESENT, s -> labelNoProfile.setValue(s)); labelNoProfile.addStyleName(ValoTheme.LABEL_H2); clippingArticlesLayout.addComponent(labelNoProfile); } }
From source file:org.jpos.qi.components.DateRangeComponent.java
License:Open Source License
private ComboBox createDateRanges() { ComboBox combo = new ComboBox(app.getMessage("or").toUpperCase()); combo.setStyleName(ValoTheme.COMBOBOX_SMALL); combo.setEmptySelectionAllowed(false); combo.setItems((Object[]) DateRange.ranges); combo.setItemCaptionGenerator(range -> app.getMessage((String) range)); combo.addValueChangeListener(event -> { if (event.getValue() != null) { datePickerFrom.setValue(null); datePickerTo.setValue(null); if (refreshBtn != null) refreshBtn.click();//from w ww. j a v a 2 s . c om } }); return combo; }
From source file:org.jpos.qi.minigl.NewEntryForm.java
License:Open Source License
private ComboBox createLayersSelector() { ComboBox<Layer> box = new ComboBox(app.getMessage("layer")); box.setItemCaptionGenerator(l -> l.getId() + " - " + l.getName()); List layers = helper.getLayers(journal); if (layers != null) { Collections.sort(layers); box.setItems(layers); if (layers.size() > 0) { box.setValue((Layer) layers.get(0)); }/* www . ja v a 2 s . com*/ } box.setEmptySelectionAllowed(false); return box; }