2
0
Fork 0

Added pdf export support, export servlet support, renamed frontends

without s and made vasc config object.
This commit is contained in:
Willem Cazander 2012-05-12 17:26:21 +02:00
parent efcbdbd519
commit b3923bd2fb
160 changed files with 5001 additions and 2552 deletions

View file

@ -0,0 +1,202 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
import net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.design.JRDesignParameter;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.export.JRCsvExporter;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.export.JRRtfExporter;
import net.sf.jasperreports.engine.export.JRXlsExporter;
import net.sf.jasperreports.engine.export.JRXmlExporter;
/**
* JRDesignManager can work with multiple designs for one JRDynamicDataSource.
*
* @author Willem Cazander
* @version 1.0 May 10, 2012
*/
public class JR4ODesignManager {
private String resourceBundle = null;
private Map<String,Object> parameters = null;
private JRDynamicDataSource dataSource = null;
private Map<String,JasperDesign> reportDesigns = null;
//private Map<String,ReportCache> cachedReports = null;
//private boolean cacheReports = true;
public JR4ODesignManager(JRDynamicDataSource dataSource,String resourceBundle) {
this(dataSource,resourceBundle,new HashMap<String,Object>(1));
}
public JR4ODesignManager(JRDynamicDataSource dataSource,String resourceBundle,Map<String,Object> parameters) {
if (dataSource==null) {
throw new NullPointerException("Can't create dynamic reports with null dynamic datasource.");
}
if (parameters==null) {
throw new NullPointerException("Can't create dynamic reports with null parameters map.");
}
if (resourceBundle==null) {
throw new NullPointerException("Can't create dynamic reports with null resourceBundle.");
}
this.dataSource = dataSource;
this.parameters = parameters;
this.resourceBundle = resourceBundle;
reportDesigns = new HashMap<String,JasperDesign>(20);
}
public JasperDesign getJasperDesignByName(String designName) {
if (designName==null) {
throw new NullPointerException("Can't search for report with null name.");
}
return reportDesigns.get(designName);
}
public void addJasperDesign(JasperDesign design) {
if (design==null) {
throw new NullPointerException("Can add null design.");
}
reportDesigns.put(design.getName(), design);
}
private JR4OParser createParser() {
JR4OParser parser = new JR4OParser(dataSource,resourceBundle);
Map<String,Object> elBeans = dataSource.addDynamicELBean();
for (String key:elBeans.keySet()) {
Object value = elBeans.get(key);
parser.addGlobalELBean(key, value);
}
return parser;
}
public void parseFile(File file) throws FileNotFoundException, SecurityException, NullPointerException, ParserConfigurationException, SAXException, IOException {
if (file==null) {
throw new NullPointerException("Can't parse null file.");
}
JR4OParser parser = createParser();
parser.parseFile(file);
for (JasperDesign design:parser.getJasperDesigns()) {
addJasperDesign(design);
}
}
public void parseResource(String resourceName) throws FileNotFoundException, SecurityException, NullPointerException, ParserConfigurationException, SAXException, IOException {
if (resourceName==null) {
throw new NullPointerException("Can't parse null resouce.");
}
JR4OParser parser = createParser();
parser.parseResource(resourceName);
for (JasperDesign design:parser.getJasperDesigns()) {
addJasperDesign(design);
}
}
public JasperReport compileReport(String designName) throws JRException {
JasperDesign design = getJasperDesignByName(designName);
if (design==null) {
throw new NullPointerException("Could not find design with name: "+designName);
}
return compileReport(design);
}
public JasperReport compileReport(JasperDesign design) throws JRException {
if (design==null) {
throw new NullPointerException("Can't compile with null design.");
}
for (String key:parameters.keySet()) {
Object value = parameters.get(key);
JRDesignParameter par = new JRDesignParameter();
par.setName(key);
par.setValueClass(value.getClass());
design.addParameter(par);
}
dataSource.addDynamicColumnClassFields(design);
return JasperCompileManager.compileReport(design);
}
public JasperPrint printReport(JasperReport report) throws JRException {
return JasperFillManager.fillReport(report, parameters, dataSource);
}
private void saveReport(JasperPrint reportPrint,JRExportType type,boolean isFile,Object out) throws JRException {
JRExporter exporter = null;
switch (type) {
default:
case PDF: exporter = new JRPdfExporter(); break;
case RTF: exporter = new JRRtfExporter(); break;
case CSV: exporter = new JRCsvExporter(); break;
case XLS: exporter = new JRXlsExporter(); break;
case XML: exporter = new JRXmlExporter(); break;
}
if (isFile) {
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,out);
} else {
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,out);
}
exporter.setParameter(JRExporterParameter.JASPER_PRINT,reportPrint);
exporter.exportReport();
}
public void saveReportStream(JasperPrint reportPrint,JRExportType type,OutputStream out) throws JRException {
saveReport(reportPrint,type,false,out);
}
public void saveReportFile(JasperPrint reportPrint,JRExportType type,String fileName) throws JRException {
saveReport(reportPrint,type,true,fileName);
}
public void saveReportStream(String name,JRExportType type,OutputStream out) throws JRException {
saveReportStream(printReport(compileReport(name)),type,out);
}
public void saveReportFile(String name,JRExportType type,String file) throws JRException {
saveReportFile(printReport(compileReport(name)),type,file);
}
public enum JRExportType {
PDF,
RTF,
CSV,
XLS,
XML;
}
}

View file

