Java 类net.sf.jasperreports.engine.JRReportTemplate 实例源码

项目:jasperreports    文件:JRBaseReport.java   
protected void copyTemplates(JRReport report, JRBaseObjectFactory factory)
{
    JRReportTemplate[] reportTemplates = report.getTemplates();
    if (reportTemplates == null || reportTemplates.length == 0)
    {
        templates = null;
    }
    else
    {
        templates = new JRReportTemplate[reportTemplates.length];
        for (int i = 0; i < reportTemplates.length; i++)
        {
            templates[i] = factory.getReportTemplate(reportTemplates[i]);
        }
    }
}
项目:jasperreports    文件:JRApiWriter.java   
/**
 * 
 */
protected void writeTemplates(JRReport report, String indent)
{
    JRReportTemplate[] templates = report.getTemplates();
    if (templates != null)
    {
        for (int i = 0; i < templates.length; i++)
        {
            JRReportTemplate template = templates[i];
            writeTemplate( template, "reportTemplate" + i);
            write( "jasperDesign.addTemplate(reportTemplate" + i + ");\n");
        }
        write("\n");
        flush();
    }
}
项目:jasperreports    文件:ReportConverter.java   
protected void loadReportStyles(JRReport report)
{
    JRReportTemplate[] templates = report.getTemplates();
    if (templates != null)
    {
        Set<String> loadedLocations = new HashSet<String>();
        for (int i = 0; i < templates.length; i++)
        {
            loadReportTemplateStyles(templates[i], loadedLocations);
        }
    }

    collectStyles(report.getStyles());
}
项目:jasperreports    文件:ReportConverter.java   
protected void loadReportTemplateStyles(JRReportTemplate template, Set<String> loadedLocations)
{
    JRExpression sourceExpression = template.getSourceExpression();
    if (sourceExpression != null)
    {
        String location = JRExpressionUtil.getSimpleExpressionText(sourceExpression);
        if (location == null)
        {
            log.warn("Template source expression " + sourceExpression.getText() 
                    + "cannot be evaluated; some styles might remain unresolved.");
        }
        else
        {
            HashSet<String> parentLocations = new HashSet<String>();
            loadTemplateStyles(location, loadedLocations, parentLocations);
        }
    }
}
项目:jasperreports    文件:JRXmlWriter.java   
protected void writeTemplates(JRReport report) throws IOException
{
    JRReportTemplate[] templates = report.getTemplates();
    if (templates != null)
    {
        for (int i = 0; i < templates.length; i++)
        {
            JRReportTemplate template = templates[i];
            writeTemplate(template);
        }
    }
}
项目:PDFReporter-Studio    文件:ImpStyleTemplate.java   
public File publish(JasperDesign jd, JRReportTemplate img, MReportUnit mrunit, IProgressMonitor monitor, Set<String> fileset, IFile file) throws Exception {
    AFileResource fres = findFile(mrunit, monitor, jd, fileset, getExpression(img), file);
    if (fres != null) {
        JRSimpleTemplate jrt = (JRSimpleTemplate) JRXmlTemplateLoader.load(fres.getFile());
        for (JRTemplateReference r : jrt.getIncludedTemplatesList()) {
            IFile[] fs = root.findFilesForLocationURI(fres.getFile().toURI());
            if (fs != null && fs.length > 0) {
                File ftr = findFile(file, r.getLocation());
                if (ftr != null && ftr.exists()) {
                    fileset.add(ftr.getAbsolutePath());
                    addResource(monitor, mrunit, fileset, ftr, new PublishOptions());
                }
            }
        }
        return fres.getFile();
    }
    return null;
}
项目:PDFReporter-Studio    文件:ExternalStylesManager.java   
/**
 * Resolve an expression and return the reference to the style or null if it can not be resolve
 * 
 * @param styleExpression expression of the external style
 * @param project project of the report
 * @param jConfig Configuration of the report to evaluate the expression
 * @return path of the style of null if the expression can't be resolved
 */
public static String evaluateStyleExpression(JRReportTemplate style, IFile project, JasperReportsConfiguration jConfig){    
    String evaluatedExpression = null;
    String projectPath = project.getLocation().toPortableString();
    JRExpression styleExpression = style.getSourceExpression();
    String expString = styleExpression != null ? styleExpression.getText() : "";
    try{
        //Check first if there are previous failed attempt to evaluate the expression
        if (!isNotValuable(projectPath, expString)){
            evaluatedExpression =  ExpressionUtil.cachedExpressionEvaluation(styleExpression, jConfig); 
            if (evaluatedExpression == null){
                //The expression is not valuable, add it to the map
                addNotValuableExpression(projectPath, expString);
                fireEvent(STYLE_NOT_FOUND_EVENT, style);
            }
        }
    }catch(Exception ex){
        ex.printStackTrace();
        //The expression is not valuable, add it to the map
        addNotValuableExpression(projectPath, expString);
        fireEvent(STYLE_NOT_FOUND_EVENT, style);
    }
    return evaluatedExpression;
}
项目:PDFReporter-Studio    文件:ExternalStylesManager.java   
/**
 * If the expression of an external style can be resolved then return all the jrstyle defined inside
 * otherwise return an empty list
 * 
 * @param styleExpression expression of the external style
 * @param project project of the report
 * @param jConfig Configuration of the report to evaluate the expression
 * @return Not null list of styles inside the external style associated with the project and expression
 */
