Java Code Examples for com.vaadin.ui.ComboBox#addItem()
The following examples show how to use
com.vaadin.ui.ComboBox#addItem() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WinServerAddSimple.java From primecloud-controller with GNU General Public License v2.0 | 6 votes |
@Override public void attach() { // サーバ名(Prefix) prefixField = new TextField(ViewProperties.getCaption("field.serverNamePrefix")); getLayout().addComponent(prefixField); // プラットフォーム cloudTable = new SelectCloudTable(); getLayout().addComponent(cloudTable); // サーバ台数 serverNumber = new ComboBox(ViewProperties.getCaption("field.serverNumber")); serverNumber.setWidth("110px"); serverNumber.setMultiSelect(false); for (int i = 1; i <= MAX_ADD_SERVER; i++) { serverNumber.addItem(i); } serverNumber.setNullSelectionAllowed(false); serverNumber.setValue(1); // 初期値は1 getLayout().addComponent(serverNumber); initValidation(); }
Example 2
Source File: InputOutputUI.java From chipster with MIT License | 5 votes |
protected void initElements() { type2 = new ComboBox(); type2.setImmediate(true); type2.setWidth(WIDTH); lbMeta = new Label("Meta:"); cbMeta = new CheckBox(); cbMeta.setDescription("Is this element Meta data"); optional.setWidth(WIDTH); type = new ComboBox(); type.setWidth(WIDTH); type.setNullSelectionAllowed(false); type.setImmediate(true); type.addItem(SINGLE_FILE); type.addItem(MULTI_FILE); type.select(SINGLE_FILE); type.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = -1134955257251483403L; @Override public void valueChange(ValueChangeEvent event) { if(type.getValue().toString().contentEquals(SINGLE_FILE)) { getSingleFileUI(); } else if(type.getValue().toString().contentEquals(MULTI_FILE)){ getMultipleFilesUI(); } } }); }
Example 3
Source File: ComboBoxFieldBuilder.java From jdal with Apache License 2.0 | 5 votes |
/** * Fill the ComboBox with items from PersistentService * @param combo ComboBox to fill * @param clazz Class of Bean containing property name * @param name property name */ protected void fillComboBox(ComboBox combo, Class<?> clazz, String name) { PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(clazz, name); Dao<?, Serializable> service = persistentServiceFactory.createPersistentService(pd.getPropertyType()); // fill combo Iterator<?> iter = service.getAll().iterator(); while(iter.hasNext()) combo.addItem(iter.next()); }
Example 4
Source File: FormUtils.java From jdal with Apache License 2.0 | 5 votes |
/** * Fill combo with a list of objeces. * @param data list to fill with. * @param clear true if clear all items before adding new ones. */ public static void fillCombo(ComboBox combo, List<?> data, boolean clear) { Object selected = combo.getValue(); if (clear) { combo.removeAllItems(); } for (Object o : data) { combo.addItem(o); } if (data.contains(selected)) combo.setValue(selected); }
Example 5
Source File: OldLoginView.java From gazpachoquest with GNU General Public License v3.0 | 4 votes |
private void addLocale(Locale locale, ComboBox languageSelector) { languageSelector.addItem(locale); languageSelector.setItemCaption(locale, "XX"); }
Example 6
Source File: OldLoginView.java From gazpachoquest with GNU General Public License v3.0 | 4 votes |
public OldLoginView() { setSizeFull(); // Language bar in the top-right corner for selecting // invitation interface language final HorizontalLayout languageBar = new HorizontalLayout(); languageBar.setHeight("50px"); // addComponent(languageBar); // setComponentAlignment(languageBar, Alignment.TOP_RIGHT); // Allow selecting a language. We are in a constructor of a // CustomComponent, so preselecting the current // language of the application can not be done before // this (and the selection) component are attached to // the application. final ComboBox languageSelector = new ComboBox("Select a language") { @Override public void attach() { super.attach(); // setValue(getLocale()); } }; // for (int i=0; i<locales.length; i++) { String locale = "es"; languageSelector.addItem(locale); languageSelector.setItemCaption(locale, "español"); // Automatically select the current locale // if (locales[i].equals(getLocale())) languageSelector.setValue(locale); // } // Create the invitation input field invitationTextField = new TextField("Invitation key:"); invitationTextField.setWidth("300px"); invitationTextField.setRequired(true); invitationTextField.setInputPrompt("Your questionnair invitation key (eg. 12345678)"); invitationTextField.setInvalidAllowed(false); // Create login button enterButton = new Button("Enter", this); // Add both to a panel VerticalLayout fields = new VerticalLayout(languageSelector, invitationTextField, enterButton); fields.setCaption("Please enter your invitation key to access the questionnair"); fields.setSpacing(true); fields.setMargin(new MarginInfo(true, true, true, false)); fields.setSizeUndefined(); // The view root layout VerticalLayout viewLayout = new VerticalLayout(fields); viewLayout.setSizeFull(); viewLayout.setComponentAlignment(fields, Alignment.MIDDLE_CENTER); viewLayout.setStyleName(Reindeer.LAYOUT_BLUE); setCompositionRoot(viewLayout); }