@ -0,0 +1,105 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o;
import java.util.ArrayList;
import java.util.List;
import javax.el.ValueExpression;
import net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource;
import net.sf.jasperreports.engine.design.JasperDesign;
import org.x4o.xml.core.X4OParser;
import org.x4o.xml.element.ElementContext;
import org.x4o.xml.element.ElementException;
/**
* JR4OParser parses xml layer for JasperReports
*
* jr4o is currently not the nicest x4o language because it is ported from old version.
*
* @author Willem Cazander
* @version 1.0 Aug 31, 2007
*/
public class JR4OParser extends X4OParser {
/** The jr40 language name */
static public final String LANGUAGE = "jr4o";
static public final String EL_DATASOURCE_NAME = "dynamicDataSource";
static public final String EL_DESIGN_LIST_NAME = "dynamicDesignList";
private List<JasperDesign> dynamicDesignList = null;
private String resourceBundle = null;
/**
* creates an JR4OParser
*/
public JR4OParser(JRDynamicDataSource dataSource,String resourceBundle) {
super(LANGUAGE);
this.resourceBundle = resourceBundle;
dynamicDesignList = new ArrayList<JasperDesign>(10);
addGlobalELBean(EL_DATASOURCE_NAME, dataSource);
addGlobalELBean(EL_DESIGN_LIST_NAME, dynamicDesignList);
}
/**
* @return The list of JasperDesigns after parsing.
*/
public List<JasperDesign> getJasperDesigns() {
for (JasperDesign d:dynamicDesignList) {
if (d.getResourceBundle()==null) {
d.setResourceBundle(resourceBundle);
}
}
return dynamicDesignList;
}
/**
* Returns the JRDynamicDataSource for the JRDynamic*Element classes.
* @param context The ElementContext to get the datasource from.
* @return The JRDynamicDataSource of this parser instance.
*/
static public JRDynamicDataSource getELDataSource(ElementContext context) throws ElementException {
ValueExpression ee = context.getExpressionFactory().createValueExpression(context.getELContext(),"${"+EL_DATASOURCE_NAME+"}",JRDynamicDataSource.class);
JRDynamicDataSource dataSource = (JRDynamicDataSource)ee.getValue(context.getELContext());
if (dataSource==null) {
throw new ElementException("Could not find dataSouce in context as: "+EL_DATASOURCE_NAME);
}
return dataSource;
}
/**
* Returns the List of designs for adding the design.
* @param context The ElementContext to get the list from.
* @return The list of designs.
*/
@SuppressWarnings("unchecked")
static public List<JasperDesign> getELDesignList(ElementContext context) throws ElementException {
ValueExpression ee = context.getExpressionFactory().createValueExpression(context.getELContext(),"${"+EL_DESIGN_LIST_NAME+"}",List.class);
List<JasperDesign> designList = (List<JasperDesign>)ee.getValue(context.getELContext());
if (designList==null) {
throw new ElementException("Could not find designList in context as: "+EL_DESIGN_LIST_NAME);
}
return designList;
}
}

View file

@ -0,0 +1,69 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o.data;
import net.sf.jasperreports.engine.type.HorizontalAlignEnum;
/**
* AbstractJRDynamicDataSource returns some default values of interface.
*
* @author Willem Cazander
* @version 1.0 May 10, 2012
*/
public abstract class AbstractJRDynamicDataSource implements JRDynamicDataSource {
/**
* @see net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource#getDynamicColumnY(int)
*/
public int getDynamicColumnY(int col) {
return 5;
}
/**
* @see net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource#getDynamicColumnHeight(int)
*/
public int getDynamicColumnHeight(int col) {
return 15;
}
/**
* @see net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource#getDynamicColumnHorizontalAlignment(int)
*/
public HorizontalAlignEnum getDynamicColumnHorizontalAlignment(int col) {
return HorizontalAlignEnum.LEFT;
}
/**
* @see net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource#isDynamicColumnStretchWithOverflow(int)
*/
public boolean isDynamicColumnStretchWithOverflow(int col) {
return true;
}
/**
* @see net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource#isDynamicColumnBlankWhenNull(int)
*/
public boolean isDynamicColumnBlankWhenNull(int col) {
return true;
}
}

View file

@ -0,0 +1,53 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o.data;
import java.util.Map;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRRewindableDataSource;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.type.HorizontalAlignEnum;
/**
* AbstractJRDynamicDataSource returns some default values of interface.
*
* @author Willem Cazander
* @version 1.0 May 10, 2012
*/
public interface JRDynamicDataSource extends JRRewindableDataSource {
public void addDynamicColumnClassFields(JasperDesign jd) throws JRException;
public Map<String,Object> addDynamicELBean();
public int getDynamicColumnCount();
public int getDynamicColumnX(int col);
public int getDynamicColumnY(int col);
public int getDynamicColumnWidth(int col);
public int getDynamicColumnHeight(int col);
public HorizontalAlignEnum getDynamicColumnHorizontalAlignment(int col);
public boolean isDynamicColumnStretchWithOverflow(int col);
public boolean isDynamicColumnBlankWhenNull(int col);
}

View file

@ -0,0 +1,148 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o.data;
import java.util.HashMap;
import java.util.Map;
import javax.swing.table.TableModel;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
import net.sf.jasperreports.engine.design.JRDesignField;
import net.sf.jasperreports.engine.design.JasperDesign;
/**
* JRDynamicDataSourceTableModel is the dynamic datasource which supportes dynamic columns in Jasper reports.
*
* @author Willem Cazander
* @version 1.0 Aug 31, 2007
*/
public class JRDynamicDataSourceTableModel extends AbstractJRDynamicDataSource {
private TableModel tableModel = null;
private int index = -1;
private int[] columnWidths = null;
private static final String PREFIX_COLUMN = "COLUMN_";
private static final String PREFIX_HEADER = "HEADER_";
private static final String INFIX_CLASS = "CLASS_";
public JRDynamicDataSourceTableModel(TableModel tableModel,int[] columnWidths) {
if (tableModel==null) {
throw new NullPointerException("TableModel can't be null.");
}
this.tableModel = tableModel;
this.columnWidths = columnWidths;
}
/**
* @see net.sf.jasperreports.engine.JRDataSource#getFieldValue(net.sf.jasperreports.engine.JRField)
*/
public Object getFieldValue(JRField jrField) throws JRException {
String fieldName = jrField.getName();
if (fieldName.startsWith(PREFIX_COLUMN)) {
return tableModel.getValueAt(index, Integer.parseInt(fieldName.substring(7)));
}
if (fieldName.startsWith(PREFIX_HEADER)) {
return tableModel.getColumnName(Integer.parseInt(fieldName.substring(7)));
}
throw new JRException("Unknown column name : " + fieldName);
}
/**
* @see net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource#addDynamicColumnClassFields(net.sf.jasperreports.engine.design.JasperDesign)
*/
public void addDynamicColumnClassFields(JasperDesign jd) throws JRException {
JRDesignField field;
for (int i=0;i<tableModel.getColumnCount();i++) {
field = new JRDesignField();
field.setName(PREFIX_COLUMN+i);
field.setValueClass(tableModel.getColumnClass(i));
jd.addField(field);
field = new JRDesignField();
field.setName(PREFIX_HEADER+i);
field.setValueClass(String.class);
jd.addField(field);
}
}
/**
* @see net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource#addDynamicELBean()
*/
public Map<String, Object> addDynamicELBean() {
Map<String,Object> result = new HashMap<String,Object>(10);
for (int i=0;i<tableModel.getColumnCount();i++) {
result.put(PREFIX_COLUMN+INFIX_CLASS+i,tableModel.getColumnClass(i));
result.put(PREFIX_HEADER+INFIX_CLASS+i,String.class);
}
return result;
}
/**
* @see net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource#getDynamicColumnX(int)
*/
public int getDynamicColumnX(int col) {
int result = 0;
for (int i=0;i<col;i++) {
if (i > columnWidths.length) {
break;
}
result += columnWidths[i];
}
return result;
}
/**
* @see net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource#getDynamicColumnWidth(int)
*/
public int getDynamicColumnWidth(int col) {
if (col > columnWidths.length) {
return 50;
}
return columnWidths[col];
}
/**
* @see net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource#getDynamicColumnCount()
*/
public int getDynamicColumnCount() {
return tableModel.getColumnCount();
}
/**
* @see net.sf.jasperreports.engine.JRDataSource#next()
*/
public boolean next() throws JRException {
index++;
return (index < tableModel.getRowCount());
}
/**
* @see net.sf.jasperreports.engine.JRRewindableDataSource#moveFirst()
*/
public void moveFirst() throws JRException {
index = -1;
}
}

