本文整理汇总了Java中net.sf.jasperreports.engine.JRTemplate类的典型用法代码示例。如果您正苦于以下问题:Java JRTemplate类的具体用法?Java JRTemplate怎么用?Java JRTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JRTemplate类属于net.sf.jasperreports.engine包,在下文中一共展示了JRTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collectTemplates
import net.sf.jasperreports.engine.JRTemplate; //导入依赖的package包/类
protected void collectTemplates() throws JRException
{
templates = new ArrayList<JRTemplate>();
if (reportTemplates != null)
{
for (JRFillReportTemplate reportTemplate : reportTemplates)
{
JRTemplate template = reportTemplate.evaluate();
if (template != null)
{
templates.add(template);
}
}
}
Collection<JRTemplate> paramTemplates = (Collection<JRTemplate>) mainDataset.getParameterValue(
JRParameter.REPORT_TEMPLATES, true);
if (paramTemplates != null)
{
templates.addAll(paramTemplates);
}
}
示例2: collectStyles
import net.sf.jasperreports.engine.JRTemplate; //导入依赖的package包/类
protected void collectStyles(JRTemplate template, List<JRStyle> externalStyles,
Set<String> loadedLocations, Set<String> templateParentLocations) throws JRException
{
collectIncludedTemplates(template, externalStyles,
loadedLocations, templateParentLocations);
JRStyle[] templateStyles = template.getStyles();
if (templateStyles != null)
{
for (int i = 0; i < templateStyles.length; i++)
{
JRStyle style = templateStyles[i];
String styleName = style.getName();
if (styleName == null)
{
throw
new JRRuntimeException(
EXCEPTION_MESSAGE_KEY_EXTERNAL_STYLE_NAME_NOT_SET,
(Object[])null
);
}
externalStyles.add(style);
}
}
}
示例3: JRFillContext
import net.sf.jasperreports.engine.JRTemplate; //导入依赖的package包/类
/**
* Constructs a fill context.
*/
public JRFillContext(BaseReportFiller masterFiller)
{
this.masterFiller = masterFiller;
this.jasperReportsContext = masterFiller.getJasperReportsContext();
this.styledTextUtil = JRStyledTextUtil.getInstance(jasperReportsContext);
loadedImageRenderers = new HashMap<Object,Renderable>();
renderersCache = new RenderersCache(jasperReportsContext);
loadedSubreports = new HashMap<Object,JasperReport>();
loadedTemplates = new HashMap<Object,JRTemplate>();
deduplicableRegistry = new DeduplicableRegistry();
FontUtil.getInstance(jasperReportsContext).resetThreadMissingFontsCache();
legacyElementStretchEnabled =
JRPropertiesUtil.getInstance(jasperReportsContext).getBooleanProperty(
StretchTypeEnum.PROPERTY_LEGACY_ELEMENT_STRETCH_ENABLED
);
legacyBandEvaluationEnabled =
JRPropertiesUtil.getInstance(jasperReportsContext).getBooleanProperty(
JRCalculator.PROPERTY_LEGACY_BAND_EVALUATION_ENABLED
);
}
示例4: prepareReportParameters
import net.sf.jasperreports.engine.JRTemplate; //导入依赖的package包/类
private Map<String, Object> prepareReportParameters(ReportType reportType, OperationResult parentResult) {
Map<String, Object> params = new HashMap<String, Object>();
if (reportType.getTemplateStyle() != null) {
byte[] reportTemplateStyleBase64 = reportType.getTemplateStyle();
byte[] reportTemplateStyle = Base64.decodeBase64(reportTemplateStyleBase64);
try {
LOGGER.trace("Style template string {}", new String(reportTemplateStyle));
InputStream inputStreamJRTX = new ByteArrayInputStream(reportTemplateStyle);
JRTemplate templateStyle = JRXmlTemplateLoader.load(inputStreamJRTX);
params.put(PARAMETER_TEMPLATE_STYLES, templateStyle);
LOGGER.trace("Style template parameter {}", templateStyle);
} catch (Exception ex) {
LOGGER.error("Error create style template parameter {}", ex.getMessage());
throw new SystemException(ex);
}
}
// for our special datasource
params.put(PARAMETER_REPORT_OID, reportType.getOid());
params.put(PARAMETER_OPERATION_RESULT, parentResult);
params.put(ReportService.PARAMETER_REPORT_SERVICE, reportService);
return params;
}
示例5: componentShowing
import net.sf.jasperreports.engine.JRTemplate; //导入依赖的package包/类
@Override
public void componentShowing() {
super.componentShowing();
JRTemplate template = ((JRTXEditorSupport)cloneableEditorSupport()).getCurrentModel();
if (template != null && ((JRTXEditorSupport)cloneableEditorSupport()).isModified())
{
// Update the content...
try {
String content = JRXmlTemplateWriter.writeTemplate(template,"UTF-8");
getEditorPane().setText(content);
getEditorPane().setCaretPosition(0);
((JRTXVisualView)((JRTXEditorSupport)cloneableEditorSupport()).descriptions[0]).setNeedModelRefresh(false);
} catch (Exception ex)
{
ex.printStackTrace();
}
}
((JRTXEditorSupport)cloneableEditorSupport()).setCurrentModel(null);
}
示例6: writeTemplate
import net.sf.jasperreports.engine.JRTemplate; //导入依赖的package包/类
/**
* Returns the XML representation of a template.
*
* @param jasperReportsContext
* @param template the template
* @param encoding the XML encoding to use
* @return the XML representation of the template
*/
public static String writeTemplate(JasperReportsContext jasperReportsContext,
JRTemplate template, String encoding)
{
StringWriter stringOut = new StringWriter();
try
{
writeTemplate(jasperReportsContext, template, stringOut, encoding);
}
catch (IOException e)
{
throw new JRRuntimeException(e);
}
return stringOut.toString();
}
示例7: JRXmlTemplateWriter
import net.sf.jasperreports.engine.JRTemplate; //导入依赖的package包/类
/**
* Creates an XML template writer.
*
* @param jasperReportsContext
* @param template the template to write
* @param out the output writer
* @param encoding the XML encoding to use
*/
public JRXmlTemplateWriter(JasperReportsContext jasperReportsContext,
JRTemplate template, Writer out, String encoding)
{
this.template = template;
this.encoding = encoding;
String version = JRPropertiesUtil.getInstance(jasperReportsContext).getProperty(JRXmlBaseWriter.PROPERTY_REPORT_VERSION);
useWriter(new JRXmlWriteHelper(out), version);
}
示例8: collectTemplateStyles
import net.sf.jasperreports.engine.JRTemplate; //导入依赖的package包/类
protected List<JRStyle> collectTemplateStyles() throws JRException
{
collectTemplates();
List<JRStyle> externalStyles = new ArrayList<JRStyle>();
HashSet<String> loadedLocations = new HashSet<String>();
for (JRTemplate template : templates)
{
collectStyles(template, externalStyles, loadedLocations);
}
return externalStyles;
}
示例9: collectIncludedTemplates
import net.sf.jasperreports.engine.JRTemplate; //导入依赖的package包/类
protected void collectIncludedTemplates(JRTemplate template, List<JRStyle> externalStyles,
Set<String> loadedLocations, Set<String> templateParentLocations) throws JRException
{
JRTemplateReference[] includedTemplates = template.getIncludedTemplates();
if (includedTemplates != null)
{
for (int i = 0; i < includedTemplates.length; i++)
{
JRTemplateReference reference = includedTemplates[i];
String location = reference.getLocation();
if (!templateParentLocations.add(location))
{
throw
new JRRuntimeException(
EXCEPTION_MESSAGE_KEY_CIRCULAR_DEPENDENCY_FOUND,
new Object[]{location}
);
}
if (loadedLocations.add(location))
{
//template not yet loaded
JRTemplate includedTemplate = JRFillReportTemplate.loadTemplate(
location, this);
collectStyles(includedTemplate, externalStyles,
loadedLocations, templateParentLocations);
}
}
}
}
示例10: xml2model
import net.sf.jasperreports.engine.JRTemplate; //导入依赖的package包/类
protected void xml2model(InputStream in) {
JRTemplate jd = JRXmlTemplateLoader.load(in);
ANode m = new MRoot(null, new JasperDesign());
IFile file = ((IFileEditorInput) getEditorInput()).getFile();
MStylesTemplate ms = new MStylesTemplate(m, file);
ms.setValue(jd);
ms.setJasperConfiguration(jrContext);
StyleTemplateFactory.createTemplate(ms, new HashSet<String>(), true, file, file.getLocation().toFile(),
(JRSimpleTemplate) jd);
setModel(m);
}
示例11: loadStyles
import net.sf.jasperreports.engine.JRTemplate; //导入依赖的package包/类
private static DRStyle[] loadStyles(JRTemplate template) {
Validate.notNull(template, "template must not be null");
JRStyle[] jrStyles = template.getStyles();
DRStyle[] styles = new DRStyle[jrStyles.length];
for (int i = 0; i < jrStyles.length; i++) {
JRStyle jrStyle = jrStyles[i];
styles[i] = convertStyle(jrStyle);
}
return styles;
}
示例12: loadTemplateStyles
import net.sf.jasperreports.engine.JRTemplate; //导入依赖的package包/类
protected void loadTemplateStyles(String location, Set<String> loadedLocations, Set<String> parentLocations)
{
if (!parentLocations.add(location))
{
throw
new JRRuntimeException(
EXCEPTION_MESSAGE_KEY_CIRCULAR_DEPENDENCY_FOUND,
new Object[]{location}
);
}
if (!loadedLocations.add(location))
{
//already loaded
return;
}
JRTemplate template;
try
{
template = JRXmlTemplateLoader.getInstance(getJasperReportsContext()).loadTemplate(location);
}
catch (Exception e)
{
log.warn("Could not load template from location " + location
+ "; some styles might remain unresolved.");
return;
}
JRTemplateReference[] includedTemplates = template.getIncludedTemplates();
if (includedTemplates != null)
{
for (int i = 0; i < includedTemplates.length; i++)
{
JRTemplateReference reference = includedTemplates[i];
loadTemplateStyles(reference.getLocation(), loadedLocations, parentLocations);
}
}
collectStyles(template.getStyles());
}
示例13: load
import net.sf.jasperreports.engine.JRTemplate; //导入依赖的package包/类
/**
* @see #loadTemplate(String)
*/
public static JRTemplate load(String location) throws JRException
{
return getDefaultInstance().loadTemplate(location);
}
示例14: loadTemplate
import net.sf.jasperreports.engine.JRTemplate; //导入依赖的package包/类
protected static JRTemplate loadTemplate(Object source, JRBaseFiller filler) throws JRException
{
JRTemplate template;
if (filler.fillContext.hasLoadedTemplate(source))
{
template = filler.fillContext.getLoadedTemplate(source);
}
else
{
if (log.isDebugEnabled())
{
log.debug("Loading styles template from " + source);
}
if (source instanceof String)
{
template = JRXmlTemplateLoader.getInstance(filler.getJasperReportsContext()).loadTemplate((String) source);
}
else if (source instanceof File)
{
template = JRXmlTemplateLoader.getInstance(filler.getJasperReportsContext()).loadTemplate((File) source);
}
else if (source instanceof URL)
{
template = JRXmlTemplateLoader.getInstance(filler.getJasperReportsContext()).loadTemplate((URL) source);
}
else if (source instanceof InputStream)
{
template = JRXmlTemplateLoader.getInstance(filler.getJasperReportsContext()).loadTemplate((InputStream) source);
}
else
{
throw
new JRRuntimeException(
EXCEPTION_MESSAGE_KEY_UNKNOWN_TEMPLATE_SOURCE,
new Object[]{source.getClass().getName()}
);
}
filler.fillContext.registerLoadedTemplate(source, template);
}
return template;
}
示例15: getTemplates
import net.sf.jasperreports.engine.JRTemplate; //导入依赖的package包/类
public List<JRTemplate> getTemplates()
{
return templates;
}