List of usage examples for com.vaadin.ui ComboBox ComboBox
public ComboBox(String caption, Collection<T> options)
From source file:annis.gui.controlpanel.SearchOptionsPanel.java
License:Apache License
public SearchOptionsPanel() { setWidth("100%"); setHeight("-1px"); pbLoadConfig = new ProgressBar(); pbLoadConfig.setIndeterminate(true); pbLoadConfig.setCaption("Loading search options..."); addComponent(pbLoadConfig);// w w w .j a v a 2 s.com cbLeftContext = new ComboBox("Left Context", contextContainerLeft); cbRightContext = new ComboBox("Right Context", contextContainerRight); cbResultsPerPage = new ComboBox("Results Per Page", resultsPerPageContainer); cbLeftContext.setNullSelectionAllowed(false); cbRightContext.setNullSelectionAllowed(false); cbResultsPerPage.setNullSelectionAllowed(false); cbLeftContext.setNewItemsAllowed(true); cbRightContext.setNewItemsAllowed(true); cbResultsPerPage.setNewItemsAllowed(true); cbLeftContext.setTextInputAllowed(true); cbRightContext.setTextInputAllowed(true); cbResultsPerPage.setTextInputAllowed(true); cbLeftContext.setImmediate(true); cbRightContext.setImmediate(true); cbResultsPerPage.setImmediate(true); cbSegmentation = new ComboBox("Show context in", segmentationContainer); cbSegmentation.setTextInputAllowed(false); cbSegmentation.setNullSelectionAllowed(true); cbSegmentation.setNewItemsAllowed(true); cbSegmentation.setNullSelectionItemId(NULL_SEGMENTATION_VALUE); cbSegmentation.addItem(NULL_SEGMENTATION_VALUE); cbSegmentation.setDescription("If corpora with multiple " + "context definitions are selected, a list of available context units will be " + "displayed. By default context is calculated in tokens " + "(e.g. 5 minimal units to the left and right of a search result). " + "Some corpora might offer further context definitions, e.g. in " + "syllables, word forms belonging to different speakers, normalized or " + "diplomatic segmentations of a manuscript, etc."); segmentationHelp = new HelpButton(cbSegmentation); cbOrder = new ComboBox("Order", orderContainer); cbOrder.setNewItemsAllowed(false); cbOrder.setNullSelectionAllowed(false); cbOrder.setImmediate(true); cbLeftContext.setVisible(false); cbRightContext.setVisible(false); cbResultsPerPage.setVisible(false); cbOrder.setVisible(false); segmentationHelp.setVisible(false); addComponent(cbLeftContext); addComponent(cbRightContext); addComponent(segmentationHelp); addComponent(cbResultsPerPage); addComponent(cbOrder); }
From source file:com.cms.utils.ComboComponent.java
public ComboComponent(String all, String vaDefault, List<AppParamsDTO> appPatamDTO, String parType) { if (DataUtil.isListNullOrEmpty(appPatamDTO)) { appPatamDTO = Lists.newArrayList(); }//from w w w.j a v a2 s . c o m Layout layout = new HorizontalLayout(); final BeanItemContainer<AppParamsDTO> container = new BeanItemContainer<AppParamsDTO>(AppParamsDTO.class); parType = parType.replace('_', '.').toLowerCase() + "."; if (appPatamDTO != null && appPatamDTO.size() > 0) { for (int i = 0; i < appPatamDTO.size(); i++) { if (appPatamDTO.get(i).getParCode().equalsIgnoreCase(vaDefault) && !DataUtil.isStringNullOrEmpty(vaDefault)) { appPatamDTO.get(i) .setDisplayName(BundleUtils.getString(parType + appPatamDTO.get(i).getParName())); objDefault = appPatamDTO.get(i); } } } // select all if (!DataUtil.isStringNullOrEmpty(all)) { objall.setDisplayName(BundleUtils.getString(parType + all)); appPatamDTO.add(0, objall); } container.addAll(appPatamDTO); combo = new ComboBox("", container); layout.addComponent(combo); combo.setItemCaptionPropertyId("valueLangView"); combo.setNullSelectionAllowed(false); // default if (!DataUtil.isStringNullOrEmpty(all)) { combo.setValue(objall); } else if (objDefault != null && !DataUtil.isStringNullOrEmpty(vaDefault)) { combo.setValue(objDefault); } setCompositionRoot(layout); setSizeFull(); }
From source file:com.esspl.datagen.ui.ExecutorView.java
License:Open Source License
public ExecutorView(DataGenApplication application) { log.debug("ExecutorView - constructor start"); dataGenApplication = application;//from w ww . j a va2s. co m setSizeFull(); VerticalLayout vl = new VerticalLayout(); vl.setSizeFull(); setCompositionRoot(vl); splitPanel = new VerticalSplitPanel(); splitPanel.setSizeFull(); //Script TextArea sqlScript = new TextArea(); sqlScript.setSizeFull(); sqlScript.setWordwrap(false); sqlScript.setStyleName("noResizeTextArea"); HorizontalLayout queryOptions = new HorizontalLayout(); queryOptions.setMargin(false, false, false, true); queryOptions.setSpacing(true); queryOptions.setWidth("100%"); queryOptions.setHeight("40px"); Button executeButton = new Button("Execute", new ClickListener() { @Override public void buttonClick(ClickEvent event) { log.info("ExecutorView - Execute Button clicked"); executeScript(sqlScript.getValue().toString()); } }); executeButton.addStyleName("small"); executeButton.setIcon(DataGenConstant.EXECUTOR_ICON); executeButton.setDescription("Press Ctrl+Enter to execute the query"); Button clearQueryButton = new Button("Clear SQL", new ClickListener() { @Override public void buttonClick(ClickEvent event) { log.info("ExecutorView - Clear SQL Button clicked"); sqlScript.setValue(""); } }); clearQueryButton.addStyleName("small"); clearQueryButton.setIcon(DataGenConstant.CLEAR_SMALL); clearQueryButton.setDescription("Clears the Sql"); Button clearConsoleButton = new Button("Clear Console", new ClickListener() { @Override public void buttonClick(ClickEvent event) { log.info("ExecutorView - Clear Console Button clicked"); logText.setValue(""); } }); clearConsoleButton.addStyleName("small"); clearConsoleButton.setIcon(DataGenConstant.CLEAR_SMALL); clearConsoleButton.setDescription("Clears the Console"); maxRowsBox = new ComboBox(null, Arrays.asList(10, 100, 500, 1000, 5000, 10000)); maxRowsBox.setDescription("Max number of rows to retrieve"); maxRowsBox.setWidth(100, UNITS_PIXELS); maxRowsBox.setNewItemsAllowed(false); maxRowsBox.setNullSelectionAllowed(false); maxRowsBox.setValue(100); //Bottom section components resultSheet = new TabSheet(); resultSheet.setSizeFull(); resultSheet.addStyleName(Runo.TABSHEET_SMALL); logText = new Label(); logText.setContentMode(Label.CONTENT_XHTML); logText.setSizeFull(); //Panel to add refresher logPanel = new Panel(); logPanel.setSizeFull(); logPanel.setScrollable(true); logPanel.setStyleName(Runo.PANEL_LIGHT); logPanel.addComponent(logText); //Refresher added to show instant log messages refresher = new Refresher(); logPanel.addComponent(refresher); //Loading image loadingImg = new Embedded("", DataGenConstant.LOADING_ICON); loadingImg.setVisible(false); logPanel.addComponent(loadingImg); resultSheet.addTab(logPanel, "Console"); resultTab = resultSheet.addTab(new Label(), "Results"); queryOptions.addComponent(executeButton); queryOptions.setComponentAlignment(executeButton, Alignment.MIDDLE_LEFT); queryOptions.addComponent(clearQueryButton); queryOptions.setComponentAlignment(clearQueryButton, Alignment.MIDDLE_LEFT); queryOptions.addComponent(clearConsoleButton); queryOptions.setComponentAlignment(clearConsoleButton, Alignment.MIDDLE_LEFT); queryOptions.setExpandRatio(clearConsoleButton, 1); queryOptions.addComponent(maxRowsBox); queryOptions.setComponentAlignment(maxRowsBox, Alignment.MIDDLE_RIGHT); splitPanel.setFirstComponent(sqlScript); splitPanel.setSecondComponent(resultSheet); vl.addComponent(queryOptions); vl.addComponent(splitPanel); vl.setExpandRatio(splitPanel, 1); sqlScript.addShortcutListener(new ShortcutListener("Execute Script", null, ShortcutAction.KeyCode.ENTER, ShortcutAction.ModifierKey.CTRL) { @Override public void handleAction(Object sender, Object target) { executeScript(sqlScript.getValue().toString()); } }); log.debug("ExecutorView - constructor end"); }
From source file:com.esspl.datagen.ui.TableSelectorView.java
License:Open Source License
protected Component createSelectors() throws SQLException { FormLayout l = new FormLayout(); l.setWidth("100%"); l.setSpacing(false);/*from w w w . ja va 2 s .c om*/ l.setMargin(true, false, true, false); String catalogTerm = (metadataRetriever != null) ? metadataRetriever.getCatalogTerm() : "DataBase"; catalogTerm = catalogTerm.substring(0, 1).toUpperCase() + catalogTerm.substring(1, catalogTerm.length()); List<String> catalogNames = (metadataRetriever != null) ? metadataRetriever.getCatalogs() : new ArrayList<String>(); final ComboBox catalogs = new ComboBox(catalogTerm + ":", catalogNames); catalogs.setWidth("100%"); catalogs.setNullSelectionAllowed(false); catalogs.setImmediate(true); catalogs.setVisible(!catalogNames.isEmpty()); String schemaTerm = (metadataRetriever != null) ? metadataRetriever.getSchemaTerm().toLowerCase() : "DataBase"; schemaTerm = schemaTerm.substring(0, 1).toUpperCase() + schemaTerm.substring(1, schemaTerm.length()); List<String> schemaNames = (metadataRetriever != null) ? metadataRetriever.getSchemas() : new ArrayList<String>(); final ComboBox schemas = new ComboBox(schemaTerm + ":", schemaNames); schemas.setWidth("100%"); schemas.setNullSelectionAllowed(false); schemas.setImmediate(true); schemas.setVisible(!schemaNames.isEmpty()); List<String> tableTypesList = (metadataRetriever != null) ? metadataRetriever.getTableTypes() : new ArrayList<String>(); final ComboBox tableTypes = new ComboBox("Object:", tableTypesList); if (tableTypesList.contains("TABLE")) tableTypes.select("TABLE"); tableTypes.setWidth("100%"); tableTypes.setNullSelectionAllowed(false); tableTypes.setImmediate(true); ValueChangeListener valueChangeListener = new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { updateTableList(catalogs, schemas, tableTypes); } }; catalogs.addListener(valueChangeListener); schemas.addListener(valueChangeListener); tableTypes.addListener(valueChangeListener); l.addComponent(catalogs); l.addComponent(schemas); l.addComponent(tableTypes); return l; }
From source file:com.example.vaadindemo.AddItemPanel.java
public HorizontalLayout draw(BeanItemContainer<ShoppingList> container) { final HorizontalLayout x = new HorizontalLayout(); x.setId("addItemPanel"); Button persistNewItemButton = new Button("Dodaj"); final Item item = new Item(); BeanItem<Item> personBean = new BeanItem<Item>(item); final FormLayout formLayout = new FormLayout(); final FieldGroup form = new FieldGroup(); //new name: form form.setItemDataSource(personBean);/*from w w w . j a v a 2 s .c om*/ form.setBuffered(true); Field imieField = form.buildAndBind("Name", "firstName"); imieField.setRequired(true); imieField.addValidator(new StringLengthValidator("bad length", 2, 5, false)); formLayout.addComponent(imieField); //Container final BeanItemContainer<Item> beanContainer = new BeanItemContainer<Item>(Item.class); //beanContainer.addBean(new Item(); //beanContainer.addBean(new Item("Bolek")); //beanContainer.addBean(new Person("Lolek", 1933)); // Put some example data in it container.addItem(new ShoppingList("Mercury", null, null)); //container.addItem(new Planet(2, "Venus")); //container.addItem(new Planet(3, "Earth")); //container.addItem(new Planet(4, "Mars")); // Create a selection component bound to the container final ComboBox select = new ComboBox("Planets", container); // Set the caption mode to read the caption directly // from the 'name' property of the bean select.setItemCaptionMode(ItemCaptionMode.PROPERTY); select.setItemCaptionPropertyId("name"); select.setImmediate(true); final Label ldd = new Label(); x.addComponent(select); x.addComponent(formLayout); x.addComponent(persistNewItemButton); x.addComponent(ldd); persistNewItemButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Label l = new Label("jsdcbsc"); x.addComponent(l); //ldd.setValue(select.getItem(item.firstName).toString()); } }); select.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { ldd.setValue(select.getItemCaption(event.getProperty().getValue())); } }); return x; }
From source file:com.github.daytron.containersdatasource.BeanSampleCombo.java
License:Open Source License
public BeanSampleCombo() { Person person1 = new Person(1L, "John", "DOE", new Date(70, 0, 1)); Person person2 = new Person(2L, "Jane", "doe", new Date(70, 0, 1)); Person person3 = new Person(3L, "jules", "winnf", new Date(48, 11, 21)); Person person4 = new Person(4L, "vincent", "Vega", new Date(54, 1, 17)); container = new BeanItemContainer<>(Person.class); container.addAll(Arrays.asList(person1, person2, person3, person4)); ComboBox comboBox = new ComboBox("List Of Persons", container); comboBox.setImmediate(true);// w ww .j a v a 2s .c o m comboBox.setNullSelectionAllowed(true); comboBox.setItemCaptionPropertyId("fullname"); comboBox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { AbstractSelect combo = (AbstractSelect) event.getProperty(); Person selected = (Person) combo.getValue(); if (selected == null) { Notification.show("Null selected"); } else { Notification.show(selected.getId() + ": " + selected.getFullname(), Notification.Type.HUMANIZED_MESSAGE); } } }); addComponent(comboBox); }
From source file:com.gmail.volodymyrdotsenko.cms.fe.vaadin.LoginUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { langRepo.findAll().forEach(e -> { langSet.add(e.getCode());//from w ww .j a va2s . c om }); lang = new ComboBox("Language", langSet); getPage().setTitle("CMS"); FormLayout loginForm = new FormLayout(); loginForm.setSizeUndefined(); loginForm.addComponent(userName = new TextField("Username")); userName.setRequired(true); loginForm.addComponent(passwordField = new PasswordField("Password")); passwordField.setRequired(true); loginForm.addComponent(rememberMe = new CheckBox("Remember me")); loginForm.addComponent(lang); lang.setRequired(true); lang.setNullSelectionAllowed(false); loginForm.addComponent(login = new Button("Login")); login.addStyleName(ValoTheme.BUTTON_PRIMARY); login.setDisableOnClick(true); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addClickListener(e -> { login(); }); VerticalLayout loginLayout = new VerticalLayout(); loginLayout.setSpacing(true); loginLayout.setSizeUndefined(); if (request.getParameter("logout") != null) { loggedOutLabel = new Label("You have been logged out!"); loggedOutLabel.addStyleName(ValoTheme.LABEL_SUCCESS); loggedOutLabel.setSizeUndefined(); loginLayout.addComponent(loggedOutLabel); loginLayout.setComponentAlignment(loggedOutLabel, Alignment.BOTTOM_CENTER); } loginLayout.addComponent(loginFailedLabel = new Label()); loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER); loginFailedLabel.setSizeUndefined(); loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE); loginFailedLabel.setVisible(false); loginLayout.addComponent(loginForm); loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER); VerticalLayout rootLayout = new VerticalLayout(loginLayout); rootLayout.setSizeFull(); rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER); setContent(rootLayout); setSizeFull(); String currentLang = getLocale().getLanguage(); if (langSet.contains(currentLang)) lang.select(currentLang); else lang.select("en"); }
From source file:com.hack23.cia.web.impl.ui.application.views.admin.agentoperations.pagemode.AgentOperationsOverviewPageModContentFactoryImpl.java
License:Apache License
@Secured({ "ROLE_ADMIN" }) @Override/* ww w . j a v a 2s . c o m*/ public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) { final VerticalLayout content = createPanelContent(); getMenuItemFactory().createMainPageMenuBar(menuBar); LabelFactory.createHeader2Label(content, ADMIN_AGENT_OPERATION); final ComboBox targetSelect = new ComboBox(TARGET, Arrays.asList(DataAgentTarget.values())); targetSelect.setId(ViewAction.START_AGENT_BUTTON + TARGET2); content.addComponent(targetSelect); content.setExpandRatio(targetSelect, ContentRatio.SMALL2); final ComboBox operationSelect = new ComboBox(OPERATION, Arrays.asList(DataAgentOperation.values())); operationSelect.setId(ViewAction.START_AGENT_BUTTON + OPERATION2); content.addComponent(operationSelect); content.setExpandRatio(operationSelect, ContentRatio.SMALL2); final Button startAgentButton = new Button(START, new StartAgentClickListener(targetSelect, operationSelect, agentContainer)); startAgentButton.setId(ViewAction.START_AGENT_BUTTON.name()); startAgentButton.setIcon(FontAwesome.CROSSHAIRS); content.addComponent(startAgentButton); content.setExpandRatio(startAgentButton, ContentRatio.SMALL3); content.setSizeFull(); content.setMargin(false); content.setSpacing(true); content.setWidth(100, Unit.PERCENTAGE); content.setHeight(100, Unit.PERCENTAGE); return content; }
From source file:com.klwork.explorer.ui.custom.SelectUsersPopupWindow.java
License:Apache License
protected void selectUser(String userId, String userName) { if (!selectedUsersTable.containsId(userId)) { Item item = selectedUsersTable.addItem(userId); item.getItemProperty("userName").setValue(userName); if (showRoles) { ComboBox comboBox = new ComboBox(null, Arrays.asList(i18nManager.getMessage(Messages.TASK_ROLE_CONTRIBUTOR), i18nManager.getMessage(Messages.TASK_ROLE_IMPLEMENTER), i18nManager.getMessage(Messages.TASK_ROLE_MANAGER), i18nManager.getMessage(Messages.TASK_ROLE_SPONSOR))); comboBox.select(i18nManager.getMessage(Messages.TASK_ROLE_CONTRIBUTOR)); comboBox.setNewItemsAllowed(true); item.getItemProperty("role").setValue(comboBox); }/*from www . j a v a 2 s.co m*/ } }
From source file:com.liferay.mail.vaadin.AccountEditor.java
License:Open Source License
private void createComponents() { addressField = new TextField(Lang.get("email-address")); addressField.focus();/*from w w w . j av a 2 s . com*/ loginField = new TextField(Lang.get("login")); personalNameField = new TextField(Lang.get("personal-name")); passwordField = new TextField(Lang.get("password")); passwordField.setSecret(true); passwordSavedCheckBox = new CheckBox(Lang.get("save-password")); mailInHostNameField = new TextField(Lang.get("incoming-imap-server")); mailInPortCombo = new ComboBox(Lang.get("incoming-port"), controller.getConfigurationManager().getIncomingPorts()); mailInSecureCheckBox = new CheckBox(Lang.get("use-secure-incoming-connection")); mailOutHostNameField = new TextField(Lang.get("outgoing-smtp-server")); mailOutPortCombo = new ComboBox(Lang.get("outgoing-port"), controller.getConfigurationManager().getOutgoingPorts()); mailOutSecureCheckBox = new CheckBox(Lang.get("use-secure-outgoing-connection")); // initial validation - the account is then tested addressField.setRequired(true); mailInHostNameField.setRequired(true); mailOutHostNameField.setRequired(true); addComponent(addressField); if (!useLocalPartOfEmailAddressAsLogin) { addComponent(loginField); } addComponent(personalNameField); addComponent(passwordField); addComponent(passwordSavedCheckBox); if (!hideSettings) { addComponent(mailInHostNameField); addComponent(mailInPortCombo); addComponent(mailInSecureCheckBox); addComponent(mailOutHostNameField); addComponent(mailOutPortCombo); addComponent(mailOutSecureCheckBox); } HorizontalLayout footer = new HorizontalLayout(); footer.setSpacing(true); okButton = new Button(Lang.get("save")); okButton.setStyleName("primary"); okButton.addListener(this); footer.addComponent(okButton); cancelButton = new Button(Lang.get("cancel")); cancelButton.addListener(this); footer.addComponent(cancelButton); // TODO add footer to layout in a cleaner manner addComponent(footer); }