View file

@ -0,0 +1,64 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o.x4o;
import java.awt.Color;
import java.util.Locale;
import org.x4o.xml.conv.AbstractStringObjectConverter;
import org.x4o.xml.conv.ObjectConverter;
import org.x4o.xml.conv.ObjectConverterException;
/**
* ColorConverter
*
* @author Willem Cazander
* @version 1.0 Aug 31, 2007
*/
public class ColorConverter extends AbstractStringObjectConverter {
private static final long serialVersionUID = 7618333644044204827L;
public Class<?> getObjectClassTo() {
return Color.class;
}
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
try {
return Color.decode(str);
} catch (Exception e) {
throw new ObjectConverterException(this,e.getMessage(),e);
}
}
public String convertStringBack(Object obj,Locale locale) throws ObjectConverterException {
return ""+((Color)obj).getRGB();
}
@Override
public ObjectConverter clone() throws CloneNotSupportedException {
ColorConverter result = new ColorConverter();
result.converters=cloneConverters();
return result;
}
}

View file

@ -0,0 +1,57 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o.x4o;
import org.x4o.xml.element.AbstractElement;
import org.x4o.xml.element.Element;
import org.x4o.xml.element.ElementException;
import net.sf.jasperreports.engine.JRDefaultStyleProvider;
import net.sf.jasperreports.engine.design.JRDesignImage;
/**
*
*
* @author Willem Cazander
* @version 1.0 Oct 5, 2007
*/
public class ImageElement extends AbstractElement {
@Override
public void doElementStart() throws ElementException {
JRDefaultStyleProvider style = findStyleFiller();
JRDesignImage image = new JRDesignImage(style);
setElementObject(image);
}
private JRDefaultStyleProvider findStyleFiller() {
Element element = getParent();
while (element!=null) {
if (element.getElementObject() instanceof JRDefaultStyleProvider) {
return (JRDefaultStyleProvider)element.getElementObject();
}
element=element.getParent();
}
return null;
}
}

View file

@ -0,0 +1,70 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o.x4o;
import org.x4o.xml.element.AbstractElementBindingHandler;
import org.x4o.xml.element.Element;
import org.x4o.xml.element.ElementBindingHandlerException;
import net.sf.jasperreports.engine.JRElementGroup;
import net.sf.jasperreports.engine.JRGroup;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.design.JRDesignElement;
/**
* JR4OElementBindingHandler
*
* @author Willem Cazander
* @version 1.0 Aug 31, 2007
*/
public class JR4OElementBindingHandler extends AbstractElementBindingHandler {
public boolean canBind(Element element) {
Object parent = element.getParent().getElementObject();
Object child = element.getElementObject();
boolean p = false;
boolean c = false;
if (parent instanceof JRDesignElement) { p=true; }
if (child instanceof JRElementGroup) { c=true; }
if (child instanceof JRGroup) { c=true; }
if (child instanceof JRStyle) { c=true; }
if (p&c) { return true; } else { return false; }
}
public void doBind(Element element) throws ElementBindingHandlerException {
Object parent = element.getParent().getElementObject();
Object child = element.getElementObject();
if (parent instanceof JRDesignElement) {
if (child instanceof JRElementGroup) {
((JRDesignElement)parent).setElementGroup((JRElementGroup)child);
}
if (child instanceof JRGroup) {
((JRDesignElement)parent).setPrintWhenGroupChanges((JRGroup)child);
}
if (child instanceof JRStyle) {
((JRDesignElement)parent).setStyle((JRStyle)child);
}
return;
}
}
}

View file

@ -0,0 +1,66 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o.x4o;
import org.x4o.xml.element.AbstractElementBindingHandler;
import org.x4o.xml.element.Element;
import org.x4o.xml.element.ElementBindingHandlerException;
import net.sf.jasperreports.engine.design.JRDesignElement;
import net.sf.jasperreports.engine.design.JRDesignElementGroup;
/**
* JR4OElementGroupBindingHandler
*
* @author Willem Cazander
* @version 1.0 Aug 31, 2007
*/
public class JR4OElementGroupBindingHandler extends AbstractElementBindingHandler {
public boolean canBind(Element element) {
Object parent = element.getParent().getElementObject();
Object child = element.getElementObject();
boolean p = false;
boolean c = false;
if (parent instanceof JRDesignElementGroup) { p=true; }
if (child instanceof JRDesignElement) { c=true; }
if (child instanceof JRDesignElementGroup) { c=true; }
if (p&c) { return true; } else { return false; }
}
public void doBind(Element element) throws ElementBindingHandlerException {
Object parent = element.getParent().getElementObject();
Object child = element.getElementObject();
if (parent instanceof JRDesignElementGroup) {
if (child instanceof JRDesignElementGroup) {
((JRDesignElementGroup)parent).addElementGroup((JRDesignElementGroup)child);
}
if (child instanceof JRDesignElement) {
((JRDesignElementGroup)parent).addElement((JRDesignElement)child);
}
return;
}
}
}

View file

@ -0,0 +1,74 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o.x4o;
import org.x4o.xml.element.AbstractElementBindingHandler;
import org.x4o.xml.element.Element;
import org.x4o.xml.element.ElementBindingHandlerException;
import net.sf.jasperreports.engine.JRField;
import net.sf.jasperreports.engine.JRParameter;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.design.JasperDesign;
/**
* JR4OJasperDesignBindingHandler
*
* @author Willem Cazander
* @version 1.0 Aug 31, 2007
*/
public class JR4OJasperDesignBindingHandler extends AbstractElementBindingHandler {
public boolean canBind(Element element) {
Object parent = element.getParent().getElementObject();
Object child = element.getElementObject();
boolean p = false;
boolean c = false;
if (parent instanceof JasperDesign) { p=true; }
if (child instanceof JRField) { c=true; }
if (child instanceof JRParameter) { c=true; }
if (child instanceof JRStyle) { c=true; }
if (p&c) { return true; } else { return false; }
}
public void doBind(Element element) throws ElementBindingHandlerException {
Object parent = element.getParent().getElementObject();
Object child = element.getElementObject();
if (parent instanceof JasperDesign) {
try {
if (child instanceof JRField) {
((JasperDesign)parent).addField((JRField)child);
}
if (child instanceof JRParameter) {
((JasperDesign)parent).addParameter((JRParameter)child);
}
if (child instanceof JRStyle) {
((JasperDesign)parent).addStyle((JRStyle)child);
}
} catch (Exception e) {
throw new ElementBindingHandlerException(e.getMessage(),e);
}
}
}
}

