List of usage examples for com.vaadin.server StreamResource setMIMEType
public void setMIMEType(String mimeType)
From source file:annis.gui.ReportBugWindow.java
License:Apache License
private void addScreenshotPreview(Layout layout, final byte[] rawImage, String mimeType) { StreamResource res = new StreamResource(new ScreenDumpStreamSource(rawImage), "screendump_" + UUID.randomUUID().toString() + ".png"); res.setMIMEType(mimeType); final Image imgScreenshot = new Image("Attached screenshot", res); imgScreenshot.setAlternateText(/*from www . j a va2 s . co m*/ "Screenshot of the ANNIS browser window, " + "no other window or part of the desktop is captured."); imgScreenshot.setVisible(false); imgScreenshot.setWidth("100%"); Button btShowScreenshot = new Button("Show attached screenshot", new ShowScreenshotClickListener(imgScreenshot)); btShowScreenshot.addStyleName(BaseTheme.BUTTON_LINK); btShowScreenshot.setIcon(FontAwesome.PLUS_SQUARE_O); layout.addComponent(btShowScreenshot); layout.addComponent(imgScreenshot); }
From source file:com.etest.pdfgenerator.TQViewer.java
public TQViewer(int tqCoverageId) { this.tqCoverageId = tqCoverageId; // setSizeFull(); setWidth("900px"); setHeight("600px"); center();// w ww.j a va 2s. c om StreamResource resource = new StreamResource(new TQCoveragePDF(getTQCoverageId()), "TQ.pdf"); resource.setMIMEType("application/pdf"); VerticalLayout v = new VerticalLayout(); v.setSizeFull(); Embedded e = new Embedded(); e.setSource(resource); e.setSizeFull(); e.setType(Embedded.TYPE_BROWSER); v.addComponent(e); setContent(v); }
From source file:com.etest.pdfviewer.ItemAnalysisOfSubjectReportViewer.java
public ItemAnalysisOfSubjectReportViewer(int tqCoverageId) { this.tqCoverageId = tqCoverageId; setWidth("900px"); setHeight("600px"); center();/*from w ww. jav a 2 s.c o m*/ StreamResource resource = new StreamResource(new ItemAnalysisOfSubjectReportPDF(getTQCoverageId()), "ItemAnalysis.pdf"); resource.setMIMEType("application/pdf"); VerticalLayout v = new VerticalLayout(); v.setSizeFull(); Embedded e = new Embedded(); e.setSource(resource); e.setSizeFull(); e.setType(Embedded.TYPE_BROWSER); v.addComponent(e); setContent(v); }
From source file:com.etest.pdfviewer.ItemAnalysisReportViewer.java
public ItemAnalysisReportViewer(int tqCoverageId) { this.tqCoverageId = tqCoverageId; setWidth("900px"); setHeight("600px"); center();/* w ww . j ava 2 s. c o m*/ StreamResource resource = new StreamResource(new ItemAnalysisReportPDF(getTqCoverageId()), "ItemAnalysis.pdf"); resource.setMIMEType("application/pdf"); VerticalLayout v = new VerticalLayout(); v.setSizeFull(); Embedded e = new Embedded(); e.setSource(resource); e.setSizeFull(); e.setType(Embedded.TYPE_BROWSER); v.addComponent(e); setContent(v); }
From source file:com.etest.pdfviewer.MultipleChoiceHelpViewer.java
public MultipleChoiceHelpViewer() { setWidth("900px"); setHeight("600px"); center();//from w w w .j a v a 2 s . c o m StreamResource.StreamSource source = new StreamResource.StreamSource() { @Override public InputStream getStream() { try { return this.getClass().getResourceAsStream("/files/TestConstRules.pdf"); } catch (Exception e) { e.getMessage(); return null; } } }; StreamResource resource = new StreamResource(source, "TestConstRules.pdf"); resource.setMIMEType("application/pdf"); VerticalLayout v = new VerticalLayout(); v.setSizeFull(); Embedded e = new Embedded(); e.setSource(resource); e.setSizeFull(); e.setType(Embedded.TYPE_BROWSER); v.addComponent(e); setContent(v); }
From source file:com.etest.pdfviewer.SummaryReportViewer.java
public SummaryReportViewer(String summaryType) { setCaption(summaryType);//from w w w . ja va 2s .co m setWidth("900px"); setHeight("600px"); center(); StreamResource resource; //= new StreamResource(new InventoryCasesReportPDF(), "InventoryOfCases.pdf"); if (summaryType.equals("Summary: Case vs Items")) { resource = new StreamResource(new InventoryCasesReportPDF(), "InventoryOfCases.pdf"); } else { resource = new StreamResource(new InventoryItemsReportPDF(), "InventoryOfItems.pdf"); } resource.setMIMEType("application/pdf"); VerticalLayout v = new VerticalLayout(); v.setSizeFull(); Embedded e = new Embedded(); e.setSource(resource); e.setSizeFull(); e.setType(Embedded.TYPE_BROWSER); v.addComponent(e); setContent(v); }
From source file:com.etest.pdfviewer.TQCriticalIndexReportViewer.java
public TQCriticalIndexReportViewer(int tqCoverageId) { this.tqCoverageId = tqCoverageId; setWidth("900px"); setHeight("600px"); center();//ww w . j a v a 2 s. c o m StreamResource resource = new StreamResource(new TQCriticalIndexValuesReportPDF(getTQCoverageId()), "TQCriticalIndexValues.pdf"); resource.setMIMEType("application/pdf"); VerticalLayout v = new VerticalLayout(); v.setSizeFull(); Embedded e = new Embedded(); e.setSource(resource); e.setSizeFull(); e.setType(Embedded.TYPE_BROWSER); v.addComponent(e); setContent(v); }
From source file:com.foc.vaadin.gui.components.FVBlobDisplay.java
License:Apache License
public void displayPDFFile() { BlobResource blobResource = getBlobResource(); if (blobResource != null) { String fileName = blobResource.getFilename(); if (fileName != null) { String mimeType = blobResource.getMIMEType(); StreamSource streamSource = new StreamSource() { private DownloadStream downloadStream = getBlobResource() != null ? getBlobResource().getStream() : null;//from w w w . j a v a 2s . c o m @Override public InputStream getStream() { return downloadStream != null ? downloadStream.getStream() : null; } }; String viewButtonCaption = "View " + fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()) + " File"; Button viewDocButton = new Button(viewButtonCaption); viewDocButton.setStyleName(Reindeer.BUTTON_LINK); if (streamSource != null) { StreamResource streamResource = new StreamResource(streamSource, fileName); streamResource.setMIMEType(mimeType); BrowserWindowOpener opener = new BrowserWindowOpener(streamResource); opener.extend(viewDocButton); settingsLayout.addComponent(viewDocButton); Resource resource = FVIconFactory.getInstance().getFVIcon(FVIconFactory.ICON_NOTE); Image image = new Image(); image.setSource(resource); addComponent(image); } } } }
From source file:com.foc.vaadin.gui.mswordGenerator.FocXmlMSWordParser.java
License:Apache License
public StreamResource getStreamResource() { // StreamSource source = new WordDocumentStreamSource("C://Users//user//Desktop//POI Word Doc Sample Table 1.docx"); StreamSource source = new CreateWordDoc(getWordOutputStream()); StreamResource resource = new StreamResource(source, "wordfile"); resource.setMIMEType("application/msword"); return resource; }
From source file:com.foc.vaadin.gui.pdfGenerator.FocXmlPDFParser.java
License:Apache License
public StreamResource getStreamResource() { StreamSource source = new CreatePDF(getPDFOutoutStream()); String filename = "pdf" + ASCII.generateRandomString(10); StreamResource resource = new StreamResource(source, filename); resource.setMIMEType("application/pdf"); // resource.getStream().setParameter("Content-Disposition", "attachment; filename=" + filename); return resource; }