public static List<JRStyle> getStyles(JRReportTemplate style, IFile project, JasperReportsConfiguration jConfig) {
    String evaluatedExpression = evaluateStyleExpression(style, project, jConfig);
    if (evaluatedExpression != null) {
        File styleFile = StyleTemplateFactory.getFile(evaluatedExpression, project);
        if (styleFile != null) {
            String key = styleFile.getAbsolutePath();
            List<JRStyle> cachedStyles = externalStylesCache.get(key);
            if (cachedStyles == null) {
                cachedStyles = new ArrayList<JRStyle>();
                StyleTemplateFactory.getStylesReference(project, evaluatedExpression, cachedStyles, new HashSet<File>());
                externalStylesCache.put(key, cachedStyles);
            }
            fireEvent(STYLE_FOUND_EVENT, style);
            return cachedStyles;
        } else {
            String projectPath = project.getLocation().toPortableString();
            JRExpression styleExpression = style.getSourceExpression();
            String expString = styleExpression != null ? styleExpression.getText() : "";
            addNotValuableExpression(projectPath, expString);
            fireEvent(STYLE_NOT_FOUND_EVENT, style);
        }
    }
    return new ArrayList<JRStyle>();
}
项目:ireport-fork    文件:AbstractStyleProperty.java   
@Override
public List getTagList() 
{
    List tags = new ArrayList();
    tags.add(new Tag( null , ""));
    List styles = jasperDesign.getStylesList();
    for (int i=0; i<styles.size(); ++i)
    {
        JRDesignStyle style = (JRDesignStyle)styles.get(i);
        tags.add(new Tag( style , style.getName()));
        style.getEventSupport().addPropertyChangeListener(
            WeakListeners.propertyChange(this, style.getEventSupport())
            );
    }

    // Add all the references too...
    JRReportTemplate[] templates = jasperDesign.getTemplates();
    for (int i=0; i<templates.length; ++i)
    {
        tags.addAll(getStyleInTemplate(templates[i]));
    }

    return tags;
}
项目:jasperreports    文件:JRXmlDigesterFactory.java   
protected static void addTemplateRules(Digester digester)
{
    String templatePattern = JRXmlConstants.ELEMENT_jasperReport + "/" + JRXmlConstants.ELEMENT_template;
    //do not change the order
    digester.addObjectCreate(templatePattern, JRDesignReportTemplate.class);
    digester.addSetNext(templatePattern, "addTemplate", JRReportTemplate.class.getName());
    @SuppressWarnings("deprecation")
    Class<?> lcDepStringExprFactoryClass = JRStringExpressionFactory.class;
    digester.addFactoryCreate(templatePattern, lcDepStringExprFactoryClass);
    digester.addCallMethod(templatePattern, "setText", 0);
    digester.addSetNext(templatePattern, "setSourceExpression", JRExpression.class.getName());
}
项目:jasperreports    文件:JRXmlWriter.java   
/**
 * 
 * @param template
 * @throws IOException
 */
protected void writeTemplate(JRReportTemplate template) throws IOException
{
    writeExpression(
            JRXmlConstants.ELEMENT_template, 
            template.getSourceExpression(),
            true, 
            String.class.getName());
}
项目:jasperreports    文件:JRApiWriter.java   
/**
 * 
 */
protected void writeTemplate( JRReportTemplate template, String templateName)
{
    write( "JRDesignReportTemplate " + templateName + " = new JRDesignReportTemplate();\n");
    writeExpression( template.getSourceExpression(), templateName, "SourceExpression", String.class.getName());
    flush();
}
项目:jasperreports    文件:JRVerifier.java   
protected void verifyReportTemplates()
{
    JRReportTemplate[] templates = jasperDesign.getTemplates();
    if (templates != null)
    {
        for (int i = 0; i < templates.length; i++)
        {
            JRReportTemplate template = templates[i];
            verifyTemplate(template);
        }
    }
}
项目:jasperreports    文件:JRVerifier.java   
protected void verifyTemplate(JRReportTemplate template)
{
    JRExpression sourceExpression = template.getSourceExpression();
    if (sourceExpression == null)
    {
        addBrokenRule("Template source expression missing.", template);
    }
}
项目:jasperreports    文件:JasperDesign.java   
/**
 * Removes a report template.
 *
 * @param template the template to remove
 * @return <code>true</code> if and only if the template has been found and removed
 */