View file

@ -0,0 +1,133 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o.x4o;
import javax.el.ValueExpression;
import org.x4o.xml.element.AbstractElement;
import org.x4o.xml.element.ElementException;
import net.forwardfire.vasc.lib.jr4o.JR4OParser;
import net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.design.JRDesignElementGroup;
import net.sf.jasperreports.engine.design.JRDesignExpression;
import net.sf.jasperreports.engine.design.JRDesignTextField;
import net.sf.jasperreports.engine.type.ModeEnum;
/**
* DynaCardsElement
*
* @author Willem Cazander
* @version 1.0 Oct 4, 2007
*/
public class JRDynamicCardsElement extends AbstractElement {
/**
* @see org.x4o.xml.element.AbstractElement#doElementStart()
*/
@Override
public void doElementStart() throws ElementException {
JRDynamicDataSource dataSource = JR4OParser.getELDataSource(getElementContext());
ValueExpression ee = getElementContext().getExpressionFactory().createValueExpression(getElementContext().getELContext(),"${Arial_Bold}",JRStyle.class);
JRStyle style = (JRStyle)ee.getValue(getElementContext().getELContext());
if (style==null) {
throw new ElementException("Could not get the font.");
}
style.setBlankWhenNull(true);
style.setMode(ModeEnum.OPAQUE);
// //DEBUG STYLE
//style.setForecolor(Color.BLACK);
//style.setBackcolor(Color.BLUE);
Object parent = getParent().getElementObject();
if (parent instanceof JRDesignElementGroup == false) {
throw new ElementException("parent is not an JRDesignElementGroup.");
}
JRDesignElementGroup group = (JRDesignElementGroup)parent;
int offsetInitial = 95;
int defaultHeight = 12;
int max = dataSource.getDynamicColumnCount();
for (int i=0;i<max;i++) {
JRDesignTextField header = new JRDesignTextField();
//header.setMode(JRElement.MODE_OPAQUE);
header.setX(24);
int off = offsetInitial;
header.setY(off+(i*defaultHeight));
header.setWidth(100);
header.setHeight(defaultHeight);
//header.setForecolor(Color.BLACK);
//header.setBackcolor(Color.BLUE);
header.setHorizontalAlignment(dataSource.getDynamicColumnHorizontalAlignment(i));
header.setStyle(style);
JRDesignExpression ex = new JRDesignExpression();
ex.setText("$F{HEADER_"+i+"}+':'");
ex.setValueClass(String.class);
header.setExpression(ex);
group.addElement(header);
}
for (int i=0;i<max;i++) {
int off = offsetInitial;
JRDesignTextField header = new JRDesignTextField();
header.setX(110);
header.setY(off+(i*defaultHeight));
header.setHeight(defaultHeight);
header.setWidth(140);
header.setStretchWithOverflow(dataSource.isDynamicColumnStretchWithOverflow(i));
header.setBlankWhenNull(dataSource.isDynamicColumnBlankWhenNull(i));
header.setHorizontalAlignment(dataSource.getDynamicColumnHorizontalAlignment(i));
header.setStyle(style);
header.setStretchWithOverflow(false);
//header.setForecolor(Color.BLACK);
//header.setBackcolor(Color.GREEN);
JRDesignExpression ex = new JRDesignExpression();
ex.setText("$F{COLUMN_"+i+"}");
//ee = getElementContext().getExpressionFactory().createValueExpression(getElementContext().getELContext(),"${COLUMN_CLASS_"+i+"}",Class.class);
//Class cl = (Class)ee.getValue(getElementContext().getELContext());
//ex.setValueClass(cl);
ex.setValueClass(String.class);
header.setExpression(ex);
group.addElement(header);
}
}
}

View file

@ -0,0 +1,92 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o.x4o;
import javax.el.ValueExpression;
import org.x4o.xml.element.AbstractElement;
import org.x4o.xml.element.ElementException;
import net.forwardfire.vasc.lib.jr4o.JR4OParser;
import net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.design.JRDesignElementGroup;
import net.sf.jasperreports.engine.design.JRDesignExpression;
import net.sf.jasperreports.engine.design.JRDesignTextField;
import net.sf.jasperreports.engine.type.ModeEnum;
/**
* DynaColumnElement
*
* @author Willem Cazander
* @version 1.0 Sep 24, 2007
*/
public class JRDynamicColumnElement extends AbstractElement {
@Override
public void doElementRun() throws ElementException {
JRDynamicDataSource dataSource = JR4OParser.getELDataSource(getElementContext());
ValueExpression ee = getElementContext().getExpressionFactory().createValueExpression(getElementContext().getELContext(),"${Arial_Bold}",JRStyle.class);
JRStyle style = (JRStyle)ee.getValue(getElementContext().getELContext());
if (style==null) {
throw new ElementException("Could not get the font.");
}
style.setMode(ModeEnum.OPAQUE);
// // Debug Style
//style.setBackcolor(Color.BLUE);
Object parent = getParent().getElementObject();
if (parent instanceof JRDesignElementGroup == false) {
throw new ElementException("parent is not an JRDesignElementGroup.");
}
JRDesignElementGroup group = (JRDesignElementGroup)parent;
int max = dataSource.getDynamicColumnCount();
for (int i=0;i<max;i++) {
JRDesignTextField column = new JRDesignTextField();
column.setX(dataSource.getDynamicColumnX(i));
column.setY(dataSource.getDynamicColumnY(i));
column.setWidth(dataSource.getDynamicColumnWidth(i));
column.setHeight(dataSource.getDynamicColumnHeight(i));
column.setStretchWithOverflow(dataSource.isDynamicColumnStretchWithOverflow(i));
column.setBlankWhenNull(dataSource.isDynamicColumnBlankWhenNull(i));
column.setHorizontalAlignment(dataSource.getDynamicColumnHorizontalAlignment(i));
column.setStyle(style);
JRDesignExpression ex = new JRDesignExpression();
ex.setText("$F{COLUMN_"+i+"}");
//ee = getElementContext().getExpressionFactory().createValueExpression(getElementContext().getELContext(),"${COLUMN_CLASS_"+i+"}",Class.class);
//Class cl = (Class)ee.getValue(getElementContext().getELContext());
//ex.setValueClass(cl);
ex.setValueClass(String.class);
column.setExpression(ex);
group.addElement(column);
}
}
}

View file

