List of usage examples for com.vaadin.ui NativeSelect NativeSelect
public NativeSelect(String caption)
From source file:com.skysql.manager.ui.MonitorsSettings.java
License:Open Source License
/** * Monitor form.// w ww .ja va2 s . c o m * * @param monitor the monitor * @param title the title * @param description the description * @param button the button */ public void monitorForm(final MonitorRecord monitor, String title, String description, String button) { final TextField monitorName = new TextField("Monitor Name"); final TextField monitorDescription = new TextField("Description"); final TextField monitorUnit = new TextField("Measurement Unit"); final TextArea monitorSQL = new TextArea("SQL Statement"); final CheckBox monitorDelta = new CheckBox("Is Delta"); final CheckBox monitorAverage = new CheckBox("Is Average"); final NativeSelect validationTarget = new NativeSelect("Validate SQL on"); final NativeSelect monitorInterval = new NativeSelect("Sampling interval"); final NativeSelect monitorChartType = new NativeSelect("Default display"); secondaryDialog = new ModalWindow(title, null); UI.getCurrent().addWindow(secondaryDialog); secondaryDialog.addCloseListener(this); final VerticalLayout formContainer = new VerticalLayout(); formContainer.setMargin(new MarginInfo(true, true, false, true)); formContainer.setSpacing(false); final Form form = new Form(); formContainer.addComponent(form); form.setImmediate(false); form.setFooter(null); form.setDescription(description); String value; if ((value = monitor.getName()) != null) { monitorName.setValue(value); } form.addField("monitorName", monitorName); form.getField("monitorName").setRequired(true); form.getField("monitorName").setRequiredError("Monitor Name is missing"); monitorName.focus(); monitorName.setImmediate(true); monitorName.addValidator(new MonitorNameValidator(monitor.getName())); if ((value = monitor.getDescription()) != null) { monitorDescription.setValue(value); } monitorDescription.setWidth("24em"); form.addField("monitorDescription", monitorDescription); if ((value = monitor.getUnit()) != null) { monitorUnit.setValue(value); } form.addField("monitorUnit", monitorUnit); if ((value = monitor.getSql()) != null) { monitorSQL.setValue(value); } monitorSQL.setWidth("24em"); monitorSQL.addValidator(new SQLValidator()); form.addField("monitorSQL", monitorSQL); final String noValidation = "None - Skip Validation"; validationTarget.setImmediate(true); validationTarget.setNullSelectionAllowed(false); validationTarget.addItem(noValidation); validationTarget.select(noValidation); OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); ArrayList<NodeInfo> nodes = overviewPanel.getNodes(); if (nodes == null || nodes.isEmpty()) { SystemInfo systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class); String systemID = systemInfo.getCurrentID(); String systemType = systemInfo.getCurrentSystem().getSystemType(); if (systemID.equals(SystemInfo.SYSTEM_ROOT)) { ClusterComponent clusterComponent = VaadinSession.getCurrent().getAttribute(ClusterComponent.class); systemID = clusterComponent.getID(); systemType = clusterComponent.getSystemType(); } nodes = new ArrayList<NodeInfo>(); for (String nodeID : systemInfo.getSystemRecord(systemID).getNodes()) { NodeInfo nodeInfo = new NodeInfo(systemID, systemType, nodeID); nodes.add(nodeInfo); } } for (NodeInfo node : nodes) { validationTarget.addItem(node.getID()); validationTarget.setItemCaption(node.getID(), node.getName()); } validationTarget.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { nodeID = (String) event.getProperty().getValue(); validateSQL = nodeID.equals(noValidation) ? false : true; } }); form.addField("validationTarget", validationTarget); monitorDelta.setValue(monitor.isDelta()); form.addField("monitorDelta", monitorDelta); monitorAverage.setValue(monitor.isAverage()); form.addField("monitorAverage", monitorAverage); SettingsValues intervalValues = new SettingsValues(SettingsValues.SETTINGS_MONITOR_INTERVAL); String[] intervals = intervalValues.getValues(); for (String interval : intervals) { monitorInterval.addItem(Integer.parseInt(interval)); } Collection<?> validIntervals = monitorInterval.getItemIds(); if (validIntervals.contains(monitor.getInterval())) { monitorInterval.select(monitor.getInterval()); } else { SystemInfo systemInfo = getSession().getAttribute(SystemInfo.class); String defaultInterval = systemInfo.getSystemRecord(systemID).getProperties() .get(SystemInfo.PROPERTY_DEFAULTMONITORINTERVAL); if (defaultInterval != null && validIntervals.contains(Integer.parseInt(defaultInterval))) { monitorInterval.select(Integer.parseInt(defaultInterval)); } else if (!validIntervals.isEmpty()) { monitorInterval.select(validIntervals.toArray()[0]); } else { new ErrorDialog(null, "No set of permissible monitor intervals found"); } monitorInterval.setNullSelectionAllowed(false); form.addField("monitorInterval", monitorInterval); } for (UserChart.ChartType type : UserChart.ChartType.values()) { monitorChartType.addItem(type.name()); } monitorChartType .select(monitor.getChartType() == null ? UserChart.ChartType.values()[0] : monitor.getChartType()); monitorChartType.setNullSelectionAllowed(false); form.addField("monitorChartType", monitorChartType); HorizontalLayout buttonsBar = new HorizontalLayout(); buttonsBar.setStyleName("buttonsBar"); buttonsBar.setSizeFull(); buttonsBar.setSpacing(true); buttonsBar.setMargin(true); buttonsBar.setHeight("49px"); Label filler = new Label(); buttonsBar.addComponent(filler); buttonsBar.setExpandRatio(filler, 1.0f); Button cancelButton = new Button("Cancel"); buttonsBar.addComponent(cancelButton); buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT); cancelButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { form.discard(); secondaryDialog.close(); } }); Button okButton = new Button(button); okButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { try { form.setComponentError(null); form.commit(); monitor.setName(monitorName.getValue()); monitor.setDescription(monitorDescription.getValue()); monitor.setUnit(monitorUnit.getValue()); monitor.setSql(monitorSQL.getValue()); monitor.setDelta(monitorDelta.getValue()); monitor.setAverage(monitorAverage.getValue()); monitor.setInterval((Integer) monitorInterval.getValue()); monitor.setChartType((String) monitorChartType.getValue()); String ID; if ((ID = monitor.getID()) == null) { if (Monitors.setMonitor(monitor)) { ID = monitor.getID(); select.addItem(ID); select.select(ID); Monitors.reloadMonitors(); monitorsAll = Monitors.getMonitorsList(systemType); } } else { Monitors.setMonitor(monitor); ChartProperties chartProperties = getSession().getAttribute(ChartProperties.class); chartProperties.setDirty(true); settingsDialog.setRefresh(true); } if (ID != null) { select.setItemCaption(ID, monitor.getName()); displayMonitorRecord(ID); secondaryDialog.close(); } } catch (EmptyValueException e) { return; } catch (InvalidValueException e) { return; } catch (Exception e) { ManagerUI.error(e.getMessage()); return; } } }); buttonsBar.addComponent(okButton); buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT); VerticalLayout windowLayout = (VerticalLayout) secondaryDialog.getContent(); windowLayout.setSpacing(false); windowLayout.setMargin(false); windowLayout.addComponent(formContainer); windowLayout.addComponent(buttonsBar); }
From source file:de.decidr.ui.view.TenantSettingsComponent.java
License:Apache License
/** * This method changes the view from advanced to basic. So only the basic * information are visible and the tenant can choose a given background or * font./*from ww w . j a va2 s. c o m*/ */ public void changeToBasic() { backgroundSelect = new NativeSelect("Background"); foregroundSelect = new NativeSelect("Foreground"); fontSelect = new NativeSelect("Font"); fontSizeSelect = new NativeSelect("Font Size"); fillSelects(); showAdvancedOptionsButton = new Button("Show CSS (advanced)"); showAdvancedOptionsButton.setSwitchMode(true); showAdvancedOptionsButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { changeToAdvanced(); } }); getSchemeHorizontalLayout().removeAllComponents(); getSchemeHorizontalLayout().addComponent(backgroundSelect); getSchemeHorizontalLayout().addComponent(foregroundSelect); getSchemeHorizontalLayout().addComponent(fontSelect); getSchemeHorizontalLayout().addComponent(fontSizeSelect); getSchemeHorizontalLayout().addComponent(showAdvancedOptionsButton); getSchemeHorizontalLayout().setComponentAlignment(showAdvancedOptionsButton, Alignment.BOTTOM_RIGHT); advancedMode = false; }
From source file:de.decidr.ui.view.WorkItemComponent.java
License:Apache License
/** * Set up the select box for showing all workitems or only those of the current tenant. *//*w w w.j a v a2s.c om*/ protected void initFilterSelect() { showWorkItemLabel = new Label("Show Work Items from: "); filterSelect = new NativeSelect(""); for (String item : FILTERS) { filterSelect.addItem(item); } filterSelect.setNullSelectionAllowed(false); filterSelect.select(FILTERS[0]); filterSelect.setImmediate(true); filterSelect.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { if (filterSelect.getValue() == FILTERS[0]) { replaceContentTable(filteredWorkItemsTable); } else { replaceContentTable(allWorkItemsTable); } } }); searchPanel.getSearchHorizontalLayout().addComponent(showWorkItemLabel); searchPanel.getSearchHorizontalLayout().addComponent(filterSelect); }
From source file:de.dimm.vsm.vaadin.VSMCMain.java
public <T> void SelectObject(Class<T> t, String caption, String buttonCaption, List<T> list, final SelectObjectCallback cb) { if (list.size() == 1) { cb.SelectedAction(list.get(0));// w w w .jav a2 s.co m return; } final NativeSelect sel = new NativeSelect(caption); sel.setNewItemsAllowed(false); sel.setInvalidAllowed(false); sel.setNullSelectionAllowed(false); for (int i = 0; i < list.size(); i++) { Object object = list.get(i); sel.addItem(object); } if (!list.isEmpty()) sel.setValue(list.get(0)); VerticalLayout vl = new VerticalLayout(); vl.setSpacing(true); NativeButton ok = new NativeButton(buttonCaption); final Window win = new Window(Txt("Auswahl") + " " + caption); win.setWidth("350px"); win.center(); ok.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { getRootWin().removeWindow(win); cb.SelectedAction(sel.getValue()); } }); vl.addComponent(sel); sel.setWidth("80%"); vl.addComponent(ok); vl.setComponentAlignment(ok, Alignment.BOTTOM_RIGHT); vl.setSizeFull(); win.addComponent(vl); getRootWin().addWindow(win); }
From source file:edu.nps.moves.mmowgli.modules.administration.AddCardClassDialog.java
License:Open Source License
public AddCardClassDialog(CardClass cls, String title) { super(title); this.cls = cls; VerticalLayout vl = new VerticalLayout(); setContent(vl);/*from w ww . j av a2 s. c om*/ vl.setSpacing(true); vl.setMargin(true); vl.setSizeUndefined(); vl.addComponent(titleTF = new TextField("Title")); titleTF.setValue("title goes here"); titleTF.setColumns(35); vl.addComponent(summTF = new TextField("Summary")); summTF.setValue("summary goes here"); summTF.setColumns(35); vl.addComponent(promptTF = new TextField("Prompt")); promptTF.setValue("prompt goes here"); promptTF.setColumns(35); vl.addComponent(colorCombo = new NativeSelect("Color")); fillCombo(); HorizontalLayout buttHL = new HorizontalLayout(); buttHL.setSpacing(true); buttHL.addComponent(cancelButt = new Button("Cancel")); cancelButt.addClickListener(new CancelListener()); buttHL.addComponent(saveButt = new Button("Save")); saveButt.addClickListener(new SaveListener()); vl.addComponent(buttHL); vl.setComponentAlignment(buttHL, Alignment.MIDDLE_RIGHT); }
From source file:edu.nps.moves.mmowgli.modules.administration.AddCardTypeDialog.java
License:Open Source License
public AddCardTypeDialog(int descType, String title) { super(title); this.typ = descType; VerticalLayout vl = new VerticalLayout(); setContent(vl);//from w w w .j a v a2 s. com vl.setSizeUndefined(); vl.setMargin(true); vl.setSpacing(true); vl.addComponent(titleTF = new TextField("Title")); titleTF.setValue("title goes here"); titleTF.setColumns(35); vl.addComponent(summTF = new TextField("Summary")); summTF.setValue("summary goes here"); summTF.setColumns(35); vl.addComponent(promptTF = new TextField("Prompt")); promptTF.setValue("prompt goes here"); promptTF.setColumns(35); vl.addComponent(colorCombo = new NativeSelect("Color")); fillCombo(); HorizontalLayout buttHL = new HorizontalLayout(); buttHL.setSpacing(true); buttHL.addComponent(cancelButt = new Button("Cancel")); cancelButt.addClickListener(new CancelListener()); buttHL.addComponent(saveButt = new Button("Save")); saveButt.addClickListener(new SaveListener()); vl.addComponent(buttHL); vl.setComponentAlignment(buttHL, Alignment.MIDDLE_RIGHT); }
From source file:facs.components.Booking.java
License:Open Source License
public Booking(final BookingModel bookingModel, Date referenceDate) { String[] sayHello = { "Kon'nichiwa", "Hello", "Halo", "Hiya", "Hej", "Hallo", "Hola", "Grezi", "Servus", "Merhaba", "Bonjour", "Ahoj", "Moi", "Ciao", "Buongiorno" }; this.bookingModel = bookingModel; this.referenceDate = referenceDate; Label infoLabel = new Label(); infoLabel.addStyleName("h4"); Label selectDeviceLabel = new Label(); selectDeviceLabel.addStyleName("h4"); selectDeviceLabel.setValue("Please Select a Device"); final Label versionLabel = new Label(); versionLabel.addStyleName("h4"); versionLabel.setValue("Version 0.1.160727"); // showSuccessfulNotification(sayHello[(int) (Math.random() * sayHello.length)] + ", " // + bookingModel.userName() + "!", ""); Date dNow = new Date(); SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss"); System.out.println(ft.format(dNow) + " INFO Calendar initiated! - User: " + bookingModel.getLDAP() + " " + versionLabel);/* w w w . java2 s . com*/ // only users who are allowed to book devices will be able to do so if (bookingModel.isNotAllowed()) { VerticalLayout errorLayout = new VerticalLayout(); infoLabel.setValue("ACCESS DENIED"); errorLayout.addComponent(infoLabel); showErrorNotification("Access Denied!", "Sorry, you're not allowed to see anything here, at least your username told us so. Do you need assistance? Please contact 'info@qbic.uni-tuebingen.de'."); setCompositionRoot(errorLayout); return; } Panel book = new Panel(); book.addStyleName(ValoTheme.PANEL_BORDERLESS); DBManager.getDatabaseInstance(); db = Database.Instance; db.userLogin(bookingModel.getLDAP()); selectedDevice = initCalendars(bookingModel.getDevicesNames()); selectedService = new NativeSelect("Please select a service:"); selectedService.setDescription("Please select the service you would like to receive!"); selectedKostenstelle = new NativeSelect("Please select konstenstelle:"); selectedKostenstelle.setDescription("Please select the Kostenstelle you would like to use!"); selectedDevice.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 8153818693511960689L; @Override public void valueChange(ValueChangeEvent event) { versionLabel.setValue(db.getUserRoleDescByLDAPId(bookingModel.getLDAP(), getCurrentDevice())); selectedKostenstelle.setVisible(true); if (bookMap.containsKey(getCurrentDevice())) { cal.removeAllComponents(); setCalendar(); if (selectedDevice.getValue().equals("Aria")) { selectedService.removeAllItems(); selectedService.addItems("Full Service", "Partial Service", "Self Service"); selectedService.setValue("Full Service"); selectedService.setVisible(true); } else if (selectedDevice.getValue().equals("Mac")) { selectedService.removeAllItems(); selectedService.addItems("Self", "Service"); selectedService.setValue("Service"); selectedService.setVisible(true); } else { selectedService.setValue(null); selectedService.setVisible(false); } } else { bookMap.put(getCurrentDevice(), initCal(bookingModel, getCurrentDevice())); cal.removeAllComponents(); setCalendar(); if (selectedDevice.getValue().equals("Aria")) { selectedService.removeAllItems(); selectedService.addItems("Full Service", "Partial Service", "Self Service"); selectedService.setValue("Full Service"); selectedService.setVisible(true); } else if (selectedDevice.getValue().equals("Mac")) { selectedService.removeAllItems(); selectedService.addItems("Self", "Service"); selectedService.setValue("Service"); selectedService.setVisible(true); } else { selectedService.setValue(null); selectedService.setVisible(false); } } } }); if (bookingModel.getProject().isEmpty()) { infoLabel.setValue(bookingModel.userName() + " Kostenstelle: " + bookingModel.getKostenstelle() + " Institute: " + bookingModel.getInstitute()); } else { infoLabel.setValue(bookingModel.userName() + " Kostenstelle: " + bookingModel.getKostenstelle() + " Project: " + bookingModel.getProject() + " Institute: " + bookingModel.getInstitute()); } // bookDeviceLayout.addComponent(infoLabel); cal.setLocale(Locale.getDefault()); cal.setImmediate(true); selectedService.setImmediate(true); cal.setSizeFull(); String submitTitle = "Book"; Button submit = new Button(submitTitle); submit.setIcon(FontAwesome.CALENDAR); submit.setDescription("Please select a device and a time frame at first then click 'BOOK'!"); submit.setSizeFull(); // submit.setVisible(false); submit.addClickListener(new ClickListener() { private static final long serialVersionUID = -3610721151565496269L; @Override public void buttonClick(ClickEvent event) { submit(bookingModel.getLDAP(), getCurrentDevice()); newEvents.clear(); refreshDataSources(); } }); String buttonTitle = "Refresh"; Button refresh = new Button(buttonTitle); refresh.setIcon(FontAwesome.REFRESH); refresh.setSizeFull(); refresh.setDescription("Click here to reload the data from the database!"); refresh.addStyleName(ValoTheme.BUTTON_FRIENDLY); refresh.addClickListener(new ClickListener() { private static final long serialVersionUID = -3610721151565496269L; @Override public void buttonClick(ClickEvent event) { refreshDataSources(); } }); gridLayout.setWidth("100%"); // add components to the grid layout gridLayout.addComponent(infoLabel, 0, 4, 3, 4); gridLayout.addComponent(versionLabel, 4, 4, 5, 4); // gridLayout.addComponent(selectDeviceLabel,0,1); gridLayout.addComponent(selectedDevice, 0, 0); gridLayout.addComponent(selectedService, 1, 0); gridLayout.addComponent(selectedKostenstelle, 2, 0); selectedService.setVisible(false); gridLayout.addComponent(cal, 0, 2, 5, 2); gridLayout.addComponent(refresh, 0, 3); gridLayout.addComponent(submit, 1, 3, 5, 3); // gridLayout.addComponent(myBookings(), 0, 5, 5, 5); gridLayout.setMargin(true); gridLayout.setSpacing(true); gridLayout.setSizeFull(); book.setContent(gridLayout); booking = new TabSheet(); booking.addStyleName(ValoTheme.TABSHEET_FRAMED); booking.addTab(book).setCaption("Calendar"); booking.addTab(myNext24HoursBookings()).setCaption("Next 24 Hours"); booking.addTab(myUpcomingBookings()).setCaption("Upcoming"); booking.addTab(myPastBookings()).setCaption("Past Bookings"); // booking.addTab(myUpcomingBookingsSQLContainer()).setCaption("Test"); setCompositionRoot(booking); }
From source file:facs.components.UploadBox.java
License:Open Source License
public UploadBox() { this.setCaption(CAPTION); // there has to be a device selected. devices = new NativeSelect("Devices"); devices.setDescription("Select a device in order to upload information for that specific devices."); devices.setNullSelectionAllowed(false); deviceNameToId = new HashMap<String, Integer>(); for (DeviceBean bean : DBManager.getDatabaseInstance().getDevices()) { deviceNameToId.put(bean.getName(), bean.getId()); devices.addItem(bean.getName()); // System.out.println("Bean.getName: " + bean.getName() + " Bean.getId: " + bean.getId()); }/*from www . jav a 2s. c o m*/ occupationGrid = new Grid(); occupationGrid.setSizeFull(); // Create the upload component and handle all its events final Upload upload = new Upload(); upload.setReceiver(this); upload.addProgressListener(this); upload.addFailedListener(this); upload.addSucceededListener(this); upload.setVisible(false); // one can only upload csvs, if a device was selected. devices.addValueChangeListener(new ValueChangeListener() { /** * */ private static final long serialVersionUID = 7890499571475184208L; @Override public void valueChange(ValueChangeEvent event) { upload.setVisible(event.getProperty().getValue() != null); } }); // Put the upload and image display in a panel // Panel panel = new Panel(UPLOAD_CAPTION); // panel.setWidth("100%"); VerticalLayout panelContent = new VerticalLayout(); panelContent.setSpacing(true); // panel.setContent(panelContent); panelContent.addComponent(devices); panelContent.addComponent(upload); panelContent.addComponent(progress); panelContent.addComponent(occupationGrid); panelContent.setMargin(true); panelContent.setSpacing(true); progress.setVisible(false); setCompositionRoot(panelContent); }
From source file:fi.jasoft.qrcode.demo.QRCodeDemo.java
License:Apache License
private NativeSelect<Color> createPrimaryColorSelect() { List<Color> colors = Arrays.asList(Color.BLACK, Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW); NativeSelect<Color> fgColor = new NativeSelect<Color>("Primary color"); fgColor.setWidth("100px"); fgColor.setItemCaptionGenerator(color -> { switch (colors.indexOf(color)) { case 0:/*from w ww. jav a 2 s . c o m*/ return "Black"; case 1: return "Red"; case 2: return "Green"; case 3: return "Blue"; case 4: return "Yellow"; } return "Black"; }); fgColor.setItems(colors); fgColor.setValue(Color.BLACK); fgColor.addValueChangeListener(e -> code.setPrimaryColor(e.getValue())); return fgColor; }
From source file:fi.jasoft.qrcode.demo.QRCodeDemo.java
License:Apache License
private NativeSelect<Color> createSecondaryColorSelect() { List<Color> colors = Arrays.asList(Color.WHITE, new Color(255, 0, 0, 50), new Color(0, 255, 0, 50), new Color(0, 0, 255, 50), new Color(255, 255, 0, 50)); final NativeSelect<Color> bgColor = new NativeSelect<Color>("Secondary color"); bgColor.setWidth("100px"); bgColor.setItemCaptionGenerator(color -> { switch (colors.indexOf(color)) { case 0:// w w w .j av a 2 s.c o m return "White"; case 1: return "Red"; case 2: return "Green"; case 3: return "Blue"; case 4: return "Yellow"; } return "White"; }); bgColor.setItems(colors); bgColor.setValue(Color.WHITE); bgColor.addValueChangeListener(e -> code.setSecondaryColor(e.getValue())); return bgColor; }