private static void displayDocumentAttachements ( final VerticalLayout panelContent , final List < DocumentAttachment > documentAttachmentList ) { for ( final DocumentAttachment documentAttachment : documentAttachmentList ) { if ( PDF . equalsIgnoreCase ( documentAttachment . getFileType ( ) ) ) { final WTPdfViewer wtPdfViewer = new WTPdfViewer ( ) ; wtPdfViewer . setSizeFull ( ) ; wtPdfViewer . setResource ( new StreamResource ( new StreamSourceImplementation ( documentAttachment . getFileUrl ( ) ) , documentAttachment . getFileName ( ) ) ) ; panelContent . addComponent ( wtPdfViewer ) ; panelContent . setExpandRatio ( wtPdfViewer , ContentRatio . LARGE ) ; } else { final VerticalLayout verticalLayout = new VerticalLayout ( ) ; panelContent . addComponent ( verticalLayout ) ; panelContent . setExpandRatio ( verticalLayout , ContentRatio . SMALL ) ; final ExternalAttachmentDownloadLink link = new ExternalAttachmentDownloadLink ( documentAttachment . getFileName ( ) , documentAttachment . getFileType ( ) , documentAttachment . getFileUrl ( ) ) ; verticalLayout . addComponent ( link ) ; } } }
Display document attachements .