@ -0,0 +1,91 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o.x4o;
import java.awt.Color;
import javax.el.ValueExpression;
import org.x4o.xml.element.AbstractElement;
import org.x4o.xml.element.ElementException;
import net.forwardfire.vasc.lib.jr4o.JR4OParser;
import net.forwardfire.vasc.lib.jr4o.data.JRDynamicDataSource;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.design.JRDesignElementGroup;
import net.sf.jasperreports.engine.design.JRDesignExpression;
import net.sf.jasperreports.engine.design.JRDesignTextField;
import net.sf.jasperreports.engine.type.HorizontalAlignEnum;
import net.sf.jasperreports.engine.type.ModeEnum;
/**
*
*
* @author Willem Cazander
* @version 1.0 Sep 24, 2007
*/
public class JRDynamicColumnHeaderElement extends AbstractElement {
/**
* @see org.x4o.xml.element.AbstractElement#doElementRun()
*/
@Override
public void doElementRun() throws ElementException {
JRDynamicDataSource dataSource = JR4OParser.getELDataSource(getElementContext());
ValueExpression ee = getElementContext().getExpressionFactory().createValueExpression(getElementContext().getELContext(),"${Arial_Bold}",JRStyle.class);
JRStyle style = (JRStyle)ee.getValue(getElementContext().getELContext());
if (style==null) {
throw new ElementException("Could not get the font.");
}
Object parent = getParent().getElementObject();
if (parent instanceof JRDesignElementGroup == false) {
throw new ElementException("parent is not an JRDesignElementGroup.");
}
JRDesignElementGroup group = (JRDesignElementGroup)parent;
int max = dataSource.getDynamicColumnCount();
for (int i=0;i<max;i++) {
JRDesignTextField header = new JRDesignTextField();
header.setMode(ModeEnum.OPAQUE);
header.setX(dataSource.getDynamicColumnX(i));
header.setY(dataSource.getDynamicColumnY(i));
header.setWidth(dataSource.getDynamicColumnWidth(i));
header.setHeight(dataSource.getDynamicColumnHeight(i));
header.setForecolor(Color.decode("#ffffff"));
header.setBackcolor(Color.decode("#bbbbbb"));
header.setHorizontalAlignment(HorizontalAlignEnum.LEFT);
header.setStyle(style);
JRDesignExpression ex = new JRDesignExpression();
ex.setText("$F{HEADER_"+i+"}");
ex.setValueClass(String.class);
header.setExpression(ex);
group.addElement(header);
}
}
}

View file

@ -0,0 +1,84 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o.x4o;
import org.x4o.xml.element.Element;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.design.JRDesignTextField;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.type.EvaluationTimeEnum;
import net.sf.jasperreports.engine.type.HorizontalAlignEnum;
import net.sf.jasperreports.engine.type.ModeEnum;
import net.sf.jasperreports.engine.type.OrientationEnum;
import net.sf.jasperreports.engine.type.PositionTypeEnum;
import net.sf.jasperreports.engine.type.VerticalAlignEnum;
/**
* JRExpressionConverter
*
* @author Willem Cazander
* @version 1.0 Aug 31, 2007
*/
public class JRExpressionConverter{
public void doConvertParameter(Element arg0, Object value){
String v = value.toString();
JRDesignTextField f= new JRDesignTextField();
f.setEvaluationTime(EvaluationTimeEnum.GROUP);
f.setHorizontalAlignment(HorizontalAlignEnum.CENTER);
f.setVerticalAlignment(VerticalAlignEnum.BOTTOM);
f.setPositionType(PositionTypeEnum.FIX_RELATIVE_TO_BOTTOM);
f.setMode(ModeEnum.OPAQUE);
JasperDesign d = new JasperDesign();
d.setOrientation(OrientationEnum.LANDSCAPE);
/*
if ("EVALUATION_TIME_AUTO".equals(v)) {
return JRExpression.EVALUATION_TIME_AUTO;
}
if ("EVALUATION_TIME_BAND".equals(v)) {
return JRExpression.EVALUATION_TIME_BAND;
}
if ("EVALUATION_TIME_COLUMN".equals(v)) {
return JRExpression.EVALUATION_TIME_COLUMN;
}
if ("EVALUATION_TIME_GROUP".equals(v)) {
return JRExpression.EVALUATION_TIME_GROUP;
}
if ("EVALUATION_TIME_NOW".equals(v)) {
return JRExpression.EVALUATION_TIME_NOW;
}
if ("EVALUATION_TIME_PAGE".equals(v)) {
return JRExpression.EVALUATION_TIME_PAGE;
}
if ("EVALUATION_TIME_REPORT".equals(v)) {
return JRExpression.EVALUATION_TIME_REPORT;
}
*/
}
}

View file

@ -0,0 +1,78 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o.x4o;
import org.x4o.xml.element.AbstractElement;
import org.x4o.xml.element.ElementException;
import net.sf.jasperreports.engine.design.JRDesignBand;
import net.sf.jasperreports.engine.design.JRDesignSection;
import net.sf.jasperreports.engine.design.JasperDesign;
/**
*
*
* @author Willem Cazander
* @version 1.0 Aug 31, 2007
*/
public class JasperDesignPageBinderElement extends AbstractElement {
@Override
public void doElementEnd() throws ElementException {
String tagType = (String)getAttributes().get("tagType");
if (getParent()==null) {
throw new ElementException("No parent element");
}
if ((getParent().getElementObject() instanceof JasperDesign)==false) {
throw new ElementException("No query parent JRDesignExpression object");
}
if ("title".equals(tagType)) {
((JasperDesign)getParent().getElementObject()).setTitle((JRDesignBand)getElementObject());
return;
}
if ("pageHeader".equals(tagType)) {
((JasperDesign)getParent().getElementObject()).setPageHeader((JRDesignBand)getElementObject());
return;
}
if ("columnHeader".equals(tagType)) {
((JasperDesign)getParent().getElementObject()).setColumnHeader((JRDesignBand)getElementObject());
return;
}
if ("detail".equals(tagType)) {
((JRDesignSection)((JasperDesign)getParent().getElementObject()).getDetailSection()).addBand((JRDesignBand)getElementObject());
return;
}
if ("pageFooter".equals(tagType)) {
((JasperDesign)getParent().getElementObject()).setPageFooter((JRDesignBand)getElementObject());
return;
}
if ("summary".equals(tagType)) {
((JasperDesign)getParent().getElementObject()).setSummary((JRDesignBand)getElementObject());
return;
}
throw new ElementException("No tagType mathched: "+tagType);
}
}

View file

@ -0,0 +1,53 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o.x4o;
import java.util.List;
import org.x4o.xml.element.AbstractElement;
import org.x4o.xml.element.ElementException;
import net.forwardfire.vasc.lib.jr4o.JR4OParser;
import net.sf.jasperreports.engine.design.JasperDesign;
/**
* JasperReportElement puts the report design in the parser design list.
*
* @author Willem Cazander
* @version 1.0 May 11, 2012
*/
public class JasperReportElement extends AbstractElement {
@Override
public void doElementRun() throws ElementException {
if (getElementObject()==null) {
throw new ElementException("Can't work with null element object.");
}
if ((getElementObject() instanceof JasperDesign)==false) {
throw new ElementException("Element object is not JasperDesign class.");
}
JasperDesign design = (JasperDesign)getElementObject();
List<JasperDesign> designs = JR4OParser.getELDesignList(getElementContext());
designs.add(design);
}
}

