List of usage examples for org.apache.wicket.request.resource ResourceStreamResource ResourceStreamResource
public ResourceStreamResource(IResourceStream stream)
From source file:com.apachecon.memories.service.UserFile.java
License:Apache License
private Image createImage(String id, boolean small) { File f = small ? thumb : file; IResource resource = new ResourceStreamResource(new FileResourceStream(f)); return new NonCachingImage(id, resource); }
From source file:de.tudarmstadt.ukp.clarin.webanno.support.FileSystemResource.java
License:Apache License
public void respond(Attributes attributes) { FileResourceStream fileResourceStream = new FileResourceStream(file); ResourceStreamResource resource = new ResourceStreamResource(fileResourceStream); resource.respond(attributes);//from w w w. j a v a2s .c om }
From source file:org.apache.isis.viewer.wicket.ui.components.widgets.zclip.ZeroClipboardLink.java
License:Apache License
private static ResourceStreamResource newSwfFileResource() { return new ResourceStreamResource( new UrlResourceStream(Resources.getResource(ZeroClipboardLink.class, FILE_NAME_SWF))); }
From source file:org.artifactory.webapp.wicket.page.logs.SystemLogsViewPanel.java
License:Open Source License
/** * Add a link to enable the download of the system log file *//*from w ww. ja va2s .com*/ private void addSystemLogsLink() { // This is very ugly and should be removed when we upgrade wicket, see RTFACT-5470 for explanation downloadLink = new DownloadLink("systemLogsLink", systemLogFile) { @Override public void onClick() { final File file = getModelObject(); IResourceStream resourceStream = new FileResourceStream(new org.apache.wicket.util.file.File(file)); ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(resourceStream) { @Override public void respond(IRequestCycle requestCycle) { IResource.Attributes attributes = new IResource.Attributes(requestCycle.getRequest(), requestCycle.getResponse()); ResourceStreamResource resource = new ResourceStreamResource(this.getResourceStream()) { @Override protected void configureCache(ResourceResponse data, Attributes attributes) { Response response = attributes.getResponse(); ((WebResponse) response).disableCaching(); } }; resource.setFileName(file.getName()); resource.setContentDisposition(ContentDisposition.ATTACHMENT); resource.respond(attributes); } }; getRequestCycle().scheduleRequestHandlerAfterCurrent(handler); } }; add(downloadLink); downloadLink.add(linkLabel); downloadLink.setOutputMarkupId(true); linkLabel.setOutputMarkupId(true); }
From source file:org.dcache.webadmin.view.beans.ThumbnailPanelBean.java
License:Open Source License
public ThumbnailPanelBean() { name = "";//from w ww. ja va 2 s . co m UrlResourceStream stream = new UrlResourceStream( Thread.currentThread().getContextClassLoader().getResource(PLACEHOLDER)); IResource resource = new ResourceStreamResource(stream); Image image = new Image("thumbnail", resource); link = new Link<String>("plotlink") { private static final long serialVersionUID = 4245101719065647956L; @Override public void onClick() { } }; link.add(image); }
From source file:org.dcache.webadmin.view.beans.ThumbnailPanelBean.java
License:Open Source License
public ThumbnailPanelBean(File file, int height, int width) { String name = file.getName(); int end = name.indexOf(RrdSettings.FILE_SUFFIX); this.name = name.substring(0, end); IResource resource = new ResourceStreamResource(new FileResourceStream(file)); Image image = new Image("thumbnail", resource); PopupSettings popupSettings = new PopupSettings(PopupSettings.RESIZABLE | PopupSettings.SCROLLBARS) .setHeight(height).setWidth(width); ResourceLink link = new ResourceLink("plotlink", resource); link.setPopupSettings(popupSettings); link.add(image);/*from w w w . j av a 2s .c om*/ this.link = link; }
From source file:org.dcache.webadmin.view.panels.billingplots.PlotsPanel.java
License:Open Source License
/** * Two thirds of this method is shared with {@link ThumbnailPanelBean}; * the latter needs to be generalized to cover this case. TODO *//* ww w .j ava 2 s .co m*/ private void loadPlots(File[] files, int width, int height) { int n = 0; int m = 0; for (File file : files) { String suffix = "_" + m + n; ResourceStreamResource resource = new ResourceStreamResource(new FileResourceStream(file)); resource.setCacheDuration(Duration.NONE); Image image = new Image(IMAGE_NAME + suffix, resource); PopupSettings popupSettings = new PopupSettings(PopupSettings.RESIZABLE | PopupSettings.SCROLLBARS) .setHeight(height).setWidth(width); ResourceLink link = new ResourceLink(LINK_NAME + suffix, resource); link.setPopupSettings(popupSettings); link.add(image); add(link); n = (n + 1) % 4; if (n == 0) { ++m; } } }
From source file:org.devgateway.toolkit.forms.util.FolderContentResource.java
License:Open Source License
public void respond(final Attributes attributes) { PageParameters parameters = attributes.getParameters(); String fileName = parameters.get(PARAM_FILE_NAME).toString(); // we use FilenameUtils to prevent "security tricks", only a file name // without path is allowed File file = new File(rootFolder, FilenameUtils.getName(fileName)); FileResourceStream fileResourceStream = new FileResourceStream(file); ResourceStreamResource resource = new ResourceStreamResource(fileResourceStream); resource.respond(attributes);//from w w w . j a v a2 s. c om }
From source file:org.hippoecm.frontend.plugins.console.editor.BinaryEditor.java
License:Apache License
public BinaryEditor(String id, JcrPropertyModel model, final IPluginContext pluginContext) { super(id, model); final IResourceStream stream = new BinaryResourceStream(model); // download//from ww w . jav a2 s . com final ResourceStreamResource resource = new ResourceStreamResource(stream); resource.setCacheDuration(Duration.NONE); try { final Node node = model.getProperty().getParent().getParent(); final StringBuilder fileName = new StringBuilder(node.getName()); if (isExtractedTextProperty(model.getProperty())) { fileName.append(".txt"); } resource.setFileName(fileName.toString()); } catch (RepositoryException e) { log.error("Unexpected exception while determining download filename", e); } final Link downloadLink = new ResourceLink("binary-download-lnk", resource); downloadLink.add(new Label("binary-download-text", "download (" + getSizeString(stream.length()) + ")")); add(downloadLink); // upload IDialogFactory factory = new IDialogFactory() { private static final long serialVersionUID = 1L; public IDialogService.Dialog createDialog() { return new BinaryUploadDialog(model); } }; final IDialogService service = pluginContext.getService(IDialogService.class.getName(), IDialogService.class); final DialogLink uploadLink = new DialogLink("binary-upload-link", new Model<>("Upload binary"), factory, service); add(uploadLink); // Jackrabbit Binary Content Identifier if this Binary is in BinaryStore. final Label contentIdentityValueLabel = new Label("content-identity-value", new PropertyModel<String>(this, "contentIdentity")); contentIdentityValueLabel.setOutputMarkupPlaceholderTag(true); contentIdentityValueLabel.setVisible(false); add(contentIdentityValueLabel); final AjaxLink contentIdentityShowLink = new AjaxLink("content-identity-show-link") { @Override public void onClick(AjaxRequestTarget target) { setContentIdentity(retrieveJackrabbitContentIdentity()); target.add(contentIdentityValueLabel.setVisible(true)); target.add(this.setVisible(false)); } }; add(contentIdentityShowLink); }
From source file:org.wicketstuff.poi.excel.TableComponentAsXlsHandler.java
License:Apache License
public void respond(IRequestCycle requestCycle) { try {//from ww w . ja v a 2 s.com TableParser parser = new TableParser(newSheet(), cellExporter); if (tableComponent instanceof IPageable) { IPageable pageable = (IPageable) tableComponent; for (int i = 0; i < pageable.getPageCount(); i++) { pageable.setCurrentPage(i); parser.parse(tableComponent); } } else { parser.parse(tableComponent); } XlsStream xlsStream = new XlsStream(parser.getSheet().getWorkbook()); ResourceStreamResource resource = new ResourceStreamResource(xlsStream); resource.setFileName(filename); resource.setContentDisposition(ContentDisposition.ATTACHMENT); IResource.Attributes a = new IResource.Attributes(requestCycle.getRequest(), requestCycle.getResponse()); resource.respond(a); } catch (Exception e) { throw new RuntimeException("Error while generating a xls file to table component", e); } }