List of usage examples for com.vaadin.ui Link setTargetName
public void setTargetName(String targetName)
From source file:ru.codeinside.gses.activiti.ftarchive.AttachmentField.java
License:Mozilla Public License
Component createDownloadLink(final FileValue fileValue) { final Link result = new Link(); result.setCaption(fileValue.getFileName()); result.setTargetName("_top"); result.setImmediate(true);//www. j av a 2s . c o m result.setDescription(""); StreamResource.StreamSource streamSource = new StreamResource.StreamSource() { public InputStream getStream() { return new ByteArrayInputStream(fileValue.getContent()); } }; StreamResource resource = new StreamResource(streamSource, fileValue.getFileName(), Flash.app()) { public DownloadStream getStream() { final StreamSource ss = getStreamSource(); if (ss == null) { return null; } final DownloadStream ds = new DownloadStream(ss.getStream(), getMIMEType(), getFilename()); ds.setCacheTime(0); try { WebBrowser browser = (WebBrowser) result.getWindow().getTerminal(); if (browser.isIE()) { URI uri = new URI(null, null, fileValue.getFileName(), null); ds.setParameter("Content-Disposition", "attachment; filename=" + uri.toASCIIString()); } else { ds.setParameter("Content-Disposition", "attachment; filename=\"" + MimeUtility.encodeWord(fileValue.getFileName(), "utf-8", "Q") + "\""); } } catch (Exception e) { ds.setParameter("Content-Disposition", "attachment; filename=" + fileValue.getFileName()); } return ds; } }; resource.setMIMEType(fileValue.getMimeType()); result.setResource(resource); return result; }
From source file:ru.codeinside.gses.webui.utils.Components.java
License:Mozilla Public License
@Deprecated public static Link createAttachShowButton(final FileValue attachment, final Application appl) { if (attachment == null) { return null; }//from w w w .ja v a 2 s . c o m final Link result = new Link(); result.setCaption(attachment.getFileName()); result.setTargetName("_top"); result.setImmediate(true); //String description = attachment.getDescription(); result.setDescription(""); StreamSource streamSource = new StreamSource() { private static final long serialVersionUID = 456334952891567271L; public InputStream getStream() { return new ByteArrayInputStream(attachment.getContent()); } }; StreamResource resource = new StreamResource(streamSource, attachment.getFileName(), appl) { private static final long serialVersionUID = -3869546661105572851L; public DownloadStream getStream() { final StreamSource ss = getStreamSource(); if (ss == null) { return null; } final DownloadStream ds = new DownloadStream(ss.getStream(), getMIMEType(), getFilename()); ds.setBufferSize(getBufferSize()); ds.setCacheTime(0); try { WebBrowser browser = (WebBrowser) result.getWindow().getTerminal(); if (browser.isIE()) { URI uri = new URI(null, null, attachment.getFileName(), null); ds.setParameter("Content-Disposition", "attachment; filename=" + uri.toASCIIString()); } else { ds.setParameter("Content-Disposition", "attachment; filename=\"" + MimeUtility.encodeWord(attachment.getFileName(), "utf-8", "Q") + "\""); } } catch (Exception e) { ds.setParameter("Content-Disposition", "attachment; filename=" + attachment.getFileName()); } return ds; } }; String type = attachment.getMimeType(); if (type != null) { resource.setMIMEType(type); } result.setResource(resource); return result; }
From source file:v7cr.ReviewTab.java
License:Open Source License
private Panel getBasicInfo(V7CR v7, Review r, Project proj, String linkUrl) { Panel p = new Panel(v7.getMessage("reviewTab.review")); p.setWidth("600px"); GridLayout grid = new GridLayout(3, 4); grid.setSizeFull();/*from ww w . j ava 2 s.c o m*/ p.setContent(grid); grid.setSpacing(true); Locale l = v7.getLocale(); SchemaDefinition sd = r.getSchemaDefinition(); grid.addComponent(new Label(sd.getFieldCaption("s", l)), 0, 0, 1, 0); p.addComponent(new Label("<b>" + LocalizedString .get(sd.getFieldDefinition("s").getPossibleValueMetaData(r.getStatus()), "caption", l) + "</b>", Label.CONTENT_XHTML)); p.addComponent(new Label(sd.getFieldCaption("p", l))); p.addComponent(new Label("[" + proj.getId() + "]")); grid.addComponent(new Label(proj.getName())); p.addComponent(new Label(sd.getFieldCaption("reviewee", l))); p.addComponent(new Label(r.getReviewee().getId())); grid.addComponent(new Label(r.getReviewee().getName())); p.addComponent(new Label(sd.getFieldCaption("t", l))); grid.addComponent(new Label(r.getTitle()), 1, 3, 2, 3); p.addComponent(new Label(v7.getMessage("reviewTab.directLink"))); Link link = new Link(linkUrl, new ExternalResource(linkUrl)); link.setTargetName("_blank"); link.setIcon(new ThemeResource("../runo/icons/16/arrow-right.png")); grid.addComponent(link); return p; }
From source file:v7cr.ReviewTab.java
License:Open Source License
private Panel getSVNPanel(V7CR v7, SchemaDefinition sd, SVNLogEntry svn, Project proj) { if (svn == null) return null; Locale l = v7.getLocale();//from w w w . j a v a2 s . c om Panel p = new Panel(v7.getMessage("reviewTab.subversion")); p.setWidth("600px"); GridLayout grid = new GridLayout(4, 4); grid.setSizeFull(); p.setContent(grid); grid.setSpacing(true); p.addComponent(new Label(sd.getFieldCaption("svn.rev", l))); p.addComponent(new Label("" + svn.getRevision())); p.addComponent(new Label(DateFormat.getDateTimeInstance().format(svn.getDate()))); p.addComponent(new Label(svn.getAuthor())); Link link = new Link(v7.getMessage("reviewTab.viewChanges"), new ExternalResource(proj.getChangesetViewUrl(svn.getRevision()))); link.setTargetName("_blank"); link.setIcon(new ThemeResource("../runo/icons/16/arrow-right.png")); p.addComponent(link); grid.addComponent(new Label(svn.getMessage()), 1, 1, 3, 1); Map<String, SVNLogEntryPath> changed = svn.getChangedPaths(); if (changed != null) { Tree changeTree = new Tree(sd.getFieldCaption("svn.changed", l) + "(" + changed.size() + ")"); Set<String> paths = changed.keySet(); for (String s : changed.keySet()) { changeTree.addItem(s); changeTree.setChildrenAllowed(s, false); changeTree.setItemCaption(s, changed.get(s).getType() + " " + s); } if (paths.size() > 5) { compressTree(changeTree, paths); } grid.addComponent(changeTree, 0, 2, 3, 2); } return p; }