View file

@ -0,0 +1,65 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o.x4o;
import org.x4o.xml.element.AbstractElement;
import org.x4o.xml.element.ElementException;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.design.JRDesignExpression;
import net.sf.jasperreports.engine.design.JRDesignImage;
/**
* ValueBodyImageExpressionElement
*
* @author Willem Cazander
* @version 1.0 Aug 31, 2007
*/
public class ValueBodyImageExpressionElement extends AbstractElement {
private StringBuffer body = new StringBuffer();
@Override
public void doCharacters(String text) throws ElementException {
body.append(text);
}
@Override
public void doElementEnd() throws ElementException {
if ((getElementObject() instanceof JRDesignExpression)==false) {
throw new ElementException("elementObject is not JRDesignExpression object");
}
String expression = body.toString().trim();
if (expression.length()>0) {
// only set then has size, can be added with text attribute in xml
((JRDesignExpression)getElementObject()).setText(body.toString());
}
if (getParent().getElementObject() instanceof JRDesignImage) {
if (getElementObject() instanceof JRExpression) {
((JRDesignImage)getParent().getElementObject()).setExpression((JRExpression)getElementObject());
}
}
}
}

View file

@ -0,0 +1,59 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o.x4o;
import org.x4o.xml.element.AbstractElement;
import org.x4o.xml.element.ElementException;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.design.JRDesignElement;
import net.sf.jasperreports.engine.design.JRDesignExpression;
/**
* ValueBodyPrintExpressionElement
*
* @author Willem Cazander
* @version 1.0 Aug 31, 2007
*/
public class ValueBodyPrintExpressionElement extends AbstractElement {
private StringBuffer body = new StringBuffer();
@Override
public void doCharacters(String text) throws ElementException {
body.append(text);
}
@Override
public void doElementEnd() throws ElementException {
if ((getElementObject() instanceof JRDesignExpression)==false) {
throw new ElementException("elementObject is not JRDesignExpression object");
}
((JRDesignExpression)getElementObject()).setText(body.toString());
if (getParent().getElementObject() instanceof JRDesignElement) {
if (getElementObject() instanceof JRExpression) {
((JRDesignElement)getParent().getElementObject()).setPrintWhenExpression((JRExpression)getElementObject());
}
}
}
}

View file

@ -0,0 +1,52 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o.x4o;
import org.x4o.xml.element.AbstractElement;
import org.x4o.xml.element.ElementException;
import net.sf.jasperreports.engine.design.JRDesignStaticText;
/**
*
*
* @author Willem Cazander
* @version 1.0 Sep 3, 2007
*/
public class ValueBodyTextElement extends AbstractElement {
private StringBuffer body = new StringBuffer();
@Override
public void doCharacters(String text) throws ElementException {
body.append(text);
}
@Override
public void doElementEnd() throws ElementException {
if (getParent().getElementObject() instanceof JRDesignStaticText) {
((JRDesignStaticText)getParent().getElementObject()).setText(body.toString());
}
}
}

View file

@ -0,0 +1,59 @@
/*
* Copyright 2007-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.lib.jr4o.x4o;
import org.x4o.xml.element.AbstractElement;
import org.x4o.xml.element.ElementException;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.design.JRDesignExpression;
import net.sf.jasperreports.engine.design.JRDesignTextField;
/**
* ValueBodyTextExpressionElement
*
* @author Willem Cazander
* @version 1.0 Aug 31, 2007
*/
public class ValueBodyTextExpressionElement extends AbstractElement {
private StringBuffer body = new StringBuffer();
@Override
public void doCharacters(String text) throws ElementException {
body.append(text);
}
@Override
public void doElementEnd() throws ElementException {
if ((getElementObject() instanceof JRDesignExpression)==false) {
throw new ElementException("elementObject is not JRDesignExpression object");
}
((JRDesignExpression)getElementObject()).setText(body.toString());
if (getParent().getElementObject() instanceof JRDesignTextField) {
if (getElementObject() instanceof JRExpression) {
((JRDesignTextField)getParent().getElementObject()).setExpression((JRExpression)getElementObject());
}
}
}
}

View file

