List of usage examples for com.vaadin.server FileDownloader extend
public void extend(EventTrigger eventTrigger)
From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.interactivepiechartfilters.StudiesPieChartFiltersContainerLayout.java
/** * * @param Quant_Central_Manager//from w w w .j a va 2s. c om * @param handler */ public StudiesPieChartFiltersContainerLayout(QuantCentralManager Quant_Central_Manager, final CSFPRHandler handler) { int layoutHeight = Page.getCurrent().getBrowserWindowHeight() - 200; int layoutWidth = Page.getCurrent().getBrowserWindowWidth() - 200; this.setWidth(layoutWidth + "px"); this.setHeight(layoutHeight + "px"); int filterWidth = layoutWidth / 3; this.setSpacing(true); boolean[] activeFilters = Quant_Central_Manager.getActiveFilters(); Map<Integer, QuantDatasetObject> quantDatasetArr = Quant_Central_Manager.getFilteredDatasetsList(); internalSelectionManager = new PieChartsSelectionManager(Quant_Central_Manager); if (quantDatasetArr == null) { return; } this.setRows(4); this.setColumns(4); int colCounter = 0; int rowCounter = 0; this.chartSet.clear(); for (int x = 0; x < activeFilters.length; x++) { String filterId = ""; if (activeFilters[x]) { Map<String, List<Integer>> dsIndexesMap = new HashMap<String, List<Integer>>(); // List<Object> valueSet = new ArrayList<Object>(); switch (x) { case 0: // filterId = "identifiedProteinsNumber"; // for (QuantDatasetObject pb : quantDatasetArr) { // if (pb == null) { // continue; // } // int value = pb.getIdentifiedProteinsNumber(); // valueSet.add(value); // } break; case 1: // filterId = "quantifiedProteinsNumber"; // for (QuantDatasetObject pb : quantDatasetArr) { // if (pb == null) { // continue; // } // int value = pb.getQuantifiedProteinsNumber(); // valueSet.add(value); // // } break; case 2: // filterId = "analyticalMethod"; // for (QuantDatasetObject pb : quantDatasetArr.values()) { // if (pb == null) { // continue; // } // String value = pb.getAnalyticalMethod(); // valueSet.add(value); // // } break; case 3: // filterId = "rawDataUrl"; // for (QuantDatasetObject pb : quantDatasetArr.values()) { // // if (pb == null) { // continue; // } // if (!dsIndexesMap.containsKey(pb.getRawDataUrl())) { // List<Integer> list = new ArrayList<Integer>(); // dsIndexesMap.put(pb.getRawDataUrl(), list); // // } // List<Integer> list = dsIndexesMap.get(pb.getRawDataUrl()); // list.add(pb.getUniqId()); // dsIndexesMap.put(pb.getRawDataUrl(), list); // valueSet.add(pb.getRawDataUrl()); // // } break; case 4: filterId = "year"; for (QuantDatasetObject pb : quantDatasetArr.values()) { if (pb == null) { continue; } if (!dsIndexesMap.containsKey(pb.getYear() + "")) { List<Integer> list = new ArrayList<Integer>(); dsIndexesMap.put(pb.getYear() + "", list); } List<Integer> list = dsIndexesMap.get(pb.getYear() + ""); list.add(pb.getDsKey()); dsIndexesMap.put(pb.getYear() + "", list); int value = pb.getYear(); // valueSet.add(value); } break; case 5: filterId = "typeOfStudy"; for (QuantDatasetObject pb : quantDatasetArr.values()) { if (pb == null) { continue; } if (!dsIndexesMap.containsKey(pb.getTypeOfStudy())) { List<Integer> list = new ArrayList<Integer>(); dsIndexesMap.put(pb.getTypeOfStudy(), list); } if (pb.getTypeOfStudy().trim().equalsIgnoreCase("")) { pb.setTypeOfStudy("Not Available"); } List<Integer> list = dsIndexesMap.get(pb.getTypeOfStudy()); list.add(pb.getDsKey()); dsIndexesMap.put(pb.getTypeOfStudy(), list); String value = pb.getTypeOfStudy(); // valueSet.add(value); } break; case 6: filterId = "sampleType"; for (QuantDatasetObject pb : quantDatasetArr.values()) { if (pb == null) { continue; } if (pb.getSampleType().trim().equalsIgnoreCase("")) { pb.setSampleType("Not Available"); } if (!dsIndexesMap.containsKey(pb.getSampleType())) { List<Integer> list = new ArrayList<Integer>(); dsIndexesMap.put(pb.getSampleType(), list); } List<Integer> list = dsIndexesMap.get(pb.getSampleType()); list.add(pb.getDsKey()); dsIndexesMap.put(pb.getSampleType(), list); String value = pb.getSampleType(); // valueSet.add(value); } break; case 7: filterId = "sampleMatching"; for (QuantDatasetObject pb : quantDatasetArr.values()) { if (pb == null) { continue; } if (pb.getSampleMatching().trim().equalsIgnoreCase("")) { pb.setSampleMatching("Not Available"); } if (!dsIndexesMap.containsKey(pb.getSampleMatching())) { List<Integer> list = new ArrayList<Integer>(); dsIndexesMap.put(pb.getSampleMatching(), list); } List<Integer> list = dsIndexesMap.get(pb.getSampleMatching()); list.add(pb.getDsKey()); dsIndexesMap.put(pb.getSampleMatching(), list); String value = pb.getSampleMatching(); // valueSet.add(value); } break; case 8: filterId = "technology"; for (QuantDatasetObject pb : quantDatasetArr.values()) { if (pb == null) { continue; } String value = pb.getTechnology(); if (value == null || value.equalsIgnoreCase("")) { value = "Not Available"; } if (!dsIndexesMap.containsKey(value)) { List<Integer> list = new ArrayList<Integer>(); dsIndexesMap.put(value, list); } List<Integer> list = dsIndexesMap.get(value); list.add(pb.getDsKey()); dsIndexesMap.put(value, list); // valueSet.add(value); } break; case 9: filterId = "analyticalApproach"; for (QuantDatasetObject pb : quantDatasetArr.values()) { if (pb == null) { continue; } String value = pb.getAnalyticalApproach(); if (value == null || value.trim().equalsIgnoreCase("")) { pb.setAnalyticalApproach("Not Available"); value = "Not Available"; } if (!dsIndexesMap.containsKey(value)) { List<Integer> list = new ArrayList<Integer>(); dsIndexesMap.put(value, list); } List<Integer> list = dsIndexesMap.get(pb.getAnalyticalApproach()); list.add(pb.getDsKey()); dsIndexesMap.put(value, list); // valueSet.add(value); } break; case 10: filterId = "enzyme"; for (QuantDatasetObject pb : quantDatasetArr.values()) { if (pb == null) { continue; } String value = pb.getEnzyme(); if (value == null || value.trim().equalsIgnoreCase("")) { value = "Not Available"; pb.setEnzyme(value); } if (!dsIndexesMap.containsKey(value)) { List<Integer> list = new ArrayList<Integer>(); dsIndexesMap.put(value, list); } List<Integer> list = dsIndexesMap.get(value); list.add(pb.getDsKey()); dsIndexesMap.put(value, list); // valueSet.add(value); } break; case 11: filterId = "shotgunTargeted"; for (QuantDatasetObject pb : quantDatasetArr.values()) { if (pb == null) { continue; } String value = pb.getShotgunTargeted(); if (value == null || value.trim().equalsIgnoreCase("")) { value = "Not Available"; pb.setShotgunTargeted(value); } if (!dsIndexesMap.containsKey(value)) { List<Integer> list = new ArrayList<Integer>(); dsIndexesMap.put(value, list); } List<Integer> list = dsIndexesMap.get(value); list.add(pb.getDsKey()); dsIndexesMap.put(value, list); // valueSet.add(value); } break; case 12: // filterId = "quantificationBasis"; // for (QuantDatasetObject pb : quantDatasetArr.values()) { // if (pb == null) { // continue; // } // String value = pb.getQuantificationBasis(); // if (value == null || value.trim().equalsIgnoreCase("")) { // value = "Not Available"; // pb.setQuantificationBasis(value); // } // if (!dsIndexesMap.containsKey(value)) { // List<Integer> list = new ArrayList<Integer>(); // dsIndexesMap.put(value, list); // // } // List<Integer> list = dsIndexesMap.get(value); // list.add(pb.getDsKey()); // dsIndexesMap.put(value, list); // valueSet.add(value); // } break; case 13: filterId = "quantBasisComment"; for (QuantDatasetObject pb : quantDatasetArr.values()) { if (pb == null) { continue; } String value = pb.getQuantBasisComment(); if (value == null || value.trim().equalsIgnoreCase("")) { value = "Not Available"; pb.setQuantBasisComment(value); } if (!dsIndexesMap.containsKey(value)) { List<Integer> list = new ArrayList<Integer>(); dsIndexesMap.put(value, list); } List<Integer> list = dsIndexesMap.get(value); list.add(pb.getDsKey()); dsIndexesMap.put(value, list); // valueSet.add(value); } break; case 14: // for (QuantDatasetObject pb : QuantDatasetListObject) { // int value = pb.getQuantifiedProteinsNumber(); // valueSet.add(value); // } break; case 15: // for (QuantDatasetObject pb : QuantDatasetListObject) { // int value = pb.getPatientsGroup1Number(); // valueSet.add(value); // } break; case 16: // for (QuantDatasetObject pb : QuantDatasetListObject) { // int value = pb.getPatientsGroup2Number(); // valueSet.add(value); // } break; case 17: // for (QuantDatasetObject pb : QuantDatasetListObject) { // String value = pb.getNormalizationStrategy(); // valueSet.add(value); // } break; } // if (!valueSet.isEmpty()) { //do we need valueSet;; JfreeDivaPieChartFilter iFilter = new JfreeDivaPieChartFilter(filterId, x, internalSelectionManager, dsIndexesMap, filterWidth); chartSet.add(iFilter.getChart()); // fullFilterList.put(filterId, valueSet); this.addComponent(iFilter, colCounter++, rowCounter); this.setComponentAlignment(iFilter, Alignment.MIDDLE_CENTER); if (colCounter == 3) { colCounter = 0; rowCounter++; } } // } } Quant_Central_Manager.setStudiesOverviewPieChart(chartSet); HorizontalLayout btnLayout = new HorizontalLayout(); btnLayout.setHeight("23px"); btnLayout.setWidthUndefined(); btnLayout.setSpacing(true); btnLayout.setStyleName(Reindeer.LAYOUT_WHITE); if (colCounter == 3) { this.addComponent(btnLayout, 2, ++rowCounter); } else { this.addComponent(btnLayout, 2, rowCounter); } this.setComponentAlignment(btnLayout, Alignment.MIDDLE_CENTER); Button applyFilters = new Button("Apply"); applyFilters.setDescription("Apply the selected filters"); applyFilters.setPrimaryStyleName("resetbtn"); applyFilters.setWidth("50px"); applyFilters.setHeight("24px"); btnLayout.addComponent(applyFilters); applyFilters.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { pieChartFiltersBtn.closePupupWindow(); } }); // Button unselectAllBtn = new Button("Unselect All"); // unselectAllBtn.setStyleName(Reindeer.BUTTON_SMALL); // btnLayout.addComponent(unselectAllBtn); // unselectAllBtn.addClickListener(new Button.ClickListener() { // // @Override // public void buttonClick(Button.ClickEvent event) { // // internalSelectionManager.unselectAll(); // // } // }); // Button unselectAllBtn = new Button("Clear"); unselectAllBtn.setPrimaryStyleName("resetbtn"); unselectAllBtn.setWidth("50px"); unselectAllBtn.setHeight("24px"); btnLayout.addComponent(unselectAllBtn); btnLayout.setComponentAlignment(unselectAllBtn, Alignment.TOP_LEFT); unselectAllBtn.setDescription("Clear All Selections"); unselectAllBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { internalSelectionManager.unselectAll(); } }); Button resetFiltersBtn = new Button("Reset"); resetFiltersBtn.setPrimaryStyleName("resetbtn"); resetFiltersBtn.setWidth("50px"); resetFiltersBtn.setHeight("24px"); btnLayout.addComponent(resetFiltersBtn); resetFiltersBtn.setDescription("Reset all applied filters"); resetFiltersBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { internalSelectionManager.resetToInitState(); internalSelectionManager.resetCentralSelectionManager(); } }); Button exportChartsBtn = new Button(""); exportChartsBtn.setWidth("24px"); exportChartsBtn.setHeight("24px"); exportChartsBtn.setPrimaryStyleName("exportpdfbtn"); btnLayout.addComponent(exportChartsBtn); exportChartsBtn.setDescription("Export all charts filters as pdf file"); // exportChartsBtn.addClickListener(new Button.ClickListener() { // @Override // public void buttonClick(Button.ClickEvent event) { // String url = handler.exportImgAsPdf(chartSet, "piechart_filters.pdf"); // FileResource res = new FileResource(new File(url)); // Page.getCurrent().open(res, "_blank", true); // } // }); StreamResource myResource = createResource(handler); FileDownloader fileDownloader = new FileDownloader(myResource); fileDownloader.extend(exportChartsBtn); pieChartFiltersBtn = new PopupInteractiveDSFiltersLayout(this); }
From source file:processes.SheetBarcodesReadyRunnable.java
License:Open Source License
private void attachDownloadToButton() { FileResource sheetSource = creator.createAndDLSheet(projectCode, projectName, investigator, contact, barcodeBeans, view.getHeaders()); FileDownloader sheetDL = new FileDownloader(sheetSource); sheetDL.extend(view.getDownloadButton()); }
From source file:processes.TubeBarcodesReadyRunnable.java
License:Open Source License
private void attachDownloadToButton() { FileResource pdfSource = creator.zipAndDownloadBarcodes(barcodeBeans); FileDownloader pdfDL = new FileDownloader(pdfSource); pdfDL.extend(view.getDownloadButton()); }
From source file:qbic.vaadincomponents.TSVDownloadComponent.java
License:Open Source License
protected void armDownloadButton(Button b, StreamResource stream, int dlnum) { if (downloaders.size() < dlnum) { FileDownloader dl = new FileDownloader(stream); dl.extend(b); downloaders.add(dl);/*from w w w .ja v a 2 s . c o m*/ } else downloaders.get(dlnum - 1).setFileDownloadResource(stream); b.setEnabled(true); }
From source file:roart.client.MyVaadinUI.java
void addListTable(VerticalLayout ts, List<ResultItem> strarr) { if (strarr.size() <= 1) { return;/* ww w . j a v a 2 s .co m*/ } SearchDisplay display = SearchService.getSearchDisplay(getCurrent()); boolean dodownload = (boolean) getSession().getAttribute("download"); Table table = new Table("Table"); table.setWidth("90%"); int columns = strarr.get(0).get().size(); for (int i = 0; i < strarr.size(); i++) { if (strarr.get(i).get().size() != columns) { System.out.println("column differs " + columns + " found " + strarr.get(i).get().size()); break; } } for (int i = 0; i < columns; i++) { if (display.highlightmlt && i == IndexFiles.HIGHLIGHTMLTCOLUMN && strarr.get(0).get().get(IndexFiles.HIGHLIGHTMLTCOLUMN).equals("Highlight and similar")) { table.addContainerProperty(strarr.get(0).get().get(i), Button.class, null); continue; } table.addContainerProperty(strarr.get(0).get().get(i), String.class, null); } if (dodownload) { if (columns > IndexFiles.FILENAMECOLUMN && strarr.get(0).get().get(IndexFiles.FILENAMECOLUMN).equals("Filename")) { table.addGeneratedColumn("Download", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { String nodename = (String) source.getItem(itemId).getItemProperty("Node").getValue(); String filename = (String) source.getItem(itemId).getItemProperty("Filename").getValue(); if (nodename != null && !nodename.equals(ControlService.nodename)) { return null; } if (filename == null) { return null; } if (false) { return null; } final FileObject fo = FileSystemDao.get(filename); if (filename.startsWith(FileSystemDao.FILE) || filename.startsWith(FileSystemDao.HDFS)) { filename = filename.substring(5); } int i = filename.lastIndexOf("/"); String fn = filename.substring(i + 1); StreamResource resource = new StreamResource(new StreamSource() { @Override public InputStream getStream() { try { return FileSystemDao.getInputStream(fo); } catch (Exception e) { log.error(Constants.EXCEPTION, e); return null; } } }, fn); //FileResource resource = new FileResource(new File(filename)); Button button = new Button("Download"); button.setStyleName(BaseTheme.BUTTON_LINK); FileDownloader downloader = new FileDownloader(resource); downloader.extend(button); return button; } }); } } for (int i = 1; i < strarr.size(); i++) { ResultItem str = strarr.get(i); if (display.highlightmlt && columns > IndexFiles.HIGHLIGHTMLTCOLUMN && strarr.get(0).get().get(IndexFiles.HIGHLIGHTMLTCOLUMN).equals("Highlight and similar")) { String text = (String) str.get().get(IndexFiles.HIGHLIGHTMLTCOLUMN); if (text != null) { String md5 = (String) str.get().get(1); str.get().set(IndexFiles.HIGHLIGHTMLTCOLUMN, getSimilar(text, md5)); } } table.addItem(str.getarr(), i); } //table.setPageLength(table.size()); ts.addComponent(table); }
From source file:ui.button.ViewCVButton.java
License:Apache License
@Override public void buttonClick(ClickEvent event) { PdfUtility pdfUtility = new PdfUtility(userId, language, new DescendingStartComparator(), null, null); pdfUtility.createPdf();/*from w ww. j a va 2 s .c o m*/ StreamResource streamResource = pdfUtility.getStreamResource(); FileDownloader downloader = new FileDownloader(streamResource); downloader.extend(this); }
From source file:ui.window.PdfWindow.java
public PdfWindow(Integer userId, String language) { setCaption("Save CV"); setSizeFull();//from ww w .ja v a 2 s. com setResizable(true); setWidth("25%"); setHeight("25%"); center(); PdfUtility pdfUtility = new PdfUtility(userId, language, new DescendingEndComparator(), null, new Date()); pdfUtility.createPdf(); StreamResource streamResource = pdfUtility.getStreamResource(); FileDownloader downloader = new FileDownloader(streamResource); LifetimeButtonLink downloadButton = new LifetimeButtonLink("Save CV", FontAwesome.SAVE); downloader.extend(downloadButton); // Here we create a new StreamResource which downloads our StreamSource, // which is our pdf. setContent(downloadButton); }
From source file:views.StandaloneTSVImport.java
License:Open Source License
private Component createTSVDownloadComponent(DesignType type, String info) { VerticalLayout v = new VerticalLayout(); v.setSpacing(true);//from ww w .j av a2 s. c om Label l = new Label(info); l.setWidth("300px"); v.addComponent(l); Button button = new Button("Download Example"); v.addComponent(button); String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath(); FileDownloader tsvDL = new FileDownloader( new FileResource(new File(basepath + "/WEB-INF/files/" + type.getFileName()))); tsvDL.extend(button); return v; }
From source file:views.StandaloneTSVImport.java
License:Open Source License
public void setTSVWithBarcodes(String tsvContent, String name) { if (downloadTSV != null) removeComponent(downloadTSV);/*from w w w .j a va 2s. co m*/ downloadTSV = new Button("Download Barcodes"); addComponent(downloadTSV); FileDownloader tsvDL = new FileDownloader(Functions.getFileStream(tsvContent, name, "tsv")); tsvDL.extend(downloadTSV); }