当前位置: 首页>>代码示例>>Java>>正文


Java FileResourceStream类代码示例

本文整理汇总了Java中org.apache.wicket.util.resource.FileResourceStream的典型用法代码示例。如果您正苦于以下问题:Java FileResourceStream类的具体用法?Java FileResourceStream怎么用?Java FileResourceStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileResourceStream类属于org.apache.wicket.util.resource包,在下文中一共展示了FileResourceStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onRequest

import org.apache.wicket.util.resource.FileResourceStream; //导入依赖的package包/类
public void onRequest() {
	final File file = initFile();	
	IResourceStream resourceStream = new FileResourceStream(new File(file));
	getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(
			new ResourceStreamRequestHandler(resourceStream) {

                   @Override
				public void respond(IRequestCycle requestCycle) {
                       try {
					    super.respond(requestCycle);
                       } finally {
                           if (removeFile) {
                               LOGGER.debug("Removing file '{}'.", new Object[]{file.getAbsolutePath()});
                               Files.remove(file);
                           }
                       }
				}
			}.setFileName(file.getName()).setContentDisposition(ContentDisposition.ATTACHMENT)
					.setCacheDuration(Duration.ONE_SECOND));
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:21,代码来源:AjaxDownloadBehaviorFromFile.java

示例2: addExportButton

import org.apache.wicket.util.resource.FileResourceStream; //导入依赖的package包/类
/**
 * Add a button for exporting the dependencies of the given event type.
 */
private void addExportButton() {
        final AjaxButton exportButton = new AjaxButton("exportButton") {
           private static final long serialVersionUID = 1L;
            @Override
            public void onSubmit(final AjaxRequestTarget target, final Form form) {
                final AJAXDownload jsonDownload = new AJAXDownload() {
                    @Override
                    protected IResourceStream getResourceStream() {
                        final File csv = JsonExporter.generateExportFileWithDependencies(selectedEventType);
                        return new FileResourceStream(new org.apache.wicket.util.file.File(csv));
                    }
                    @Override
                    protected String getFileName() {
                        return selectedEventType.getTypeName() + "-dependencies.json";
                    }
                };
                ExportImportDependenciesPanel.this.add(jsonDownload);
                jsonDownload.initiate(target);
                ExportImportDependenciesPanel.this.page.getFeedbackPanel().success("Json created.");
                target.add(ExportImportDependenciesPanel.this.page.getFeedbackPanel());
            }
        };
        exportForm.add(exportButton);
}
 
开发者ID:bptlab,项目名称:Unicorn,代码行数:28,代码来源:ExportImportDependenciesPanel.java

示例3: onRequest

import org.apache.wicket.util.resource.FileResourceStream; //导入依赖的package包/类
public void onRequest() {
	final File file = initFile();
	IResourceStream resourceStream = new FileResourceStream(new File(file));
	getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(
			new ResourceStreamRequestHandler(resourceStream) {

                   @Override
				public void respond(IRequestCycle requestCycle) {
                       try {
					    super.respond(requestCycle);
                       } finally {
                           if (removeFile) {
                               LOGGER.debug("Removing file '{}'.", new Object[]{file.getAbsolutePath()});
                               Files.remove(file);
                           }
                       }
				}
			}.setFileName(file.getName()).setContentDisposition(ContentDisposition.ATTACHMENT)
					.setCacheDuration(Duration.ONE_SECOND));
}
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:21,代码来源:AjaxDownloadBehaviorFromFile.java

示例4: makeZipLogStream

import org.apache.wicket.util.resource.FileResourceStream; //导入依赖的package包/类
@Nonnull
private ResourceStreamResource makeZipLogStream(IModel<URI> logPath) {
    return new ResourceStreamResource() {
        @Override
        protected IResourceStream getResourceStream() {
            try {
                return new FileResourceStream(new File(makeZip(logPath)));
            } catch (IOException ex) {
                getLogger().error(ex.getMessage(), ex);
            }
            return null;
        }
    };
}
 
开发者ID:opensingular,项目名称:singular-server,代码行数:15,代码来源:LogPanel.java

示例5: addExportValuesButton

import org.apache.wicket.util.resource.FileResourceStream; //导入依赖的package包/类
/**
 * Add a button to export the input values given via input fields.
 */
private void addExportValuesButton() {
    final AjaxLink exportButton = new AjaxLink<Void>("exportValuesButton") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            layoutForm.modelChanged();
            final AJAXDownload jsonDownload = new AJAXDownload() {
                @Override
                protected IResourceStream getResourceStream() {
                    JSONArray valuesForExport = new JSONArray();
                    for (AttributeInput input : attributeInputs) {
                        valuesForExport.put(input.toJson());
                    }
                    final File json = JsonExporter
                            .generateExportFileWithValues(selectedEventType, valuesForExport, eventCount, scaleFactor, eventTimestamps);
                    if (json == null) {
                        return null;
                    }
                    return new FileResourceStream(new org.apache.wicket.util.file.File(json));
                }
                @Override
                protected String getFileName() {
                    return selectedEventType.getTypeName() + "-values.json";
                }
            };
            GeneratePanel.this.add(jsonDownload);
            jsonDownload.initiate(target);

            GeneratePanel.this.page.getFeedbackPanel().success("Json created.");
            target.add(GeneratePanel.this.page.getFeedbackPanel());
        }
    };
    layoutForm.add(exportButton);
}
 
