List of usage examples for com.vaadin.ui ComboBox setPageLength
public void setPageLength(int pageLength)
From source file:fi.semantum.strategia.widget.Property.java
License:Open Source License
public static void updateProperties(final Main main, final Base base, boolean canWrite) { final Database database = main.getDatabase(); String headerText = main.getUIState().currentItem.getCaption(database); main.propertyCells.add(Utils.excelRow(headerText)); Label header = new Label(headerText); header.setWidth("800px"); header.addStyleName("propertyHeader"); header.addStyleName(ValoTheme.LABEL_HUGE); header.addStyleName(ValoTheme.LABEL_BOLD); main.properties.addComponent(header); main.properties.setComponentAlignment(header, Alignment.MIDDLE_CENTER); ArrayList<Pair> sorted = new ArrayList<Pair>(main.getUIState().currentItem.properties); Collections.sort(sorted, new Comparator<Pair>() { @Override/*from w w w .j av a 2 s . c o m*/ public int compare(Pair arg0, Pair arg1) { final Property p0 = database.find(arg0.first); final Property p1 = database.find(arg1.first); return p0.getId(database).compareTo(p1.getId(database)); } }); Property typeProperty = Property.find(database, Property.TYPE); for (Pair pair : sorted) { // Skip type if (typeProperty.uuid.equals(pair.first)) continue; final Property p = database.find(pair.first); String value = pair.second; final HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); String label = p.getText(database); main.propertyCells.add(Utils.excelRow(label, value)); Label l = new Label(label); l.setWidth("450px"); l.addStyleName("propertyName"); hl.addComponent(l); List<String> enumeration = p.getEnumeration(database); if (enumeration.isEmpty()) { final TextField tf = new TextField(); tf.setValue(value); tf.setWidth("350px"); hl.addComponent(tf); hl.setComponentAlignment(tf, Alignment.MIDDLE_LEFT); tf.setReadOnly(p.readOnly); tf.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 7729833503749464603L; @Override public void valueChange(ValueChangeEvent event) { Utils.loseFocus(hl); if (p.set(main, main.getUIState().currentItem, tf.getValue())) Updates.update(main, true); } }); tf.setReadOnly(!canWrite); } else { final ComboBox combo = new ComboBox(); combo.setWidth("350px"); combo.setInvalidAllowed(false); combo.setNullSelectionAllowed(false); for (String e : enumeration) { combo.addItem(e); } combo.select(p.getEnumerationValue(database, value)); combo.setPageLength(0); combo.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 3511164709346832901L; @Override public void valueChange(ValueChangeEvent event) { Utils.loseFocus(hl); if (p.set(main, main.getUIState().currentItem, combo.getValue().toString())) Updates.update(main, true); } }); combo.setReadOnly(!canWrite); hl.addComponent(combo); hl.setComponentAlignment(combo, Alignment.MIDDLE_LEFT); } hl.setComponentAlignment(l, Alignment.MIDDLE_LEFT); main.properties.addComponent(hl); main.properties.setComponentAlignment(hl, Alignment.MIDDLE_CENTER); } }
From source file:org.eclipse.hawkbit.ui.common.builder.ComboBoxBuilder.java
License:Open Source License
/** * @return a new ComboBox// w ww. j a v a 2 s .com */ 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; }
From source file:org.eclipse.hawkbit.ui.management.targettable.TargetBulkUpdateWindowLayout.java
License:Open Source License
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();/* w w w .j a v a2s . c o m*/ 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; }
From source file:org.opencms.ui.apps.CmsFileExplorer.java
License:Open Source License
/** * Creates the site selector combo box.<p> * * @param cms the current cms context/*w ww .jav a2s . c o m*/ * * @return the combo box */ private ComboBox createSiteSelect(CmsObject cms) { final IndexedContainer availableSites = CmsVaadinUtils.getAvailableSitesContainer(cms, SITE_CAPTION); ComboBox combo = new ComboBox(null, availableSites); combo.setTextInputAllowed(true); combo.setNullSelectionAllowed(false); combo.setWidth("200px"); 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); combo.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); if (availableSites.containsId(value)) { changeSite(value, null); m_appContext.updateOnChange(); availableSites.removeAllContainerFilters(); } } }); if (Page.getCurrent().getBrowserWindowHeight() > 650) { combo.setPageLength(20); } return combo; }
From source file:org.opencms.ui.dataview.CmsDataViewPanel.java
License:Open Source License
/** * Changes the displayed filters to a new set.<p> * * @param newFilters the new filters/*from ww w . j a v a 2 s .co m*/ */ public void updateFilters(List<CmsDataViewFilter> newFilters) { if (newFilters.isEmpty()) { m_filterContainer.setVisible(false); } if (m_filters.equals(newFilters)) { return; } m_filterContainer.removeAllComponents(); m_filters = newFilters; m_filterMap.clear(); for (CmsDataViewFilter filter : newFilters) { m_filterMap.put(filter.getId(), filter); final CmsDataViewFilter finalFilter = filter; ComboBox select = new ComboBox(filter.getNiceName()); select.setWidth("175px"); select.setNullSelectionAllowed(false); select.setPageLength(0); Map<String, String> options = filter.getOptions(); for (Map.Entry<String, String> entry : options.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); select.addItem(key); select.setItemCaption(key, value); } select.setValue(filter.getValue()); if (filter.getHelpText() != null) { select.setDescription(filter.getHelpText()); } select.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { String newValue = (String) (event.getProperty().getValue()); updateFilter(finalFilter.getId(), newValue); } }); m_filterContainer.addComponent(select); } }
From source file:org.opencms.workplace.tools.git.ui.CmsGitToolOptionsPanel.java
License:Open Source License
/** * Creates a new module selector, containing only the modules for which no check box is already displayed.<p> * * @return the new module selector//from w ww. ja v a 2 s. c om */ private ComboBox createModuleSelector() { ComboBox result = new ComboBox(); result.setPageLength(20); result.setWidth("350px"); result.setFilteringMode(FilteringMode.CONTAINS); result.setNewItemsAllowed(false); result.setNullSelectionAllowed(false); List<String> moduleNames = Lists.newArrayList(); for (CmsModule module : OpenCms.getModuleManager().getAllInstalledModules()) { String moduleName = module.getName(); if (!m_moduleCheckboxes.containsKey(moduleName)) { moduleNames.add(moduleName); } } Collections.sort(moduleNames); for (String moduleName : moduleNames) { result.addItem(moduleName); } return result; }
From source file:org.vaadin.spinkit.demo.DemoUI.java
License:Apache License
private Component spinnerSizesContainer() { int types = SpinnerSize.values().length; GridLayout spinners = new GridLayout(4, (types / 4 + types % 4)); spinners.setSizeFull();/*from www. j av a 2s . c o m*/ spinners.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); spinners.setSpacing(true); ComboBox selector = new ComboBox("Select spinner type", Arrays.asList(SpinnerType.values())); selector.setNullSelectionAllowed(false); selector.setPageLength(0); selector.setValue(SpinnerType.ROTATING_PLANE); selector.addValueChangeListener(e -> { for (Component c : spinners) { if (c instanceof Spinner) { ((Spinner) c).setType((SpinnerType) selector.getValue()); } } }); StringToEnumConverter converter = new StringToEnumConverter(); for (SpinnerSize size : SpinnerSize.values()) { Spinner spinner = new Spinner(SpinnerType.ROTATING_PLANE); spinner.setSize(size); spinner.setCaption(converter.convertToPresentation(size, String.class, getLocale())); spinners.addComponent(spinner); } VerticalLayout l = new VerticalLayout(); l.setDefaultComponentAlignment(Alignment.TOP_CENTER); l.setSizeFull(); l.setMargin(false); l.setSpacing(true); l.addComponents(selector, spinners); l.setExpandRatio(spinners, 1); return l; }
From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.PopupRecombineDiseaseGroups.java
private ComboBox generateLabelList(String diseaseCategory) { final ComboBox diseaseGroupsList = new ComboBox(); diseaseGroupsList.setStyleName("diseasegrouplist"); diseaseGroupsList.setNullSelectionAllowed(false); diseaseGroupsList.setImmediate(true); diseaseGroupsList.setNewItemsAllowed(true); diseaseGroupsList.setWidth(300, Unit.PIXELS); diseaseGroupsList.setInputPrompt("Select or enter new disease group name"); diseaseGroupsList.setPageLength(500); for (String name : default_DiseaseCat_DiseaseGroupMap.get(diseaseCategory).values()) { diseaseGroupsList.addItem(name); if (!captionAstrMap.containsKey(name)) { captionAstrMap.put(name, 0); }/*from w ww . ja va 2 s . c o m*/ } diseaseGroupsList.setNewItemHandler(new AbstractSelect.NewItemHandler() { @Override public void addNewItem(String newItemCaption) { diseaseGroupsList.addItem(newItemCaption + "*"); diseaseGroupsList.select(newItemCaption + "*"); captionAstrMap.put(newItemCaption + "*", 1); } }); diseaseGroupsList.setHeight("24px"); diseaseGroupsList.addValueChangeListener(new Property.ValueChangeListener() { private String lastSelected = ""; @Override public void valueChange(Property.ValueChangeEvent event) { String selectedItem = event.getProperty().getValue().toString(); if (!selectedItem.equalsIgnoreCase(diseaseGroupsList.getData().toString())) { String astr = ""; if (!selectedItem.contains("*")) { astr = "*"; captionAstrMap.put(selectedItem, captionAstrMap.get(selectedItem) + 1); } else { } diseaseGroupsList.setItemCaption(selectedItem, selectedItem + astr); } else { diseaseGroupsList.setItemCaption(diseaseGroupsList.getData().toString(), diseaseGroupsList.getData().toString()); } if (!lastSelected.equalsIgnoreCase("")) { captionAstrMap.put(lastSelected, Math.max(captionAstrMap.get(lastSelected) - 1, 0)); } lastSelected = selectedItem; } }); return diseaseGroupsList; }