Java 类net.sf.jasperreports.engine.util.FileResolver 实例源码

项目:PDFReporter-Studio    文件:SelectionHelper.java   
public static final boolean openEditor(IFile file, String path) {
    try {
        if (file != null && path != null) {
            // String pathname = FileUtils.findRelativePath(rpath, path);
            FileResolver fileResolver = getFileResolver(file);

            File fileToBeOpened = fileResolver.resolveFile(path);

            if (file != null && fileToBeOpened != null && fileToBeOpened.exists() && fileToBeOpened.isFile()) {
                IFileStore fileStore = EFS.getLocalFileSystem().getStore(fileToBeOpened.toURI());

                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

                IDE.openEditorOnFileStore(page, fileStore);
                return true;
            }
        }
    } catch (PartInitException e) {
        e.printStackTrace();
    }
    return false;
}
项目:jasperreports    文件:JRAbstractExporter.java   
/**
 *
 */
@SuppressWarnings("deprecation")
protected void ensureJasperReportsContext()
{
    if (
        parameters.containsKey(JRExporterParameter.CLASS_LOADER)
        || parameters.containsKey(JRExporterParameter.URL_HANDLER_FACTORY)
        || parameters.containsKey(JRExporterParameter.FILE_RESOLVER)
        )
    {
        LocalJasperReportsContext localJasperReportsContext = new LocalJasperReportsContext(jasperReportsContext);

        if (parameters.containsKey(JRExporterParameter.CLASS_LOADER))
        {
            localJasperReportsContext.setClassLoader((ClassLoader)parameters.get(JRExporterParameter.CLASS_LOADER));
        }

        if (parameters.containsKey(JRExporterParameter.URL_HANDLER_FACTORY))
        {
            localJasperReportsContext.setURLStreamHandlerFactory((URLStreamHandlerFactory)parameters.get(JRExporterParameter.URL_HANDLER_FACTORY));
        }

        if (parameters.containsKey(JRExporterParameter.FILE_RESOLVER))
        {
            localJasperReportsContext.setFileResolver((FileResolver)parameters.get(JRExporterParameter.FILE_RESOLVER));
        }

        setJasperReportsContext(localJasperReportsContext);
    }

    FontUtil.getInstance(jasperReportsContext).resetThreadMissingFontsCache();
}
项目:jasperreports    文件:JRResourcesFillUtil.java   
@SuppressWarnings("deprecation")
public static ResourcesFillContext setResourcesFillContext(Map<String,Object> parameterValues)
{
    ResourcesFillContext context = new ResourcesFillContext();

    ClassLoader classLoader = (ClassLoader) parameterValues.get(
            JRParameter.REPORT_CLASS_LOADER);
    if (classLoader != null)
    {
        JRResourcesUtil.setThreadClassLoader(classLoader);
        context.setClassLoader(classLoader);
    }

    URLStreamHandlerFactory urlHandlerFactory = (URLStreamHandlerFactory) 
            parameterValues.get(JRParameter.REPORT_URL_HANDLER_FACTORY);
    if (urlHandlerFactory != null)
    {
        JRResourcesUtil.setThreadURLHandlerFactory(urlHandlerFactory);
        context.setUrlHandlerFactory(urlHandlerFactory);
    }

    FileResolver fileResolver = (FileResolver) parameterValues.get(
            JRParameter.REPORT_FILE_RESOLVER);
    if (fileResolver != null)
    {
        JRResourcesUtil.setThreadFileResolver(fileResolver);
        context.setFileResolver(fileResolver);
    }

    return context;
}
项目:PDFReporter-Studio    文件:SelectionHelper.java   
public static FileResolver getFileResolver() {
    IEditorPart ep = getActiveJRXMLEditor();
    if (ep != null && ep.getEditorInput() instanceof IFileEditorInput) {
        IFileEditorInput fe = ((IFileEditorInput) ep.getEditorInput());
        return getFileResolver(fe.getFile());
    }
    URLFileResolver fileResolver = new URLFileResolver(Arrays.asList(new File[] { new File(".") })); //$NON-NLS-1$
    fileResolver.setResolveAbsolutePath(true);
    return fileResolver;
}
项目:PDFReporter-Studio    文件:StyleTemplateFactory.java   
protected static IFile resolveTemplates(IFile refFile, List<Object> plist, JasperReportsConfiguration jConfig,
        JRDesignReportTemplate drt) {
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    String str = ExpressionUtil.eval(drt.getSourceExpression(), jConfig);
    if (str != null) {
        if (refFile == null)
            refFile = ((IFileEditorInput) SelectionHelper.getActiveJRXMLEditor().getEditorInput()).getFile();

        for (int i = plist.size() - 1; i >= 0; i--) {
            Object obj = plist.get(i);
            if (obj instanceof JRDesignReportTemplate) {
                str = ExpressionUtil.eval(((JRDesignReportTemplate) obj).getSourceExpression(), jConfig);
            } else if (obj instanceof JRTemplateReference) {
                str = ((JRTemplateReference) obj).getLocation();
            }

            FileResolver fileResolver = SelectionHelper.getFileResolver(refFile);
            File fileToBeOpened = fileResolver.resolveFile(str);
            if (fileToBeOpened != null && fileToBeOpened.exists() && fileToBeOpened.isFile()) {
                IFile[] fs = root.findFilesForLocationURI(fileToBeOpened.toURI());
                if (fs != null && fs.length > 0) {
                    refFile = fs[0];
                } else
                    break;
            }
        }
        return refFile;
    }
    return null;
}
项目:jasper-utils    文件:RU.java   
public static Object getResource(FileResolver fileResolver, String filename) {

        if (fileResolver == null || !(fileResolver instanceof ClassPathFileResolver)) {
            return filename;
        }

        for (String path : ((ClassPathFileResolver) fileResolver).getClassPath()) {
            InputStream is = RU.class.getResourceAsStream(path + "/" + filename);
            if (is != null) {
                return is;
            }
        }

        return filename;
    }
