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; }
public static void getStylesReference(IFile file, String location, List<JRStyle> list, Set<File> files) { if (location == null) return; File fileToBeOpened = getFile(location, file); if (files.contains(fileToBeOpened)) return; if (fileToBeOpened != null && fileToBeOpened.exists() && fileToBeOpened.isFile()) { files.add(fileToBeOpened); JRSimpleTemplate jrst = (JRSimpleTemplate) JRXmlTemplateLoader.load(fileToBeOpened); list.addAll(jrst.getStylesList()); List<JRTemplateReference> tlist = jrst.getIncludedTemplatesList(); if (tlist != null && !tlist.isEmpty()) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IFile[] fs = root.findFilesForLocationURI(fileToBeOpened.toURI()); if (fs != null && fs[0] != null) for (JRTemplateReference tr : tlist) getStylesReference(fs[0], tr.getLocation(), list, files); } } }
public static void getStylesReference(String absoulteLocation, List<JRStyle> list, Set<File> files) { if (absoulteLocation == null) return; File fileToBeOpened = new File(absoulteLocation); if (files.contains(fileToBeOpened)) return; if (fileToBeOpened != null && fileToBeOpened.exists() && fileToBeOpened.isFile()) { files.add(fileToBeOpened); JRSimpleTemplate jrst = (JRSimpleTemplate) JRXmlTemplateLoader.load(fileToBeOpened); list.addAll(jrst.getStylesList()); List<JRTemplateReference> tlist = jrst.getIncludedTemplatesList(); if (tlist != null && !tlist.isEmpty()) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IFile[] fs = root.findFilesForLocationURI(fileToBeOpened.toURI()); if (fs != null && fs[0] != null) for (JRTemplateReference tr : tlist) getStylesReference(fs[0], tr.getLocation(), list, files); } } }
/** * We will initialize file contents with the imported styles */ @Override protected InputStream openContentStream() { try { JRSimpleTemplate tmp = new JRSimpleTemplate(); if (stylesToImport == null || stylesToImport.isEmpty()){ JRDesignStyle jrDesignStyle = new JRDesignStyle(); jrDesignStyle.setName("SimpleStyle"); //$NON-NLS-1$ tmp.addStyle(jrDesignStyle); } else { for(JRStyle style : stylesToImport){ tmp.addStyle(style); } } String contents = JRXmlTemplateWriter.writeTemplate(tmp); return new ByteArrayInputStream(contents.getBytes()); } catch (JRException e) { e.printStackTrace(); } return null; }
@Override protected void setParentStyle(JRDesignStyle currentStyle, String parentStyleName) { JRSimpleTemplate template = (JRSimpleTemplate) digester.peek(digester.getCount() - 1); JRStyle parent = template.getStyle(parentStyleName); if (parent == null) { currentStyle.setParentStyleNameReference(parentStyleName); } else { currentStyle.setParentStyle(parent); } }
protected RuleSet readRuleSet() { return new RuleSetBase() { @Override public void addRuleInstances(Digester digester) { digester.addObjectCreate(PATTERN_ROOT, JRSimpleTemplate.class); digester.addCallMethod(PATTERN_INCLUDED_TEMPLATE, "addIncludedTemplate", 0); digester.addFactoryCreate(PATTERN_STYLE, JRTemplateStyleFactory.class); digester.addSetNext(PATTERN_STYLE, "addStyle", JRStyle.class.getName()); digester.addFactoryCreate(PATTERN_STYLE_PEN, JRPenFactory.Style.class.getName()); digester.addFactoryCreate(PATTERN_BOX, JRBoxFactory.class.getName()); digester.addFactoryCreate(PATTERN_BOX_PEN, JRPenFactory.Box.class.getName()); digester.addFactoryCreate(PATTERN_BOX_TOP_PEN, JRPenFactory.Top.class.getName()); digester.addFactoryCreate(PATTERN_BOX_LEFT_PEN, JRPenFactory.Left.class.getName()); digester.addFactoryCreate(PATTERN_BOX_BOTTOM_PEN, JRPenFactory.Bottom.class.getName()); digester.addFactoryCreate(PATTERN_BOX_RIGHT_PEN, JRPenFactory.Right.class.getName()); digester.addFactoryCreate(PATTERN_PARAGRAPH, JRParagraphFactory.class.getName()); digester.addFactoryCreate(PATTERN_TAB_STOP, TabStopFactory.class.getName()); digester.addSetNext(PATTERN_TAB_STOP, "addTabStop", TabStop.class.getName()); } }; }
public static ANode createNode(ANode parent, Object obj, int index, IFile file, JRSimpleTemplate jrst) { if (obj instanceof JRDesignStyle) { index += jrst.getIncludedTemplatesList().size(); return new MStyle(parent, (JRDesignStyle) obj, index); } if (obj instanceof JRTemplateReference) { ANode n = new MStyleTemplateReference(parent, (JRTemplateReference) obj, index); createTemplateReference(n, ((JRTemplateReference) obj).getLocation(), -1, new HashSet<String>(), false, file); } return null; }
public static void createTemplateReference(ANode parent, String location, int newIndex, Set<String> set, boolean editable, IFile file) { if (file == null) return; File fileToBeOpened = getFile(location, file); if (fileToBeOpened != null && fileToBeOpened.exists() && fileToBeOpened.isFile()) { JRSimpleTemplate jrst = (JRSimpleTemplate) JRXmlTemplateLoader.load(fileToBeOpened); createTemplate(parent, set, editable, file, fileToBeOpened, jrst); } }
/** * We will initialize file contents with a sample text. */ protected InputStream openContentStream() { try { JRSimpleTemplate tmp = new JRSimpleTemplate(); JRDesignStyle jrDesignStyle = new JRDesignStyle(); jrDesignStyle.setName("SimpleStyle"); //$NON-NLS-1$ tmp.addStyle(jrDesignStyle); String contents = JRXmlTemplateWriter.writeTemplate(tmp); return new ByteArrayInputStream(contents.getBytes()); } catch (JRException e) { e.printStackTrace(); } return null; }
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); }
protected String doModel2xml() throws Exception { JRSimpleTemplate report = (JRSimpleTemplate) model.getChildren().get(0).getValue(); IFile file = ((IFileEditorInput) getEditorInput()).getFile(); String xml = JRXmlTemplateWriter.writeTemplate(report, JRXmlWriterHelper.fixencoding(file.getCharset(true))); xml = xml.replaceFirst("<jasperTemplate ", "<!-- Created with PDFReporter Studio -->\n<jasperTemplate "); //$NON-NLS-1$ //$NON-NLS-2$ return xml; }
public StyleNode(JRSimpleTemplate template, JRBaseStyle style, Lookup doLkp) { super (Children.LEAF, new ProxyLookup(doLkp, Lookups.fixed(template, style))); this.template = template; this.style = style; init(); }
@SuppressWarnings("unchecked") public NameProperty(JRDesignStyle style, JRSimpleTemplate template) { super(JRDesignStyle.PROPERTY_NAME, String.class, I18n.getString("StyleNode.Property.Name"), I18n.getString("StyleNode.Property.NameStyle")); this.style = style; this.template = template; this.setValue("oneline", Boolean.TRUE); }
@SuppressWarnings("unchecked") public DefaultStyleProperty(JRDesignStyle style, JRSimpleTemplate template) { super(JRDesignStyle.PROPERTY_DEFAULT, Boolean.class, "Default Style", I18n.getString("StyleNode.Property.DefaultStyle")); this.template = template; this.style = style; }
@SuppressWarnings("unchecked") public StylesChildren(JRSimpleTemplate template, Lookup doLkp) { super(new ArrayList()); this.template = template; this.doLkp=doLkp; //this.template.getEventSupport().addPropertyChangeListener(this); }
public void setCurrentModel(JRSimpleTemplate currentModel) { // Update the lookup... if (this.currentModel != null) { ((JRTXDataObject)getDataObject()).getIc().remove(this.currentModel); } this.currentModel = currentModel; if (this.currentModel != null) { ((JRTXDataObject)getDataObject()).getIc().add(this.currentModel); } }
public TemplateReferenceNode(JRSimpleTemplate template, JRTemplateReference reference, Lookup doLkp) { super (Children.LEAF, new ProxyLookup(doLkp, Lookups.fixed(template, reference))); this.template = template; this.reference = reference; init(); }
@SuppressWarnings("unchecked") public LocationProperty(JRTemplateReference reference, JRSimpleTemplate template, TemplateReferenceNode node) { super( Node.PROP_NAME, String.class, "Location", "Location"); this.setReference(reference); this.template = template; this.node = node; this.setValue("oneline", Boolean.TRUE); }
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; }
public JRSimpleTemplate getStylesTemplate() { for (INode node : getRoot().getChildren()) if (node instanceof MStylesTemplate) return (JRSimpleTemplate) node.getValue(); return null; }
/** * Instantiates a new delete style template command. */ public DeleteStyleTemplateCommand(MStylesTemplate destNode, MStyleTemplateReference srcNode) { super(); this.jrDesign = (JRSimpleTemplate) destNode.getValue(); this.jrTemplate = (JRTemplateReference) srcNode.getValue(); }
public LibraryTemplateReferenceNode(JRSimpleTemplate template, JRTemplateReference reference, Lookup doLkp) { super (template, reference, doLkp); }
public LibraryStyleNode(JRSimpleTemplate template, JRBaseStyle style, Lookup doLkp) { super (template, style, doLkp); }
public StylesLibraryChildren(JRSimpleTemplate template, Lookup doLkp) { super(template,doLkp); }
/** * @return the template */ public JRSimpleTemplate getTemplate() { return template; }
/** * @param template the template to set */ public void setTemplate(JRSimpleTemplate template) { this.template = template; }
public JRSimpleTemplate getCurrentModel() { return currentModel; }
public TemplateNode(JRSimpleTemplate template, Lookup doLkp) { this(new StylesChildren(template,doLkp), template, doLkp); }
/** * Instantiates a new creates the style template command. * * @param destNode * the dest node * @param srcNode * the src node * @param index * the index */ public CreateStyleTemplateReferenceCommand(MStylesTemplate destNode, MStyleTemplateReference srcNode, int index) { super(); this.jrDesign = (JRSimpleTemplate) destNode.getValue(); this.index = index; if (srcNode != null && srcNode.getValue() != null) this.jrTemplate = (JRTemplateReference) srcNode.getValue(); }
/** * Instantiates a new creates the style command. * * @param destNode * the dest node * @param srcNode * the src node * @param index * the index */ public CreateStyleCommand(MStylesTemplate destNode, MStyle srcNode, int index) { super(); this.jrDesign = (JRSimpleTemplate) destNode.getValue(); this.index = index; if (srcNode != null && srcNode.getValue() != null) this.jrStyle = (JRDesignStyle) srcNode.getValue(); }
/** * Instantiates a new delete style command. * * @param destNode * the dest node * @param srcNode * the src node */ public DeleteStyleCommand(MStylesTemplate destNode, MStyle srcNode) { super(); this.jrDesign = (JRSimpleTemplate) destNode.getValue(); this.jrStyle = (JRDesignStyle) srcNode.getValue(); }