@ -0,0 +1,187 @@
<?xml version="1.0" encoding="UTF-8"?>
<eld:root xmlns:eld="http://eld.x4o.org/eld/eld-lang.eld">
<!-- NOTE: REDO this file using interfaces and auto binding handlers and rm most elementClassName's -->
<eld:elementBindingHandler bean.class="net.forwardfire.vasc.lib.jr4o.x4o.JR4OElementBindingHandler"/>
<eld:elementBindingHandler bean.class="net.forwardfire.vasc.lib.jr4o.x4o.JR4OElementGroupBindingHandler"/>
<eld:elementBindingHandler bean.class="net.forwardfire.vasc.lib.jr4o.x4o.JR4OJasperDesignBindingHandler"/>
<eld:elementClass tag="report" objectClassName="java.lang.Object"/>
<eld:elementClass tag="jasperReport" objectClassName="net.sf.jasperreports.engine.design.JasperDesign" elementClassName="net.forwardfire.vasc.lib.jr4o.x4o.JasperReportElement">
<eld:elementClassAttribute attributeName="orientation">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.OrientationEnum"/>
</eld:elementClassAttribute>
</eld:elementClass>
<eld:elementClass tag="field" objectClassName="net.sf.jasperreports.engine.design.JRDesignField">
<eld:elementClassAttribute attributeName="valueClass">
<eld:attributeClassConverter/>
</eld:elementClassAttribute>
</eld:elementClass>
<eld:elementClass tag="parameter" objectClassName="net.sf.jasperreports.engine.design.JRDesignParameter">
<eld:elementClassAttribute attributeName="valueClass">
<eld:attributeClassConverter/>
</eld:elementClassAttribute>
</eld:elementClass>
<eld:elementClass tag="title" objectClassName="net.sf.jasperreports.engine.design.JRDesignBand" elementClassName="net.forwardfire.vasc.lib.jr4o.x4o.JasperDesignPageBinderElement"/>
<eld:elementClass tag="pageHeader" objectClassName="net.sf.jasperreports.engine.design.JRDesignBand" elementClassName="net.forwardfire.vasc.lib.jr4o.x4o.JasperDesignPageBinderElement"/>
<eld:elementClass tag="columnHeader" objectClassName="net.sf.jasperreports.engine.design.JRDesignBand" elementClassName="net.forwardfire.vasc.lib.jr4o.x4o.JasperDesignPageBinderElement"/>
<eld:elementClass tag="detail" objectClassName="net.sf.jasperreports.engine.design.JRDesignBand" elementClassName="net.forwardfire.vasc.lib.jr4o.x4o.JasperDesignPageBinderElement"/>
<eld:elementClass tag="pageFooter" objectClassName="net.sf.jasperreports.engine.design.JRDesignBand" elementClassName="net.forwardfire.vasc.lib.jr4o.x4o.JasperDesignPageBinderElement"/>
<eld:elementClass tag="summary" objectClassName="net.sf.jasperreports.engine.design.JRDesignBand" elementClassName="net.forwardfire.vasc.lib.jr4o.x4o.JasperDesignPageBinderElement"/>
<eld:elementClass tag="band" objectClassName="net.sf.jasperreports.engine.design.JRDesignBand"/>
<eld:elementClass tag="textField" objectClassName="net.sf.jasperreports.engine.design.JRDesignTextField">
<eld:elementClassAttribute attributeName="evaluationTime">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.EvaluationTimeEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="horizontalAlignment">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.HorizontalAlignEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="verticalAlignment">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.VerticalAlignEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="positionType">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.PositionTypeEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="mode">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.ModeEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="forecolor">
<eld:attributeBeanConverter bean.class="net.forwardfire.vasc.lib.jr4o.x4o.ColorConverter" />
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="backcolor">
<eld:attributeBeanConverter bean.class="net.forwardfire.vasc.lib.jr4o.x4o.ColorConverter" />
</eld:elementClassAttribute>
</eld:elementClass>
<eld:elementClass tag="staticText" objectClassName="net.sf.jasperreports.engine.design.JRDesignStaticText">
<eld:elementClassAttribute attributeName="evaluationTime">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.EvaluationTimeEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="horizontalAlignment">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.HorizontalAlignEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="verticalAlignment">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.VerticalAlignEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="positionType">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.PositionTypeEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="mode">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.ModeEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="forecolor">
<eld:attributeBeanConverter bean.class="net.forwardfire.vasc.lib.jr4o.x4o.ColorConverter" />
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="backcolor">
<eld:attributeBeanConverter bean.class="net.forwardfire.vasc.lib.jr4o.x4o.ColorConverter" />
</eld:elementClassAttribute>
</eld:elementClass>
<eld:elementClass tag="textElement" objectClassName="org.x4o.xml.impl.lang.ParentObjectElement">
<eld:elementClassAttribute attributeName="horizontalAlignment">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.HorizontalAlignEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="verticalAlignment">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.VerticalAlignEnum"/>
</eld:elementClassAttribute>
</eld:elementClass>
<eld:elementClass tag="textFieldExpression" objectClassName="net.sf.jasperreports.engine.design.JRDesignExpression" elementClassName="net.forwardfire.vasc.lib.jr4o.x4o.ValueBodyTextExpressionElement">
<eld:elementClassAttribute attributeName="valueClass">
<eld:attributeClassConverter/>
</eld:elementClassAttribute>
</eld:elementClass>
<!--
<eld:elementClass tag="text" objectClassName="net.sf.jasperreports.engine.design.JRDesignExpression" elementClassName="net.forwardfire.vasc.lib.jr4o.x4o.ValueBodyTextExpressionElement">
<eld:elementClassAttribute attributeName="valueClass">
<eld:attributeClassConverter/>
</eld:elementClassAttribute>
</eld:elementClass>
-->
<eld:elementClass tag="printWhenExpression" objectClassName="net.sf.jasperreports.engine.design.JRDesignExpression" elementClassName="net.forwardfire.vasc.lib.jr4o.x4o.ValueBodyPrintExpressionElement">
<eld:elementClassAttribute attributeName="valueClass">
<eld:attributeClassConverter/>
</eld:elementClassAttribute>
</eld:elementClass>
<eld:elementClass tag="font" objectClassName="net.sf.jasperreports.engine.design.JRDesignFont"/>
<eld:elementClass tag="reportFont" objectClassName="net.sf.jasperreports.engine.design.JRDesignReportFont"/>
<eld:elementClass tag="style" objectClassName="net.sf.jasperreports.engine.design.JRDesignStyle"/>
<eld:elementClass tag="reportElement" elementClassName="org.x4o.xml.impl.lang.ParentObjectElement">
<eld:elementClassAttribute attributeName="positionType">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.PositionTypeEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="mode">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.ModeEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="forecolor">
<eld:attributeBeanConverter bean.class="net.forwardfire.vasc.lib.jr4o.x4o.ColorConverter" />
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="backcolor">
<eld:attributeBeanConverter bean.class="net.forwardfire.vasc.lib.jr4o.x4o.ColorConverter" />
</eld:elementClassAttribute>
</eld:elementClass>
<eld:elementClass tag="line" objectClassName="net.sf.jasperreports.engine.design.JRDesignLine">
<eld:elementClassAttribute attributeName="positionType">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.PositionTypeEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="forecolor">
<eld:attributeBeanConverter bean.class="net.forwardfire.vasc.lib.jr4o.x4o.ColorConverter" />
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="backcolor">
<eld:attributeBeanConverter bean.class="net.forwardfire.vasc.lib.jr4o.x4o.ColorConverter" />
</eld:elementClassAttribute>
</eld:elementClass>
<eld:elementClass tag="rectangle" objectClassName="net.sf.jasperreports.engine.design.JRDesignRectangle">
<eld:elementClassAttribute attributeName="positionType">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.PositionTypeEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="forecolor">
<eld:attributeBeanConverter bean.class="net.forwardfire.vasc.lib.jr4o.x4o.ColorConverter" />
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="backcolor">
<eld:attributeBeanConverter bean.class="net.forwardfire.vasc.lib.jr4o.x4o.ColorConverter" />
</eld:elementClassAttribute>
</eld:elementClass>
<eld:elementClass tag="image" elementClassName="net.forwardfire.vasc.lib.jr4o.x4o.ImageElement">
<eld:elementClassAttribute attributeName="evaluationTime">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.EvaluationTimeEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="horizontalAlignment">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.HorizontalAlignEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="verticalAlignment">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.VerticalAlignEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="positionType">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.PositionTypeEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="mode">
<eld:attributeEnumConverter enumClass="net.sf.jasperreports.engine.type.ModeEnum"/>
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="forecolor">
<eld:attributeBeanConverter bean.class="net.forwardfire.vasc.lib.jr4o.x4o.ColorConverter" />
</eld:elementClassAttribute>
<eld:elementClassAttribute attributeName="backcolor">
<eld:attributeBeanConverter bean.class="net.forwardfire.vasc.lib.jr4o.x4o.ColorConverter" />
</eld:elementClassAttribute>
</eld:elementClass>
<eld:elementClass tag="imageExpression" objectClassName="net.sf.jasperreports.engine.design.JRDesignExpression" elementClassName="net.forwardfire.vasc.lib.jr4o.x4o.ValueBodyImageExpressionElement">
<eld:elementClassAttribute attributeName="valueClass">
<eld:attributeClassConverter/>
</eld:elementClassAttribute>
</eld:elementClass>
<eld:elementClass tag="dynamicColumnHeader" elementClassName="net.forwardfire.vasc.lib.jr4o.x4o.JRDynamicColumnHeaderElement"/>
<eld:elementClass tag="dynamicColumn" elementClassName="net.forwardfire.vasc.lib.jr4o.x4o.JRDynamicColumnElement"/>
<eld:elementClass tag="dynamicCards" elementClassName="net.forwardfire.vasc.lib.jr4o.x4o.JRDynamicCardsElement"/>
</eld:root>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>JR4O namespaces</comment>
<entry key="eld.http://jr4o.vasc.forwardfire.net/eld/jr4o-lang.eld">jr4o-lang.eld</entry>
</properties>

