List of usage examples for com.vaadin.server StreamResource StreamResource
public StreamResource(StreamSource streamSource, String filename)
From source file:ui.receiver.PhotoUploadReceiver.java
License:Apache License
@Override public void uploadSucceeded(Upload.SucceededEvent event) { ServiceLocator.findLifetimeService().addUserPhoto(super.getUserId(), super.getBaos().toByteArray()); ((UserUI) super.getWindow().getUI()).getBackground() .setSource(new StreamResource(new StreamResource.StreamSource() { @Override/*w ww .j a va 2s . c o m*/ public InputStream getStream() { return new ByteArrayInputStream(getBaos().toByteArray()); } }, event.getFilename() + "_" + getUserId())); super.getWindow().close(); Notification.show("Upload succeeded", Notification.Type.TRAY_NOTIFICATION); Page.getCurrent().reload(); }
From source file:ui.tabsheet.DocumentsTabSheet.java
License:Apache License
private Component getView(final Certificate c) { BrowserFrame pdf = new BrowserFrame("", new StreamResource(new StreamResource.StreamSource() { @Override//from www.jav a 2 s . co m public InputStream getStream() { return new ByteArrayInputStream(c.getImage()); } }, "cert" + "_" + c.getAchievementId() + ".pdf")); pdf.setSizeFull(); VerticalLayout layout = new VerticalLayout(pdf); layout.setSizeFull(); Panel p = new Panel(layout); return pdf; }
From source file:ui.user.UserView.java
License:Apache License
private static Image getUserImage(final Integer userId, String language) { return new Image("", new StreamResource(new StreamResource.StreamSource() { @Override/*w w w . j ava 2 s .c o m*/ public InputStream getStream() { try { Photo photo = ServiceLocator.findLifetimeService().getUserPhoto(userId); return new ByteArrayInputStream(photo.getImage()); } catch (UserWithoutPhotoException ex) { Logger.getLogger(UserView.class.getName()).log(Level.SEVERE, null, ex); return new ByteArrayInputStream(new byte[] {}); } } }, "user_" + userId)); }
From source file:ui.visitor.VisitorView.java
License:Apache License
private static Image getVisitorImage(final Integer userId, String language) { return new Image("", new StreamResource(new StreamResource.StreamSource() { @Override/*w w w. j a va 2s. co m*/ public InputStream getStream() { try { Photo photo = ServiceLocator.findLifetimeService().getUserPhoto(userId); return new ByteArrayInputStream(photo.getImage()); } catch (UserWithoutPhotoException ex) { Logger.getLogger(UserView.class.getName()).log(Level.SEVERE, null, ex); return new ByteArrayInputStream(new byte[] {}); } } }, "visitor_" + userId)); }
From source file:ui.wizard.PdfLayout.java
License:Apache License
private Component getView(final byte[] bytes) { BrowserFrame pdf = new BrowserFrame("", new StreamResource(new StreamResource.StreamSource() { @Override//from w w w.j a v a2 s. c o m public InputStream getStream() { return new ByteArrayInputStream(bytes); } }, "cv" + "_" + getUsername() + ".pdf")); pdf.setSizeFull(); VerticalLayout layout = new VerticalLayout(pdf); layout.setSizeFull(); Panel p = new Panel(layout); return pdf; }