ComboBox cb = new MyComboBox(); cb.setItemCaptionPropertyId("nome,sobreNome"); //...
private void populateTypeNameCombo() { typeComboBox.setContainerDataSource( HawkbitCommonUtil.createLazyQueryContainer(new BeanQueryFactory<>(SoftwareModuleTypeBeanQuery.class))); typeComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME); }
private void populateTypeNameCombo() { typeComboBox.setContainerDataSource( HawkbitCommonUtil.createLazyQueryContainer(new BeanQueryFactory<>(SoftwareModuleTypeBeanQuery.class))); typeComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME); }
combo.setItemCaptionPropertyId("description");
public class ComboBoxComponent extends VerticalLayout { public ComboBoxComponent() { BeanItemContainer<Person> dataSource = new BeanItemContainer<>(HasCaption.class); ComboBox comboBox = new ComboBox(); comboBox.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY); // use a fake property which will get identified by the getter comboBox.setItemCaptionPropertyId("caption"); addComponent(comboBox); comboBox.setContainerDataSource(dataSource); Random random = new Random(); for (int i = 0; i < 10; i++) { dataSource.addBean(new Person("Name " + i, "Surname " + i, random.nextInt(99) + 1)); } } }
/** * Generates the options items for the combo box using the map entry keys as values and the values as labels.<p> * * @param box the combo box to prepare * @param options the box options */ public static void prepareComboBox(ComboBox box, Map<?, String> options) { IndexedContainer container = new IndexedContainer(); container.addContainerProperty(PROPERTY_VALUE, Object.class, null); container.addContainerProperty(PROPERTY_LABEL, String.class, ""); for (Entry<?, String> entry : options.entrySet()) { Item item = container.addItem(entry.getKey()); item.getItemProperty(PROPERTY_VALUE).setValue(entry.getKey()); item.getItemProperty(PROPERTY_LABEL).setValue(entry.getValue()); } box.setContainerDataSource(container); box.setItemCaptionPropertyId(PROPERTY_LABEL); }
/** * Populate DistributionSet Type name combo. */ private void populateDistSetTypeNameCombo() { distsetTypeNameComboBox.setContainerDataSource(getDistSetTypeLazyQueryContainer()); distsetTypeNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME); distsetTypeNameComboBox.setValue(getDefaultDistributionSetType().getId()); }
/** * Populate DistributionSet Type name combo. */ private void populateDistSetTypeNameCombo() { distsetTypeNameComboBox.setContainerDataSource(getDistSetTypeLazyQueryContainer()); distsetTypeNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME); distsetTypeNameComboBox.setValue(getDefaultDistributionSetType().getId()); }
protected AbstractField createTextField() { ComboBox out = new ComboBox(); out.setItemCaptionPropertyId("title"); out.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY); out.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS); out.setNullSelectionAllowed(false); //TODO container = new IndexedContainer(); // container.addContainerProperty("id", String.class, ""); container.addContainerProperty("title", String.class, ""); out.setContainerDataSource(container); return out; }
BeanItemContainer<Person> container = new BeanItemContainer<Person>(Person.class); container.addAll(myPersonList); ComboBox combobox = new ComboBox(); combobox.setContainerDataSource(container); combobox.setItemCaptionMode(Select.ITEM_CAPTION_MODE_PROPERTY); combobox.setItemCaptionPropertyId("name"); // the person's name field will be shown on the UI // imho if you want to add a static text (String) into a container // which populated with Person objects then you have to make a fake Person object Person staticText = new Person(); staticText.setName("My static text"); combobox.addItem(staticText); // if you want to specify the index of the item, add them one by one in for cycle // and insert the static text item in the appropritate place
private void buildUI() { combo = new ComboBox(null, container); combo.setImmediate(true); combo.setNullSelectionAllowed(false); combo.setWidth(200 + "px"); combo.setId(ID.getId(Optional.empty(), this, combo)); combo.setContainerDataSource(container); // Sets the combobox to show a certain property as the item caption combo.setItemCaptionPropertyId(LocaleContainer.PropertyName.NAME); combo.setItemCaptionMode(ItemCaptionMode.PROPERTY); // Sets the icon to use with the items combo.setItemIconPropertyId(LocaleContainer.PropertyName.FLAG); combo.setValue(currentLocale.getLocale() .toLanguageTag()); combo.addValueChangeListener(this); }
/** * @return a new ComboBox */ public ComboBox buildCombBox() { final ComboBox comboBox = SPUIComponentProvider.getComboBox(null, "", null, ValoTheme.COMBOBOX_SMALL, false, "", prompt); comboBox.setImmediate(true); comboBox.setPageLength(7); comboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME); comboBox.setSizeUndefined(); if (caption != null) { comboBox.setCaption(caption); } if (id != null) { comboBox.setId(id); } if (valueChangeListener != null) { comboBox.addValueChangeListener(valueChangeListener); } return comboBox; } }
/** * @return a new ComboBox */ public ComboBox buildCombBox() { final ComboBox comboBox = SPUIComponentProvider.getComboBox(null, "", null, ValoTheme.COMBOBOX_SMALL, false, "", prompt); comboBox.setImmediate(true); comboBox.setPageLength(7); comboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME); comboBox.setSizeUndefined(); if (caption != null) { comboBox.setCaption(caption); } if (id != null) { comboBox.setId(id); } if (valueChangeListener != null) { comboBox.addValueChangeListener(valueChangeListener); } return comboBox; } }
/* Creating a container, with a property of "name". Item Id is a number, here. Can be anything (unique). * Alternatively, you could use the IndexedContainer to generate it's own ItemId : * cityContainer.getItem(cityContainer.addItem()).getItemProperty("name").setValue("New York"); */ IndexedContainer cityContainer = new IndexedContainer(); cityContainer.addContainerProperty("name", String.class, null); cityContainer.addItem(1).getItemProperty("name").setValue("New York"); cityContainer.addItem(2).getItemProperty("name").setValue("Turku"); cityContainer.addItem(3).getItemProperty("name").setValue("Paris"); cityContainer.addItem(4).getItemProperty("name").setValue("Zanzibar"); cityContainer.addItem(5).getItemProperty("name").setValue("Turin"); cityContainer.addItem(6).getItemProperty("name").setValue("London"); cityContainer.getItem(cityContainer.addItem()).getItemProperty("name").setValue("New York"); /* Lets sort the container on ascending name*/ cityContainer.sort(new Object[]{"name"}, new boolean[]{true}); /* Here's a comboBox that uses that container, where we are using the "name" property as the item caption */ ComboBox comboBox = new ComboBox("City", cityContainer); comboBox.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY); comboBox.setItemCaptionPropertyId("name");
private ComboBox getDsComboField() { final Container container = createContainer(); final ComboBox dsComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("bulkupload.ds.name"), "", null, null, false, "", i18n.getMessage("bulkupload.ds.name")); dsComboBox.setSizeUndefined(); dsComboBox.addStyleName(SPUIDefinitions.BULK_UPLOD_DS_COMBO_STYLE); dsComboBox.setImmediate(true); dsComboBox.setFilteringMode(FilteringMode.STARTSWITH); dsComboBox.setPageLength(7); dsComboBox.setContainerDataSource(container); dsComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME_VERSION); dsComboBox.setId(UIComponentIdProvider.BULK_UPLOAD_DS_COMBO); dsComboBox.setWidth("100%"); return dsComboBox; }
private ComboBox getDsComboField() { final Container container = createContainer(); final ComboBox dsComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("bulkupload.ds.name"), "", null, null, false, "", i18n.getMessage("bulkupload.ds.name")); dsComboBox.setSizeUndefined(); dsComboBox.addStyleName(SPUIDefinitions.BULK_UPLOD_DS_COMBO_STYLE); dsComboBox.setImmediate(true); dsComboBox.setFilteringMode(FilteringMode.STARTSWITH); dsComboBox.setPageLength(7); dsComboBox.setContainerDataSource(container); dsComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME_VERSION); dsComboBox.setId(UIComponentIdProvider.BULK_UPLOAD_DS_COMBO); dsComboBox.setWidth("100%"); return dsComboBox; }
/** * Prepares a combo box.<p> * * @param container the indexed item container * @param captionKey the caption message key * * @return the combo box */ private ComboBox prepareComboBox(IndexedContainer container, String captionKey) { ComboBox result = new ComboBox(CmsVaadinUtils.getWpMessagesForCurrentLocale().key(captionKey), container); result.setTextInputAllowed(true); result.setNullSelectionAllowed(false); result.setWidth("100%"); result.setInputPrompt( Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_EXPLORER_CLICK_TO_EDIT_0)); result.setItemCaptionPropertyId(CAPTION_PROPERTY); result.setFilteringMode(FilteringMode.CONTAINS); return result; } }
/** * Prepares a combo box.<p> * * @param container the indexed item container * @param captionKey the caption message key * * @return the combo box */ private ComboBox prepareComboBox(IndexedContainer container, String captionKey) { ComboBox result = new ComboBox(CmsVaadinUtils.getWpMessagesForCurrentLocale().key(captionKey), container); result.setTextInputAllowed(true); result.setNullSelectionAllowed(false); result.setWidth("100%"); result.setInputPrompt( Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_EXPLORER_CLICK_TO_EDIT_0)); result.setItemCaptionPropertyId(CAPTION_PROPERTY); result.setFilteringMode(FilteringMode.CONTAINS); return result; } }
combo.setInputPrompt( Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_EXPLORER_CLICK_TO_EDIT_0)); combo.setItemCaptionPropertyId(SITE_CAPTION); combo.select(cms.getRequestContext().getSiteRoot()); combo.setFilteringMode(FilteringMode.CONTAINS);
getSiteSelector().setValue(m_siteRoot); getSiteSelector().setNullSelectionAllowed(false); getSiteSelector().setItemCaptionPropertyId(PROPERTY_SITE_CAPTION); getSiteSelector().setFilteringMode(FilteringMode.CONTAINS); getSiteSelector().addValueChangeListener(new ValueChangeListener() {