Java Code Examples for com.vaadin.ui.ComboBox#setValue()
The following examples show how to use
com.vaadin.ui.ComboBox#setValue() .
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: MaintenanceWindowLayout.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
/** * Combo box to pick the time zone offset. */ private void createMaintenanceTimeZoneControl() { // ComboBoxBuilder cannot be used here, because Builder do // 'comboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);' // which interferes our code: 'timeZone.addItems(getAllTimeZones());' timeZone = new ComboBox(); timeZone.setId(UIComponentIdProvider.MAINTENANCE_WINDOW_TIME_ZONE_ID); timeZone.setCaption(i18n.getMessage("caption.maintenancewindow.timezone")); timeZone.addItems(getAllTimeZones()); timeZone.setValue(getClientTimeZone()); timeZone.addStyleName(ValoTheme.COMBOBOX_SMALL); timeZone.setTextInputAllowed(false); timeZone.setNullSelectionAllowed(false); }
Example 3
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 4
Source File: DemoUI.java From gantt with Apache License 2.0 | 4 votes |
private Panel createControls() { Panel panel = new Panel(); panel.setWidth(100, Unit.PERCENTAGE); controls = new HorizontalLayout(); controls.setSpacing(true); controls.setMargin(true); panel.setContent(controls); subControls = new HorizontalLayout(); subControls.setSpacing(true); subControls.setVisible(false); start = createStartDateField(); end = createEndDateField(); Button createStep = new Button("Create New Step...", createStepClickListener); HorizontalLayout heightAndUnit = new HorizontalLayout(Util.createHeightEditor(gantt), Util.createHeightUnitEditor(gantt)); HorizontalLayout widthAndUnit = new HorizontalLayout(Util.createWidthEditor(gantt), Util.createWidthUnitEditor(gantt)); reso = new NativeSelect<Resolution>("Resolution"); reso.setEmptySelectionAllowed(false); reso.setItems(org.tltv.gantt.client.shared.Resolution.Hour, org.tltv.gantt.client.shared.Resolution.Day, org.tltv.gantt.client.shared.Resolution.Week); reso.setValue(gantt.getResolution()); resolutionValueChangeRegistration = Optional.of(reso.addValueChangeListener(resolutionValueChangeListener)); localeSelect = new NativeSelect<Locale>("Locale") { @Override public void attach() { super.attach(); if (getValue() == null) { // use default locale setValue(gantt.getLocale()); addValueChangeListener(localeValueChangeListener); } } }; localeSelect.setEmptySelectionAllowed(false); localeSelect.setItems(Locale.getAvailableLocales()); localeSelect.setItemCaptionGenerator((l) -> l.getDisplayName(getLocale())); ComboBox<String> timezoneSelect = new ComboBox<String>("Timezone"); timezoneSelect.setWidth(300, Unit.PIXELS); timezoneSelect.setEmptySelectionAllowed(false); timezoneSelect.setItemCaptionGenerator(new ItemCaptionGenerator<String>() { @Override public String apply(String item) { if ("Default".equals(item)) { return "Default (" + getDefaultTimeZone().getDisplayName() + ")"; } TimeZone tz = TimeZone.getTimeZone(item); return tz.getID() + " (raw offset " + (tz.getRawOffset() / 60000) + "m)"; } }); List<String> items = new ArrayList<>(); items.add("Default"); items.addAll(Gantt.getSupportedTimeZoneIDs()); timezoneSelect.setItems((caption, fltr) -> caption.contains(fltr), items); timezoneSelect.setValue("Default"); timezoneSelect.addValueChangeListener(timezoneValueChangeListener); final Button toggleSubControlsBtn = new Button("Show More Settings..."); toggleSubControlsBtn.addStyleName("link"); toggleSubControlsBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { subControls.setVisible(!subControls.isVisible()); toggleSubControlsBtn.setCaption(subControls.isVisible() ? "Less Settings..." : "More Settings..."); } }); controls.addComponent(start); controls.addComponent(end); controls.addComponent(reso); controls.addComponent(subControls); controls.addComponent(toggleSubControlsBtn); controls.setComponentAlignment(toggleSubControlsBtn, Alignment.BOTTOM_CENTER); subControls.addComponent(localeSelect); subControls.addComponent(timezoneSelect); subControls.addComponent(heightAndUnit); subControls.addComponent(widthAndUnit); subControls.addComponent(createStep); subControls.setComponentAlignment(createStep, Alignment.MIDDLE_LEFT); return panel; }
Example 5
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); }