开发者ID:bptlab,项目名称:Unicorn,代码行数:37,代码来源:GeneratePanel.java

示例6: getResourceStream

import org.apache.wicket.util.resource.FileResourceStream; //导入依赖的package包/类
protected IResourceStream getResourceStream() {
	File file = tempFileModel.getObject();
	if (file != null && file.exists() && file.canRead() && file.isFile()) {
		return new FileResourceStream(file);
	}
	
	throw new IllegalStateException();
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:9,代码来源:AbstractDeferredDownloadBehavior.java

示例7: OfferDownloadConfig

import org.apache.wicket.util.resource.FileResourceStream; //导入依赖的package包/类
/**
 * If it is more than one file, it will package it into a zip. If it is just one file, it will directly offer that
 * one.
 */
public OfferDownloadConfig(final List<File> files, final String packagedFileName) throws IOException {
    if (files.size() > 1) {
        final File tempFile = zipFiles(files, packagedFileName);
        this.fileName = tempFile.getName();
        this.resourceStream = new FileResourceStream(tempFile);
    } else if (files.size() == 1) {
        final File file = files.get(0);
        this.fileName = file.getName();
        this.resourceStream = new FileResourceStream(file);
    } else {
        throw new IllegalArgumentException("Please provide something to download");
    }
}
 
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:18,代码来源:OfferDownloadConfig.java

示例8: respond

import org.apache.wicket.util.resource.FileResourceStream; //导入依赖的package包/类
@Override
public void respond(Attributes attributes)
{
    FileResourceStream fileResourceStream = new FileResourceStream(file);
    ResourceStreamResource resource = new ResourceStreamResource(fileResourceStream);
    resource.respond(attributes);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:8,代码来源:FileSystemResource.java

示例9: commonInit

import org.apache.wicket.util.resource.FileResourceStream; //导入依赖的package包/类
void commonInit()
{
    downloadBehavior = new AbstractAjaxBehavior()
    {
        private static final long serialVersionUID = 3472918725573624819L;

        @Override
        public void onRequest()
        {
            String name = filename != null ? filename.getObject() : null;
            
            // If no filename has been set explicitly, try to get it from the resource
            IResourceStream is = AjaxDownloadLink.this.getModelObject();
            if (name == null) {
                if (is instanceof FileResourceStream) {
                    name = ((FileResourceStream) is).getFile().getName();
                }
                else if (is instanceof FileSystemResourceStream) {
                    name = ((FileSystemResourceStream) is).getPath().getFileName().toString();
                }
            }
            
            ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(
                    AjaxDownloadLink.this.getModelObject(), name);
            handler.setContentDisposition(ContentDisposition.ATTACHMENT);
            getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
        }
    };
    add(downloadBehavior);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:31,代码来源:AjaxDownloadLink.java

示例10: export

import org.apache.wicket.util.resource.FileResourceStream; //导入依赖的package包/类
private FileResourceStream export()
{
    File downloadFile = null;
    String username = state.getObject().getMode()
            .equals(Mode.AUTOMATION)
            && preferences.getObject().documentType
                    .equals(SELECTEXPORT.AUTOMATED.toString()) ? "CORRECTION_USER"
                            : SecurityContextHolder.getContext().getAuthentication()
                                    .getName();
    try {
        downloadFile = importExportService.exportAnnotationDocument(
                state.getObject().getDocument(), username,
                importExportService.getWritableFormats()
                        .get(importExportService
                                .getWritableFormatId(preferences.getObject().format)),
                state.getObject().getDocument().getName(),
                state.getObject().getMode());
    }
    catch (Exception e) {
        LOG.error("Export failed", e);
        error("Export failed:" + ExceptionUtils.getRootCauseMessage(e));
        // This will cause the open dialog to pop up again, but at least
        // the error feedback message will be visible. With the 
        // RestartResponseException the feedback message only flashes.
        throw new NonResettingRestartException(getPage().getPageClass());
    }
        
    return new FileResourceStream(downloadFile);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:30,代码来源:ExportDocumentDialogContent.java

示例11: GuidelinesDialogContent

import org.apache.wicket.util.resource.FileResourceStream; //导入依赖的package包/类
public GuidelinesDialogContent(String aId, final ModalWindow modalWindow,
        final IModel<AnnotatorState> aModel)
{
    super(aId);

    // Overall progress by Projects
    RepeatingView guidelineRepeater = new RepeatingView("guidelineRepeater");
    add(guidelineRepeater);
    
    for (String guidelineFileName : projectService
            .listGuidelines(aModel.getObject().getProject())) {
        AbstractItem item = new AbstractItem(guidelineRepeater.newChildId());

        guidelineRepeater.add(item);

        // Add a popup window link to display annotation guidelines
        PopupSettings popupSettings = new PopupSettings(
                PopupSettings.RESIZABLE | PopupSettings.SCROLLBARS).setHeight(500)
                        .setWidth(700);

        IResourceStream stream = new FileResourceStream(projectService
                .getGuideline(aModel.getObject().getProject(), guidelineFileName));
        ResourceStreamResource resource = new ResourceStreamResource(stream);
        ResourceLink<Void> rlink = new ResourceLink<>("guideine", resource);
        rlink.setPopupSettings(popupSettings);
        item.add(new Label("guidelineName", guidelineFileName));
        item.add(rlink);
    }
    
    add(new LambdaAjaxLink("cancel", (target) -> modalWindow.close(target)));
}
 
开发者ID:webanno,项目名称:webanno,代码行数:32,代码来源:GuidelinesDialogContent.java

示例12: updateCache

import org.apache.wicket.util.resource.FileResourceStream; //导入依赖的package包/类
private void updateCache(Key key, IResourceStream stream) {
    if (null == stream) {
        cache.put(key, DMDNullResourceStreamReference.INSTANCE);
    } else if (stream instanceof FileResourceStream) {
        FileResourceStream fileResourceStream = (FileResourceStream) stream;
        cache.put(key, new DMDFileResourceStreamReference(fileResourceStream));
    } else if (stream instanceof UrlResourceStream) {
        UrlResourceStream urlResourceStream = (UrlResourceStream) stream;
        cache.put(key, new DMDUrlResourceStreamReference(urlResourceStream));
    }
}
 
开发者ID:Nocket,项目名称:nocket,代码行数:12,代码来源:DMDCachingResourceStreamLocator.java

示例13: onClick

import org.apache.wicket.util.resource.FileResourceStream; //导入依赖的package包/类
@Override
public void onClick()
{
    final File file = getModelObject();
    if (file == null)
    {
        throw new IllegalStateException(getClass().getName() +
            " failed to retrieve a File object from model");
    }

    String fileName = encodedFileName();

    final IResourceStream resourceStream = new FileResourceStream(
        new org.apache.wicket.util.file.File(file)) {
        
        private static final long serialVersionUID = 1L;

        @Override
        public String getContentType() {
            return "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml";
        }
    };
    
    getRequestCycle().scheduleRequestHandlerAfterCurrent(
        new ResourceStreamRequestHandler(resourceStream)
        {
            @Override
            public void respond(IRequestCycle requestCycle)
            {
                super.respond(requestCycle);
                Files.remove(file);
            }
        }.setFileName(fileName)
            .setContentDisposition(ContentDisposition.ATTACHMENT));
}
 
开发者ID:isisaddons-legacy,项目名称:isis-wicket-excel,代码行数:36,代码来源:ExcelFileDownloadLink.java

示例14: respond

import org.apache.wicket.util.resource.FileResourceStream; //导入依赖的package包/类
@Override
public void respond(final Attributes attributes) {
    final FileResourceStream fileResourceStream = new FileResourceStream(file);
    final ResourceStreamResource resource = new ResourceStreamResource(fileResourceStream);
    resource.respond(attributes);
}
 
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:7,代码来源:FileResource.java

示例15: DMDFileResourceStreamReference

import org.apache.wicket.util.resource.FileResourceStream; //导入依赖的package包/类
DMDFileResourceStreamReference(final FileResourceStream fileResourceStream) {
    fileName = fileResourceStream.getFile().getAbsolutePath();
    saveResourceStream(fileResourceStream);
}
 
开发者ID:Nocket,项目名称:nocket,代码行数:5,代码来源:DMDFileResourceStreamReference.java


注:本文中的org.apache.wicket.util.resource.FileResourceStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。