项目:ireport-fork    文件:ProxyFileResolver.java   
/**
 * Add a resolver on top of the list....
 * 
 * @param resolver
 */
public void addResolver(FileResolver resolver)
{
    if (!resolvers.contains(resolver))
    {
        resolvers.add(0, resolver);
    }
}
项目:ireport-fork    文件:ProxyFileResolver.java   
public File resolveFile(String arg0) {

    for (FileResolver res : resolvers)
    {
        try {
            File f = res.resolveFile(arg0);
            if (f!= null) return f;
        } catch (Exception ex)
        {

        }
    }

    return null;
}
项目:ireport-fork    文件:IReportManager.java   
public java.util.List<FileResolver> getFileResolvers() {

    if (fileResolvers == null)
    {
        fileResolvers = new ArrayList<FileResolver>();
    }
    return fileResolvers;
}
项目:jasperreports    文件:JRResourcesFillUtil.java   
public FileResolver getFileResolver()
{
    return fileResolver;
}
项目:jasperreports    文件:JRResourcesFillUtil.java   
public void setFileResolver(FileResolver fileResolver)
{
    this.fileResolver = fileResolver;
}
项目:jasperreports    文件:DefaultRepositoryService.java   
/**
 *
 */
public void setFileResolver(FileResolver fileResolver) 
{
    this.fileResolver = fileResolver;
}
项目:ireport-fork    文件:ProxyFileResolver.java   
public void removeResolver(FileResolver resolver)
{
    resolvers.remove(resolver);
}
项目:ireport-fork    文件:ProxyFileResolver.java   
public ProxyFileResolver()
{
    resolvers = new ArrayList<FileResolver>();
}
项目:ireport-fork    文件:ProxyFileResolver.java   
public ProxyFileResolver(List<FileResolver> resolverList)
{
    this();
    resolvers.addAll(resolverList);
}
项目:ireport-fork    文件:IReportManager.java   
public void setFileResolvers(java.util.List<FileResolver> fileResolvers) {
    this.fileResolvers = fileResolvers;
}