View file

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://jr4o.vasc.forwardfire.net/eld/jr4o-lang.eld">
<!--
Format is made JR compatible for easy copy/paste except;
- root report tag with namespace for jr4o language.
- style tags need el.id for reference in docs and dynamic report elements.
- can use multiple reports in one xml
- not all JR tags are supported only the ones needed for ~this report see jr4o-lang.eld file.
-->
<jasperReport name="generic-landscape" columnCount="1" pageWidth="842" pageHeight="595" columnWidth="800" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30" orientation="LANDSCAPE">
<style el.id="Arial_Normal" name="Arial_Normal" isDefault="true" fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false" />
<style el.id="Arial_Bold" name="Arial_Bold" isDefault="false" fontName="Arial" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false" />
<style el.id="Arial_Italic" name="Arial_Italic" isDefault="false" fontName="Arial" size="10" isBold="false" isItalic="true" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1252" isPdfEmbedded="false" />
<style el.id="Arial_Header" name="Arial_Header" isDefault="false" fontName="Arial" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
<title tagType="title" height="60">
<line x="0" y="0" width="800" height="1"/>
<textField isBlankWhenNull="true" x="40" y="10" width="276" height="30" style="${Arial_Normal}" fontSize="18">
<textFieldExpression valueClass="java.lang.String"><![CDATA[$P{title}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true" x="40" y="30" width="200" height="30" style="${Arial_Normal}">
<textFieldExpression valueClass="java.lang.String"><![CDATA[$P{description}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true" x="350" y="30" width="150" height="16" style="${Arial_Normal}">
<textFieldExpression valueClass="java.lang.String"><![CDATA[$P{titleSubject}]]></textFieldExpression>
</textField>
</title>
<columnHeader tagType="columnHeader" height="20">
<dynamicColumnHeader/>
</columnHeader>
<detail tagType="detail" height="20">
<line x="0" y="0" width="800" height="1"/>
<dynamicColumn/>
</detail>
<pageFooter tagType="pageFooter" height="40">
<line x="0" y="10" width="800" height="1"/>
<textField isBlankWhenNull="true" x="20" y="20" width="150" height="16" style="${Arial_Normal}">
<textFieldExpression valueClass="java.lang.String"><![CDATA[$P{titleSubject}]]></textFieldExpression>
</textField>
<textField x="200" y="20" width="80" height="15" horizontalAlignment="RIGHT">
<textFieldExpression valueClass="java.lang.String"><![CDATA[$R{report.footer.page}+" "+String.valueOf($V{PAGE_NUMBER})+" "]]></textFieldExpression>
</textField>
<textField x="280" y="20" width="100" height="15" evaluationTime="REPORT">
<textFieldExpression valueClass="java.lang.String"><![CDATA[$R{report.footer.pageOf}+String.valueOf($V{PAGE_NUMBER})+" "+$R{report.footer.printed}]]></textFieldExpression>
</textField>
<textField x="370" y="20" width="150" height="15" pattern="dd-MM-yyyy - HH:mm:ss">
<textFieldExpression valueClass="java.util.Date"><![CDATA[new Date()]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true" x="650" y="20" width="150" height="16" style="${Arial_Normal}">
<textFieldExpression valueClass="java.lang.String"><![CDATA[$P{title}]]></textFieldExpression>
</textField>
</pageFooter>
<summary tagType="summary" height="35">
</summary>
</jasperReport>
<jasperReport name="generic-portrait" columnCount="1" pageWidth="595" pageHeight="842" columnWidth="554" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30" orientation="LANDSCAPE">
<style el.id="Arial_Normal" name="Arial_Normal" isDefault="true" fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false" />
<style el.id="Arial_Bold" name="Arial_Bold" isDefault="false" fontName="Arial" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false" />
<style el.id="Arial_Italic" name="Arial_Italic" isDefault="false" fontName="Arial" size="10" isBold="false" isItalic="true" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1252" isPdfEmbedded="false" />
<style el.id="Arial_Header" name="Arial_Header" isDefault="false" fontName="Arial" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
<title tagType="title" height="60">
<line x="0" y="0" width="800" height="1"/>
<textField isBlankWhenNull="true" x="40" y="10" width="276" height="30" style="${Arial_Normal}" fontSize="18">
<textFieldExpression valueClass="java.lang.String"><![CDATA[$P{title}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true" x="40" y="30" width="200" height="30" style="${Arial_Normal}">
<textFieldExpression valueClass="java.lang.String"><![CDATA[$P{description}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true" x="350" y="30" width="150" height="16" style="${Arial_Normal}">
<textFieldExpression valueClass="java.lang.String"><![CDATA[$P{titleSubject}]]></textFieldExpression>
</textField>
</title>
<columnHeader tagType="columnHeader" height="20">
<dynamicColumnHeader/>
</columnHeader>
<detail tagType="detail" height="20">
<line x="0" y="0" width="800" height="1"/>
<dynamicColumn/>
</detail>
<pageFooter tagType="pageFooter" height="40">
<line x="0" y="10" width="800" height="1"/>
<textField isBlankWhenNull="true" x="20" y="20" width="150" height="16" style="${Arial_Normal}">
<textFieldExpression valueClass="java.lang.String"><![CDATA[$P{titleSubject}]]></textFieldExpression>
</textField>
<textField x="200" y="20" width="80" height="15" horizontalAlignment="RIGHT">
<textFieldExpression valueClass="java.lang.String"><![CDATA[$R{report.footer.page}+" "+String.valueOf($V{PAGE_NUMBER})+" "]]></textFieldExpression>
</textField>
<textField x="280" y="20" width="100" height="15" evaluationTime="REPORT">
<textFieldExpression valueClass="java.lang.String"><![CDATA[$R{report.footer.pageOf}+String.valueOf($V{PAGE_NUMBER})+" "+$R{report.footer.printed}]]></textFieldExpression>
</textField>
<textField x="370" y="20" width="150" height="15" pattern="dd-MM-yyyy - HH:mm:ss">
<textFieldExpression valueClass="java.util.Date"><![CDATA[new Date()]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true" x="650" y="20" width="150" height="16" style="${Arial_Normal}">
<textFieldExpression valueClass="java.lang.String"><![CDATA[$P{title}]]></textFieldExpression>
</textField>
</pageFooter>
<summary tagType="summary" height="35">
</summary>
</jasperReport>
</report>