public boolean removeTemplate(JRReportTemplate template)
{
    int idx = templateList.indexOf(template);
    if (idx >= 0)
    {
        templateList.remove(idx);
        getEventSupport().fireCollectionElementRemovedEvent(PROPERTY_TEMPLATES, template, idx);
        return true;
    }
    return false;
}
项目:jasperreports    文件:JRFillReportTemplate.java   
public JRFillReportTemplate(JRReportTemplate template, JRBaseFiller filler, JRFillObjectFactory factory)
{
    factory.put(template, this);

    parent = template;
    this.filler = filler;
}
项目:jasperreports    文件:JRFillObjectFactory.java   
public JRFillReportTemplate getReportTemplate(JRReportTemplate template)
{
    JRFillReportTemplate fillTemplate = null;
    if (template != null)
    {
        fillTemplate = (JRFillReportTemplate) get(template);
        if (fillTemplate == null)
        {
            fillTemplate = new JRFillReportTemplate(template, filler, this);
        }
    }
    return fillTemplate;
}
项目:jasperreports    文件:JRBaseFiller.java   
protected void createReportTemplates(JRFillObjectFactory factory)
{
    JRReportTemplate[] templates = jasperReport.getTemplates();
    if (templates != null)
    {
        reportTemplates = new JRFillReportTemplate[templates.length];

        for (int i = 0; i < templates.length; i++)
        {
            JRReportTemplate template = templates[i];
            reportTemplates[i] = factory.getReportTemplate(template);
        }
    }
}
项目:PDFReporter-Studio    文件:ExternalStylesManager.java   
/**
 * Fire an event of style found or not found
 * 
 * @param event the text of the event, should be STYLE_NOT_FOUND_EVENT or STYLE_FOUND_EVENT
 * @param element JRelement of the template style
 */
private static void fireEvent(String event, JRReportTemplate element){
    if (element instanceof JRChangeEventsSupport){
        JRChangeEventsSupport eventElement = (JRChangeEventsSupport)element;
        eventElement.getEventSupport().firePropertyChange(event, null, null);
    }
}
项目:PDFReporter-Studio    文件:ExternalStylesManager.java   
/**
 * Search in all the external styles template of a report a style with a specific name
 * and return it. If it can't be found it return null, and if there are more styles in 
 * different templates with the searched name then the first one found is returned
 * 
 * @param styleName the name of the style searched
 * @param jConfig jasper configuration of the report 
 * @return a JRStyle reference of the searched style or null if it can't be found between 
 * the defined external styles
 */
