List of usage examples for com.vaadin.ui ListSelect ListSelect
public ListSelect(String caption, Collection<T> options)
From source file:com.esspl.datagen.ui.SettingsView.java
License:Open Source License
private Component createWorkArea() { HorizontalSplitPanel split = new HorizontalSplitPanel(); split.setSizeFull();// www .j a v a2 s .c om split.setSplitPosition(30); List<ConnectionProfile> profiles = SettingsManager.get().getConfiguration().getProfiles(); list = new ListSelect(null, new BeanItemContainer<ConnectionProfile>(ConnectionProfile.class, profiles)); list.setSizeFull(); list.setNullSelectionAllowed(false); list.setImmediate(true); if (!profiles.isEmpty()) { list.select(profiles.get(0)); } list.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { refreshDetails(); } }); panel = new Panel(); panel.setSizeFull(); split.addComponent(list); split.addComponent(panel); return split; }
From source file:com.ocs.dynamo.ui.component.FancyListSelect.java
License:Apache License
/** * Constructor/*from ww w . j a v a 2 s.c o m*/ * * @param service * the service used to query the database * @param entityModel * the entity model * @param attributeModel * the attribute mode * @param filters * the filter to apply when searching * @param search * whether the component is used in a search screen * @param sortOrder * the sort order * @param joins * the joins to use when fetching data when filling the popup dialog */ public FancyListSelect(BaseService<ID, T> service, EntityModel<T> entityModel, AttributeModel attributeModel, Filter filter, boolean search, SortOrder... sortOrders) { super(service, entityModel, attributeModel); this.sortOrders = sortOrders; this.filter = filter; this.addAllowed = !search && (attributeModel != null && attributeModel.isQuickAddAllowed()); container = new BeanItemContainer<>(getEntityModel().getEntityClass()); listSelect = new ListSelect(null, container); comboBox = new EntityComboBox<ID, T>(getEntityModel(), getAttributeModel(), getService(), this.filter, sortOrders); }
From source file:de.catma.ui.repository.wizard.IndexerOptionsPanel.java
License:Open Source License
private void initComponents() { setSpacing(true);/*from w ww . j a va 2 s .co m*/ setSizeFull(); Label infoLabel = new Label(); infoLabel.setContentMode(Label.CONTENT_XHTML); infoLabel.setValue("<p>This section allows you to finetune the creation " + "of the word list of your Source Document.</p>" + "<p>If you are unsure what to do, just select the language " + "and leave everything else unmodified.</p>"); addComponent(infoLabel, 0, 0, 2, 0); cbUseApostrophe = new CheckBox("always use the apostrophe as a word separator"); addComponent(cbUseApostrophe, 0, 1, 2, 1); Locale[] all = Locale.getAvailableLocales(); sortedLangs = new TreeSet<LanguageItem>(); for (Locale locale : all) { sortedLangs.add(new LanguageItem(locale)); } languagesListSelect = new ListSelect("Please select the predominant language of the Source Document:", sortedLangs); languagesListSelect.setNullSelectionAllowed(false); languagesListSelect.setSizeFull(); languagesListSelect.setImmediate(true); addComponent(languagesListSelect, 0, 2, 0, 3); unseparableCharacterSequencesListSelect = new ListSelect("Unseparable character sequences:"); unseparableCharacterSequencesListSelect.setNullSelectionAllowed(false); unseparableCharacterSequencesListSelect.setSizeFull(); unseparableCharacterSequencesListSelect.setImmediate(true); addComponent(unseparableCharacterSequencesListSelect, 1, 2, 1, 3); HorizontalLayout ucsAddRemoveLayout = new HorizontalLayout(); Panel ucsAddRemovePanel = new Panel(ucsAddRemoveLayout); ucsAddRemovePanel.setStyleName(Reindeer.PANEL_LIGHT); ucsAddRemoveLayout.setSpacing(true); ucsAddRemoveLayout.setSizeFull(); btAddUcs = new Button("Add entry"); btAddUcs.setEnabled(false); ucsAddRemovePanel.addComponent(btAddUcs); tfUcs = new TextField(); tfUcs.setInputPrompt("Add things like 'e.g.' as you see fit."); tfUcs.setImmediate(true); tfUcs.setTextChangeEventMode(TextChangeEventMode.EAGER); tfUcs.setWidth("100%"); ucsAddRemovePanel.addComponent(tfUcs); ucsAddRemoveLayout.setExpandRatio(tfUcs, 2); btRemoveUcs = new Button("Remove entry"); btRemoveUcs.setEnabled(false); ucsAddRemovePanel.addComponent(btRemoveUcs); addComponent(ucsAddRemovePanel, 1, 4); VerticalLayout loadSavePanel = new VerticalLayout(); loadSavePanel.setSpacing(true); loadSavePanel.setWidth("80px"); btLoadUcsList = new Button("Load list"); loadSavePanel.addComponent(btLoadUcsList); btSaveUcsList = new Button("Save list"); loadSavePanel.addComponent(btSaveUcsList); addComponent(loadSavePanel, 2, 2); setColumnExpandRatio(0, 2); setColumnExpandRatio(1, 2); setRowExpandRatio(2, 2); setRowExpandRatio(3, 2); }
From source file:de.catma.ui.tagger.PropertyValueEditorFormFieldFactory.java
License:Open Source License
public PropertyValueEditorFormFieldFactory(Set<String> initialValues) { valueBox = new ListSelect("Values", initialValues); valueBox.setNewItemsAllowed(true);// w w w . ja v a2s . co m valueBox.setMultiSelect(true); valueBox.setSizeFull(); }
From source file:de.catma.ui.tagmanager.PropertyDefinitionDialog.java
License:Open Source License
private void initComponents(String caption) { setMargin(true);/* w ww .ja va2s.c o m*/ setSpacing(true); GridLayout propPanel = new GridLayout(3, 3); propPanel.setSpacing(true); nameInput = new TextField("Name"); nameInput.setRequired(true); if (propertyDefinition != null) { nameInput.setValue(propertyDefinition.getName()); } propPanel.addComponent(nameInput, 0, 0, 2, 0); if (propertyDefinition != null) { valueInput = new ListSelect("Possible values", propertyDefinition.getPossibleValueList().getPropertyValueList().getValues()); } else { valueInput = new ListSelect("Possible values"); } valueInput.setWidth("100%"); valueInput.setRequired(true); valueInput.setNullSelectionAllowed(false); propPanel.addComponent(valueInput, 0, 1, 2, 1); newValueInput = new TextField("Add possible value"); propPanel.addComponent(newValueInput, 0, 2); btAdd = new Button("+"); propPanel.addComponent(btAdd, 1, 2); propPanel.setComponentAlignment(btAdd, Alignment.BOTTOM_CENTER); btRemove = new Button("-"); propPanel.addComponent(btRemove, 2, 2); propPanel.setComponentAlignment(btRemove, Alignment.BOTTOM_CENTER); addComponent(propPanel); HorizontalLayout buttonPanel = new HorizontalLayout(); buttonPanel.setSpacing(true); btSave = new Button("Save"); buttonPanel.addComponent(btSave); buttonPanel.setComponentAlignment(btSave, Alignment.MIDDLE_RIGHT); btCancel = new Button("Cancel"); buttonPanel.addComponent(btCancel); buttonPanel.setComponentAlignment(btCancel, Alignment.MIDDLE_RIGHT); addComponent(buttonPanel); setComponentAlignment(buttonPanel, Alignment.MIDDLE_RIGHT); window = new Window(caption); window.setContent(this); window.setWidth("30%"); window.setHeight("70%"); window.center(); }
From source file:org.azrul.langkuik.framework.customtype.attachment.AttachmentCustomTypeUICreator.java
@Override public Component createUIForForm(final C currentBean, final Class<? extends CustomType> attachmentClass, final String pojoFieldName, final BeanView beanView, final DataAccessObject<C> conatainerClassDao, final DataAccessObject<? extends CustomType> customTypeDao, final RelationManagerFactory relationManagerFactory, final Configuration config, final ComponentState componentState, final Window window) { final FormLayout form = new FormLayout(); final DataAccessObject<AttachmentCustomType> attachmentDao = ((DataAccessObject<AttachmentCustomType>) customTypeDao); final Collection<AttachmentCustomType> attachments = attachmentDao.find(currentBean, pojoFieldName, null, true, 0, Integer.parseInt(config.get("uploadCountLimit"))); final WebEntityItemContainer attachmentIC = new WebEntityItemContainer(attachmentClass); if (!attachments.isEmpty()) { attachmentIC.addAll(attachments); }//from w ww . j a v a2 s . c om final ListSelect attachmentList = new ListSelect("", attachmentIC); createAtachmentList(attachmentList, attachments, config, beanView, form); final String relativePath = currentBean.getClass().getCanonicalName() + File.separator + conatainerClassDao.getIdentifierValue(currentBean); final String fullPath = config.get("attachmentRepository") + File.separator + relativePath; MyUploadHandler<C> uploadFinishHandler = new MyUploadHandler<>(currentBean, Integer.parseInt(config.get("uploadCountLimit").trim()), pojoFieldName, fullPath, relativePath, attachmentList, attachmentIC, customTypeDao, attachmentClass, relationManagerFactory); //File upload/download/delete buttons HorizontalLayout attachmentButtons = new HorizontalLayout(); attachmentButtons.setSpacing(true); UploadStateWindow uploadStateWindow = new UploadStateWindow(); MultiFileUpload fileUpload = new MultiFileUpload(uploadFinishHandler, uploadStateWindow); uploadFinishHandler.setFileUpload(fileUpload); fileUpload.getSmartUpload().setEnabled(true); fileUpload.getSmartUpload().setMaxFileSize(Integer.parseInt(config.get("uploadSizeLimit").trim())); fileUpload.getSmartUpload().setUploadButtonCaptions("Upload files", "Upload files"); fileUpload.getSmartUpload().setId("Upload files"); fileUpload.setId("Upload files2"); Button deleteAttachmentBtn = new Button("Delete file", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Collection<AttachmentCustomType> attachments = (Collection<AttachmentCustomType>) attachmentList .getValue(); if (!attachments.isEmpty()) { customTypeDao.unlinkAndDelete(attachments, currentBean, pojoFieldName, relationManagerFactory.create(currentBean.getClass(), attachmentClass)); Collection<AttachmentCustomType> a = attachmentDao.find(currentBean, pojoFieldName, null, true, 0, Integer.parseInt(config.get("uploadCountLimit"))); attachmentIC.removeAllItems(); attachmentIC.addAll(a); attachmentIC.refreshItems(); } } }); deleteAttachmentBtn.setId(deleteAttachmentBtn.getCaption()); Button downloadAttachmentBtn = new Button("Download file", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Collection<AttachmentCustomType> attachments = (Collection<AttachmentCustomType>) attachmentList .getValue(); if (!attachments.isEmpty()) { AttachmentCustomType attachment = attachments.iterator().next(); final String fullPath = config.get("attachmentRepository") + File.separator + attachment.getRelativeLocation() + File.separator + attachment.getFileName(); FileResource res = new FileResource(new File(fullPath)); beanView.setViewResource("DOWNLOAD", res); ResourceReference rr = ResourceReference.create(res, beanView, "DOWNLOAD"); Page.getCurrent().open(rr.getURL(), null); } } }); downloadAttachmentBtn.setId(downloadAttachmentBtn.getCaption()); Button closeWindowBtn = new Button("Close", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { window.close(); } }); closeWindowBtn.setId(closeWindowBtn.getCaption()); if (componentState.equals(ComponentState.EDITABLE)) { attachmentButtons.addComponent(fileUpload); attachmentButtons.addComponent(deleteAttachmentBtn); } if (componentState.equals(ComponentState.EDITABLE) || componentState.equals(ComponentState.READ_ONLY)) { attachmentButtons.addComponent(downloadAttachmentBtn); } attachmentButtons.addComponent(closeWindowBtn); form.addComponent(attachmentButtons); form.setMargin(true); //beanView.addComponent(form); return form; }
From source file:org.eclipse.skalli.view.component.PeopleSearchWindow.java
License:Open Source License
private void createContents() { setModal(true);//from w ww. j av a 2 s. co m setCaption("Search people..."); setWidth("310px"); //$NON-NLS-1$ setHeight("400px"); //$NON-NLS-1$ root = new VerticalLayout(); root.setMargin(true); root.setSpacing(true); HorizontalLayout search = new HorizontalLayout(); search.setSpacing(true); searchField = new TextField("Search for:"); searchField.setWidth("20em"); //$NON-NLS-1$ searchField.setImmediate(true); searchField.addListener(new ValueChangeListener() { @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { search((String) searchField.getValue()); list.focus(); } }); search.addComponent(searchField); search.setComponentAlignment(searchField, Alignment.BOTTOM_LEFT); search.setExpandRatio(searchField, 1.0f); Button searchButton = new NativeButton("", new Button.ClickListener() { //$NON-NLS-1$ @Override public void buttonClick(ClickEvent event) { search((String) searchField.getValue()); } }); searchButton.setDescription("Search"); searchButton.setStyleName(STYLE_USER_DOSEARCH); search.addComponent(searchButton); search.setComponentAlignment(searchButton, Alignment.BOTTOM_LEFT); search.setExpandRatio(searchButton, 0); root.addComponent(search); list = new ListSelect("Search results:", dataSource); list.setSizeFull(); list.setMultiSelect(true); list.setImmediate(true); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); Button addButton = new Button("Add"); addButton.setIcon(ICON_BUTTON_ADD_SELECTED); addButton.setDescription("Adds the selected person to the list."); addButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Set<User> values = (Set<User>) list.getValue(); if (selectHandler != null && values != null) { selectHandler.onPeopleSelected(values); list.removeAllItems(); searchField.setValue(""); //$NON-NLS-1$ searchField.focus(); } } }); buttons.addComponent(addButton); Button addAndCloseButton = new Button("Add & Close"); addAndCloseButton.setIcon(ICON_BUTTON_ADD_SELECTED); addAndCloseButton.setDescription("Adds the selected person to the list and closes the dialog."); addAndCloseButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Set<User> values = (Set<User>) list.getValue(); if (selectHandler != null && values != null) { selectHandler.onPeopleSelected(values); close(); } } }); buttons.addComponent(addAndCloseButton); root.addComponent(list); root.addComponent(buttons); root.setSizeFull(); root.setExpandRatio(list, 1); // root.setStyleName(STYLE_LAYOUT); setContent(root); searchField.focus(); }
From source file:org.opennms.features.topology.plugins.widget.internal.SimpleViewContribution.java
License:Open Source License
@SuppressWarnings("serial") @Override/*from w w w . jav a 2 s. c o m*/ public Component getView(final WidgetContext widgetContext) { ListSelect listSelect = new ListSelect("Select a city", cities); listSelect.setHeight("100%"); listSelect.setWidth("100%"); listSelect.setImmediate(true); listSelect.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { Notification.show("" + event.getProperty()); } }); return listSelect; }
From source file:org.processbase.ui.bpm.generator.GeneratedWindow.java
License:Open Source License
private ListSelect getListSelect(Widget widget, Collection options) { ListSelect component = new ListSelect(widget.getLabel(), options); component.setMultiSelect(true);/*from w w w .j a va 2 s. co m*/ return component; }
From source file:org.ripla.web.demo.widgets.views.SelectionWidgetsView.java
License:Open Source License
public SelectionWidgetsView(final CountryContainer inCountries) { super();// w ww . j av a2 s. c o m final IMessages lMessages = Activator.getMessages(); final VerticalLayout lLayout = initLayout(lMessages, "widgets.title.page.select"); //$NON-NLS-1$ final HorizontalLayout lColumns = new HorizontalLayout(); lColumns.setSpacing(true); lLayout.addComponent(lColumns); final VerticalLayout lCol1 = new VerticalLayout(); lCol1.setSizeUndefined(); lColumns.addComponent(lCol1); final VerticalLayout lCol2 = new VerticalLayout(); lCol2.setSizeUndefined(); lColumns.addComponent(lCol2); final VerticalLayout lCol3 = new VerticalLayout(); lCol3.setSizeUndefined(); lColumns.addComponent(lCol3); lColumns.setExpandRatio(lCol3, 1); lCol1.addComponent(getSubtitle(lMessages.getMessage("widgets.selection.subtitle.list"))); //$NON-NLS-1$ final ListSelect lList1 = new ListSelect(null, inCountries); lList1.setItemCaptionMode(ItemCaptionMode.ID); lList1.setRows(10); lList1.setMultiSelect(true); lList1.setNullSelectionAllowed(false); lList1.select(inCountries.getIdByIndex(0)); lList1.setImmediate(true); lList1.addValueChangeListener(new Listener()); lCol1.addComponent(lList1); lCol1.addComponent(getSubtitle(lMessages.getMessage("widgets.selection.subtitle.combox"))); //$NON-NLS-1$ final ComboBox lCombo = new ComboBox(null, inCountries); lCombo.setInputPrompt(lMessages.getMessage("widgets.selection.combox.prompt")); //$NON-NLS-1$ lCombo.setNullSelectionAllowed(false); lCombo.setFilteringMode(FilteringMode.STARTSWITH); lCombo.setImmediate(true); lCombo.addValueChangeListener(new Listener()); lCol1.addComponent(lCombo); lCol2.addComponent(getSubtitle(lMessages.getMessage("widgets.selection.subtitle.options.single"))); //$NON-NLS-1$ List<String> lCountries = getRandomSubset(inCountries, OPTION_SIZE, System.currentTimeMillis()); final OptionGroup lOptions1 = new OptionGroup(null, lCountries); lOptions1.setNullSelectionAllowed(false); lOptions1.select(lCountries.get(0)); lOptions1.setImmediate(true); lOptions1.addValueChangeListener(new Listener()); lCol2.addComponent(lOptions1); lCol2.addComponent(getSubtitle(lMessages.getMessage("widgets.selection.subtitle.options.multiple"))); //$NON-NLS-1$ lCountries = getRandomSubset(inCountries, OPTION_SIZE, System.currentTimeMillis() + 2000); final OptionGroup lOptions2 = new OptionGroup(null, lCountries); lOptions2.setNullSelectionAllowed(false); lOptions2.setMultiSelect(true); lOptions2.select(lCountries.get(0)); lOptions2.setImmediate(true); lOptions2.addValueChangeListener(new Listener()); lCol2.addComponent(lOptions2); lCol3.addComponent(getSubtitle(lMessages.getMessage("widgets.selection.subtitle.twin"))); //$NON-NLS-1$ final TwinColSelect lCountrySelect = new TwinColSelect(); lCountrySelect.setContainerDataSource(inCountries); lCountrySelect.setRows(OPTION_SIZE); lCountrySelect.setNullSelectionAllowed(true); lCountrySelect.setMultiSelect(true); lCountrySelect.setWidth(400, Unit.PIXELS); lCol3.addComponent(lCountrySelect); }