List of usage examples for com.vaadin.ui Grid setSelectionMode
public GridSelectionModel<T> setSelectionMode(SelectionMode selectionMode)
From source file:org.tylproject.vaadin.addon.fields.collectiontables.CollectionTable.java
License:Apache License
public void initGridAdaptor() { Grid gridComponent = gridAdaptor.getComponent(); gridComponent.setSizeFull();/*from www. j av a 2 s . co m*/ gridComponent.setWidth("100%"); gridComponent.setHeight("300px"); gridComponent.setSelectionMode(Grid.SelectionMode.SINGLE); }
From source file:org.vaadin.gridfiledownloadertest.GridFileDownloaderUI.java
License:Apache License
@SuppressWarnings("unchecked") @Override/*from w ww. j a va2 s. co m*/ protected void init(VaadinRequest request) { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); setContent(layout); final Grid grid = new Grid("Attachment grid"); grid.setHeightMode(HeightMode.ROW); grid.setHeightByRows(5); grid.setSelectionMode(SelectionMode.NONE); Column column = grid.addColumn("filename"); column.setHeaderCaption("File name"); column.setExpandRatio(1); Indexed dataSource = grid.getContainerDataSource(); for (int i = 1; i <= 5; ++i) { DownloadPojo cp = new DownloadPojo(i); Item item = dataSource.addItem(cp); item.getItemProperty("filename").setValue(cp.getName()); } layout.addComponent(grid); addGridFileDownloader(grid); // set tooltip for the default download column grid.setCellDescriptionGenerator(new CellDescriptionGenerator() { @Override public String getDescription(CellReference cell) { if (FontAwesome.DOWNLOAD.equals(cell.getPropertyId())) { return "download"; } return null; } }); // clear the header HeaderCell downloadHeader = grid.getHeaderRow(0).getCell(FontAwesome.DOWNLOAD); downloadHeader.setHtml(""); }
From source file:org.vaadin.peholmst.samples.dddwebinar.ui.appointments.DoctorSection.java
@PostConstruct void init() {/* w w w . ja v a 2 s . c o m*/ setSizeFull(); setSpacing(true); Label title = new Label("Doctor"); title.addStyleName(ValoTheme.LABEL_H2); addComponent(title); doctorName = new TextField("Name"); doctorName.setWidth("100%"); addComponent(doctorName); licenseContainer = new BeanItemContainer<>(License.class); licenseContainer.addNestedContainerProperty("type.name"); Grid doctorLicenses = new Grid("Licenses", licenseContainer); doctorLicenses.setColumns("number", "type.name"); doctorLicenses.setSizeFull(); doctorLicenses.setSelectionMode(Grid.SelectionMode.NONE); addComponent(doctorLicenses); setExpandRatio(doctorLicenses, 1.0f); model.addObserver(this); // Same scope, no need to remove afterwards }
From source file:probe.com.view.core.MultiSelectionTable.java
/** * *///from w w w . j a v a 2s. c o m public MultiSelectionTable() { setSpacing(true); // Set up combo boxes with possible values setWidth(100, Unit.PERCENTAGE); // Editor is not enabled when setEnabled(false); Indexed datares = new BeanContainer(null); // Create new Grid with BeanItemContainer filled with BugEntries Grid grid = new Grid(datares); grid.setSizeFull(); // Hide the "changed" property grid.removeColumn("changed"); // Activate multi selection mode grid.setSelectionMode(SelectionMode.MULTI); // Add a rowstyle generator to display recently changed items. // Also uses another style for closed entries grid.setRowStyleGenerator(new RowStyleGenerator() { @Override public String getStyle(RowReference rowReference) { Item item = rowReference.getItem(); boolean closed = item.getItemProperty("status").getValue() == Status.CLOSED; boolean changed = (Boolean) item.getItemProperty("changed").getValue(); if (closed) { if (changed) { // Combined style return "changed closed"; } // Closed style return "closed"; } else if (changed) { // Modified style return "changed"; } // No style return null; } }); // Make Editor listen to changes in the selection of this Grid grid.addSelectionListener(this); }
From source file:qbic.vaadincomponents.InputFilesComponent.java
License:Open Source License
/** * DAVID/*from w w w . j a v a 2s .c o m*/ * * @param wfparameters * @param datasets */ public void buildLayout(Map<String, Parameter> wfparameters, BeanItemContainer<DatasetBean> datasets) { wfmap = wfparameters; for (Map.Entry<String, Parameter> entry : wfmap.entrySet()) { GeneratedPropertyContainer gpcontainer = null; Grid newGrid = new Grid(gpcontainer); if (entry.getValue() instanceof FileParameter || entry.getValue() instanceof FileListParameter) { // TODO also do filtering on filetype level List<String> range = getRange(entry.getValue()); if (range.contains("fasta") || range.contains("gtf")) { gpcontainer = fastaContainer(); // show only bwaIndex references for bwa } else if (range.contains("bwaIndex")) { gpcontainer = fastaContainerFiltered("bwa"); } else if (range.contains("barcodes")) { gpcontainer = fastaContainerFiltered("barcodes"); } else if (range.contains("shRNAlibrary")) { gpcontainer = fastaContainerFiltered("shRNAlibrary"); } else { gpcontainer = filter(datasets, range); } newGrid.setContainerDataSource(gpcontainer); newGrid.setSelectionMode(getSelectionMode(entry.getValue())); } else { // showError(String.format("Invalid Inputfile Parameter!", entry.getKey())); helpers.Utils.Notification("Invalid Inputfile Parameter", "Invalid value for inputfile parameter has been provided." + entry.getKey(), "error"); } HorizontalLayout layout = new HorizontalLayout(); layout.setMargin(new MarginInfo(true, true, true, true)); layout.setSizeFull(); newGrid.setWidth("100%"); layout.addComponent(newGrid); // if (newGrid.getContainerDataSource().size() == 0) { // Notification.show( // String.format("No dataset of type %s available in this project!", entry.getKey()), // Type.WARNING_MESSAGE); // helpers.Utils // .Notification( // "Missing Dataset Type", // String // .format( // "Workflow submission might not be possible because no dataset of type %s is available in // this project", // entry.getKey()), "warning"); layout.addComponent(newGrid); // } helpers.GridFunctions.addColumnFilters(newGrid, gpcontainer); inputFileForm.addTab(layout, entry.getKey()); } }
From source file:qbic.vaadincomponents.InputFilesComponent.java
License:Open Source License
public void buildForm(Set<Entry<String, Parameter>> wfparameters, BeanItemContainer<DatasetBean> datasets) { inputFileForm.removeAllComponents(); inputFileForm.setSizeFull();//from www .j av a2 s.c om wfmap.clear(); for (Map.Entry<String, Parameter> entry : wfparameters) { wfmap.put(entry.getKey(), entry.getValue()); GeneratedPropertyContainer gpcontainer = null; Grid newGrid = new Grid(gpcontainer); if (entry.getValue() instanceof FileParameter) { FileParameter fileParam = (FileParameter) entry.getValue(); List<String> associatedDataTypes = fileParam.getRange(); // String associatedDataType = fileParam.getTitle(); if (associatedDataTypes.contains("fasta") || associatedDataTypes.contains("gtf")) { // if (associatedDataType.toLowerCase().equals("fasta")) { BeanItemContainer<FastaBean> subContainer = new BeanItemContainer<FastaBean>(FastaBean.class); FastaDB db = new FastaDB(); subContainer.addAll(db.getAll()); gpcontainer = new GeneratedPropertyContainer(subContainer); gpcontainer.addGeneratedProperty("Type", new PropertyValueGenerator<String>() { @Override public Class<String> getType() { return String.class; } @Override public String getValue(Item item, Object itemId, Object propertyId) { String detailedType = item.getItemProperty("detailedType").getValue().toString(); return detailedType; } }); gpcontainer.removeContainerProperty("path"); gpcontainer.removeContainerProperty("detailedType"); } else { BeanItemContainer<DatasetBean> subContainer = new BeanItemContainer<DatasetBean>( DatasetBean.class); for (java.util.Iterator<DatasetBean> i = datasets.getItemIds().iterator(); i.hasNext();) { DatasetBean dataset = i.next(); if (associatedDataTypes.contains(dataset.getFileType().toLowerCase())) { // if (associatedDataType.toLowerCase().equals(dataset.getFileType().toLowerCase())) { subContainer.addBean(dataset); } } gpcontainer = new GeneratedPropertyContainer(subContainer); gpcontainer.removeContainerProperty("fullPath"); gpcontainer.removeContainerProperty("openbisCode"); } newGrid.setContainerDataSource(gpcontainer); newGrid.setSelectionMode(SelectionMode.SINGLE); } else if (entry.getValue() instanceof FileListParameter) { FileListParameter fileParam = (FileListParameter) entry.getValue(); List<String> associatedDataTypes = fileParam.getRange(); BeanItemContainer<DatasetBean> subContainer = new BeanItemContainer<DatasetBean>(DatasetBean.class); for (java.util.Iterator<DatasetBean> i = datasets.getItemIds().iterator(); i.hasNext();) { DatasetBean dataset = i.next(); if (associatedDataTypes.contains(dataset.getFileType().toLowerCase())) { subContainer.addBean(dataset); } } gpcontainer = new GeneratedPropertyContainer(subContainer); gpcontainer.removeContainerProperty("fullPath"); gpcontainer.removeContainerProperty("openbisCode"); newGrid.setContainerDataSource(gpcontainer); newGrid.setSelectionMode(SelectionMode.MULTI); } else { helpers.Utils.Notification("Invalid Inputfile Parameter", "Invalid inputfile parameter has been selected: " + entry.getKey(), "error"); } HorizontalLayout layout = new HorizontalLayout(); layout.setMargin(new MarginInfo(true, true, true, true)); layout.setSizeFull(); newGrid.setWidth("100%"); layout.addComponent(newGrid); // if (newGrid.getContainerDataSource().size() == 0) { // helpers.Utils // .Notification( // "Missing Dataset Type", // String // .format( // "Workflow submission might not be possible because no dataset of type %s is available in // this project", // entry.getKey()), "warning"); // Notification.show( // String.format("No dataset of type %s available in this project!", entry.getKey()), // Type.WARNING_MESSAGE); layout.addComponent(newGrid); // } inputFileForm.addTab(layout, entry.getKey()); } }