public static JRStyle getExternalStyle(String styleName, JasperReportsConfiguration jConfig){
    JasperDesign design = jConfig.getJasperDesign();
    if (design != null){
        IFile project = (IFile) jConfig.get(FileUtils.KEY_FILE);
        for (JRReportTemplate template : design.getTemplatesList()){
            List<JRStyle> loadedStyles = getStyles(template, project, jConfig);
            JRStyle searchedStyle = searchStyleInList(loadedStyles, styleName);
            if (searchedStyle != null) return searchedStyle;
        }
    }
    return null;
}
项目:PDFReporter-Studio    文件:ReportFactory.java   
public static void createStyles(JasperReportsConfiguration jConfig, JasperDesign jd, ANode report, int index) {
    MStyles nStyle = new MStyles(report, index);
    if (jd.getTemplates() != null)
        for (Iterator<JRReportTemplate> it = jd.getTemplatesList().iterator(); it.hasNext();)
            createNode(nStyle, it.next(), -1, (IFile) jConfig.get(FileUtils.KEY_FILE));
    if (jd.getStyles() != null) {
        for (JRStyle jrstyle : jd.getStylesList()) {
            ANode mstyle = createNode(nStyle, jrstyle, -1);
            if (((JRDesignStyle) jrstyle).getConditionalStyleList() != null)
                for (Object jrc : ((JRDesignStyle) jrstyle).getConditionalStyleList())
                    createNode(mstyle, jrc, -1);
        }
    }
    nStyle.updateDefaulStyle();
}
项目:ireport-fork    文件:AbstractStyleProperty.java   
List getStyleInTemplate(JRReportTemplate template)
{
    List styleNames = new ArrayList();
    if (template != null)
    {
        String fileNameExp = Misc.getExpressionText(template.getSourceExpression());
        if (fileNameExp != null && fileNameExp.length() > 0)
        {
            ExpressionFileResolver resolver = new ExpressionFileResolver(
                    (JRDesignExpression)template.getSourceExpression(),jasperDesign.getMainDesignDataset(), jasperDesign);

            File f = resolver.resolveFile(null);
            if (f!=null && f.exists())
            {
                try {
                    // try to load this jrtx template...
                    JRSimpleTemplate template2 = (JRSimpleTemplate) JRXmlTemplateLoader.load(new FileInputStream(f));

                    JRStyle[] styles = template2.getStyles();
                    for (int i=0; i<styles.length; ++i)
                    {
                        styleNames.add(new Tag(styles[i].getName(),I18n.getString("property.styleNameReference",  styles[i].getName())));
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    }
    return styleNames;
}
项目:jasperreports    文件:JRBaseReport.java   
@Override
public JRReportTemplate[] getTemplates()
{
    return templates;
}
项目:jasperreports    文件:JRBaseReportTemplate.java   
public JRBaseReportTemplate(JRReportTemplate reportTemplate, JRAbstractObjectFactory factory)
{
    factory.put(reportTemplate, this);

    sourceExpression = factory.getExpression(reportTemplate.getSourceExpression());
}
项目:jasperreports    文件:JasperDesign.java   
@Override
public JRReportTemplate[] getTemplates()
{
    return templateList.toArray(new JRReportTemplate[templateList.size()]);
}
项目:jasperreports    文件:TableReport.java   
@Override
public JRReportTemplate[] getTemplates()
{
    // the parent report's templates are always used for the subreport
    return null;
}
项目:PDFReporter-Studio    文件:JrxmlPublishContributor.java   
protected void publishTemplates(MReportUnit mrunit, IProgressMonitor monitor, JasperDesign jasper, Set<String> fileset, IFile file, String version) throws Exception {
    for (JRReportTemplate rt : jasper.getTemplatesList()) {
        impStyle.publish(jasper, rt, mrunit, monitor, fileset, file);
    }
}
项目:PDFReporter-Studio    文件:ImpStyleTemplate.java   
protected JRDesignExpression getExpression(JRReportTemplate img) {
    return (JRDesignExpression) ((JRReportTemplate) img).getSourceExpression();
}
项目:PDFReporter-Studio    文件:StyleTemplateFactory.java   
private static List<JRStyle> getStyles(JasperReportsConfiguration jConfig, JasperDesign jd, IFile file) {
    List<JRStyle> list = new ArrayList<JRStyle>();
    for (JRReportTemplate t : jd.getTemplatesList())
        list.addAll(ExternalStylesManager.getStyles(t, file, jConfig));
    return list;
}
项目:ireport-fork    文件:TemplateReferenceNode.java   
/**
 * @return the template
 */
public JRReportTemplate getTemplate() {
    return template;
}
项目:ireport-fork    文件:TemplateElementValidationItem.java   
public TemplateElementValidationItem(JRReportTemplate template)
{
   this.template = template;
}
项目:ireport-fork    文件:TemplateElementValidationItem.java   
/**
 * @return the template
 */
public JRReportTemplate getTemplate() {
    return template;
}
项目:ireport-fork    文件:TemplateElementValidationItem.java   
/**
 * @param template the template to set
 */
public void setTemplate(JRReportTemplate template) {
    this.template = template;
}
项目:jasperreports    文件:JasperDesign.java   
/**
 * Inserts a report template at specified position.
 *
 * @param index the template position.
 * @param template the template to insert.
 * @see #getTemplates()
 */
public void addTemplate(int index, JRReportTemplate template)
{
    templateList.add(index, template);

    getEventSupport().fireCollectionElementAddedEvent(PROPERTY_TEMPLATES, template, index);
}
项目:jasperreports    文件:JasperDesign.java   
/**
 * Adds a report template.
 *
 * @param template the template to add.
 * @see #getTemplates()
 */
public void addTemplate(JRReportTemplate template)
{
    addTemplate(templateList.size(), template);
}
项目:jasperreports    文件:JasperDesign.java   
/**
 * Returns the list of report templates defined in the report.
 * 
 * @return the list of {@link JRReportTemplate} objects for the report
 * @see #getTemplates()
 * @see #addTemplate(JRReportTemplate)
 */
public List<JRReportTemplate> getTemplatesList()
{
    return templateList;
}
项目:PDFReporter-Studio    文件:MStyleTemplate.java   
/**
 * Instantiates a new m style template.
 * 
 * @param parent
 *          the parent
 * @param jrstyle
 *          the jrstyle
 * @param newIndex
 *          the new index
 */
public MStyleTemplate(ANode parent, JRReportTemplate jrstyle, int newIndex) {
    super(parent, newIndex);
    setValue(jrstyle);
}