first commit
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import net.sf.jasperreports.engine.JRException;
|
||||
import net.sf.jasperreports.engine.util.JRLoader;
|
||||
|
||||
public abstract class JRAbstractClassCompiler extends JRAbstractJavaCompiler implements JRMultiClassCompiler {
|
||||
protected JRAbstractClassCompiler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
protected String compileUnits(JRCompilationUnit[] units, String classpath, File tempDirFile) throws JRException {
|
||||
File[] sources = new File[units.length];
|
||||
for (int i = 0; i < sources.length; i++)
|
||||
sources[i] = units[i].getSourceFile();
|
||||
File[] classFiles = new File[units.length];
|
||||
for (int j = 0; j < classFiles.length; j++)
|
||||
classFiles[j] = new File(tempDirFile, units[j].getName() + ".class");
|
||||
try {
|
||||
String errors = compileClasses(sources, classpath);
|
||||
if (errors == null)
|
||||
for (int m = 0; m < units.length; m++) {
|
||||
byte[] classBytes = JRLoader.loadBytes(classFiles[m]);
|
||||
units[m].setCompileData((Serializable)classBytes);
|
||||
}
|
||||
return errors;
|
||||
} finally {
|
||||
for (int k = 0; k < classFiles.length; k++) {
|
||||
if (classFiles[k].exists())
|
||||
classFiles[k].delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkLanguage(String language) throws JRException {
|
||||
if (!"java".equals(language))
|
||||
throw new JRException("Language \"" + language + "\" not supported by this report compiler.\n" + "Expecting \"java\" instead.");
|
||||
}
|
||||
|
||||
protected JRCompilationSourceCode generateSourceCode(JRSourceCompileTask sourceTask) throws JRException {
|
||||
return JRClassGenerator.generateClass(sourceTask);
|
||||
}
|
||||
|
||||
protected String getSourceFileName(String unitName) {
|
||||
return unitName + ".java";
|
||||
}
|
||||
}
|
@@ -0,0 +1,189 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Random;
|
||||
import net.sf.jasperreports.crosstabs.JRCrosstab;
|
||||
import net.sf.jasperreports.crosstabs.design.JRDesignCrosstab;
|
||||
import net.sf.jasperreports.engine.JRDataset;
|
||||
import net.sf.jasperreports.engine.JRException;
|
||||
import net.sf.jasperreports.engine.JRExpressionCollector;
|
||||
import net.sf.jasperreports.engine.JRReport;
|
||||
import net.sf.jasperreports.engine.JRRuntimeException;
|
||||
import net.sf.jasperreports.engine.JasperReport;
|
||||
import net.sf.jasperreports.engine.fill.JREvaluator;
|
||||
import net.sf.jasperreports.engine.util.JRProperties;
|
||||
import net.sf.jasperreports.engine.util.JRSaver;
|
||||
import net.sf.jasperreports.engine.util.JRStringUtil;
|
||||
|
||||
public abstract class JRAbstractCompiler implements JRCompiler {
|
||||
private static final int NAME_SUFFIX_RANDOM_MAX = 1000000;
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
private final boolean needsSourceFiles;
|
||||
|
||||
protected JRAbstractCompiler(boolean needsSourceFiles) {
|
||||
this.needsSourceFiles = needsSourceFiles;
|
||||
}
|
||||
|
||||
public static String getUnitName(JasperReport report, JRDataset dataset) {
|
||||
return getUnitName((JRReport)report, dataset, report.getCompileNameSuffix());
|
||||
}
|
||||
|
||||
protected static String getUnitName(JRReport report, JRDataset dataset, String nameSuffix) {
|
||||
if (dataset.isMainDataset()) {
|
||||
className = report.getName();
|
||||
} else {
|
||||
className = report.getName() + "_" + dataset.getName();
|
||||
}
|
||||
String className = JRStringUtil.getLiteral(className) + nameSuffix;
|
||||
return className;
|
||||
}
|
||||
|
||||
public static String getUnitName(JasperReport report, JRCrosstab crosstab) {
|
||||
return getUnitName((JRReport)report, crosstab.getId(), report.getCompileNameSuffix());
|
||||
}
|
||||
|
||||
protected static String getUnitName(JRReport report, JRCrosstab crosstab, JRExpressionCollector expressionCollector, String nameSuffix) {
|
||||
Integer crosstabId = expressionCollector.getCrosstabId(crosstab);
|
||||
if (crosstabId == null)
|
||||
throw new JRRuntimeException("Crosstab ID not found.");
|
||||
return getUnitName(report, crosstabId.intValue(), nameSuffix);
|
||||
}
|
||||
|
||||
protected static String getUnitName(JRReport report, int crosstabId, String nameSuffix) {
|
||||
return JRStringUtil.getLiteral(report.getName()) + "_CROSSTAB" + crosstabId + nameSuffix;
|
||||
}
|
||||
|
||||
public final JasperReport compileReport(JasperDesign jasperDesign) throws JRException {
|
||||
checkLanguage(jasperDesign.getLanguage());
|
||||
JRExpressionCollector expressionCollector = JRExpressionCollector.collector((JRReport)jasperDesign);
|
||||
verifyDesign(jasperDesign, expressionCollector);
|
||||
String nameSuffix = createNameSuffix();
|
||||
boolean isKeepJavaFile = JRProperties.getBooleanProperty("net.sf.jasperreports.compiler.keep.java.file");
|
||||
File tempDirFile = null;
|
||||
if (isKeepJavaFile || this.needsSourceFiles) {
|
||||
String tempDirStr = JRProperties.getProperty("net.sf.jasperreports.compiler.temp.dir");
|
||||
tempDirFile = new File(tempDirStr);
|
||||
if (!tempDirFile.exists() || !tempDirFile.isDirectory())
|
||||
throw new JRException("Temporary directory not found : " + tempDirStr);
|
||||
}
|
||||
List datasets = jasperDesign.getDatasetsList();
|
||||
List crosstabs = jasperDesign.getCrosstabs();
|
||||
JRCompilationUnit[] units = new JRCompilationUnit[datasets.size() + crosstabs.size() + 1];
|
||||
units[0] = createCompileUnit(jasperDesign, jasperDesign.getMainDesignDataset(), expressionCollector, tempDirFile, nameSuffix);
|
||||
int sourcesCount = 1;
|
||||
for (Iterator iterator = datasets.iterator(); iterator.hasNext(); sourcesCount++) {
|
||||
JRDesignDataset dataset = iterator.next();
|
||||
units[sourcesCount] = createCompileUnit(jasperDesign, dataset, expressionCollector, tempDirFile, nameSuffix);
|
||||
}
|
||||
for (Iterator it = crosstabs.iterator(); it.hasNext(); sourcesCount++) {
|
||||
JRDesignCrosstab crosstab = it.next();
|
||||
units[sourcesCount] = createCompileUnit(jasperDesign, crosstab, expressionCollector, tempDirFile, nameSuffix);
|
||||
}
|
||||
String classpath = JRProperties.getProperty("net.sf.jasperreports.compiler.classpath");
|
||||
try {
|
||||
String compileErrors = compileUnits(units, classpath, tempDirFile);
|
||||
if (compileErrors != null)
|
||||
throw new JRException("Errors were encountered when compiling report expressions class file:\n" + compileErrors);
|
||||
JRReportCompileData reportCompileData = new JRReportCompileData();
|
||||
reportCompileData.setMainDatasetCompileData(units[0].getCompileData());
|
||||
for (ListIterator listIterator1 = datasets.listIterator(); listIterator1.hasNext(); ) {
|
||||
JRDesignDataset dataset = listIterator1.next();
|
||||
reportCompileData.setDatasetCompileData((JRDataset)dataset, units[listIterator1.nextIndex()].getCompileData());
|
||||
}
|
||||
for (ListIterator listIterator = crosstabs.listIterator(); listIterator.hasNext(); ) {
|
||||
JRDesignCrosstab crosstab = listIterator.next();
|
||||
Integer crosstabId = expressionCollector.getCrosstabId((JRCrosstab)crosstab);
|
||||
reportCompileData.setCrosstabCompileData(crosstabId.intValue(), units[datasets.size() + listIterator.nextIndex()].getCompileData());
|
||||
}
|
||||
JasperReport jasperReport = new JasperReport((JRReport)jasperDesign, getCompilerClass(), reportCompileData, expressionCollector, nameSuffix);
|
||||
return jasperReport;
|
||||
} catch (JRException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new JRException("Error compiling report design.", e);
|
||||
} finally {
|
||||
if (this.needsSourceFiles && !isKeepJavaFile)
|
||||
deleteSourceFiles(units);
|
||||
}
|
||||
}
|
||||
|
||||
private static String createNameSuffix() {
|
||||
return "_" + System.currentTimeMillis() + "_" + random.nextInt(1000000);
|
||||
}
|
||||
|
||||
protected String getCompilerClass() {
|
||||
return getClass().getName();
|
||||
}
|
||||
|
||||
private void verifyDesign(JasperDesign jasperDesign, JRExpressionCollector expressionCollector) throws JRException {
|
||||
Collection brokenRules = JRVerifier.verifyDesign(jasperDesign, expressionCollector);
|
||||
if (brokenRules != null && brokenRules.size() > 0)
|
||||
throw new JRValidationException(brokenRules);
|
||||
}
|
||||
|
||||
private JRCompilationUnit createCompileUnit(JasperDesign jasperDesign, JRDesignDataset dataset, JRExpressionCollector expressionCollector, File saveSourceDir, String nameSuffix) throws JRException {
|
||||
String unitName = getUnitName((JRReport)jasperDesign, (JRDataset)dataset, nameSuffix);
|
||||
JRSourceCompileTask sourceTask = new JRSourceCompileTask(jasperDesign, dataset, expressionCollector, unitName);
|
||||
JRCompilationSourceCode sourceCode = generateSourceCode(sourceTask);
|
||||
File sourceFile = getSourceFile(saveSourceDir, unitName, sourceCode);
|
||||
return new JRCompilationUnit(unitName, sourceCode, sourceFile, expressionCollector.getExpressions((JRDataset)dataset));
|
||||
}
|
||||
|
||||
private JRCompilationUnit createCompileUnit(JasperDesign jasperDesign, JRDesignCrosstab crosstab, JRExpressionCollector expressionCollector, File saveSourceDir, String nameSuffix) throws JRException {
|
||||
String unitName = getUnitName((JRReport)jasperDesign, (JRCrosstab)crosstab, expressionCollector, nameSuffix);
|
||||
JRSourceCompileTask sourceTask = new JRSourceCompileTask(jasperDesign, crosstab, expressionCollector, unitName);
|
||||
JRCompilationSourceCode sourceCode = generateSourceCode(sourceTask);
|
||||
File sourceFile = getSourceFile(saveSourceDir, unitName, sourceCode);
|
||||
return new JRCompilationUnit(unitName, sourceCode, sourceFile, expressionCollector.getExpressions((JRCrosstab)crosstab));
|
||||
}
|
||||
|
||||
private File getSourceFile(File saveSourceDir, String unitName, JRCompilationSourceCode sourceCode) throws JRException {
|
||||
File sourceFile = null;
|
||||
if (saveSourceDir != null) {
|
||||
String fileName = getSourceFileName(unitName);
|
||||
sourceFile = new File(saveSourceDir, fileName);
|
||||
JRSaver.saveClassSource(sourceCode.getCode(), sourceFile);
|
||||
}
|
||||
return sourceFile;
|
||||
}
|
||||
|
||||
private void deleteSourceFiles(JRCompilationUnit[] units) {
|
||||
for (int i = 0; i < units.length; i++)
|
||||
units[i].getSourceFile().delete();
|
||||
}
|
||||
|
||||
public JREvaluator loadEvaluator(JasperReport jasperReport) throws JRException {
|
||||
return loadEvaluator(jasperReport, jasperReport.getMainDataset());
|
||||
}
|
||||
|
||||
public JREvaluator loadEvaluator(JasperReport jasperReport, JRDataset dataset) throws JRException {
|
||||
String unitName = getUnitName(jasperReport, dataset);
|
||||
JRReportCompileData reportCompileData = (JRReportCompileData)jasperReport.getCompileData();
|
||||
Serializable compileData = reportCompileData.getDatasetCompileData(dataset);
|
||||
return loadEvaluator(compileData, unitName);
|
||||
}
|
||||
|
||||
public JREvaluator loadEvaluator(JasperReport jasperReport, JRCrosstab crosstab) throws JRException {
|
||||
String unitName = getUnitName(jasperReport, crosstab);
|
||||
JRReportCompileData reportCompileData = (JRReportCompileData)jasperReport.getCompileData();
|
||||
Serializable compileData = reportCompileData.getCrosstabCompileData(crosstab);
|
||||
return loadEvaluator(compileData, unitName);
|
||||
}
|
||||
|
||||
protected abstract JREvaluator loadEvaluator(Serializable paramSerializable, String paramString) throws JRException;
|
||||
|
||||
protected abstract void checkLanguage(String paramString) throws JRException;
|
||||
|
||||
protected abstract JRCompilationSourceCode generateSourceCode(JRSourceCompileTask paramJRSourceCompileTask) throws JRException;
|
||||
|
||||
protected abstract String compileUnits(JRCompilationUnit[] paramArrayOfJRCompilationUnit, String paramString, File paramFile) throws JRException;
|
||||
|
||||
protected abstract String getSourceFileName(String paramString);
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import net.sf.jasperreports.engine.JRException;
|
||||
import net.sf.jasperreports.engine.fill.JREvaluator;
|
||||
import net.sf.jasperreports.engine.util.JRClassLoader;
|
||||
import net.sf.jasperreports.engine.util.JRProperties;
|
||||
import org.apache.commons.collections.ReferenceMap;
|
||||
|
||||
public abstract class JRAbstractJavaCompiler extends JRAbstractCompiler {
|
||||
public static final String PROPERTY_EVALUATOR_CLASS_REFERENCE_FIX_ENABLED = "net.sf.jasperreports.evaluator.class.reference.fix.enabled";
|
||||
|
||||
private static ThreadLocal classFromBytesRef = new ThreadLocal();
|
||||
|
||||
private static Object CLASS_CACHE_NULL_KEY = new Object();
|
||||
|
||||
private static Map classCache = (Map)new ReferenceMap(2, 1);
|
||||
|
||||
protected JRAbstractJavaCompiler(boolean needsSourceFiles) {
|
||||
super(needsSourceFiles);
|
||||
}
|
||||
|
||||
protected JREvaluator loadEvaluator(Serializable compileData, String className) throws JRException {
|
||||
JREvaluator evaluator = null;
|
||||
try {
|
||||
Class clazz = getClassFromCache(className);
|
||||
if (clazz == null) {
|
||||
clazz = JRClassLoader.loadClassFromBytes(className, (byte[])compileData);
|
||||
putClassInCache(className, clazz);
|
||||
}
|
||||
if (JRProperties.getBooleanProperty("net.sf.jasperreports.evaluator.class.reference.fix.enabled"))
|
||||
classFromBytesRef.set(clazz);
|
||||
evaluator = (JREvaluator)clazz.newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new JRException("Error loading expression class : " + className, e);
|
||||
}
|
||||
return evaluator;
|
||||
}
|
||||
|
||||
protected static Object classCacheKey() {
|
||||
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
Object key = (contextClassLoader == null) ? CLASS_CACHE_NULL_KEY : contextClassLoader;
|
||||
return key;
|
||||
}
|
||||
|
||||
protected static synchronized Class getClassFromCache(String className) {
|
||||
Object key = classCacheKey();
|
||||
Map contextMap = (Map)classCache.get(key);
|
||||
Class cachedClass = null;
|
||||
if (contextMap != null)
|
||||
cachedClass = (Class)contextMap.get(className);
|
||||
return cachedClass;
|
||||
}
|
||||
|
||||
protected static synchronized void putClassInCache(String className, Class loadedClass) {
|
||||
ReferenceMap referenceMap;
|
||||
Object key = classCacheKey();
|
||||
Map contextMap = (Map)classCache.get(key);
|
||||
if (contextMap == null) {
|
||||
referenceMap = new ReferenceMap(0, 1);
|
||||
classCache.put(key, referenceMap);
|
||||
}
|
||||
referenceMap.put(className, loadedClass);
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.io.File;
|
||||
import net.sf.jasperreports.engine.JRException;
|
||||
|
||||
public abstract class JRAbstractMultiClassCompiler extends JRAbstractClassCompiler {
|
||||
public String compileClass(File sourceFile, String classpath) throws JRException {
|
||||
return compileClasses(new File[] { sourceFile }, classpath);
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.io.File;
|
||||
import net.sf.jasperreports.engine.JRException;
|
||||
|
||||
public interface JRClassCompiler {
|
||||
String compileClass(File paramFile, String paramString) throws JRException;
|
||||
}
|
482
hrmsEjb/net/sf/jasperreports/engine/design/JRClassGenerator.java
Normal file
482
hrmsEjb/net/sf/jasperreports/engine/design/JRClassGenerator.java
Normal file
@@ -0,0 +1,482 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
import net.sf.jasperreports.engine.JRException;
|
||||
import net.sf.jasperreports.engine.JRExpression;
|
||||
import net.sf.jasperreports.engine.JRExpressionChunk;
|
||||
import net.sf.jasperreports.engine.JRField;
|
||||
import net.sf.jasperreports.engine.JRParameter;
|
||||
import net.sf.jasperreports.engine.JRVariable;
|
||||
import net.sf.jasperreports.engine.util.JRStringUtil;
|
||||
|
||||
public class JRClassGenerator {
|
||||
private static final int EXPR_MAX_COUNT_PER_METHOD = 100;
|
||||
|
||||
protected static final String SOURCE_EXPRESSION_ID_START = "$JR_EXPR_ID=";
|
||||
|
||||
protected static final int sOURCE_EXPRESSION_ID_START_LENGTH = "$JR_EXPR_ID=".length();
|
||||
|
||||
protected static final String SOURCE_EXPRESSION_ID_END = "$";
|
||||
|
||||
private static Map fieldPrefixMap = null;
|
||||
|
||||
private static Map variablePrefixMap = null;
|
||||
|
||||
private static Map methodSuffixMap = null;
|
||||
|
||||
protected final JRSourceCompileTask sourceTask;
|
||||
|
||||
protected Map parametersMap;
|
||||
|
||||
protected Map fieldsMap;
|
||||
|
||||
protected Map variablesMap;
|
||||
|
||||
protected JRVariable[] variables;
|
||||
|
||||
static {
|
||||
fieldPrefixMap = new HashMap();
|
||||
fieldPrefixMap.put(new Byte((byte)1), "Old");
|
||||
fieldPrefixMap.put(new Byte((byte)2), "");
|
||||
fieldPrefixMap.put(new Byte((byte)3), "");
|
||||
variablePrefixMap = new HashMap();
|
||||
variablePrefixMap.put(new Byte((byte)1), "Old");
|
||||
variablePrefixMap.put(new Byte((byte)2), "Estimated");
|
||||
variablePrefixMap.put(new Byte((byte)3), "");
|
||||
methodSuffixMap = new HashMap();
|
||||
methodSuffixMap.put(new Byte((byte)1), "Old");
|
||||
methodSuffixMap.put(new Byte((byte)2), "Estimated");
|
||||
methodSuffixMap.put(new Byte((byte)3), "");
|
||||
}
|
||||
|
||||
protected JRClassGenerator(JRSourceCompileTask sourceTask) {
|
||||
this.sourceTask = sourceTask;
|
||||
this.parametersMap = sourceTask.getParametersMap();
|
||||
this.fieldsMap = sourceTask.getFieldsMap();
|
||||
this.variablesMap = sourceTask.getVariablesMap();
|
||||
this.variables = sourceTask.getVariables();
|
||||
}
|
||||
|
||||
public static JRCompilationSourceCode generateClass(JRSourceCompileTask sourceTask) throws JRException {
|
||||
JRClassGenerator generator = new JRClassGenerator(sourceTask);
|
||||
return generator.generateClass();
|
||||
}
|
||||
|
||||
protected JRCompilationSourceCode generateClass() throws JRException {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
generateClassStart(sb);
|
||||
generateDeclarations(sb);
|
||||
generateInitMethod(sb);
|
||||
generateInitParamsMethod(sb);
|
||||
if (this.fieldsMap != null)
|
||||
generateInitFieldsMethod(sb);
|
||||
generateInitVarsMethod(sb);
|
||||
List expressions = this.sourceTask.getExpressions();
|
||||
sb.append(generateMethod((byte)3, expressions));
|
||||
if (this.sourceTask.isOnlyDefaultEvaluation()) {
|
||||
List empty = new ArrayList();
|
||||
sb.append(generateMethod((byte)1, empty));
|
||||
sb.append(generateMethod((byte)2, empty));
|
||||
} else {
|
||||
sb.append(generateMethod((byte)1, expressions));
|
||||
sb.append(generateMethod((byte)2, expressions));
|
||||
}
|
||||
sb.append("}\n");
|
||||
String code = sb.toString();
|
||||
JRExpression[] lineExpressions = parseSourceLines(code);
|
||||
return new JRDefaultCompilationSourceCode(code, lineExpressions);
|
||||
}
|
||||
|
||||
private void generateInitMethod(StringBuffer sb) {
|
||||
sb.append("\n");
|
||||
sb.append("\n");
|
||||
sb.append(" /**\n");
|
||||
sb.append(" *\n");
|
||||
sb.append(" */\n");
|
||||
sb.append(" public void customizedInit(\n");
|
||||
sb.append(" Map pm,\n");
|
||||
sb.append(" Map fm,\n");
|
||||
sb.append(" Map vm\n");
|
||||
sb.append(" )\n");
|
||||
sb.append(" {\n");
|
||||
sb.append(" initParams(pm);\n");
|
||||
if (this.fieldsMap != null)
|
||||
sb.append(" initFields(fm);\n");
|
||||
sb.append(" initVars(vm);\n");
|
||||
sb.append(" }\n");
|
||||
sb.append("\n");
|
||||
sb.append("\n");
|
||||
}
|
||||
|
||||
protected final void generateClassStart(StringBuffer sb) {
|
||||
sb.append("/*\n");
|
||||
sb.append(" * Generated by JasperReports - ");
|
||||
sb.append((new SimpleDateFormat()).format(new Date()));
|
||||
sb.append("\n");
|
||||
sb.append(" */\n");
|
||||
sb.append("import net.sf.jasperreports.engine.*;\n");
|
||||
sb.append("import net.sf.jasperreports.engine.fill.*;\n");
|
||||
sb.append("\n");
|
||||
sb.append("import java.util.*;\n");
|
||||
sb.append("import java.math.*;\n");
|
||||
sb.append("import java.text.*;\n");
|
||||
sb.append("import java.io.*;\n");
|
||||
sb.append("import java.net.*;\n");
|
||||
sb.append("\n");
|
||||
String[] imports = this.sourceTask.getImports();
|
||||
if (imports != null && imports.length > 0)
|
||||
for (int i = 0; i < imports.length; i++) {
|
||||
sb.append("import ");
|
||||
sb.append(imports[i]);
|
||||
sb.append(";\n");
|
||||
}
|
||||
sb.append("\n");
|
||||
sb.append("\n");
|
||||
sb.append("/**\n");
|
||||
sb.append(" *\n");
|
||||
sb.append(" */\n");
|
||||
sb.append("public class ");
|
||||
sb.append(this.sourceTask.getUnitName());
|
||||
sb.append(" extends JREvaluator\n");
|
||||
sb.append("{\n");
|
||||
sb.append("\n");
|
||||
sb.append("\n");
|
||||
sb.append(" /**\n");
|
||||
sb.append(" *\n");
|
||||
sb.append(" */\n");
|
||||
}
|
||||
|
||||
protected final void generateDeclarations(StringBuffer sb) {
|
||||
if (this.parametersMap != null && this.parametersMap.size() > 0) {
|
||||
Collection parameterNames = this.parametersMap.keySet();
|
||||
for (Iterator it = parameterNames.iterator(); it.hasNext(); ) {
|
||||
sb.append(" private JRFillParameter parameter_");
|
||||
sb.append(JRStringUtil.getLiteral(it.next()));
|
||||
sb.append(" = null;\n");
|
||||
}
|
||||
}
|
||||
if (this.fieldsMap != null && this.fieldsMap.size() > 0) {
|
||||
Collection fieldNames = this.fieldsMap.keySet();
|
||||
for (Iterator it = fieldNames.iterator(); it.hasNext(); ) {
|
||||
sb.append(" private JRFillField field_");
|
||||
sb.append(JRStringUtil.getLiteral(it.next()));
|
||||
sb.append(" = null;\n");
|
||||
}
|
||||
}
|
||||
if (this.variables != null && this.variables.length > 0)
|
||||
for (int i = 0; i < this.variables.length; i++) {
|
||||
sb.append(" private JRFillVariable variable_");
|
||||
sb.append(JRStringUtil.getLiteral(this.variables[i].getName()));
|
||||
sb.append(" = null;\n");
|
||||
}
|
||||
}
|
||||
|
||||
protected final void generateInitParamsMethod(StringBuffer sb) throws JRException {
|
||||
Iterator parIt = null;
|
||||
if (this.parametersMap != null && this.parametersMap.size() > 0) {
|
||||
parIt = this.parametersMap.keySet().iterator();
|
||||
} else {
|
||||
parIt = Collections.EMPTY_SET.iterator();
|
||||
}
|
||||
generateInitParamsMethod(sb, parIt, 0);
|
||||
}
|
||||
|
||||
protected final void generateInitFieldsMethod(StringBuffer sb) throws JRException {
|
||||
Iterator fieldIt = null;
|
||||
if (this.fieldsMap != null && this.fieldsMap.size() > 0) {
|
||||
fieldIt = this.fieldsMap.keySet().iterator();
|
||||
} else {
|
||||
fieldIt = Collections.EMPTY_SET.iterator();
|
||||
}
|
||||
generateInitFieldsMethod(sb, fieldIt, 0);
|
||||
}
|
||||
|
||||
protected final void generateInitVarsMethod(StringBuffer sb) throws JRException {
|
||||
Iterator varIt = null;
|
||||
if (this.variables != null && this.variables.length > 0) {
|
||||
varIt = Arrays.<JRVariable>asList(this.variables).iterator();
|
||||
} else {
|
||||
varIt = Collections.EMPTY_LIST.iterator();
|
||||
}
|
||||
generateInitVarsMethod(sb, varIt, 0);
|
||||
}
|
||||
|
||||
private void generateInitParamsMethod(StringBuffer sb, Iterator it, int index) throws JRException {
|
||||
sb.append(" /**\n");
|
||||
sb.append(" *\n");
|
||||
sb.append(" */\n");
|
||||
sb.append(" private void initParams");
|
||||
if (index > 0)
|
||||
sb.append(index);
|
||||
sb.append("(Map pm)\n");
|
||||
sb.append(" {\n");
|
||||
for (int i = 0; i < 100 && it.hasNext(); i++) {
|
||||
String parameterName = it.next();
|
||||
sb.append(" parameter_");
|
||||
sb.append(JRStringUtil.getLiteral(parameterName));
|
||||
sb.append(" = (JRFillParameter)pm.get(\"");
|
||||
sb.append(parameterName);
|
||||
sb.append("\");\n");
|
||||
}
|
||||
if (it.hasNext()) {
|
||||
sb.append(" initParams");
|
||||
sb.append(index + 1);
|
||||
sb.append("(pm);\n");
|
||||
}
|
||||
sb.append(" }\n");
|
||||
sb.append("\n");
|
||||
sb.append("\n");
|
||||
if (it.hasNext())
|
||||
generateInitParamsMethod(sb, it, index + 1);
|
||||
}
|
||||
|
||||
private void generateInitFieldsMethod(StringBuffer sb, Iterator it, int index) throws JRException {
|
||||
sb.append(" /**\n");
|
||||
sb.append(" *\n");
|
||||
sb.append(" */\n");
|
||||
sb.append(" private void initFields");
|
||||
if (index > 0)
|
||||
sb.append(index);
|
||||
sb.append("(Map fm)\n");
|
||||
sb.append(" {\n");
|
||||
for (int i = 0; i < 100 && it.hasNext(); i++) {
|
||||
String fieldName = it.next();
|
||||
sb.append(" field_");
|
||||
sb.append(JRStringUtil.getLiteral(fieldName));
|
||||
sb.append(" = (JRFillField)fm.get(\"");
|
||||
sb.append(fieldName);
|
||||
sb.append("\");\n");
|
||||
}
|
||||
if (it.hasNext()) {
|
||||
sb.append(" initFields");
|
||||
sb.append(index + 1);
|
||||
sb.append("(fm);\n");
|
||||
}
|
||||
sb.append(" }\n");
|
||||
sb.append("\n");
|
||||
sb.append("\n");
|
||||
if (it.hasNext())
|
||||
generateInitFieldsMethod(sb, it, index + 1);
|
||||
}
|
||||
|
||||
private void generateInitVarsMethod(StringBuffer sb, Iterator it, int index) throws JRException {
|
||||
sb.append(" /**\n");
|
||||
sb.append(" *\n");
|
||||
sb.append(" */\n");
|
||||
sb.append(" private void initVars");
|
||||
if (index > 0)
|
||||
sb.append(index);
|
||||
sb.append("(Map vm)\n");
|
||||
sb.append(" {\n");
|
||||
for (int i = 0; i < 100 && it.hasNext(); i++) {
|
||||
String variableName = ((JRVariable)it.next()).getName();
|
||||
sb.append(" variable_");
|
||||
sb.append(JRStringUtil.getLiteral(variableName));
|
||||
sb.append(" = (JRFillVariable)vm.get(\"");
|
||||
sb.append(variableName);
|
||||
sb.append("\");\n");
|
||||
}
|
||||
if (it.hasNext()) {
|
||||
sb.append(" initVars");
|
||||
sb.append(index + 1);
|
||||
sb.append("(vm);\n");
|
||||
}
|
||||
sb.append(" }\n");
|
||||
sb.append("\n");
|
||||
sb.append("\n");
|
||||
if (it.hasNext())
|
||||
generateInitVarsMethod(sb, it, index + 1);
|
||||
}
|
||||
|
||||
protected final String generateMethod(byte evaluationType, List expressionsList) throws JRException {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if (expressionsList.size() > 0) {
|
||||
sb.append(generateMethod(expressionsList.listIterator(), 0, evaluationType));
|
||||
} else {
|
||||
sb.append(" /**\n");
|
||||
sb.append(" *\n");
|
||||
sb.append(" */\n");
|
||||
sb.append(" public Object evaluate");
|
||||
sb.append((String)methodSuffixMap.get(new Byte(evaluationType)));
|
||||
sb.append("(int id) throws Throwable\n");
|
||||
sb.append(" {\n");
|
||||
sb.append(" return null;\n");
|
||||
sb.append(" }\n");
|
||||
sb.append("\n");
|
||||
sb.append("\n");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String generateMethod(Iterator it, int index, byte evaluationType) throws JRException {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(" /**\n");
|
||||
sb.append(" *\n");
|
||||
sb.append(" */\n");
|
||||
if (index > 0) {
|
||||
sb.append(" private Object evaluate");
|
||||
sb.append((String)methodSuffixMap.get(new Byte(evaluationType)));
|
||||
sb.append(index);
|
||||
} else {
|
||||
sb.append(" public Object evaluate");
|
||||
sb.append((String)methodSuffixMap.get(new Byte(evaluationType)));
|
||||
}
|
||||
sb.append("(int id) throws Throwable\n");
|
||||
sb.append(" {\n");
|
||||
sb.append(" Object value = null;\n");
|
||||
sb.append("\n");
|
||||
sb.append(" switch (id)\n");
|
||||
sb.append(" {\n");
|
||||
for (int i = 0; it.hasNext() && i < 100; i++) {
|
||||
JRExpression expression = it.next();
|
||||
sb.append(" case ");
|
||||
sb.append(this.sourceTask.getExpressionId(expression));
|
||||
sb.append(" : \n");
|
||||
sb.append(" {\n");
|
||||
sb.append(" value = (");
|
||||
sb.append(expression.getValueClassName());
|
||||
sb.append(")(");
|
||||
sb.append(generateExpression(expression, evaluationType));
|
||||
sb.append(");");
|
||||
appendExpressionComment(sb, expression);
|
||||
sb.append("\n");
|
||||
sb.append(" break;\n");
|
||||
sb.append(" }\n");
|
||||
}
|
||||
sb.append(" default :\n");
|
||||
sb.append(" {\n");
|
||||
if (it.hasNext()) {
|
||||
sb.append(" value = evaluate");
|
||||
sb.append((String)methodSuffixMap.get(new Byte(evaluationType)));
|
||||
sb.append(index + 1);
|
||||
sb.append("(id);\n");
|
||||
}
|
||||
sb.append(" }\n");
|
||||
sb.append(" }\n");
|
||||
sb.append(" \n");
|
||||
sb.append(" return value;\n");
|
||||
sb.append(" }\n");
|
||||
sb.append("\n");
|
||||
sb.append("\n");
|
||||
if (it.hasNext())
|
||||
sb.append(generateMethod(it, index + 1, evaluationType));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String generateExpression(JRExpression expression, byte evaluationType) {
|
||||
JRParameter jrParameter = null;
|
||||
JRField jrField = null;
|
||||
JRVariable jrVariable = null;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
JRExpressionChunk[] chunks = expression.getChunks();
|
||||
JRExpressionChunk chunk = null;
|
||||
String chunkText = null;
|
||||
if (chunks != null && chunks.length > 0)
|
||||
for (int i = 0; i < chunks.length; i++) {
|
||||
chunk = chunks[i];
|
||||
chunkText = chunk.getText();
|
||||
if (chunkText == null)
|
||||
chunkText = "";
|
||||
switch (chunk.getType()) {
|
||||
case 1:
|
||||
appendExpressionText(expression, sb, chunkText);
|
||||
break;
|
||||
case 2:
|
||||
jrParameter = (JRParameter)this.parametersMap.get(chunkText);
|
||||
sb.append("((");
|
||||
sb.append(jrParameter.getValueClassName());
|
||||
sb.append(")parameter_");
|
||||
sb.append(JRStringUtil.getLiteral(chunkText));
|
||||
sb.append(".getValue())");
|
||||
break;
|
||||
case 3:
|
||||
jrField = (JRField)this.fieldsMap.get(chunkText);
|
||||
sb.append("((");
|
||||
sb.append(jrField.getValueClassName());
|
||||
sb.append(")field_");
|
||||
sb.append(JRStringUtil.getLiteral(chunkText));
|
||||
sb.append(".get");
|
||||
sb.append((String)fieldPrefixMap.get(new Byte(evaluationType)));
|
||||
sb.append("Value())");
|
||||
break;
|
||||
case 4:
|
||||
jrVariable = (JRVariable)this.variablesMap.get(chunkText);
|
||||
sb.append("((");
|
||||
sb.append(jrVariable.getValueClassName());
|
||||
sb.append(")variable_");
|
||||
sb.append(JRStringUtil.getLiteral(chunkText));
|
||||
sb.append(".get");
|
||||
sb.append((String)variablePrefixMap.get(new Byte(evaluationType)));
|
||||
sb.append("Value())");
|
||||
break;
|
||||
case 5:
|
||||
sb.append("str(\"");
|
||||
sb.append(chunkText);
|
||||
sb.append("\")");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sb.length() == 0)
|
||||
sb.append("null");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected void appendExpressionText(JRExpression expression, StringBuffer sb, String chunkText) {
|
||||
StringTokenizer tokenizer = new StringTokenizer(chunkText, "\n", true);
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
String token = tokenizer.nextToken();
|
||||
if (token.equals("\n"))
|
||||
appendExpressionComment(sb, expression);
|
||||
sb.append(token);
|
||||
}
|
||||
}
|
||||
|
||||
protected void appendExpressionComment(StringBuffer sb, JRExpression expression) {
|
||||
sb.append("//");
|
||||
sb.append("$JR_EXPR_ID=");
|
||||
sb.append(this.sourceTask.getExpressionId(expression));
|
||||
sb.append("$");
|
||||
}
|
||||
|
||||
protected JRExpression[] parseSourceLines(String sourceCode) {
|
||||
List expressions = new ArrayList();
|
||||
int start = 0;
|
||||
int end = sourceCode.indexOf('\n');
|
||||
while (end >= 0) {
|
||||
JRExpression expression = null;
|
||||
if (start < end) {
|
||||
String line = sourceCode.substring(start, end);
|
||||
expression = getLineExpression(line);
|
||||
}
|
||||
expressions.add(expression);
|
||||
start = end + 1;
|
||||
end = sourceCode.indexOf('\n', start);
|
||||
}
|
||||
return expressions.<JRExpression>toArray(new JRExpression[expressions.size()]);
|
||||
}
|
||||
|
||||
protected JRExpression getLineExpression(String line) {
|
||||
JRExpression expression = null;
|
||||
int exprIdStart = line.indexOf("$JR_EXPR_ID=");
|
||||
if (exprIdStart >= 0) {
|
||||
exprIdStart += sOURCE_EXPRESSION_ID_START_LENGTH;
|
||||
int exprIdEnd = line.indexOf("$", exprIdStart);
|
||||
if (exprIdEnd >= 0)
|
||||
try {
|
||||
int exprId = Integer.parseInt(line.substring(exprIdStart, exprIdEnd));
|
||||
expression = this.sourceTask.getExpression(exprId);
|
||||
} catch (NumberFormatException e) {}
|
||||
}
|
||||
return expression;
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import net.sf.jasperreports.engine.JRExpression;
|
||||
|
||||
public interface JRCompilationSourceCode {
|
||||
String getCode();
|
||||
|
||||
JRExpression getExpressionAtLine(int paramInt);
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class JRCompilationUnit {
|
||||
private final String name;
|
||||
|
||||
private final JRCompilationSourceCode source;
|
||||
|
||||
private final File sourceFile;
|
||||
|
||||
private final List expressions;
|
||||
|
||||
private Serializable compileData;
|
||||
|
||||
public JRCompilationUnit(String name, JRCompilationSourceCode sourceCode, File sourceFile, List expressions) {
|
||||
this.name = name;
|
||||
this.source = sourceCode;
|
||||
this.sourceFile = sourceFile;
|
||||
this.expressions = expressions;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getSourceCode() {
|
||||
return this.source.getCode();
|
||||
}
|
||||
|
||||
public JRCompilationSourceCode getCompilationSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
public File getSourceFile() {
|
||||
return this.sourceFile;
|
||||
}
|
||||
|
||||
public List getExpressions() {
|
||||
return this.expressions;
|
||||
}
|
||||
|
||||
public void setCompileData(Serializable compileData) {
|
||||
this.compileData = compileData;
|
||||
}
|
||||
|
||||
public Serializable getCompileData() {
|
||||
return this.compileData;
|
||||
}
|
||||
}
|
19
hrmsEjb/net/sf/jasperreports/engine/design/JRCompiler.java
Normal file
19
hrmsEjb/net/sf/jasperreports/engine/design/JRCompiler.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import net.sf.jasperreports.crosstabs.JRCrosstab;
|
||||
import net.sf.jasperreports.engine.JRDataset;
|
||||
import net.sf.jasperreports.engine.JRException;
|
||||
import net.sf.jasperreports.engine.JasperReport;
|
||||
import net.sf.jasperreports.engine.fill.JREvaluator;
|
||||
|
||||
public interface JRCompiler {
|
||||
public static final String COMPILER_PREFIX = "net.sf.jasperreports.compiler.";
|
||||
|
||||
JasperReport compileReport(JasperDesign paramJasperDesign) throws JRException;
|
||||
|
||||
JREvaluator loadEvaluator(JasperReport paramJasperReport) throws JRException;
|
||||
|
||||
JREvaluator loadEvaluator(JasperReport paramJasperReport, JRDataset paramJRDataset) throws JRException;
|
||||
|
||||
JREvaluator loadEvaluator(JasperReport paramJasperReport, JRCrosstab paramJRCrosstab) throws JRException;
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import net.sf.jasperreports.engine.JRExpression;
|
||||
|
||||
public class JRDefaultCompilationSourceCode implements JRCompilationSourceCode {
|
||||
private final String sourceCode;
|
||||
|
||||
private final JRExpression[] lineExpressions;
|
||||
|
||||
public JRDefaultCompilationSourceCode(String sourceCode, JRExpression[] lineExpressions) {
|
||||
this.sourceCode = sourceCode;
|
||||
this.lineExpressions = lineExpressions;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return this.sourceCode;
|
||||
}
|
||||
|
||||
public JRExpression getExpressionAtLine(int line) {
|
||||
if (this.lineExpressions == null || line <= 0 || line > this.lineExpressions.length)
|
||||
return null;
|
||||
return this.lineExpressions[line - 1];
|
||||
}
|
||||
}
|
68
hrmsEjb/net/sf/jasperreports/engine/design/JRDesignBand.java
Normal file
68
hrmsEjb/net/sf/jasperreports/engine/design/JRDesignBand.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import net.sf.jasperreports.engine.JRBand;
|
||||
import net.sf.jasperreports.engine.JRExpression;
|
||||
import net.sf.jasperreports.engine.JROrigin;
|
||||
|
||||
public class JRDesignBand extends JRDesignElementGroup implements JRBand {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
public static final String PROPERTY_HEIGHT = "height";
|
||||
|
||||
public static final String PROPERTY_PRINT_WHEN_EXPRESSION = "printWhenExpression";
|
||||
|
||||
protected int height = 0;
|
||||
|
||||
protected boolean isSplitAllowed = true;
|
||||
|
||||
protected JRExpression printWhenExpression = null;
|
||||
|
||||
private JROrigin origin;
|
||||
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
int old = this.height;
|
||||
this.height = height;
|
||||
getEventSupport().firePropertyChange("height", old, this.height);
|
||||
}
|
||||
|
||||
public boolean isSplitAllowed() {
|
||||
return this.isSplitAllowed;
|
||||
}
|
||||
|
||||
public void setSplitAllowed(boolean isSplitAllowed) {
|
||||
boolean old = this.isSplitAllowed;
|
||||
this.isSplitAllowed = isSplitAllowed;
|
||||
getEventSupport().firePropertyChange("splitAllowed", old, this.isSplitAllowed);
|
||||
}
|
||||
|
||||
public JRExpression getPrintWhenExpression() {
|
||||
return this.printWhenExpression;
|
||||
}
|
||||
|
||||
public void setPrintWhenExpression(JRExpression expression) {
|
||||
Object old = this.printWhenExpression;
|
||||
this.printWhenExpression = expression;
|
||||
getEventSupport().firePropertyChange("printWhenExpression", old, this.printWhenExpression);
|
||||
}
|
||||
|
||||
public JROrigin getOrigin() {
|
||||
return this.origin;
|
||||
}
|
||||
|
||||
void setOrigin(JROrigin origin) {
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
JRDesignBand clone = (JRDesignBand)super.clone();
|
||||
if (this.printWhenExpression != null)
|
||||
clone.printWhenExpression = (JRExpression)this.printWhenExpression.clone();
|
||||
if (this.origin != null)
|
||||
clone.origin = (JROrigin)this.origin.clone();
|
||||
return clone;
|
||||
}
|
||||
}
|
932
hrmsEjb/net/sf/jasperreports/engine/design/JRDesignChart.java
Normal file
932
hrmsEjb/net/sf/jasperreports/engine/design/JRDesignChart.java
Normal file
@@ -0,0 +1,932 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import net.sf.jasperreports.charts.design.JRDesignAreaPlot;
|
||||
import net.sf.jasperreports.charts.design.JRDesignBar3DPlot;
|
||||
import net.sf.jasperreports.charts.design.JRDesignBarPlot;
|
||||
import net.sf.jasperreports.charts.design.JRDesignBubblePlot;
|
||||
import net.sf.jasperreports.charts.design.JRDesignCandlestickPlot;
|
||||
import net.sf.jasperreports.charts.design.JRDesignCategoryDataset;
|
||||
import net.sf.jasperreports.charts.design.JRDesignHighLowDataset;
|
||||
import net.sf.jasperreports.charts.design.JRDesignHighLowPlot;
|
||||
import net.sf.jasperreports.charts.design.JRDesignLinePlot;
|
||||
import net.sf.jasperreports.charts.design.JRDesignMeterPlot;
|
||||
import net.sf.jasperreports.charts.design.JRDesignMultiAxisPlot;
|
||||
import net.sf.jasperreports.charts.design.JRDesignPie3DPlot;
|
||||
import net.sf.jasperreports.charts.design.JRDesignPieDataset;
|
||||
import net.sf.jasperreports.charts.design.JRDesignPiePlot;
|
||||
import net.sf.jasperreports.charts.design.JRDesignScatterPlot;
|
||||
import net.sf.jasperreports.charts.design.JRDesignThermometerPlot;
|
||||
import net.sf.jasperreports.charts.design.JRDesignTimeSeriesDataset;
|
||||
import net.sf.jasperreports.charts.design.JRDesignTimeSeriesPlot;
|
||||
import net.sf.jasperreports.charts.design.JRDesignValueDataset;
|
||||
import net.sf.jasperreports.charts.design.JRDesignXyDataset;
|
||||
import net.sf.jasperreports.charts.design.JRDesignXyzDataset;
|
||||
import net.sf.jasperreports.engine.JRBox;
|
||||
import net.sf.jasperreports.engine.JRBoxContainer;
|
||||
import net.sf.jasperreports.engine.JRChart;
|
||||
import net.sf.jasperreports.engine.JRChartDataset;
|
||||
import net.sf.jasperreports.engine.JRChartPlot;
|
||||
import net.sf.jasperreports.engine.JRCommonElement;
|
||||
import net.sf.jasperreports.engine.JRDefaultStyleProvider;
|
||||
import net.sf.jasperreports.engine.JRExpression;
|
||||
import net.sf.jasperreports.engine.JRExpressionCollector;
|
||||
import net.sf.jasperreports.engine.JRFont;
|
||||
import net.sf.jasperreports.engine.JRGroup;
|
||||
import net.sf.jasperreports.engine.JRHyperlink;
|
||||
import net.sf.jasperreports.engine.JRHyperlinkHelper;
|
||||
import net.sf.jasperreports.engine.JRHyperlinkParameter;
|
||||
import net.sf.jasperreports.engine.JRLineBox;
|
||||
import net.sf.jasperreports.engine.JRPen;
|
||||
import net.sf.jasperreports.engine.JRRuntimeException;
|
||||
import net.sf.jasperreports.engine.JRVisitor;
|
||||
import net.sf.jasperreports.engine.base.JRBaseLineBox;
|
||||
import net.sf.jasperreports.engine.util.JRBoxUtil;
|
||||
import net.sf.jasperreports.engine.util.JRPenUtil;
|
||||
import net.sf.jasperreports.engine.util.JRStyleResolver;
|
||||
import net.sf.jasperreports.engine.util.LineBoxWrapper;
|
||||
|
||||
public class JRDesignChart extends JRDesignElement implements JRChart {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
public static final String PROPERTY_ANCHOR_NAME_EXPRESSION = "anchorNameExpression";
|
||||
|
||||
public static final String PROPERTY_BOOKMARK_LEVEL = "bookmarkLevel";
|
||||
|
||||
public static final String PROPERTY_EVALUATION_GROUP = "evaluationGroup";
|
||||
|
||||
public static final String PROPERTY_EVALUATION_TIME = "evaluationTime";
|
||||
|
||||
public static final String PROPERTY_CHART_TYPE = "chartType";
|
||||
|
||||
public static final String PROPERTY_CUSTOMIZER_CLASS = "customizerClass";
|
||||
|
||||
public static final String PROPERTY_DATASET = "dataset";
|
||||
|
||||
public static final String PROPERTY_LEGEND_FONT = "legendFont";
|
||||
|
||||
public static final String PROPERTY_SUBTITLE_EXPRESSION = "subtitleExpression";
|
||||
|
||||
public static final String PROPERTY_SUBTITLE_FONT = "subtitleFont";
|
||||
|
||||
public static final String PROPERTY_TITLE_EXPRESSION = "titleExpression";
|
||||
|
||||
public static final String PROPERTY_TITLE_FONT = "titleFont";
|
||||
|
||||
protected byte chartType = 0;
|
||||
|
||||
protected boolean isShowLegend = false;
|
||||
|
||||
protected byte evaluationTime = 1;
|
||||
|
||||
protected byte hyperlinkType = 0;
|
||||
|
||||
protected String linkType;
|
||||
|
||||
protected byte hyperlinkTarget = 1;
|
||||
|
||||
protected byte titlePosition = 1;
|
||||
|
||||
protected Color titleColor = null;
|
||||
|
||||
protected Color subtitleColor = null;
|
||||
|
||||
protected Color legendColor = null;
|
||||
|
||||
protected Color legendBackgroundColor = null;
|
||||
|
||||
protected byte legendPosition = 2;
|
||||
|
||||
protected String renderType;
|
||||
|
||||
protected JRFont titleFont = null;
|
||||
|
||||
protected JRFont subtitleFont = null;
|
||||
|
||||
protected JRFont legendFont = null;
|
||||
|
||||
protected String customizerClass;
|
||||
|
||||
protected JRGroup evaluationGroup = null;
|
||||
|
||||
protected JRExpression titleExpression = null;
|
||||
|
||||
protected JRExpression subtitleExpression = null;
|
||||
|
||||
protected JRExpression anchorNameExpression = null;
|
||||
|
||||
protected JRExpression hyperlinkReferenceExpression = null;
|
||||
|
||||
protected JRExpression hyperlinkAnchorExpression = null;
|
||||
|
||||
protected JRExpression hyperlinkPageExpression = null;
|
||||
|
||||
private JRExpression hyperlinkTooltipExpression;
|
||||
|
||||
private List hyperlinkParameters;
|
||||
|
||||
protected JRChartDataset dataset = null;
|
||||
|
||||
protected JRChartPlot plot = null;
|
||||
|
||||
protected JRLineBox lineBox;
|
||||
|
||||
protected int bookmarkLevel = 0;
|
||||
|
||||
private Byte border;
|
||||
|
||||
private Byte topBorder;
|
||||
|
||||
private Byte leftBorder;
|
||||
|
||||
private Byte bottomBorder;
|
||||
|
||||
private Byte rightBorder;
|
||||
|
||||
private Color borderColor;
|
||||
|
||||
private Color topBorderColor;
|
||||
|
||||
private Color leftBorderColor;
|
||||
|
||||
private Color bottomBorderColor;
|
||||
|
||||
private Color rightBorderColor;
|
||||
|
||||
private Integer padding;
|
||||
|
||||
private Integer topPadding;
|
||||
|
||||
private Integer leftPadding;
|
||||
|
||||
private Integer bottomPadding;
|
||||
|
||||
private Integer rightPadding;
|
||||
|
||||
public JRDesignChart(JRDefaultStyleProvider defaultStyleProvider, byte chartType) {
|
||||
super(defaultStyleProvider);
|
||||
this.border = null;
|
||||
this.topBorder = null;
|
||||
this.leftBorder = null;
|
||||
this.bottomBorder = null;
|
||||
this.rightBorder = null;
|
||||
this.borderColor = null;
|
||||
this.topBorderColor = null;
|
||||
this.leftBorderColor = null;
|
||||
this.bottomBorderColor = null;
|
||||
this.rightBorderColor = null;
|
||||
this.padding = null;
|
||||
this.topPadding = null;
|
||||
this.leftPadding = null;
|
||||
this.bottomPadding = null;
|
||||
this.rightPadding = null;
|
||||
setChartType(chartType);
|
||||
this.hyperlinkParameters = new ArrayList();
|
||||
this.lineBox = (JRLineBox)new JRBaseLineBox((JRBoxContainer)this);
|
||||
}
|
||||
|
||||
public boolean isShowLegend() {
|
||||
return this.isShowLegend;
|
||||
}
|
||||
|
||||
public void setShowLegend(boolean isShowLegend) {
|
||||
boolean old = this.isShowLegend;
|
||||
this.isShowLegend = isShowLegend;
|
||||
getEventSupport().firePropertyChange("showLegend", old, this.isShowLegend);
|
||||
}
|
||||
|
||||
public String getRenderType() {
|
||||
return this.renderType;
|
||||
}
|
||||
|
||||
public void setRenderType(String renderType) {
|
||||
String old = this.renderType;
|
||||
this.renderType = renderType;
|
||||
getEventSupport().firePropertyChange("renderType", old, this.renderType);
|
||||
}
|
||||
|
||||
public byte getEvaluationTime() {
|
||||
return this.evaluationTime;
|
||||
}
|
||||
|
||||
public void setEvaluationTime(byte evaluationTime) {
|
||||
byte old = this.evaluationTime;
|
||||
this.evaluationTime = evaluationTime;
|
||||
getEventSupport().firePropertyChange("evaluationTime", old, this.evaluationTime);
|
||||
}
|
||||
|
||||
public JRGroup getEvaluationGroup() {
|
||||
return this.evaluationGroup;
|
||||
}
|
||||
|
||||
public void setEvaluationGroup(JRGroup group) {
|
||||
Object old = this.evaluationGroup;
|
||||
this.evaluationGroup = group;
|
||||
getEventSupport().firePropertyChange("evaluationGroup", old, this.evaluationGroup);
|
||||
}
|
||||
|
||||
public JRBox getBox() {
|
||||
return (JRBox)new LineBoxWrapper(getLineBox());
|
||||
}
|
||||
|
||||
public JRLineBox getLineBox() {
|
||||
return this.lineBox;
|
||||
}
|
||||
|
||||
public void setBox(JRBox box) {
|
||||
JRBoxUtil.setBoxToLineBox(box, this.lineBox);
|
||||
}
|
||||
|
||||
public JRFont getTitleFont() {
|
||||
return this.titleFont;
|
||||
}
|
||||
|
||||
public void setTitleFont(JRFont font) {
|
||||
Object old = this.titleFont;
|
||||
this.titleFont = font;
|
||||
getEventSupport().firePropertyChange("titleFont", old, this.titleFont);
|
||||
}
|
||||
|
||||
public byte getTitlePosition() {
|
||||
return this.titlePosition;
|
||||
}
|
||||
|
||||
public void setTitlePosition(byte titlePosition) {
|
||||
byte old = this.titlePosition;
|
||||
this.titlePosition = titlePosition;
|
||||
getEventSupport().firePropertyChange("titlePosition", old, this.titlePosition);
|
||||
}
|
||||
|
||||
public Color getTitleColor() {
|
||||
return JRStyleResolver.getTitleColor(this);
|
||||
}
|
||||
|
||||
public Color getOwnTitleColor() {
|
||||
return this.titleColor;
|
||||
}
|
||||
|
||||
public void setTitleColor(Color titleColor) {
|
||||
Object old = this.titleColor;
|
||||
this.titleColor = titleColor;
|
||||
getEventSupport().firePropertyChange("titleColor", old, this.titleColor);
|
||||
}
|
||||
|
||||
public JRFont getSubtitleFont() {
|
||||
return this.subtitleFont;
|
||||
}
|
||||
|
||||
public void setSubtitleFont(JRFont font) {
|
||||
Object old = this.subtitleFont;
|
||||
this.subtitleFont = font;
|
||||
getEventSupport().firePropertyChange("subtitleFont", old, this.subtitleFont);
|
||||
}
|
||||
|
||||
public Color getSubtitleColor() {
|
||||
return JRStyleResolver.getSubtitleColor(this);
|
||||
}
|
||||
|
||||
public Color getOwnSubtitleColor() {
|
||||
return this.subtitleColor;
|
||||
}
|
||||
|
||||
public void setSubtitleColor(Color subtitleColor) {
|
||||
Object old = this.subtitleColor;
|
||||
this.subtitleColor = subtitleColor;
|
||||
getEventSupport().firePropertyChange("subtitleColor", old, this.subtitleColor);
|
||||
}
|
||||
|
||||
public Color getOwnLegendColor() {
|
||||
return this.legendColor;
|
||||
}
|
||||
|
||||
public Color getLegendColor() {
|
||||
return JRStyleResolver.getLegendColor(this);
|
||||
}
|
||||
|
||||
public void setLegendColor(Color legendColor) {
|
||||
Object old = this.legendColor;
|
||||
this.legendColor = legendColor;
|
||||
getEventSupport().firePropertyChange("legendColor", old, this.legendColor);
|
||||
}
|
||||
|
||||
public Color getOwnLegendBackgroundColor() {
|
||||
return this.legendBackgroundColor;
|
||||
}
|
||||
|
||||
public Color getLegendBackgroundColor() {
|
||||
return JRStyleResolver.getLegendBackgroundColor(this);
|
||||
}
|
||||
|
||||
public void setLegendBackgroundColor(Color legendBackgroundColor) {
|
||||
Object old = this.legendBackgroundColor;
|
||||
this.legendBackgroundColor = legendBackgroundColor;
|
||||
getEventSupport().firePropertyChange("legendBackgroundColor", old, this.legendBackgroundColor);
|
||||
}
|
||||
|
||||
public JRFont getLegendFont() {
|
||||
return this.legendFont;
|
||||
}
|
||||
|
||||
public void setLegendFont(JRFont legendFont) {
|
||||
Object old = this.legendFont;
|
||||
this.legendFont = legendFont;
|
||||
getEventSupport().firePropertyChange("legendFont", old, this.legendFont);
|
||||
}
|
||||
|
||||
public byte getLegendPosition() {
|
||||
return this.legendPosition;
|
||||
}
|
||||
|
||||
public void setLegendPosition(byte legendPosition) {
|
||||
byte old = this.legendPosition;
|
||||
this.legendPosition = legendPosition;
|
||||
getEventSupport().firePropertyChange("legendPosition", old, this.legendPosition);
|
||||
}
|
||||
|
||||
public byte getHyperlinkType() {
|
||||
return JRHyperlinkHelper.getHyperlinkType((JRHyperlink)this);
|
||||
}
|
||||
|
||||
public void setHyperlinkType(byte hyperlinkType) {
|
||||
setLinkType(JRHyperlinkHelper.getLinkType(hyperlinkType));
|
||||
}
|
||||
|
||||
public byte getHyperlinkTarget() {
|
||||
return this.hyperlinkTarget;
|
||||
}
|
||||
|
||||
public void setHyperlinkTarget(byte hyperlinkTarget) {
|
||||
byte old = this.hyperlinkTarget;
|
||||
this.hyperlinkTarget = hyperlinkTarget;
|
||||
getEventSupport().firePropertyChange("hyperlinkTarget", old, this.hyperlinkTarget);
|
||||
}
|
||||
|
||||
public JRExpression getTitleExpression() {
|
||||
return this.titleExpression;
|
||||
}
|
||||
|
||||
public void setTitleExpression(JRExpression expression) {
|
||||
Object old = this.titleExpression;
|
||||
this.titleExpression = expression;
|
||||
getEventSupport().firePropertyChange("titleExpression", old, this.titleExpression);
|
||||
}
|
||||
|
||||
public JRExpression getSubtitleExpression() {
|
||||
return this.subtitleExpression;
|
||||
}
|
||||
|
||||
public void setSubtitleExpression(JRExpression expression) {
|
||||
Object old = this.subtitleExpression;
|
||||
this.subtitleExpression = expression;
|
||||
getEventSupport().firePropertyChange("subtitleExpression", old, this.subtitleExpression);
|
||||
}
|
||||
|
||||
public JRExpression getAnchorNameExpression() {
|
||||
return this.anchorNameExpression;
|
||||
}
|
||||
|
||||
public void setAnchorNameExpression(JRExpression anchorNameExpression) {
|
||||
Object old = this.anchorNameExpression;
|
||||
this.anchorNameExpression = anchorNameExpression;
|
||||
getEventSupport().firePropertyChange("anchorNameExpression", old, this.anchorNameExpression);
|
||||
}
|
||||
|
||||
public JRExpression getHyperlinkReferenceExpression() {
|
||||
return this.hyperlinkReferenceExpression;
|
||||
}
|
||||
|
||||
public void setHyperlinkReferenceExpression(JRExpression hyperlinkReferenceExpression) {
|
||||
Object old = this.hyperlinkReferenceExpression;
|
||||
this.hyperlinkReferenceExpression = hyperlinkReferenceExpression;
|
||||
getEventSupport().firePropertyChange("hyperlinkReferenceExpression", old, this.hyperlinkReferenceExpression);
|
||||
}
|
||||
|
||||
public JRExpression getHyperlinkAnchorExpression() {
|
||||
return this.hyperlinkAnchorExpression;
|
||||
}
|
||||
|
||||
public void setHyperlinkAnchorExpression(JRExpression hyperlinkAnchorExpression) {
|
||||
Object old = this.hyperlinkAnchorExpression;
|
||||
this.hyperlinkAnchorExpression = hyperlinkAnchorExpression;
|
||||
getEventSupport().firePropertyChange("hyperlinkAnchorExpression", old, this.hyperlinkAnchorExpression);
|
||||
}
|
||||
|
||||
public JRExpression getHyperlinkPageExpression() {
|
||||
return this.hyperlinkPageExpression;
|
||||
}
|
||||
|
||||
public void setHyperlinkPageExpression(JRExpression hyperlinkPageExpression) {
|
||||
Object old = this.hyperlinkPageExpression;
|
||||
this.hyperlinkPageExpression = hyperlinkPageExpression;
|
||||
getEventSupport().firePropertyChange("hyperlinkPageExpression", old, this.hyperlinkPageExpression);
|
||||
}
|
||||
|
||||
public JRChartDataset getDataset() {
|
||||
return this.dataset;
|
||||
}
|
||||
|
||||
public JRChartPlot getPlot() {
|
||||
return this.plot;
|
||||
}
|
||||
|
||||
public byte getChartType() {
|
||||
return this.chartType;
|
||||
}
|
||||
|
||||
public void setChartType(byte chartType) {
|
||||
byte old = this.chartType;
|
||||
this.chartType = chartType;
|
||||
switch (chartType) {
|
||||
case 1:
|
||||
this.dataset = (JRChartDataset)new JRDesignCategoryDataset(this.dataset);
|
||||
this.plot = (JRChartPlot)new JRDesignAreaPlot(this.plot, this);
|
||||
break;
|
||||
case 3:
|
||||
this.dataset = (JRChartDataset)new JRDesignCategoryDataset(this.dataset);
|
||||
this.plot = (JRChartPlot)new JRDesignBarPlot(this.plot, this);
|
||||
break;
|
||||
case 2:
|
||||
this.dataset = (JRChartDataset)new JRDesignCategoryDataset(this.dataset);
|
||||
this.plot = (JRChartPlot)new JRDesignBar3DPlot(this.plot, this);
|
||||
break;
|
||||
case 4:
|
||||
this.dataset = (JRChartDataset)new JRDesignXyzDataset(this.dataset);
|
||||
this.plot = (JRChartPlot)new JRDesignBubblePlot(this.plot, this);
|
||||
break;
|
||||
case 5:
|
||||
this.dataset = (JRChartDataset)new JRDesignHighLowDataset(this.dataset);
|
||||
this.plot = (JRChartPlot)new JRDesignCandlestickPlot(this.plot, this);
|
||||
break;
|
||||
case 6:
|
||||
this.dataset = (JRChartDataset)new JRDesignHighLowDataset(this.dataset);
|
||||
this.plot = (JRChartPlot)new JRDesignHighLowPlot(this.plot, this);
|
||||
break;
|
||||
case 7:
|
||||
this.dataset = (JRChartDataset)new JRDesignCategoryDataset(this.dataset);
|
||||
this.plot = (JRChartPlot)new JRDesignLinePlot(this.plot, this);
|
||||
break;
|
||||
case 17:
|
||||
this.dataset = (JRChartDataset)new JRDesignValueDataset(this.dataset);
|
||||
this.plot = (JRChartPlot)new JRDesignMeterPlot(this.plot, this);
|
||||
break;
|
||||
case 19:
|
||||
this.plot = (JRChartPlot)new JRDesignMultiAxisPlot(this.plot, this);
|
||||
this.dataset = null;
|
||||
break;
|
||||
case 9:
|
||||
this.dataset = (JRChartDataset)new JRDesignPieDataset(this.dataset);
|
||||
this.plot = (JRChartPlot)new JRDesignPiePlot(this.plot, this);
|
||||
break;
|
||||
case 8:
|
||||
this.dataset = (JRChartDataset)new JRDesignPieDataset(this.dataset);
|
||||
this.plot = (JRChartPlot)new JRDesignPie3DPlot(this.plot, this);
|
||||
break;
|
||||
case 10:
|
||||
this.dataset = (JRChartDataset)new JRDesignXyDataset(this.dataset);
|
||||
this.plot = (JRChartPlot)new JRDesignScatterPlot(this.plot, this);
|
||||
break;
|
||||
case 12:
|
||||
this.dataset = (JRChartDataset)new JRDesignCategoryDataset(this.dataset);
|
||||
this.plot = (JRChartPlot)new JRDesignBarPlot(this.plot, this);
|
||||
break;
|
||||
case 11:
|
||||
this.dataset = (JRChartDataset)new JRDesignCategoryDataset(this.dataset);
|
||||
this.plot = (JRChartPlot)new JRDesignBar3DPlot(this.plot, this);
|
||||
break;
|
||||
case 18:
|
||||
this.dataset = (JRChartDataset)new JRDesignValueDataset(this.dataset);
|
||||
this.plot = (JRChartPlot)new JRDesignThermometerPlot(this.plot, this);
|
||||
break;
|
||||
case 16:
|
||||
this.dataset = (JRChartDataset)new JRDesignTimeSeriesDataset(this.dataset);
|
||||
this.plot = (JRChartPlot)new JRDesignTimeSeriesPlot(this.plot, this);
|
||||
break;
|
||||
case 13:
|
||||
this.dataset = (JRChartDataset)new JRDesignXyDataset(this.dataset);
|
||||
this.plot = (JRChartPlot)new JRDesignAreaPlot(this.plot, this);
|
||||
break;
|
||||
case 14:
|
||||
this.plot = (JRChartPlot)new JRDesignBarPlot(this.plot, this);
|
||||
break;
|
||||
case 15:
|
||||
this.dataset = (JRChartDataset)new JRDesignXyDataset(this.dataset);
|
||||
this.plot = (JRChartPlot)new JRDesignLinePlot(this.plot, this);
|
||||
break;
|
||||
case 20:
|
||||
this.dataset = (JRChartDataset)new JRDesignCategoryDataset(this.dataset);
|
||||
this.plot = (JRChartPlot)new JRDesignAreaPlot(this.plot, this);
|
||||
break;
|
||||
default:
|
||||
throw new JRRuntimeException("Chart type not supported.");
|
||||
}
|
||||
getEventSupport().firePropertyChange("chartType", old, this.chartType);
|
||||
}
|
||||
|
||||
public void setDataset(JRChartDataset ds) {
|
||||
Object old = this.dataset;
|
||||
switch (ds.getDatasetType()) {
|
||||
case 2:
|
||||
this.dataset = ds;
|
||||
break;
|
||||
case 7:
|
||||
this.dataset = ds;
|
||||
break;
|
||||
case 1:
|
||||
this.dataset = ds;
|
||||
break;
|
||||
case 5:
|
||||
this.dataset = ds;
|
||||
break;
|
||||
case 6:
|
||||
this.dataset = ds;
|
||||
break;
|
||||
case 8:
|
||||
this.dataset = ds;
|
||||
break;
|
||||
case 3:
|
||||
this.dataset = ds;
|
||||
break;
|
||||
case 4:
|
||||
this.dataset = ds;
|
||||
break;
|
||||
}
|
||||
getEventSupport().firePropertyChange("dataset", old, this.dataset);
|
||||
}
|
||||
|
||||
public void collectExpressions(JRExpressionCollector collector) {
|
||||
collector.collect(this);
|
||||
}
|
||||
|
||||
public void visit(JRVisitor visitor) {
|
||||
visitor.visitChart(this);
|
||||
}
|
||||
|
||||
public int getBookmarkLevel() {
|
||||
return this.bookmarkLevel;
|
||||
}
|
||||
|
||||
public void setBookmarkLevel(int bookmarkLevel) {
|
||||
int old = this.bookmarkLevel;
|
||||
this.bookmarkLevel = bookmarkLevel;
|
||||
getEventSupport().firePropertyChange("bookmarkLevel", old, this.bookmarkLevel);
|
||||
}
|
||||
|
||||
public String getCustomizerClass() {
|
||||
return this.customizerClass;
|
||||
}
|
||||
|
||||
public void setCustomizerClass(String customizerClass) {
|
||||
Object old = this.customizerClass;
|
||||
this.customizerClass = customizerClass;
|
||||
getEventSupport().firePropertyChange("customizerClass", old, this.customizerClass);
|
||||
}
|
||||
|
||||
public byte getMode() {
|
||||
return JRStyleResolver.getMode((JRCommonElement)this, (byte)2);
|
||||
}
|
||||
|
||||
public byte getBorder() {
|
||||
return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getPen());
|
||||
}
|
||||
|
||||
public Byte getOwnBorder() {
|
||||
return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getPen());
|
||||
}
|
||||
|
||||
public void setBorder(byte border) {
|
||||
JRPenUtil.setLinePenFromPen(border, (JRPen)this.lineBox.getPen());
|
||||
}
|
||||
|
||||
public void setBorder(Byte border) {
|
||||
JRPenUtil.setLinePenFromPen(border, (JRPen)this.lineBox.getPen());
|
||||
}
|
||||
|
||||
public Color getBorderColor() {
|
||||
return this.lineBox.getPen().getLineColor();
|
||||
}
|
||||
|
||||
public Color getOwnBorderColor() {
|
||||
return this.lineBox.getPen().getOwnLineColor();
|
||||
}
|
||||
|
||||
public void setBorderColor(Color borderColor) {
|
||||
this.lineBox.getPen().setLineColor(borderColor);
|
||||
}
|
||||
|
||||
public int getPadding() {
|
||||
return this.lineBox.getPadding().intValue();
|
||||
}
|
||||
|
||||
public Integer getOwnPadding() {
|
||||
return this.lineBox.getOwnPadding();
|
||||
}
|
||||
|
||||
public void setPadding(int padding) {
|
||||
this.lineBox.setPadding(padding);
|
||||
}
|
||||
|
||||
public void setPadding(Integer padding) {
|
||||
this.lineBox.setPadding(padding);
|
||||
}
|
||||
|
||||
public byte getTopBorder() {
|
||||
return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getTopPen());
|
||||
}
|
||||
|
||||
public Byte getOwnTopBorder() {
|
||||
return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getTopPen());
|
||||
}
|
||||
|
||||
public void setTopBorder(byte topBorder) {
|
||||
JRPenUtil.setLinePenFromPen(topBorder, (JRPen)this.lineBox.getTopPen());
|
||||
}
|
||||
|
||||
public void setTopBorder(Byte topBorder) {
|
||||
JRPenUtil.setLinePenFromPen(topBorder, (JRPen)this.lineBox.getTopPen());
|
||||
}
|
||||
|
||||
public Color getTopBorderColor() {
|
||||
return this.lineBox.getTopPen().getLineColor();
|
||||
}
|
||||
|
||||
public Color getOwnTopBorderColor() {
|
||||
return this.lineBox.getTopPen().getOwnLineColor();
|
||||
}
|
||||
|
||||
public void setTopBorderColor(Color topBorderColor) {
|
||||
this.lineBox.getTopPen().setLineColor(topBorderColor);
|
||||
}
|
||||
|
||||
public int getTopPadding() {
|
||||
return this.lineBox.getTopPadding().intValue();
|
||||
}
|
||||
|
||||
public Integer getOwnTopPadding() {
|
||||
return this.lineBox.getOwnTopPadding();
|
||||
}
|
||||
|
||||
public void setTopPadding(int topPadding) {
|
||||
this.lineBox.setTopPadding(topPadding);
|
||||
}
|
||||
|
||||
public void setTopPadding(Integer topPadding) {
|
||||
this.lineBox.setTopPadding(topPadding);
|
||||
}
|
||||
|
||||
public byte getLeftBorder() {
|
||||
return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getLeftPen());
|
||||
}
|
||||
|
||||
public Byte getOwnLeftBorder() {
|
||||
return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getLeftPen());
|
||||
}
|
||||
|
||||
public void setLeftBorder(byte leftBorder) {
|
||||
JRPenUtil.setLinePenFromPen(leftBorder, (JRPen)this.lineBox.getLeftPen());
|
||||
}
|
||||
|
||||
public void setLeftBorder(Byte leftBorder) {
|
||||
JRPenUtil.setLinePenFromPen(leftBorder, (JRPen)this.lineBox.getLeftPen());
|
||||
}
|
||||
|
||||
public Color getLeftBorderColor() {
|
||||
return this.lineBox.getLeftPen().getLineColor();
|
||||
}
|
||||
|
||||
public Color getOwnLeftBorderColor() {
|
||||
return this.lineBox.getLeftPen().getOwnLineColor();
|
||||
}
|
||||
|
||||
public void setLeftBorderColor(Color leftBorderColor) {
|
||||
this.lineBox.getLeftPen().setLineColor(leftBorderColor);
|
||||
}
|
||||
|
||||
public int getLeftPadding() {
|
||||
return this.lineBox.getLeftPadding().intValue();
|
||||
}
|
||||
|
||||
public Integer getOwnLeftPadding() {
|
||||
return this.lineBox.getOwnLeftPadding();
|
||||
}
|
||||
|
||||
public void setLeftPadding(int leftPadding) {
|
||||
this.lineBox.setLeftPadding(leftPadding);
|
||||
}
|
||||
|
||||
public void setLeftPadding(Integer leftPadding) {
|
||||
this.lineBox.setLeftPadding(leftPadding);
|
||||
}
|
||||
|
||||
public byte getBottomBorder() {
|
||||
return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getBottomPen());
|
||||
}
|
||||
|
||||
public Byte getOwnBottomBorder() {
|
||||
return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getBottomPen());
|
||||
}
|
||||
|
||||
public void setBottomBorder(byte bottomBorder) {
|
||||
JRPenUtil.setLinePenFromPen(bottomBorder, (JRPen)this.lineBox.getBottomPen());
|
||||
}
|
||||
|
||||
public void setBottomBorder(Byte bottomBorder) {
|
||||
JRPenUtil.setLinePenFromPen(bottomBorder, (JRPen)this.lineBox.getBottomPen());
|
||||
}
|
||||
|
||||
public Color getBottomBorderColor() {
|
||||
return this.lineBox.getBottomPen().getLineColor();
|
||||
}
|
||||
|
||||
public Color getOwnBottomBorderColor() {
|
||||
return this.lineBox.getBottomPen().getOwnLineColor();
|
||||
}
|
||||
|
||||
public void setBottomBorderColor(Color bottomBorderColor) {
|
||||
this.lineBox.getBottomPen().setLineColor(bottomBorderColor);
|
||||
}
|
||||
|
||||
public int getBottomPadding() {
|
||||
return this.lineBox.getBottomPadding().intValue();
|
||||
}
|
||||
|
||||
public Integer getOwnBottomPadding() {
|
||||
return this.lineBox.getOwnBottomPadding();
|
||||
}
|
||||
|
||||
public void setBottomPadding(int bottomPadding) {
|
||||
this.lineBox.setBottomPadding(bottomPadding);
|
||||
}
|
||||
|
||||
public void setBottomPadding(Integer bottomPadding) {
|
||||
this.lineBox.setBottomPadding(bottomPadding);
|
||||
}
|
||||
|
||||
public byte getRightBorder() {
|
||||
return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getRightPen());
|
||||
}
|
||||
|
||||
public Byte getOwnRightBorder() {
|
||||
return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getRightPen());
|
||||
}
|
||||
|
||||
public void setRightBorder(byte rightBorder) {
|
||||
JRPenUtil.setLinePenFromPen(rightBorder, (JRPen)this.lineBox.getRightPen());
|
||||
}
|
||||
|
||||
public void setRightBorder(Byte rightBorder) {
|
||||
JRPenUtil.setLinePenFromPen(rightBorder, (JRPen)this.lineBox.getRightPen());
|
||||
}
|
||||
|
||||
public Color getRightBorderColor() {
|
||||
return this.lineBox.getRightPen().getLineColor();
|
||||
}
|
||||
|
||||
public Color getOwnRightBorderColor() {
|
||||
return this.lineBox.getRightPen().getOwnLineColor();
|
||||
}
|
||||
|
||||
public void setRightBorderColor(Color rightBorderColor) {
|
||||
this.lineBox.getRightPen().setLineColor(rightBorderColor);
|
||||
}
|
||||
|
||||
public int getRightPadding() {
|
||||
return this.lineBox.getRightPadding().intValue();
|
||||
}
|
||||
|
||||
public Integer getOwnRightPadding() {
|
||||
return this.lineBox.getOwnRightPadding();
|
||||
}
|
||||
|
||||
public void setRightPadding(int rightPadding) {
|
||||
this.lineBox.setRightPadding(rightPadding);
|
||||
}
|
||||
|
||||
public void setRightPadding(Integer rightPadding) {
|
||||
this.lineBox.setRightPadding(rightPadding);
|
||||
}
|
||||
|
||||
public String getLinkType() {
|
||||
return this.linkType;
|
||||
}
|
||||
|
||||
public void setLinkType(String type) {
|
||||
Object old = this.linkType;
|
||||
this.linkType = type;
|
||||
getEventSupport().firePropertyChange("linkType", old, this.linkType);
|
||||
}
|
||||
|
||||
public JRHyperlinkParameter[] getHyperlinkParameters() {
|
||||
JRHyperlinkParameter[] parameters;
|
||||
if (this.hyperlinkParameters.isEmpty()) {
|
||||
parameters = null;
|
||||
} else {
|
||||
parameters = new JRHyperlinkParameter[this.hyperlinkParameters.size()];
|
||||
this.hyperlinkParameters.toArray((Object[])parameters);
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public List getHyperlinkParametersList() {
|
||||
return this.hyperlinkParameters;
|
||||
}
|
||||
|
||||
public void addHyperlinkParameter(JRHyperlinkParameter parameter) {
|
||||
this.hyperlinkParameters.add(parameter);
|
||||
getEventSupport().fireCollectionElementAddedEvent("hyperlinkParameters", parameter, this.hyperlinkParameters.size() - 1);
|
||||
}
|
||||
|
||||
public void removeHyperlinkParameter(JRHyperlinkParameter parameter) {
|
||||
int idx = this.hyperlinkParameters.indexOf(parameter);
|
||||
if (idx >= 0) {
|
||||
this.hyperlinkParameters.remove(idx);
|
||||
getEventSupport().fireCollectionElementRemovedEvent("hyperlinkParameters", parameter, idx);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeHyperlinkParameter(String parameterName) {
|
||||
for (ListIterator it = this.hyperlinkParameters.listIterator(); it.hasNext(); ) {
|
||||
JRHyperlinkParameter parameter = it.next();
|
||||
if (parameter.getName() != null && parameter.getName().equals(parameterName)) {
|
||||
it.remove();
|
||||
getEventSupport().fireCollectionElementRemovedEvent("hyperlinkParameters", parameter, it.nextIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void normalizeLinkType() {
|
||||
if (this.linkType == null)
|
||||
this.linkType = JRHyperlinkHelper.getLinkType(this.hyperlinkType);
|
||||
this.hyperlinkType = 0;
|
||||
}
|
||||
|
||||
public JRExpression getHyperlinkTooltipExpression() {
|
||||
return this.hyperlinkTooltipExpression;
|
||||
}
|
||||
|
||||
public void setHyperlinkTooltipExpression(JRExpression hyperlinkTooltipExpression) {
|
||||
Object old = this.hyperlinkTooltipExpression;
|
||||
this.hyperlinkTooltipExpression = hyperlinkTooltipExpression;
|
||||
getEventSupport().firePropertyChange("hyperlinkTooltipExpression", old, this.hyperlinkTooltipExpression);
|
||||
}
|
||||
|
||||
public Color getDefaultLineColor() {
|
||||
return getForecolor();
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
JRDesignChart clone = (JRDesignChart)super.clone();
|
||||
if (this.hyperlinkParameters != null) {
|
||||
clone.hyperlinkParameters = new ArrayList(this.hyperlinkParameters.size());
|
||||
for (int i = 0; i < this.hyperlinkParameters.size(); i++)
|
||||
clone.hyperlinkParameters.add(((JRHyperlinkParameter)this.hyperlinkParameters.get(i)).clone());
|
||||
}
|
||||
if (this.titleExpression != null)
|
||||
clone.titleExpression = (JRExpression)this.titleExpression.clone();
|
||||
if (this.subtitleExpression != null)
|
||||
clone.subtitleExpression = (JRExpression)this.subtitleExpression.clone();
|
||||
if (this.anchorNameExpression != null)
|
||||
clone.anchorNameExpression = (JRExpression)this.anchorNameExpression.clone();
|
||||
if (this.hyperlinkReferenceExpression != null)
|
||||
clone.hyperlinkReferenceExpression = (JRExpression)this.hyperlinkReferenceExpression.clone();
|
||||
if (this.hyperlinkAnchorExpression != null)
|
||||
clone.hyperlinkAnchorExpression = (JRExpression)this.hyperlinkAnchorExpression.clone();
|
||||
if (this.hyperlinkPageExpression != null)
|
||||
clone.hyperlinkPageExpression = (JRExpression)this.hyperlinkPageExpression.clone();
|
||||
if (this.hyperlinkTooltipExpression != null)
|
||||
clone.hyperlinkTooltipExpression = (JRExpression)this.hyperlinkTooltipExpression.clone();
|
||||
if (this.dataset != null)
|
||||
clone.dataset = (JRChartDataset)this.dataset.clone();
|
||||
if (this.plot != null)
|
||||
clone.plot = (JRChartPlot)this.plot.clone(clone);
|
||||
return clone;
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
if (this.lineBox == null) {
|
||||
this.lineBox = (JRLineBox)new JRBaseLineBox((JRBoxContainer)this);
|
||||
JRBoxUtil.setToBox(this.border, this.topBorder, this.leftBorder, this.bottomBorder, this.rightBorder, this.borderColor, this.topBorderColor, this.leftBorderColor, this.bottomBorderColor, this.rightBorderColor, this.padding, this.topPadding, this.leftPadding, this.bottomPadding, this.rightPadding, this.lineBox);
|
||||
this.border = null;
|
||||
this.topBorder = null;
|
||||
this.leftBorder = null;
|
||||
this.bottomBorder = null;
|
||||
this.rightBorder = null;
|
||||
this.borderColor = null;
|
||||
this.topBorderColor = null;
|
||||
this.leftBorderColor = null;
|
||||
this.bottomBorderColor = null;
|
||||
this.rightBorderColor = null;
|
||||
this.padding = null;
|
||||
this.topPadding = null;
|
||||
this.leftPadding = null;
|
||||
this.bottomPadding = null;
|
||||
this.rightPadding = null;
|
||||
}
|
||||
normalizeLinkType();
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import net.sf.jasperreports.engine.JRChartDataset;
|
||||
import net.sf.jasperreports.engine.JRElementDataset;
|
||||
import net.sf.jasperreports.engine.base.JRBaseObjectFactory;
|
||||
|
||||
public abstract class JRDesignChartDataset extends JRDesignElementDataset implements JRChartDataset {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
public JRDesignChartDataset() {}
|
||||
|
||||
public JRDesignChartDataset(JRChartDataset dataset) {
|
||||
super((JRElementDataset)dataset);
|
||||
}
|
||||
|
||||
public JRDesignChartDataset(JRChartDataset dataset, JRBaseObjectFactory factory) {
|
||||
super((JRElementDataset)dataset, factory);
|
||||
}
|
||||
|
||||
public byte getDatasetType() {
|
||||
return -1;
|
||||
}
|
||||
}
|
589
hrmsEjb/net/sf/jasperreports/engine/design/JRDesignDataset.java
Normal file
589
hrmsEjb/net/sf/jasperreports/engine/design/JRDesignDataset.java
Normal file
@@ -0,0 +1,589 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.Serializable;
|
||||
import java.net.URLStreamHandlerFactory;
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.TimeZone;
|
||||
import net.sf.jasperreports.engine.JRAbstractScriptlet;
|
||||
import net.sf.jasperreports.engine.JRDataSource;
|
||||
import net.sf.jasperreports.engine.JRException;
|
||||
import net.sf.jasperreports.engine.JRExpression;
|
||||
import net.sf.jasperreports.engine.JRField;
|
||||
import net.sf.jasperreports.engine.JRGroup;
|
||||
import net.sf.jasperreports.engine.JRParameter;
|
||||
import net.sf.jasperreports.engine.JRQuery;
|
||||
import net.sf.jasperreports.engine.JRRuntimeException;
|
||||
import net.sf.jasperreports.engine.JRSortField;
|
||||
import net.sf.jasperreports.engine.JRVariable;
|
||||
import net.sf.jasperreports.engine.JRVirtualizer;
|
||||
import net.sf.jasperreports.engine.base.JRBaseDataset;
|
||||
import net.sf.jasperreports.engine.query.JRQueryExecuterFactory;
|
||||
import net.sf.jasperreports.engine.util.FileResolver;
|
||||
import net.sf.jasperreports.engine.util.FormatFactory;
|
||||
import net.sf.jasperreports.engine.util.JRQueryExecuterUtils;
|
||||
|
||||
public class JRDesignDataset extends JRBaseDataset {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
public static final String PROPERTY_FIELDS = "fields";
|
||||
|
||||
public static final String PROPERTY_FILTER_EXPRESSION = "filterExpression";
|
||||
|
||||
public static final String PROPERTY_GROUPS = "groups";
|
||||
|
||||
public static final String PROPERTY_NAME = "name";
|
||||
|
||||
public static final String PROPERTY_PARAMETERS = "parameters";
|
||||
|
||||
public static final String PROPERTY_QUERY = "query";
|
||||
|
||||
public static final String PROPERTY_RESOURCE_BUNDLE = "resourceBundle";
|
||||
|
||||
public static final String PROPERTY_SCRIPTLET_CLASS = "scriptletClass";
|
||||
|
||||
public static final String PROPERTY_SORT_FIELDS = "sortFields";
|
||||
|
||||
public static final String PROPERTY_VARIABLES = "variables";
|
||||
|
||||
protected Map parametersMap = new HashMap();
|
||||
|
||||
protected List parametersList = new ArrayList();
|
||||
|
||||
protected Map fieldsMap = new HashMap();
|
||||
|
||||
protected List fieldsList = new ArrayList();
|
||||
|
||||
protected Map sortFieldsMap = new HashMap();
|
||||
|
||||
protected List sortFieldsList = new ArrayList();
|
||||
|
||||
protected Map variablesMap = new HashMap();
|
||||
|
||||
protected List variablesList = new ArrayList();
|
||||
|
||||
protected Map groupsMap = new HashMap();
|
||||
|
||||
protected List groupsList = new ArrayList();
|
||||
|
||||
private class QueryLanguageChangeListener implements PropertyChangeListener, Serializable {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
private final JRDesignDataset this$0;
|
||||
|
||||
private QueryLanguageChangeListener() {}
|
||||
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
JRDesignDataset.this.queryLanguageChanged((String)evt.getOldValue(), (String)evt.getNewValue());
|
||||
}
|
||||
}
|
||||
|
||||
private PropertyChangeListener queryLanguageChangeListener = new QueryLanguageChangeListener();
|
||||
|
||||
private static final Object[] BUILT_IN_PARAMETERS = new Object[] {
|
||||
"REPORT_PARAMETERS_MAP", Map.class, "REPORT_CONNECTION", Connection.class, "REPORT_MAX_COUNT", Integer.class, "REPORT_DATA_SOURCE", JRDataSource.class, "REPORT_SCRIPTLET", JRAbstractScriptlet.class,
|
||||
"REPORT_LOCALE", Locale.class, "REPORT_RESOURCE_BUNDLE", ResourceBundle.class, "REPORT_TIME_ZONE", TimeZone.class, "REPORT_FORMAT_FACTORY", FormatFactory.class, "REPORT_CLASS_LOADER", ClassLoader.class,
|
||||
"REPORT_URL_HANDLER_FACTORY", URLStreamHandlerFactory.class, "REPORT_FILE_RESOLVER", FileResolver.class };
|
||||
|
||||
private static final Object[] BUILT_IN_PARAMETERS_MAIN = new Object[] { "REPORT_VIRTUALIZER", JRVirtualizer.class, "IS_IGNORE_PAGINATION", Boolean.class, "REPORT_TEMPLATES", Collection.class };
|
||||
|
||||
public JRDesignDataset(boolean isMain) {
|
||||
super(isMain);
|
||||
addBuiltinParameters(BUILT_IN_PARAMETERS);
|
||||
if (isMain)
|
||||
addBuiltinParameters(BUILT_IN_PARAMETERS_MAIN);
|
||||
try {
|
||||
if (isMain) {
|
||||
addVariable(createPageNumberVariable());
|
||||
addVariable(createColumnNumberVariable());
|
||||
}
|
||||
addVariable(createReportCountVariable());
|
||||
if (isMain) {
|
||||
addVariable(createPageCountVariable());
|
||||
addVariable(createColumnCountVariable());
|
||||
}
|
||||
} catch (JRException e) {}
|
||||
}
|
||||
|
||||
private static JRDesignVariable createPageCountVariable() {
|
||||
JRDesignVariable variable = new JRDesignVariable();
|
||||
variable.setName("PAGE_COUNT");
|
||||
variable.setValueClass(Integer.class);
|
||||
variable.setResetType((byte)2);
|
||||
variable.setCalculation((byte)1);
|
||||
variable.setSystemDefined(true);
|
||||
JRDesignExpression expression = new JRDesignExpression();
|
||||
expression.setValueClass(Integer.class);
|
||||
expression.setText("new Integer(1)");
|
||||
variable.setExpression((JRExpression)expression);
|
||||
expression = new JRDesignExpression();
|
||||
expression.setValueClass(Integer.class);
|
||||
expression.setText("new Integer(0)");
|
||||
variable.setInitialValueExpression((JRExpression)expression);
|
||||
return variable;
|
||||
}
|
||||
|
||||
private static JRDesignVariable createColumnNumberVariable() {
|
||||
JRDesignVariable variable = new JRDesignVariable();
|
||||
variable.setName("COLUMN_NUMBER");
|
||||
variable.setValueClass(Integer.class);
|
||||
variable.setResetType((byte)2);
|
||||
variable.setCalculation((byte)8);
|
||||
variable.setSystemDefined(true);
|
||||
JRDesignExpression expression = new JRDesignExpression();
|
||||
expression.setValueClass(Integer.class);
|
||||
expression.setText("new Integer(1)");
|
||||
variable.setInitialValueExpression((JRExpression)expression);
|
||||
return variable;
|
||||
}
|
||||
|
||||
private static JRDesignVariable createPageNumberVariable() {
|
||||
JRDesignVariable variable = new JRDesignVariable();
|
||||
variable.setName("PAGE_NUMBER");
|
||||
variable.setValueClass(Integer.class);
|
||||
variable.setResetType((byte)1);
|
||||
variable.setCalculation((byte)8);
|
||||
variable.setSystemDefined(true);
|
||||
JRDesignExpression expression = new JRDesignExpression();
|
||||
expression.setValueClass(Integer.class);
|
||||
expression.setText("new Integer(1)");
|
||||
variable.setInitialValueExpression((JRExpression)expression);
|
||||
return variable;
|
||||
}
|
||||
|
||||
private static JRDesignVariable createColumnCountVariable() {
|
||||
JRDesignVariable variable = new JRDesignVariable();
|
||||
variable.setName("COLUMN_COUNT");
|
||||
variable.setValueClass(Integer.class);
|
||||
variable.setResetType((byte)3);
|
||||
variable.setCalculation((byte)1);
|
||||
variable.setSystemDefined(true);
|
||||
JRDesignExpression expression = new JRDesignExpression();
|
||||
expression.setValueClass(Integer.class);
|
||||
expression.setText("new Integer(1)");
|
||||
variable.setExpression((JRExpression)expression);
|
||||
expression = new JRDesignExpression();
|
||||
expression.setValueClass(Integer.class);
|
||||
expression.setText("new Integer(0)");
|
||||
variable.setInitialValueExpression((JRExpression)expression);
|
||||
return variable;
|
||||
}
|
||||
|
||||
private void addBuiltinParameters(Object[] parametersArray) {
|
||||
for (int i = 0; i < parametersArray.length; i++) {
|
||||
JRDesignParameter parameter = new JRDesignParameter();
|
||||
parameter.setName((String)parametersArray[i++]);
|
||||
parameter.setValueClass((Class)parametersArray[i]);
|
||||
parameter.setSystemDefined(true);
|
||||
try {
|
||||
addParameter((JRParameter)parameter);
|
||||
} catch (JRException e) {}
|
||||
}
|
||||
}
|
||||
|
||||
private static JRDesignVariable createReportCountVariable() {
|
||||
JRDesignVariable variable = new JRDesignVariable();
|
||||
variable.setName("REPORT_COUNT");
|
||||
variable.setValueClass(Integer.class);
|
||||
variable.setResetType((byte)1);
|
||||
variable.setCalculation((byte)1);
|
||||
variable.setSystemDefined(true);
|
||||
JRDesignExpression expression = new JRDesignExpression();
|
||||
expression.setValueClass(Integer.class);
|
||||
expression.setText("new Integer(1)");
|
||||
variable.setExpression((JRExpression)expression);
|
||||
expression = new JRDesignExpression();
|
||||
expression.setValueClass(Integer.class);
|
||||
expression.setText("new Integer(0)");
|
||||
variable.setInitialValueExpression((JRExpression)expression);
|
||||
return variable;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
Object old = this.name;
|
||||
this.name = name;
|
||||
getEventSupport().firePropertyChange("name", old, this.name);
|
||||
}
|
||||
|
||||
public JRParameter[] getParameters() {
|
||||
JRParameter[] parametersArray = new JRParameter[this.parametersList.size()];
|
||||
this.parametersList.toArray((Object[])parametersArray);
|
||||
return parametersArray;
|
||||
}
|
||||
|
||||
public List getParametersList() {
|
||||
return this.parametersList;
|
||||
}
|
||||
|
||||
public Map getParametersMap() {
|
||||
return this.parametersMap;
|
||||
}
|
||||
|
||||
public void addParameter(JRParameter parameter) throws JRException {
|
||||
if (this.parametersMap.containsKey(parameter.getName()))
|
||||
throw new JRException("Duplicate declaration of parameter : " + parameter.getName());
|
||||
this.parametersList.add(parameter);
|
||||
this.parametersMap.put(parameter.getName(), parameter);
|
||||
getEventSupport().fireCollectionElementAddedEvent("parameters", parameter, this.parametersList.size() - 1);
|
||||
}
|
||||
|
||||
public JRParameter removeParameter(String parameterName) {
|
||||
return removeParameter((JRParameter)this.parametersMap.get(parameterName));
|
||||
}
|
||||
|
||||
public JRParameter removeParameter(JRParameter parameter) {
|
||||
if (parameter != null) {
|
||||
int idx = this.parametersList.indexOf(parameter);
|
||||
if (idx >= 0) {
|
||||
this.parametersList.remove(idx);
|
||||
this.parametersMap.remove(parameter.getName());
|
||||
getEventSupport().fireCollectionElementRemovedEvent("parameters", parameter, idx);
|
||||
}
|
||||
}
|
||||
return parameter;
|
||||
}
|
||||
|
||||
public void setQuery(JRDesignQuery query) {
|
||||
Object old = query;
|
||||
String oldLanguage = null;
|
||||
if (this.query != null) {
|
||||
((JRDesignQuery)this.query).removePropertyChangeListener("language", this.queryLanguageChangeListener);
|
||||
oldLanguage = this.query.getLanguage();
|
||||
}
|
||||
this.query = (JRQuery)query;
|
||||
String newLanguage = null;
|
||||
if (query != null) {
|
||||
query.addPropertyChangeListener("language", this.queryLanguageChangeListener);
|
||||
newLanguage = query.getLanguage();
|
||||
}
|
||||
queryLanguageChanged(oldLanguage, newLanguage);
|
||||
getEventSupport().firePropertyChange("query", old, this.query);
|
||||
}
|
||||
|
||||
public void setScriptletClass(String scriptletClass) {
|
||||
Object old = this.scriptletClass;
|
||||
this.scriptletClass = scriptletClass;
|
||||
if (scriptletClass == null) {
|
||||
((JRDesignParameter)this.parametersMap.get("REPORT_SCRIPTLET")).setValueClass(JRAbstractScriptlet.class);
|
||||
} else {
|
||||
((JRDesignParameter)this.parametersMap.get("REPORT_SCRIPTLET")).setValueClassName(scriptletClass);
|
||||
}
|
||||
getEventSupport().firePropertyChange("scriptletClass", old, this.scriptletClass);
|
||||
}
|
||||
|
||||
public JRField[] getFields() {
|
||||
JRField[] fieldsArray = new JRField[this.fieldsList.size()];
|
||||
this.fieldsList.toArray((Object[])fieldsArray);
|
||||
return fieldsArray;
|
||||
}
|
||||
|
||||
public List getFieldsList() {
|
||||
return this.fieldsList;
|
||||
}
|
||||
|
||||
public Map getFieldsMap() {
|
||||
return this.fieldsMap;
|
||||
}
|
||||
|
||||
public void addField(JRField field) throws JRException {
|
||||
if (this.fieldsMap.containsKey(field.getName()))
|
||||
throw new JRException("Duplicate declaration of field : " + field.getName());
|
||||
this.fieldsList.add(field);
|
||||
this.fieldsMap.put(field.getName(), field);
|
||||
getEventSupport().fireCollectionElementAddedEvent("fields", field, this.fieldsList.size() - 1);
|
||||
}
|
||||
|
||||
public JRField removeField(String fieldName) {
|
||||
return removeField((JRField)this.fieldsMap.get(fieldName));
|
||||
}
|
||||
|
||||
public JRField removeField(JRField field) {
|
||||
if (field != null) {
|
||||
int idx = this.fieldsList.indexOf(field);
|
||||
if (idx >= 0) {
|
||||
this.fieldsList.remove(idx);
|
||||
this.fieldsMap.remove(field.getName());
|
||||
getEventSupport().fireCollectionElementRemovedEvent("fields", field, idx);
|
||||
}
|
||||
}
|
||||
return field;
|
||||
}
|
||||
|
||||
public JRSortField[] getSortFields() {
|
||||
JRSortField[] sortFieldsArray = new JRSortField[this.sortFieldsList.size()];
|
||||
this.sortFieldsList.toArray((Object[])sortFieldsArray);
|
||||
return sortFieldsArray;
|
||||
}
|
||||
|
||||
public List getSortFieldsList() {
|
||||
return this.sortFieldsList;
|
||||
}
|
||||
|
||||
public void addSortField(JRSortField sortField) throws JRException {
|
||||
if (this.sortFieldsMap.containsKey(sortField.getName()))
|
||||
throw new JRException("Duplicate declaration of sort field : " + sortField.getName());
|
||||
this.sortFieldsList.add(sortField);
|
||||
this.sortFieldsMap.put(sortField.getName(), sortField);
|
||||
getEventSupport().fireCollectionElementAddedEvent("sortFields", sortField, this.sortFieldsList.size() - 1);
|
||||
}
|
||||
|
||||
public JRSortField removeSortField(String fieldName) {
|
||||
return removeSortField((JRSortField)this.sortFieldsMap.get(fieldName));
|
||||
}
|
||||
|
||||
public JRSortField removeSortField(JRSortField sortField) {
|
||||
if (sortField != null) {
|
||||
int idx = this.sortFieldsList.indexOf(sortField);
|
||||
if (idx >= 0) {
|
||||
this.sortFieldsList.remove(idx);
|
||||
this.sortFieldsMap.remove(sortField.getName());
|
||||
getEventSupport().fireCollectionElementRemovedEvent("sortFields", sortField, idx);
|
||||
}
|
||||
}
|
||||
return sortField;
|
||||
}
|
||||
|
||||
public JRVariable[] getVariables() {
|
||||
JRVariable[] variablesArray = new JRVariable[this.variablesList.size()];
|
||||
this.variablesList.toArray((Object[])variablesArray);
|
||||
return variablesArray;
|
||||
}
|
||||
|
||||
public List getVariablesList() {
|
||||
return this.variablesList;
|
||||
}
|
||||
|
||||
public Map getVariablesMap() {
|
||||
return this.variablesMap;
|
||||
}
|
||||
|
||||
public void addVariable(JRDesignVariable variable) throws JRException {
|
||||
addVariable(variable, false);
|
||||
}
|
||||
|
||||
protected void addVariable(JRDesignVariable variable, boolean system) throws JRException {
|
||||
int addedIdx;
|
||||
if (this.variablesMap.containsKey(variable.getName()))
|
||||
throw new JRException("Duplicate declaration of variable : " + variable.getName());
|
||||
if (system) {
|
||||
ListIterator it = this.variablesList.listIterator();
|
||||
while (it.hasNext()) {
|
||||
JRVariable var = it.next();
|
||||
if (!var.isSystemDefined()) {
|
||||
it.previous();
|
||||
break;
|
||||
}
|
||||
}
|
||||
it.add(variable);
|
||||
addedIdx = it.previousIndex();
|
||||
} else {
|
||||
this.variablesList.add(variable);
|
||||
addedIdx = this.variablesList.size() - 1;
|
||||
}
|
||||
this.variablesMap.put(variable.getName(), variable);
|
||||
getEventSupport().fireCollectionElementAddedEvent("variables", variable, addedIdx);
|
||||
}
|
||||
|
||||
public JRVariable removeVariable(String variableName) {
|
||||
return removeVariable((JRVariable)this.variablesMap.get(variableName));
|
||||
}
|
||||
|
||||
public JRVariable removeVariable(JRVariable variable) {
|
||||
if (variable != null) {
|
||||
int idx = this.variablesList.indexOf(variable);
|
||||
if (idx >= 0) {
|
||||
this.variablesList.remove(idx);
|
||||
this.variablesMap.remove(variable.getName());
|
||||
getEventSupport().fireCollectionElementRemovedEvent("variables", variable, idx);
|
||||
}
|
||||
}
|
||||
return variable;
|
||||
}
|
||||
|
||||
public JRGroup[] getGroups() {
|
||||
JRGroup[] groupsArray = new JRGroup[this.groupsList.size()];
|
||||
this.groupsList.toArray((Object[])groupsArray);
|
||||
return groupsArray;
|
||||
}
|
||||
|
||||
public List getGroupsList() {
|
||||
return this.groupsList;
|
||||
}
|
||||
|
||||
public Map getGroupsMap() {
|
||||
return this.groupsMap;
|
||||
}
|
||||
|
||||
public void addGroup(JRDesignGroup group) throws JRException {
|
||||
if (this.groupsMap.containsKey(group.getName()))
|
||||
throw new JRException("Duplicate declaration of group : " + group.getName());
|
||||
JRDesignVariable countVariable = new JRDesignVariable();
|
||||
countVariable.setName(group.getName() + "_COUNT");
|
||||
countVariable.setValueClass(Integer.class);
|
||||
countVariable.setResetType((byte)4);
|
||||
countVariable.setResetGroup((JRGroup)group);
|
||||
countVariable.setCalculation((byte)1);
|
||||
countVariable.setSystemDefined(true);
|
||||
JRDesignExpression expression = new JRDesignExpression();
|
||||
expression.setValueClass(Integer.class);
|
||||
expression.setText("new Integer(1)");
|
||||
countVariable.setExpression((JRExpression)expression);
|
||||
expression = new JRDesignExpression();
|
||||
expression.setValueClass(Integer.class);
|
||||
expression.setText("new Integer(0)");
|
||||
countVariable.setInitialValueExpression((JRExpression)expression);
|
||||
addVariable(countVariable, true);
|
||||
group.setCountVariable((JRVariable)countVariable);
|
||||
this.groupsList.add(group);
|
||||
this.groupsMap.put(group.getName(), group);
|
||||
getEventSupport().fireCollectionElementAddedEvent("groups", group, this.groupsList.size() - 1);
|
||||
}
|
||||
|
||||
public JRGroup removeGroup(String groupName) {
|
||||
return removeGroup((JRGroup)this.groupsMap.get(groupName));
|
||||
}
|
||||
|
||||
public JRGroup removeGroup(JRGroup group) {
|
||||
if (group != null) {
|
||||
removeVariable(group.getCountVariable());
|
||||
int idx = this.groupsList.indexOf(group);
|
||||
if (idx >= 0) {
|
||||
this.groupsList.remove(idx);
|
||||
this.groupsMap.remove(group.getName());
|
||||
getEventSupport().fireCollectionElementRemovedEvent("groups", group, idx);
|
||||
}
|
||||
}
|
||||
return group;
|
||||
}
|
||||
|
||||
public void setResourceBundle(String resourceBundle) {
|
||||
Object old = this.resourceBundle;
|
||||
this.resourceBundle = resourceBundle;
|
||||
getEventSupport().firePropertyChange("resourceBundle", old, this.resourceBundle);
|
||||
}
|
||||
|
||||
protected void queryLanguageChanged(String oldLanguage, String newLanguage) {
|
||||
try {
|
||||
if (oldLanguage != null) {
|
||||
JRQueryExecuterFactory queryExecuterFactory = JRQueryExecuterUtils.getQueryExecuterFactory(oldLanguage);
|
||||
Object[] builtinParameters = queryExecuterFactory.getBuiltinParameters();
|
||||
if (builtinParameters != null)
|
||||
removeBuiltinParameters(builtinParameters);
|
||||
}
|
||||
if (newLanguage != null) {
|
||||
JRQueryExecuterFactory queryExecuterFactory = JRQueryExecuterUtils.getQueryExecuterFactory(newLanguage);
|
||||
Object[] builtinParameters = queryExecuterFactory.getBuiltinParameters();
|
||||
if (builtinParameters != null) {
|
||||
addBuiltinParameters(builtinParameters);
|
||||
sortSystemParamsFirst();
|
||||
}
|
||||
}
|
||||
} catch (JRException e) {
|
||||
throw new JRRuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void sortSystemParamsFirst() {
|
||||
Collections.sort(this.parametersList, new Comparator() {
|
||||
private final JRDesignDataset this$0;
|
||||
|
||||
public int compare(Object o1, Object o2) {
|
||||
JRParameter p1 = (JRParameter)o1;
|
||||
JRParameter p2 = (JRParameter)o2;
|
||||
boolean s1 = p1.isSystemDefined();
|
||||
boolean s2 = p2.isSystemDefined();
|
||||
return s1 ? (s2 ? 0 : -1) : (s2 ? 1 : 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void removeBuiltinParameters(Object[] builtinParameters) {
|
||||
for (int i = 0; i < builtinParameters.length; i += 2) {
|
||||
String parameterName = (String)builtinParameters[i];
|
||||
JRParameter parameter = (JRParameter)this.parametersMap.get(parameterName);
|
||||
if (parameter.isSystemDefined())
|
||||
removeParameter(parameter);
|
||||
}
|
||||
}
|
||||
|
||||
public void setProperty(String propName, String value) {
|
||||
getPropertiesMap().setProperty(propName, value);
|
||||
}
|
||||
|
||||
public void setFilterExpression(JRExpression expression) {
|
||||
Object old = this.filterExpression;
|
||||
this.filterExpression = expression;
|
||||
getEventSupport().firePropertyChange("filterExpression", old, this.filterExpression);
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
if (this.sortFieldsMap == null)
|
||||
this.sortFieldsMap = new HashMap();
|
||||
if (this.sortFieldsList == null)
|
||||
this.sortFieldsList = new ArrayList();
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
JRDesignDataset clone = (JRDesignDataset)super.clone();
|
||||
if (this.parametersList != null) {
|
||||
clone.parametersList = new ArrayList(this.parametersList.size());
|
||||
clone.parametersMap = new HashMap(this.parametersList.size());
|
||||
for (int i = 0; i < this.parametersList.size(); i++) {
|
||||
JRParameter parameter = (JRParameter)((JRParameter)this.parametersList.get(i)).clone();
|
||||
clone.parametersList.add(parameter);
|
||||
clone.parametersMap.put(parameter.getName(), parameter);
|
||||
}
|
||||
}
|
||||
if (this.fieldsList != null) {
|
||||
clone.fieldsList = new ArrayList(this.fieldsList.size());
|
||||
clone.fieldsMap = new HashMap(this.fieldsList.size());
|
||||
for (int i = 0; i < this.fieldsList.size(); i++) {
|
||||
JRField field = (JRField)((JRField)this.fieldsList.get(i)).clone();
|
||||
clone.fieldsList.add(field);
|
||||
clone.fieldsMap.put(field.getName(), field);
|
||||
}
|
||||
}
|
||||
if (this.sortFieldsList != null) {
|
||||
clone.sortFieldsList = new ArrayList(this.sortFieldsList.size());
|
||||
clone.sortFieldsMap = new HashMap(this.sortFieldsList.size());
|
||||
for (int i = 0; i < this.sortFieldsList.size(); i++) {
|
||||
JRSortField sortField = (JRSortField)((JRSortField)this.sortFieldsList.get(i)).clone();
|
||||
clone.sortFieldsList.add(sortField);
|
||||
clone.sortFieldsMap.put(sortField.getName(), sortField);
|
||||
}
|
||||
}
|
||||
if (this.variablesList != null) {
|
||||
clone.variablesList = new ArrayList(this.variablesList.size());
|
||||
clone.variablesMap = new HashMap(this.variablesList.size());
|
||||
for (int i = 0; i < this.variablesList.size(); i++) {
|
||||
JRVariable variable = (JRVariable)((JRVariable)this.variablesList.get(i)).clone();
|
||||
clone.variablesList.add(variable);
|
||||
clone.variablesMap.put(variable.getName(), variable);
|
||||
}
|
||||
}
|
||||
if (this.groupsList != null) {
|
||||
clone.groupsList = new ArrayList(this.groupsList.size());
|
||||
clone.groupsMap = new HashMap(this.groupsList.size());
|
||||
for (int i = 0; i < this.groupsList.size(); i++) {
|
||||
JRGroup group = (JRGroup)((JRGroup)this.groupsList.get(i)).clone();
|
||||
clone.groupsList.add(group);
|
||||
clone.groupsMap.put(group.getName(), group);
|
||||
}
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
}
|
139
hrmsEjb/net/sf/jasperreports/engine/design/JRDesignElement.java
Normal file
139
hrmsEjb/net/sf/jasperreports/engine/design/JRDesignElement.java
Normal file
@@ -0,0 +1,139 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import net.sf.jasperreports.engine.JRDefaultStyleProvider;
|
||||
import net.sf.jasperreports.engine.JRElementGroup;
|
||||
import net.sf.jasperreports.engine.JRExpression;
|
||||
import net.sf.jasperreports.engine.JRGroup;
|
||||
import net.sf.jasperreports.engine.JRPropertyExpression;
|
||||
import net.sf.jasperreports.engine.JRStyle;
|
||||
import net.sf.jasperreports.engine.base.JRBaseElement;
|
||||
|
||||
public abstract class JRDesignElement extends JRBaseElement {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
public static final String PROPERTY_ELEMENT_GROUP = "elementGroup";
|
||||
|
||||
public static final String PROPERTY_HEIGHT = "height";
|
||||
|
||||
public static final String PROPERTY_KEY = "key";
|
||||
|
||||
public static final String PROPERTY_PRINT_WHEN_EXPRESSION = "printWhenExpression";
|
||||
|
||||
public static final String PROPERTY_PRINT_WHEN_GROUP_CHANGES = "printWhenGroupChanges";
|
||||
|
||||
public static final String PROPERTY_PARENT_STYLE = "parentStyle";
|
||||
|
||||
public static final String PROPERTY_PARENT_STYLE_NAME_REFERENCE = "parentStyleNameReference";
|
||||
|
||||
public static final String PROPERTY_Y = "y";
|
||||
|
||||
public static final String PROPERTY_PROPERTY_EXPRESSIONS = "propertyExpressions";
|
||||
|
||||
private List propertyExpressions = new ArrayList();
|
||||
|
||||
protected JRDesignElement(JRDefaultStyleProvider defaultStyleProvider) {
|
||||
super(defaultStyleProvider);
|
||||
this.positionType = 2;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
Object old = this.key;
|
||||
this.key = key;
|
||||
getEventSupport().firePropertyChange("key", old, this.key);
|
||||
}
|
||||
|
||||
public void setY(int y) {
|
||||
int old = this.y;
|
||||
this.y = y;
|
||||
getEventSupport().firePropertyChange("y", old, this.y);
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
int old = this.height;
|
||||
this.height = height;
|
||||
getEventSupport().firePropertyChange("height", old, this.height);
|
||||
}
|
||||
|
||||
public void setPrintWhenExpression(JRExpression expression) {
|
||||
Object old = this.printWhenExpression;
|
||||
this.printWhenExpression = expression;
|
||||
getEventSupport().firePropertyChange("printWhenExpression", old, this.printWhenExpression);
|
||||
}
|
||||
|
||||
public void setPrintWhenGroupChanges(JRGroup group) {
|
||||
Object old = this.printWhenGroupChanges;
|
||||
this.printWhenGroupChanges = group;
|
||||
getEventSupport().firePropertyChange("printWhenGroupChanges", old, this.printWhenGroupChanges);
|
||||
}
|
||||
|
||||
public void setElementGroup(JRElementGroup elementGroup) {
|
||||
Object old = this.elementGroup;
|
||||
this.elementGroup = elementGroup;
|
||||
getEventSupport().firePropertyChange("elementGroup", old, this.elementGroup);
|
||||
}
|
||||
|
||||
public void setStyle(JRStyle style) {
|
||||
Object old = this.parentStyle;
|
||||
this.parentStyle = style;
|
||||
getEventSupport().firePropertyChange("parentStyle", old, this.parentStyle);
|
||||
}
|
||||
|
||||
public void setStyleNameReference(String styleName) {
|
||||
Object old = this.parentStyleNameReference;
|
||||
this.parentStyleNameReference = styleName;
|
||||
getEventSupport().firePropertyChange("parentStyleNameReference", old, this.parentStyleNameReference);
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
if (this.propertyExpressions == null)
|
||||
this.propertyExpressions = new ArrayList();
|
||||
}
|
||||
|
||||
public void addPropertyExpression(JRPropertyExpression propertyExpression) {
|
||||
this.propertyExpressions.add(propertyExpression);
|
||||
getEventSupport().fireCollectionElementAddedEvent("propertyExpressions", propertyExpression, this.propertyExpressions.size() - 1);
|
||||
}
|
||||
|
||||
public void removePropertyExpression(JRPropertyExpression propertyExpression) {
|
||||
int idx = this.propertyExpressions.indexOf(propertyExpression);
|
||||
if (idx >= 0) {
|
||||
this.propertyExpressions.remove(idx);
|
||||
getEventSupport().fireCollectionElementRemovedEvent("propertyExpressions", propertyExpression, idx);
|
||||
}
|
||||
}
|
||||
|
||||
public JRPropertyExpression removePropertyExpression(String name) {
|
||||
JRPropertyExpression removed = null;
|
||||
for (ListIterator it = this.propertyExpressions.listIterator(); it.hasNext(); ) {
|
||||
JRPropertyExpression prop = it.next();
|
||||
if (name.equals(prop.getName())) {
|
||||
removed = prop;
|
||||
int idx = it.previousIndex();
|
||||
it.remove();
|
||||
getEventSupport().fireCollectionElementRemovedEvent("propertyExpressions", removed, idx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
public List getPropertyExpressionsList() {
|
||||
return this.propertyExpressions;
|
||||
}
|
||||
|
||||
public JRPropertyExpression[] getPropertyExpressions() {
|
||||
JRPropertyExpression[] props;
|
||||
if (this.propertyExpressions.isEmpty()) {
|
||||
props = null;
|
||||
} else {
|
||||
props = (JRPropertyExpression[])this.propertyExpressions.toArray((Object[])new JRPropertyExpression[this.propertyExpressions.size()]);
|
||||
}
|
||||
return props;
|
||||
}
|
||||
}
|
@@ -0,0 +1,82 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import net.sf.jasperreports.engine.JRDatasetRun;
|
||||
import net.sf.jasperreports.engine.JRElementDataset;
|
||||
import net.sf.jasperreports.engine.JRExpression;
|
||||
import net.sf.jasperreports.engine.JRGroup;
|
||||
import net.sf.jasperreports.engine.base.JRBaseElementDataset;
|
||||
import net.sf.jasperreports.engine.base.JRBaseObjectFactory;
|
||||
import net.sf.jasperreports.engine.design.events.JRChangeEventsSupport;
|
||||
import net.sf.jasperreports.engine.design.events.JRPropertyChangeSupport;
|
||||
|
||||
public abstract class JRDesignElementDataset extends JRBaseElementDataset implements JRChangeEventsSupport {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
public static final String PROPERTY_DATASET_RUN = "datasetRun";
|
||||
|
||||
public static final String PROPERTY_INCREMENT_GROUP = "incrementGroup";
|
||||
|
||||
public static final String PROPERTY_INCREMENT_TYPE = "incrementType";
|
||||
|
||||
public static final String PROPERTY_INCREMENT_WHEN_EXPRESSION = "incrementWhenExpression";
|
||||
|
||||
public static final String PROPERTY_RESET_GROUP = "resetGroup";
|
||||
|
||||
public static final String PROPERTY_RESET_TYPE = "resetType";
|
||||
|
||||
private transient JRPropertyChangeSupport eventSupport;
|
||||
|
||||
public JRDesignElementDataset() {}
|
||||
|
||||
public JRDesignElementDataset(JRElementDataset dataset) {
|
||||
super(dataset);
|
||||
}
|
||||
|
||||
public JRDesignElementDataset(JRElementDataset dataset, JRBaseObjectFactory factory) {
|
||||
super(dataset, factory);
|
||||
}
|
||||
|
||||
public void setResetType(byte resetType) {
|
||||
byte old = this.resetType;
|
||||
this.resetType = resetType;
|
||||
getEventSupport().firePropertyChange("resetType", old, this.resetType);
|
||||
}
|
||||
|
||||
public void setIncrementType(byte incrementType) {
|
||||
byte old = this.incrementType;
|
||||
this.incrementType = incrementType;
|
||||
getEventSupport().firePropertyChange("incrementType", old, this.incrementType);
|
||||
}
|
||||
|
||||
public void setResetGroup(JRGroup group) {
|
||||
Object old = this.resetGroup;
|
||||
this.resetGroup = group;
|
||||
getEventSupport().firePropertyChange("resetGroup", old, this.resetGroup);
|
||||
}
|
||||
|
||||
public void setIncrementGroup(JRGroup group) {
|
||||
Object old = this.incrementGroup;
|
||||
this.incrementGroup = group;
|
||||
getEventSupport().firePropertyChange("incrementGroup", old, this.incrementGroup);
|
||||
}
|
||||
|
||||
public void setDatasetRun(JRDatasetRun datasetRun) {
|
||||
Object old = this.datasetRun;
|
||||
this.datasetRun = datasetRun;
|
||||
getEventSupport().firePropertyChange("datasetRun", old, this.datasetRun);
|
||||
}
|
||||
|
||||
public void setIncrementWhenExpression(JRExpression expression) {
|
||||
Object old = this.incrementWhenExpression;
|
||||
this.incrementWhenExpression = expression;
|
||||
getEventSupport().firePropertyChange("incrementWhenExpression", old, this.incrementWhenExpression);
|
||||
}
|
||||
|
||||
public JRPropertyChangeSupport getEventSupport() {
|
||||
synchronized (this) {
|
||||
if (this.eventSupport == null)
|
||||
this.eventSupport = new JRPropertyChangeSupport(this);
|
||||
}
|
||||
return this.eventSupport;
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import net.sf.jasperreports.engine.JRElementGroup;
|
||||
import net.sf.jasperreports.engine.base.JRBaseElementGroup;
|
||||
import net.sf.jasperreports.engine.design.events.JRChangeEventsSupport;
|
||||
import net.sf.jasperreports.engine.design.events.JRPropertyChangeSupport;
|
||||
|
||||
public class JRDesignElementGroup extends JRBaseElementGroup implements JRChangeEventsSupport {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
public static final String PROPERTY_ELEMENT_GROUP = "elementGroup";
|
||||
|
||||
public static final String PROPERTY_CHILDREN = "children";
|
||||
|
||||
private transient JRPropertyChangeSupport eventSupport;
|
||||
|
||||
public void setElementGroup(JRElementGroup elementGroup) {
|
||||
Object old = this.elementGroup;
|
||||
this.elementGroup = elementGroup;
|
||||
getEventSupport().firePropertyChange("elementGroup", old, this.elementGroup);
|
||||
}
|
||||
|
||||
public void addElement(JRDesignElement element) {
|
||||
element.setElementGroup((JRElementGroup)this);
|
||||
this.children.add(element);
|
||||
getEventSupport().fireCollectionElementAddedEvent("children", element, this.children.size() - 1);
|
||||
}
|
||||
|
||||
public JRDesignElement removeElement(JRDesignElement element) {
|
||||
element.setElementGroup(null);
|
||||
int idx = this.children.indexOf(element);
|
||||
if (idx >= 0) {
|
||||
this.children.remove(idx);
|
||||
getEventSupport().fireCollectionElementRemovedEvent("children", element, idx);
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public void addElementGroup(JRDesignElementGroup elemGrp) {
|
||||
elemGrp.setElementGroup((JRElementGroup)this);
|
||||
this.children.add(elemGrp);
|
||||
getEventSupport().fireCollectionElementAddedEvent("children", elemGrp, this.children.size() - 1);
|
||||
}
|
||||
|
||||
public JRDesignElementGroup removeElementGroup(JRDesignElementGroup elemGrp) {
|
||||
elemGrp.setElementGroup((JRElementGroup)null);
|
||||
int idx = this.children.indexOf(elemGrp);
|
||||
if (idx >= 0) {
|
||||
this.children.remove(idx);
|
||||
getEventSupport().fireCollectionElementRemovedEvent("children", elemGrp, idx);
|
||||
}
|
||||
return elemGrp;
|
||||
}
|
||||
|
||||
public JRPropertyChangeSupport getEventSupport() {
|
||||
synchronized (this) {
|
||||
if (this.eventSupport == null)
|
||||
this.eventSupport = new JRPropertyChangeSupport(this);
|
||||
}
|
||||
return this.eventSupport;
|
||||
}
|
||||
}
|
@@ -0,0 +1,176 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
import net.sf.jasperreports.engine.JRExpressionChunk;
|
||||
import net.sf.jasperreports.engine.base.JRBaseExpression;
|
||||
import net.sf.jasperreports.engine.design.events.JRChangeEventsSupport;
|
||||
import net.sf.jasperreports.engine.design.events.JRPropertyChangeSupport;
|
||||
|
||||
public class JRDesignExpression extends JRBaseExpression implements JRChangeEventsSupport {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
public static final String PROPERTY_TEXT = "text";
|
||||
|
||||
public static final String PROPERTY_VALUE_CLASS_NAME = "valueClassName";
|
||||
|
||||
protected List chunks = new ArrayList();
|
||||
|
||||
private transient JRPropertyChangeSupport eventSupport;
|
||||
|
||||
public JRDesignExpression() {
|
||||
regenerateId();
|
||||
}
|
||||
|
||||
public void setValueClass(Class clazz) {
|
||||
setValueClassName(clazz.getName());
|
||||
}
|
||||
|
||||
public void setValueClassName(String className) {
|
||||
Object old = this.valueClassName;
|
||||
this.valueClassName = className;
|
||||
this.valueClass = null;
|
||||
this.valueClassRealName = null;
|
||||
getEventSupport().firePropertyChange("valueClassName", old, this.valueClassName);
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public JRExpressionChunk[] getChunks() {
|
||||
JRExpressionChunk[] chunkArray = null;
|
||||
if (this.chunks != null && this.chunks.size() > 0) {
|
||||
chunkArray = new JRExpressionChunk[this.chunks.size()];
|
||||
this.chunks.toArray((Object[])chunkArray);
|
||||
}
|
||||
return chunkArray;
|
||||
}
|
||||
|
||||
public void setChunks(List chunks) {
|
||||
this.chunks.clear();
|
||||
this.chunks.addAll(chunks);
|
||||
}
|
||||
|
||||
public void addChunk(JRDesignExpressionChunk chunk) {
|
||||
this.chunks.add(chunk);
|
||||
}
|
||||
|
||||
protected void addChunk(byte type, String text) {
|
||||
JRDesignExpressionChunk chunk = new JRDesignExpressionChunk();
|
||||
chunk.setType(type);
|
||||
chunk.setText(text);
|
||||
this.chunks.add(chunk);
|
||||
}
|
||||
|
||||
public void addTextChunk(String text) {
|
||||
JRDesignExpressionChunk chunk = new JRDesignExpressionChunk();
|
||||
chunk.setType((byte)1);
|
||||
chunk.setText(text);
|
||||
this.chunks.add(chunk);
|
||||
}
|
||||
|
||||
public void addParameterChunk(String text) {
|
||||
JRDesignExpressionChunk chunk = new JRDesignExpressionChunk();
|
||||
chunk.setType((byte)2);
|
||||
chunk.setText(text);
|
||||
this.chunks.add(chunk);
|
||||
}
|
||||
|
||||
public void addFieldChunk(String text) {
|
||||
JRDesignExpressionChunk chunk = new JRDesignExpressionChunk();
|
||||
chunk.setType((byte)3);
|
||||
chunk.setText(text);
|
||||
this.chunks.add(chunk);
|
||||
}
|
||||
|
||||
public void addVariableChunk(String text) {
|
||||
JRDesignExpressionChunk chunk = new JRDesignExpressionChunk();
|
||||
chunk.setType((byte)4);
|
||||
chunk.setText(text);
|
||||
this.chunks.add(chunk);
|
||||
}
|
||||
|
||||
public void addResourceChunk(String text) {
|
||||
JRDesignExpressionChunk chunk = new JRDesignExpressionChunk();
|
||||
chunk.setType((byte)5);
|
||||
chunk.setText(text);
|
||||
this.chunks.add(chunk);
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
Object old = getText();
|
||||
this.chunks.clear();
|
||||
if (text != null) {
|
||||
StringBuffer textChunk = new StringBuffer();
|
||||
StringTokenizer tkzer = new StringTokenizer(text, "$", true);
|
||||
int behindDelims = 0;
|
||||
while (tkzer.hasMoreTokens()) {
|
||||
String token = tkzer.nextToken();
|
||||
if (token.equals("$")) {
|
||||
if (behindDelims > 0)
|
||||
textChunk.append("$");
|
||||
behindDelims++;
|
||||
continue;
|
||||
}
|
||||
byte chunkType = 1;
|
||||
if (behindDelims > 0)
|
||||
if (token.startsWith("P{")) {
|
||||
chunkType = 2;
|
||||
} else if (token.startsWith("F{")) {
|
||||
chunkType = 3;
|
||||
} else if (token.startsWith("V{")) {
|
||||
chunkType = 4;
|
||||
} else if (token.startsWith("R{")) {
|
||||
chunkType = 5;
|
||||
}
|
||||
if (chunkType == 1) {
|
||||
if (behindDelims > 0)
|
||||
textChunk.append("$");
|
||||
textChunk.append(token);
|
||||
} else {
|
||||
int end = token.indexOf('}');
|
||||
if (end > 0) {
|
||||
if (behindDelims > 1) {
|
||||
textChunk.append(token);
|
||||
} else {
|
||||
if (textChunk.length() > 0)
|
||||
addTextChunk(textChunk.toString());
|
||||
addChunk(chunkType, token.substring(2, end));
|
||||
textChunk = new StringBuffer(token.substring(end + 1));
|
||||
}
|
||||
} else {
|
||||
if (behindDelims > 0)
|
||||
textChunk.append("$");
|
||||
textChunk.append(token);
|
||||
}
|
||||
}
|
||||
behindDelims = 0;
|
||||
}
|
||||
if (behindDelims > 0)
|
||||
textChunk.append("$");
|
||||
if (textChunk.length() > 0)
|
||||
addTextChunk(textChunk.toString());
|
||||
}
|
||||
getEventSupport().firePropertyChange("text", old, text);
|
||||
}
|
||||
|
||||
public JRPropertyChangeSupport getEventSupport() {
|
||||
synchronized (this) {
|
||||
if (this.eventSupport == null)
|
||||
this.eventSupport = new JRPropertyChangeSupport(this);
|
||||
}
|
||||
return this.eventSupport;
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
JRDesignExpression clone = (JRDesignExpression)super.clone();
|
||||
if (this.chunks != null) {
|
||||
clone.chunks = new ArrayList(this.chunks.size());
|
||||
for (int i = 0; i < this.chunks.size(); i++)
|
||||
clone.chunks.add(((JRExpressionChunk)this.chunks.get(i)).clone());
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import net.sf.jasperreports.engine.base.JRBaseExpressionChunk;
|
||||
import net.sf.jasperreports.engine.design.events.JRChangeEventsSupport;
|
||||
import net.sf.jasperreports.engine.design.events.JRPropertyChangeSupport;
|
||||
|
||||
public class JRDesignExpressionChunk extends JRBaseExpressionChunk implements JRChangeEventsSupport {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
public static final String PROPERTY_TEXT = "text";
|
||||
|
||||
public static final String PROPERTY_TYPE = "type";
|
||||
|
||||
private transient JRPropertyChangeSupport eventSupport;
|
||||
|
||||
public void setType(byte type) {
|
||||
byte old = this.type;
|
||||
this.type = type;
|
||||
getEventSupport().firePropertyChange("type", old, this.type);
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
Object old = this.text;
|
||||
this.text = text;
|
||||
getEventSupport().firePropertyChange("text", old, this.text);
|
||||
}
|
||||
|
||||
public JRPropertyChangeSupport getEventSupport() {
|
||||
synchronized (this) {
|
||||
if (this.eventSupport == null)
|
||||
this.eventSupport = new JRPropertyChangeSupport(this);
|
||||
}
|
||||
return this.eventSupport;
|
||||
}
|
||||
}
|
@@ -0,0 +1,83 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import net.sf.jasperreports.engine.JRCommonGraphicElement;
|
||||
import net.sf.jasperreports.engine.JRDefaultStyleProvider;
|
||||
import net.sf.jasperreports.engine.JRGraphicElement;
|
||||
import net.sf.jasperreports.engine.JRPen;
|
||||
import net.sf.jasperreports.engine.JRPenContainer;
|
||||
import net.sf.jasperreports.engine.base.JRBasePen;
|
||||
import net.sf.jasperreports.engine.util.JRPenUtil;
|
||||
import net.sf.jasperreports.engine.util.JRStyleResolver;
|
||||
|
||||
public abstract class JRDesignGraphicElement extends JRDesignElement implements JRGraphicElement {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
protected JRPen linePen;
|
||||
|
||||
protected Byte fill;
|
||||
|
||||
private Byte pen;
|
||||
|
||||
protected JRDesignGraphicElement(JRDefaultStyleProvider defaultStyleProvider) {
|
||||
super(defaultStyleProvider);
|
||||
this.linePen = (JRPen)new JRBasePen((JRPenContainer)this);
|
||||
}
|
||||
|
||||
public JRPen getLinePen() {
|
||||
return this.linePen;
|
||||
}
|
||||
|
||||
public byte getPen() {
|
||||
return JRPenUtil.getPenFromLinePen(this.linePen);
|
||||
}
|
||||
|
||||
public Byte getOwnPen() {
|
||||
return JRPenUtil.getOwnPenFromLinePen(this.linePen);
|
||||
}
|
||||
|
||||
public void setPen(byte pen) {
|
||||
setPen(new Byte(pen));
|
||||
}
|
||||
|
||||
public void setPen(Byte pen) {
|
||||
JRPenUtil.setLinePenFromPen(pen, this.linePen);
|
||||
}
|
||||
|
||||
public byte getFill() {
|
||||
return JRStyleResolver.getFill((JRCommonGraphicElement)this);
|
||||
}
|
||||
|
||||
public Byte getOwnFill() {
|
||||
return this.fill;
|
||||
}
|
||||
|
||||
public void setFill(byte fill) {
|
||||
setFill(new Byte(fill));
|
||||
}
|
||||
|
||||
public void setFill(Byte fill) {
|
||||
Object old = this.fill;
|
||||
this.fill = fill;
|
||||
getEventSupport().firePropertyChange("fill", old, this.fill);
|
||||
}
|
||||
|
||||
public Float getDefaultLineWidth() {
|
||||
return JRPen.LINE_WIDTH_1;
|
||||
}
|
||||
|
||||
public Color getDefaultLineColor() {
|
||||
return getForecolor();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
if (this.linePen == null) {
|
||||
this.linePen = (JRPen)new JRBasePen((JRPenContainer)this);
|
||||
JRPenUtil.setLinePenFromPen(this.pen, this.linePen);
|
||||
this.pen = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import net.sf.jasperreports.engine.JRBand;
|
||||
import net.sf.jasperreports.engine.JRExpression;
|
||||
import net.sf.jasperreports.engine.JROrigin;
|
||||
import net.sf.jasperreports.engine.JRVariable;
|
||||
import net.sf.jasperreports.engine.base.JRBaseGroup;
|
||||
|
||||
public class JRDesignGroup extends JRBaseGroup {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
public static final String PROPERTY_COUNT_VARIABLE = "countVariable";
|
||||
|
||||
public static final String PROPERTY_EXPRESSION = "expression";
|
||||
|
||||
public static final String PROPERTY_GROUP_FOOTER = "groupFooter";
|
||||
|
||||
public static final String PROPERTY_GROUP_HEADER = "groupHeader";
|
||||
|
||||
public static final String PROPERTY_NAME = "name";
|
||||
|
||||
public void setName(String name) {
|
||||
Object old = this.name;
|
||||
this.name = name;
|
||||
updateBandOrigins();
|
||||
getEventSupport().firePropertyChange("name", old, this.name);
|
||||
}
|
||||
|
||||
public void setExpression(JRExpression expression) {
|
||||
Object old = this.expression;
|
||||
this.expression = expression;
|
||||
getEventSupport().firePropertyChange("expression", old, this.expression);
|
||||
}
|
||||
|
||||
public void setGroupHeader(JRBand groupHeader) {
|
||||
Object old = this.groupHeader;
|
||||
this.groupHeader = groupHeader;
|
||||
setBandOrigin(this.groupHeader, (byte)5);
|
||||
getEventSupport().firePropertyChange("groupHeader", old, this.groupHeader);
|
||||
}
|
||||
|
||||
public void setGroupFooter(JRBand groupFooter) {
|
||||
Object old = this.groupFooter;
|
||||
this.groupFooter = groupFooter;
|
||||
setBandOrigin(this.groupFooter, (byte)7);
|
||||
getEventSupport().firePropertyChange("groupFooter", old, this.groupFooter);
|
||||
}
|
||||
|
||||
public void setCountVariable(JRVariable countVariable) {
|
||||
Object old = this.countVariable;
|
||||
this.countVariable = countVariable;
|
||||
getEventSupport().firePropertyChange("countVariable", old, this.countVariable);
|
||||
}
|
||||
|
||||
protected void setBandOrigin(JRBand band, byte type) {
|
||||
if (band instanceof JRDesignBand) {
|
||||
JROrigin origin = new JROrigin(null, getName(), type);
|
||||
((JRDesignBand)band).setOrigin(origin);
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateBandOrigins() {
|
||||
setBandOrigin(getGroupHeader(), (byte)5);
|
||||
setBandOrigin(getGroupFooter(), (byte)7);
|
||||
}
|
||||
}
|
687
hrmsEjb/net/sf/jasperreports/engine/design/JRDesignImage.java
Normal file
687
hrmsEjb/net/sf/jasperreports/engine/design/JRDesignImage.java
Normal file
@@ -0,0 +1,687 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import net.sf.jasperreports.engine.JRAlignment;
|
||||
import net.sf.jasperreports.engine.JRBox;
|
||||
import net.sf.jasperreports.engine.JRBoxContainer;
|
||||
import net.sf.jasperreports.engine.JRCommonElement;
|
||||
import net.sf.jasperreports.engine.JRCommonImage;
|
||||
import net.sf.jasperreports.engine.JRDefaultStyleProvider;
|
||||
import net.sf.jasperreports.engine.JRExpression;
|
||||
import net.sf.jasperreports.engine.JRExpressionCollector;
|
||||
import net.sf.jasperreports.engine.JRGroup;
|
||||
import net.sf.jasperreports.engine.JRHyperlink;
|
||||
import net.sf.jasperreports.engine.JRHyperlinkHelper;
|
||||
import net.sf.jasperreports.engine.JRHyperlinkParameter;
|
||||
import net.sf.jasperreports.engine.JRImage;
|
||||
import net.sf.jasperreports.engine.JRLineBox;
|
||||
import net.sf.jasperreports.engine.JRPen;
|
||||
import net.sf.jasperreports.engine.JRVisitor;
|
||||
import net.sf.jasperreports.engine.base.JRBaseLineBox;
|
||||
import net.sf.jasperreports.engine.util.JRBoxUtil;
|
||||
import net.sf.jasperreports.engine.util.JRPenUtil;
|
||||
import net.sf.jasperreports.engine.util.JRStyleResolver;
|
||||
import net.sf.jasperreports.engine.util.LineBoxWrapper;
|
||||
|
||||
public class JRDesignImage extends JRDesignGraphicElement implements JRImage {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
public static final String PROPERTY_ANCHOR_NAME_EXPRESSION = "anchorNameExpression";
|
||||
|
||||
public static final String PROPERTY_BOOKMARK_LEVEL = "bookmarkLevel";
|
||||
|
||||
public static final String PROPERTY_EVALUATION_GROUP = "evaluationGroup";
|
||||
|
||||
public static final String PROPERTY_EVALUATION_TIME = "evaluationTime";
|
||||
|
||||
public static final String PROPERTY_EXPRESSION = "expression";
|
||||
|
||||
protected Byte scaleImage;
|
||||
|
||||
protected Byte horizontalAlignment;
|
||||
|
||||
protected Byte verticalAlignment;
|
||||
|
||||
protected Boolean isUsingCache = null;
|
||||
|
||||
protected boolean isLazy = false;
|
||||
|
||||
protected byte onErrorType = 1;
|
||||
|
||||
protected byte evaluationTime = 1;
|
||||
|
||||
protected byte hyperlinkType = 0;
|
||||
|
||||
protected String linkType;
|
||||
|
||||
protected byte hyperlinkTarget = 1;
|
||||
|
||||
private List hyperlinkParameters;
|
||||
|
||||
protected JRLineBox lineBox = null;
|
||||
|
||||
protected JRGroup evaluationGroup = null;
|
||||
|
||||
protected JRExpression expression = null;
|
||||
|
||||
protected JRExpression anchorNameExpression = null;
|
||||
|
||||
protected JRExpression hyperlinkReferenceExpression = null;
|
||||
|
||||
protected JRExpression hyperlinkAnchorExpression = null;
|
||||
|
||||
protected JRExpression hyperlinkPageExpression = null;
|
||||
|
||||
private JRExpression hyperlinkTooltipExpression;
|
||||
|
||||
protected int bookmarkLevel = 0;
|
||||
|
||||
private Byte border;
|
||||
|
||||
private Byte topBorder;
|
||||
|
||||
private Byte leftBorder;
|
||||
|
||||
private Byte bottomBorder;
|
||||
|
||||
private Byte rightBorder;
|
||||
|
||||
private Color borderColor;
|
||||
|
||||
private Color topBorderColor;
|
||||
|
||||
private Color leftBorderColor;
|
||||
|
||||
private Color bottomBorderColor;
|
||||
|
||||
private Color rightBorderColor;
|
||||
|
||||
private Integer padding;
|
||||
|
||||
private Integer topPadding;
|
||||
|
||||
private Integer leftPadding;
|
||||
|
||||
private Integer bottomPadding;
|
||||
|
||||
private Integer rightPadding;
|
||||
|
||||
public JRDesignImage(JRDefaultStyleProvider defaultStyleProvider) {
|
||||
super(defaultStyleProvider);
|
||||
this.border = null;
|
||||
this.topBorder = null;
|
||||
this.leftBorder = null;
|
||||
this.bottomBorder = null;
|
||||
this.rightBorder = null;
|
||||
this.borderColor = null;
|
||||
this.topBorderColor = null;
|
||||
this.leftBorderColor = null;
|
||||
this.bottomBorderColor = null;
|
||||
this.rightBorderColor = null;
|
||||
this.padding = null;
|
||||
this.topPadding = null;
|
||||
this.leftPadding = null;
|
||||
this.bottomPadding = null;
|
||||
this.rightPadding = null;
|
||||
this.hyperlinkParameters = new ArrayList();
|
||||
this.lineBox = (JRLineBox)new JRBaseLineBox((JRBoxContainer)this);
|
||||
}
|
||||
|
||||
public byte getMode() {
|
||||
return JRStyleResolver.getMode((JRCommonElement)this, (byte)2);
|
||||
}
|
||||
|
||||
public byte getScaleImage() {
|
||||
return JRStyleResolver.getScaleImage((JRCommonImage)this);
|
||||
}
|
||||
|
||||
public Byte getOwnScaleImage() {
|
||||
return this.scaleImage;
|
||||
}
|
||||
|
||||
public void setScaleImage(byte scaleImage) {
|
||||
setScaleImage(new Byte(scaleImage));
|
||||
}
|
||||
|
||||
public void setScaleImage(Byte scaleImage) {
|
||||
Object old = this.scaleImage;
|
||||
this.scaleImage = scaleImage;
|
||||
getEventSupport().firePropertyChange("scaleImage", old, this.scaleImage);
|
||||
}
|
||||
|
||||
public byte getHorizontalAlignment() {
|
||||
return JRStyleResolver.getHorizontalAlignment((JRAlignment)this);
|
||||
}
|
||||
|
||||
public Byte getOwnHorizontalAlignment() {
|
||||
return this.horizontalAlignment;
|
||||
}
|
||||
|
||||
public void setHorizontalAlignment(byte horizontalAlignment) {
|
||||
setHorizontalAlignment(new Byte(horizontalAlignment));
|
||||
}
|
||||
|
||||
public void setHorizontalAlignment(Byte horizontalAlignment) {
|
||||
Object old = this.horizontalAlignment;
|
||||
this.horizontalAlignment = horizontalAlignment;
|
||||
getEventSupport().firePropertyChange("horizontalAlignment", old, this.horizontalAlignment);
|
||||
}
|
||||
|
||||
public byte getVerticalAlignment() {
|
||||
return JRStyleResolver.getVerticalAlignment((JRAlignment)this);
|
||||
}
|
||||
|
||||
public Byte getOwnVerticalAlignment() {
|
||||
return this.verticalAlignment;
|
||||
}
|
||||
|
||||
public void setVerticalAlignment(byte verticalAlignment) {
|
||||
setVerticalAlignment(new Byte(verticalAlignment));
|
||||
}
|
||||
|
||||
public void setVerticalAlignment(Byte verticalAlignment) {
|
||||
Object old = this.verticalAlignment;
|
||||
this.verticalAlignment = verticalAlignment;
|
||||
getEventSupport().firePropertyChange("verticalAlignment", old, this.verticalAlignment);
|
||||
}
|
||||
|
||||
public boolean isUsingCache() {
|
||||
if (this.isUsingCache == null) {
|
||||
if (getExpression() != null)
|
||||
return String.class.getName().equals(getExpression().getValueClassName());
|
||||
return true;
|
||||
}
|
||||
return this.isUsingCache.booleanValue();
|
||||
}
|
||||
|
||||
public Boolean isOwnUsingCache() {
|
||||
return this.isUsingCache;
|
||||
}
|
||||
|
||||
public byte getEvaluationTime() {
|
||||
return this.evaluationTime;
|
||||
}
|
||||
|
||||
public JRBox getBox() {
|
||||
return (JRBox)new LineBoxWrapper(getLineBox());
|
||||
}
|
||||
|
||||
public JRLineBox getLineBox() {
|
||||
return this.lineBox;
|
||||
}
|
||||
|
||||
public void setBox(JRBox box) {
|
||||
JRBoxUtil.setBoxToLineBox(box, this.lineBox);
|
||||
}
|
||||
|
||||
public byte getHyperlinkType() {
|
||||
return JRHyperlinkHelper.getHyperlinkType((JRHyperlink)this);
|
||||
}
|
||||
|
||||
public byte getHyperlinkTarget() {
|
||||
return this.hyperlinkTarget;
|
||||
}
|
||||
|
||||
public JRGroup getEvaluationGroup() {
|
||||
return this.evaluationGroup;
|
||||
}
|
||||
|
||||
public JRExpression getExpression() {
|
||||
return this.expression;
|
||||
}
|
||||
|
||||
public JRExpression getAnchorNameExpression() {
|
||||
return this.anchorNameExpression;
|
||||
}
|
||||
|
||||
public JRExpression getHyperlinkReferenceExpression() {
|
||||
return this.hyperlinkReferenceExpression;
|
||||
}
|
||||
|
||||
public JRExpression getHyperlinkAnchorExpression() {
|
||||
return this.hyperlinkAnchorExpression;
|
||||
}
|
||||
|
||||
public JRExpression getHyperlinkPageExpression() {
|
||||
return this.hyperlinkPageExpression;
|
||||
}
|
||||
|
||||
public void setUsingCache(boolean isUsingCache) {
|
||||
setUsingCache(isUsingCache ? Boolean.TRUE : Boolean.FALSE);
|
||||
}
|
||||
|
||||
public void setUsingCache(Boolean isUsingCache) {
|
||||
Object old = this.isUsingCache;
|
||||
this.isUsingCache = isUsingCache;
|
||||
getEventSupport().firePropertyChange("usingCache", old, this.isUsingCache);
|
||||
}
|
||||
|
||||
public boolean isLazy() {
|
||||
return this.isLazy;
|
||||
}
|
||||
|
||||
public void setLazy(boolean isLazy) {
|
||||
boolean old = this.isLazy;
|
||||
this.isLazy = isLazy;
|
||||
getEventSupport().firePropertyChange("lazy", old, this.isLazy);
|
||||
}
|
||||
|
||||
public byte getOnErrorType() {
|
||||
return this.onErrorType;
|
||||
}
|
||||
|
||||
public void setOnErrorType(byte onErrorType) {
|
||||
byte old = this.onErrorType;
|
||||
this.onErrorType = onErrorType;
|
||||
getEventSupport().firePropertyChange("onErrorType", old, this.onErrorType);
|
||||
}
|
||||
|
||||
public void setEvaluationTime(byte evaluationTime) {
|
||||
byte old = this.evaluationTime;
|
||||
this.evaluationTime = evaluationTime;
|
||||
getEventSupport().firePropertyChange("evaluationTime", old, this.evaluationTime);
|
||||
}
|
||||
|
||||
public void setHyperlinkType(byte hyperlinkType) {
|
||||
setLinkType(JRHyperlinkHelper.getLinkType(hyperlinkType));
|
||||
}
|
||||
|
||||
public void setHyperlinkTarget(byte hyperlinkTarget) {
|
||||
byte old = this.hyperlinkTarget;
|
||||
this.hyperlinkTarget = hyperlinkTarget;
|
||||
getEventSupport().firePropertyChange("hyperlinkTarget", old, this.hyperlinkTarget);
|
||||
}
|
||||
|
||||
public void setEvaluationGroup(JRGroup evaluationGroup) {
|
||||
Object old = this.evaluationGroup;
|
||||
this.evaluationGroup = evaluationGroup;
|
||||
getEventSupport().firePropertyChange("evaluationGroup", old, this.evaluationGroup);
|
||||
}
|
||||
|
||||
public void setExpression(JRExpression expression) {
|
||||
Object old = this.expression;
|
||||
this.expression = expression;
|
||||
getEventSupport().firePropertyChange("expression", old, this.expression);
|
||||
}
|
||||
|
||||
public void setAnchorNameExpression(JRExpression anchorNameExpression) {
|
||||
Object old = this.anchorNameExpression;
|
||||
this.anchorNameExpression = anchorNameExpression;
|
||||
getEventSupport().firePropertyChange("anchorNameExpression", old, this.anchorNameExpression);
|
||||
}
|
||||
|
||||
public void setHyperlinkReferenceExpression(JRExpression hyperlinkReferenceExpression) {
|
||||
Object old = this.hyperlinkReferenceExpression;
|
||||
this.hyperlinkReferenceExpression = hyperlinkReferenceExpression;
|
||||
getEventSupport().firePropertyChange("hyperlinkReferenceExpression", old, this.hyperlinkReferenceExpression);
|
||||
}
|
||||
|
||||
public void setHyperlinkAnchorExpression(JRExpression hyperlinkAnchorExpression) {
|
||||
Object old = this.hyperlinkAnchorExpression;
|
||||
this.hyperlinkAnchorExpression = hyperlinkAnchorExpression;
|
||||
getEventSupport().firePropertyChange("hyperlinkAnchorExpression", old, this.hyperlinkAnchorExpression);
|
||||
}
|
||||
|
||||
public void setHyperlinkPageExpression(JRExpression hyperlinkPageExpression) {
|
||||
Object old = this.hyperlinkPageExpression;
|
||||
this.hyperlinkPageExpression = hyperlinkPageExpression;
|
||||
getEventSupport().firePropertyChange("hyperlinkPageExpression", old, this.hyperlinkPageExpression);
|
||||
}
|
||||
|
||||
public void visit(JRVisitor visitor) {
|
||||
visitor.visitImage(this);
|
||||
}
|
||||
|
||||
public void collectExpressions(JRExpressionCollector collector) {
|
||||
collector.collect(this);
|
||||
}
|
||||
|
||||
public int getBookmarkLevel() {
|
||||
return this.bookmarkLevel;
|
||||
}
|
||||
|
||||
public void setBookmarkLevel(int bookmarkLevel) {
|
||||
int old = this.bookmarkLevel;
|
||||
this.bookmarkLevel = bookmarkLevel;
|
||||
getEventSupport().firePropertyChange("bookmarkLevel", old, this.bookmarkLevel);
|
||||
}
|
||||
|
||||
public Float getDefaultLineWidth() {
|
||||
return JRPen.LINE_WIDTH_0;
|
||||
}
|
||||
|
||||
public byte getBorder() {
|
||||
return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getPen());
|
||||
}
|
||||
|
||||
public Byte getOwnBorder() {
|
||||
return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getPen());
|
||||
}
|
||||
|
||||
public void setBorder(byte border) {
|
||||
JRPenUtil.setLinePenFromPen(border, (JRPen)this.lineBox.getPen());
|
||||
}
|
||||
|
||||
public void setBorder(Byte border) {
|
||||
JRPenUtil.setLinePenFromPen(border, (JRPen)this.lineBox.getPen());
|
||||
}
|
||||
|
||||
public Color getBorderColor() {
|
||||
return this.lineBox.getPen().getLineColor();
|
||||
}
|
||||
|
||||
public Color getOwnBorderColor() {
|
||||
return this.lineBox.getPen().getOwnLineColor();
|
||||
}
|
||||
|
||||
public void setBorderColor(Color borderColor) {
|
||||
this.lineBox.getPen().setLineColor(borderColor);
|
||||
}
|
||||
|
||||
public int getPadding() {
|
||||
return this.lineBox.getPadding().intValue();
|
||||
}
|
||||
|
||||
public Integer getOwnPadding() {
|
||||
return this.lineBox.getOwnPadding();
|
||||
}
|
||||
|
||||
public void setPadding(int padding) {
|
||||
this.lineBox.setPadding(padding);
|
||||
}
|
||||
|
||||
public void setPadding(Integer padding) {
|
||||
this.lineBox.setPadding(padding);
|
||||
}
|
||||
|
||||
public byte getTopBorder() {
|
||||
return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getTopPen());
|
||||
}
|
||||
|
||||
public Byte getOwnTopBorder() {
|
||||
return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getTopPen());
|
||||
}
|
||||
|
||||
public void setTopBorder(byte topBorder) {
|
||||
JRPenUtil.setLinePenFromPen(topBorder, (JRPen)this.lineBox.getTopPen());
|
||||
}
|
||||
|
||||
public void setTopBorder(Byte topBorder) {
|
||||
JRPenUtil.setLinePenFromPen(topBorder, (JRPen)this.lineBox.getTopPen());
|
||||
}
|
||||
|
||||
public Color getTopBorderColor() {
|
||||
return this.lineBox.getTopPen().getLineColor();
|
||||
}
|
||||
|
||||
public Color getOwnTopBorderColor() {
|
||||
return this.lineBox.getTopPen().getOwnLineColor();
|
||||
}
|
||||
|
||||
public void setTopBorderColor(Color topBorderColor) {
|
||||
this.lineBox.getTopPen().setLineColor(topBorderColor);
|
||||
}
|
||||
|
||||
public int getTopPadding() {
|
||||
return this.lineBox.getTopPadding().intValue();
|
||||
}
|
||||
|
||||
public Integer getOwnTopPadding() {
|
||||
return this.lineBox.getOwnTopPadding();
|
||||
}
|
||||
|
||||
public void setTopPadding(int topPadding) {
|
||||
this.lineBox.setTopPadding(topPadding);
|
||||
}
|
||||
|
||||
public void setTopPadding(Integer topPadding) {
|
||||
this.lineBox.setTopPadding(topPadding);
|
||||
}
|
||||
|
||||
public byte getLeftBorder() {
|
||||
return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getLeftPen());
|
||||
}
|
||||
|
||||
public Byte getOwnLeftBorder() {
|
||||
return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getLeftPen());
|
||||
}
|
||||
|
||||
public void setLeftBorder(byte leftBorder) {
|
||||
JRPenUtil.setLinePenFromPen(leftBorder, (JRPen)this.lineBox.getLeftPen());
|
||||
}
|
||||
|
||||
public void setLeftBorder(Byte leftBorder) {
|
||||
JRPenUtil.setLinePenFromPen(leftBorder, (JRPen)this.lineBox.getLeftPen());
|
||||
}
|
||||
|
||||
public Color getLeftBorderColor() {
|
||||
return this.lineBox.getLeftPen().getLineColor();
|
||||
}
|
||||
|
||||
public Color getOwnLeftBorderColor() {
|
||||
return this.lineBox.getLeftPen().getOwnLineColor();
|
||||
}
|
||||
|
||||
public void setLeftBorderColor(Color leftBorderColor) {
|
||||
this.lineBox.getLeftPen().setLineColor(leftBorderColor);
|
||||
}
|
||||
|
||||
public int getLeftPadding() {
|
||||
return this.lineBox.getLeftPadding().intValue();
|
||||
}
|
||||
|
||||
public Integer getOwnLeftPadding() {
|
||||
return this.lineBox.getOwnLeftPadding();
|
||||
}
|
||||
|
||||
public void setLeftPadding(int leftPadding) {
|
||||
this.lineBox.setLeftPadding(leftPadding);
|
||||
}
|
||||
|
||||
public void setLeftPadding(Integer leftPadding) {
|
||||
this.lineBox.setLeftPadding(leftPadding);
|
||||
}
|
||||
|
||||
public byte getBottomBorder() {
|
||||
return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getBottomPen());
|
||||
}
|
||||
|
||||
public Byte getOwnBottomBorder() {
|
||||
return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getBottomPen());
|
||||
}
|
||||
|
||||
public void setBottomBorder(byte bottomBorder) {
|
||||
JRPenUtil.setLinePenFromPen(bottomBorder, (JRPen)this.lineBox.getBottomPen());
|
||||
}
|
||||
|
||||
public void setBottomBorder(Byte bottomBorder) {
|
||||
JRPenUtil.setLinePenFromPen(bottomBorder, (JRPen)this.lineBox.getBottomPen());
|
||||
}
|
||||
|
||||
public Color getBottomBorderColor() {
|
||||
return this.lineBox.getBottomPen().getLineColor();
|
||||
}
|
||||
|
||||
public Color getOwnBottomBorderColor() {
|
||||
return this.lineBox.getBottomPen().getOwnLineColor();
|
||||
}
|
||||
|
||||
public void setBottomBorderColor(Color bottomBorderColor) {
|
||||
this.lineBox.getBottomPen().setLineColor(bottomBorderColor);
|
||||
}
|
||||
|
||||
public int getBottomPadding() {
|
||||
return this.lineBox.getBottomPadding().intValue();
|
||||
}
|
||||
|
||||
public Integer getOwnBottomPadding() {
|
||||
return this.lineBox.getOwnBottomPadding();
|
||||
}
|
||||
|
||||
public void setBottomPadding(int bottomPadding) {
|
||||
this.lineBox.setBottomPadding(bottomPadding);
|
||||
}
|
||||
|
||||
public void setBottomPadding(Integer bottomPadding) {
|
||||
this.lineBox.setBottomPadding(bottomPadding);
|
||||
}
|
||||
|
||||
public byte getRightBorder() {
|
||||
return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getRightPen());
|
||||
}
|
||||
|
||||
public Byte getOwnRightBorder() {
|
||||
return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getRightPen());
|
||||
}
|
||||
|
||||
public void setRightBorder(byte rightBorder) {
|
||||
JRPenUtil.setLinePenFromPen(rightBorder, (JRPen)this.lineBox.getRightPen());
|
||||
}
|
||||
|
||||
public void setRightBorder(Byte rightBorder) {
|
||||
JRPenUtil.setLinePenFromPen(rightBorder, (JRPen)this.lineBox.getRightPen());
|
||||
}
|
||||
|
||||
public Color getRightBorderColor() {
|
||||
return this.lineBox.getRightPen().getLineColor();
|
||||
}
|
||||
|
||||
public Color getOwnRightBorderColor() {
|
||||
return this.lineBox.getRightPen().getOwnLineColor();
|
||||
}
|
||||
|
||||
public void setRightBorderColor(Color rightBorderColor) {
|
||||
this.lineBox.getRightPen().setLineColor(rightBorderColor);
|
||||
}
|
||||
|
||||
public int getRightPadding() {
|
||||
return this.lineBox.getRightPadding().intValue();
|
||||
}
|
||||
|
||||
public Integer getOwnRightPadding() {
|
||||
return this.lineBox.getOwnRightPadding();
|
||||
}
|
||||
|
||||
public void setRightPadding(int rightPadding) {
|
||||
this.lineBox.setRightPadding(rightPadding);
|
||||
}
|
||||
|
||||
public void setRightPadding(Integer rightPadding) {
|
||||
this.lineBox.setRightPadding(rightPadding);
|
||||
}
|
||||
|
||||
public String getLinkType() {
|
||||
return this.linkType;
|
||||
}
|
||||
|
||||
public void setLinkType(String type) {
|
||||
Object old = this.linkType;
|
||||
this.linkType = type;
|
||||
getEventSupport().firePropertyChange("linkType", old, this.linkType);
|
||||
}
|
||||
|
||||
public JRHyperlinkParameter[] getHyperlinkParameters() {
|
||||
JRHyperlinkParameter[] parameters;
|
||||
if (this.hyperlinkParameters.isEmpty()) {
|
||||
parameters = null;
|
||||
} else {
|
||||
parameters = new JRHyperlinkParameter[this.hyperlinkParameters.size()];
|
||||
this.hyperlinkParameters.toArray((Object[])parameters);
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public List getHyperlinkParametersList() {
|
||||
return this.hyperlinkParameters;
|
||||
}
|
||||
|
||||
public void addHyperlinkParameter(JRHyperlinkParameter parameter) {
|
||||
this.hyperlinkParameters.add(parameter);
|
||||
getEventSupport().fireCollectionElementAddedEvent("hyperlinkParameters", parameter, this.hyperlinkParameters.size() - 1);
|
||||
}
|
||||
|
||||
public void removeHyperlinkParameter(JRHyperlinkParameter parameter) {
|
||||
int idx = this.hyperlinkParameters.indexOf(parameter);
|
||||
if (idx >= 0) {
|
||||
this.hyperlinkParameters.remove(idx);
|
||||
getEventSupport().fireCollectionElementRemovedEvent("hyperlinkParameters", parameter, idx);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeHyperlinkParameter(String parameterName) {
|
||||
for (ListIterator it = this.hyperlinkParameters.listIterator(); it.hasNext(); ) {
|
||||
JRHyperlinkParameter parameter = it.next();
|
||||
if (parameter.getName() != null && parameter.getName().equals(parameterName)) {
|
||||
it.remove();
|
||||
getEventSupport().fireCollectionElementRemovedEvent("hyperlinkParameters", parameter, it.nextIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void normalizeLinkType() {
|
||||
if (this.linkType == null)
|
||||
this.linkType = JRHyperlinkHelper.getLinkType(this.hyperlinkType);
|
||||
this.hyperlinkType = 0;
|
||||
}
|
||||
|
||||
public JRExpression getHyperlinkTooltipExpression() {
|
||||
return this.hyperlinkTooltipExpression;
|
||||
}
|
||||
|
||||
public void setHyperlinkTooltipExpression(JRExpression hyperlinkTooltipExpression) {
|
||||
Object old = this.hyperlinkTooltipExpression;
|
||||
this.hyperlinkTooltipExpression = hyperlinkTooltipExpression;
|
||||
getEventSupport().firePropertyChange("hyperlinkTooltipExpression", old, this.hyperlinkTooltipExpression);
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
JRDesignImage clone = (JRDesignImage)super.clone();
|
||||
if (this.hyperlinkParameters != null) {
|
||||
clone.hyperlinkParameters = new ArrayList(this.hyperlinkParameters.size());
|
||||
for (int i = 0; i < this.hyperlinkParameters.size(); i++)
|
||||
clone.hyperlinkParameters.add(((JRHyperlinkParameter)this.hyperlinkParameters.get(i)).clone());
|
||||
}
|
||||
if (this.expression != null)
|
||||
clone.expression = (JRExpression)this.expression.clone();
|
||||
if (this.anchorNameExpression != null)
|
||||
clone.anchorNameExpression = (JRExpression)this.anchorNameExpression.clone();
|
||||
if (this.hyperlinkReferenceExpression != null)
|
||||
clone.hyperlinkReferenceExpression = (JRExpression)this.hyperlinkReferenceExpression.clone();
|
||||
if (this.hyperlinkAnchorExpression != null)
|
||||
clone.hyperlinkAnchorExpression = (JRExpression)this.hyperlinkAnchorExpression.clone();
|
||||
if (this.hyperlinkPageExpression != null)
|
||||
clone.hyperlinkPageExpression = (JRExpression)this.hyperlinkPageExpression.clone();
|
||||
if (this.hyperlinkTooltipExpression != null)
|
||||
clone.hyperlinkTooltipExpression = (JRExpression)this.hyperlinkTooltipExpression.clone();
|
||||
return clone;
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
if (this.lineBox == null) {
|
||||
this.lineBox = (JRLineBox)new JRBaseLineBox((JRBoxContainer)this);
|
||||
JRBoxUtil.setToBox(this.border, this.topBorder, this.leftBorder, this.bottomBorder, this.rightBorder, this.borderColor, this.topBorderColor, this.leftBorderColor, this.bottomBorderColor, this.rightBorderColor, this.padding, this.topPadding, this.leftPadding, this.bottomPadding, this.rightPadding, this.lineBox);
|
||||
this.border = null;
|
||||
this.topBorder = null;
|
||||
this.leftBorder = null;
|
||||
this.bottomBorder = null;
|
||||
this.rightBorder = null;
|
||||
this.borderColor = null;
|
||||
this.topBorderColor = null;
|
||||
this.leftBorderColor = null;
|
||||
this.bottomBorderColor = null;
|
||||
this.rightBorderColor = null;
|
||||
this.padding = null;
|
||||
this.topPadding = null;
|
||||
this.leftPadding = null;
|
||||
this.bottomPadding = null;
|
||||
this.rightPadding = null;
|
||||
}
|
||||
normalizeLinkType();
|
||||
}
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import net.sf.jasperreports.engine.JRExpression;
|
||||
import net.sf.jasperreports.engine.base.JRBaseParameter;
|
||||
|
||||
public class JRDesignParameter extends JRBaseParameter {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
public static final String PROPERTY_DEFAULT_VALUE_EXPRESSION = "defaultValueExpression";
|
||||
|
||||
public static final String PROPERTY_FOR_PROMPTING = "forPrompting";
|
||||
|
||||
public static final String PROPERTY_NAME = "name";
|
||||
|
||||
public static final String PROPERTY_SYSTEM_DEFINED = "systemDefined";
|
||||
|
||||
public static final String PROPERTY_VALUE_CLASS_NAME = "valueClassName";
|
||||
|
||||
public void setName(String name) {
|
||||
Object old = this.name;
|
||||
this.name = name;
|
||||
getEventSupport().firePropertyChange("name", old, this.name);
|
||||
}
|
||||
|
||||
public void setValueClass(Class clazz) {
|
||||
setValueClassName(clazz.getName());
|
||||
}
|
||||
|
||||
public void setValueClassName(String className) {
|
||||
Object old = this.valueClassName;
|
||||
this.valueClassName = className;
|
||||
this.valueClass = null;
|
||||
this.valueClassRealName = null;
|
||||
getEventSupport().firePropertyChange("valueClassName", old, this.valueClassName);
|
||||
}
|
||||
|
||||
public void setSystemDefined(boolean isSystemDefined) {
|
||||
boolean old = this.isSystemDefined;
|
||||
this.isSystemDefined = isSystemDefined;
|
||||
getEventSupport().firePropertyChange("systemDefined", old, this.isSystemDefined);
|
||||
}
|
||||
|
||||
public void setForPrompting(boolean isForPrompting) {
|
||||
boolean old = this.isForPrompting;
|
||||
this.isForPrompting = isForPrompting;
|
||||
getEventSupport().firePropertyChange("forPrompting", old, this.isForPrompting);
|
||||
}
|
||||
|
||||
public void setDefaultValueExpression(JRExpression expression) {
|
||||
Object old = this.defaultValueExpression;
|
||||
this.defaultValueExpression = expression;
|
||||
getEventSupport().firePropertyChange("defaultValueExpression", old, this.defaultValueExpression);
|
||||
}
|
||||
}
|
140
hrmsEjb/net/sf/jasperreports/engine/design/JRDesignQuery.java
Normal file
140
hrmsEjb/net/sf/jasperreports/engine/design/JRDesignQuery.java
Normal file
@@ -0,0 +1,140 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.sf.jasperreports.engine.JRQueryChunk;
|
||||
import net.sf.jasperreports.engine.base.JRBaseQuery;
|
||||
import net.sf.jasperreports.engine.design.events.JRChangeEventsSupport;
|
||||
import net.sf.jasperreports.engine.design.events.JRPropertyChangeSupport;
|
||||
import net.sf.jasperreports.engine.util.JRQueryChunkHandler;
|
||||
import net.sf.jasperreports.engine.util.JRQueryParser;
|
||||
|
||||
public class JRDesignQuery extends JRBaseQuery implements JRChangeEventsSupport {
|
||||
private transient JRPropertyChangeSupport propSupport;
|
||||
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
public static final String PROPERTY_LANGUAGE = "language";
|
||||
|
||||
public static final String PROPERTY_TEXT = "text";
|
||||
|
||||
protected List chunks = new ArrayList();
|
||||
|
||||
private final transient JRQueryChunkHandler chunkAdder = new JRQueryChunkHandler() {
|
||||
private final JRDesignQuery this$0;
|
||||
|
||||
public void handleParameterChunk(String text) {
|
||||
JRDesignQuery.this.addParameterChunk(text);
|
||||
}
|
||||
|
||||
public void handleParameterClauseChunk(String text) {
|
||||
JRDesignQuery.this.addParameterClauseChunk(text);
|
||||
}
|
||||
|
||||
public void handleTextChunk(String text) {
|
||||
JRDesignQuery.this.addTextChunk(text);
|
||||
}
|
||||
|
||||
public void handleClauseChunk(String[] tokens) {
|
||||
JRDesignQuery.this.addClauseChunk(tokens);
|
||||
}
|
||||
};
|
||||
|
||||
public JRQueryChunk[] getChunks() {
|
||||
JRQueryChunk[] chunkArray = null;
|
||||
if (this.chunks != null && this.chunks.size() > 0) {
|
||||
chunkArray = new JRQueryChunk[this.chunks.size()];
|
||||
this.chunks.toArray((Object[])chunkArray);
|
||||
}
|
||||
return chunkArray;
|
||||
}
|
||||
|
||||
public void setChunks(List chunks) {
|
||||
this.chunks = chunks;
|
||||
}
|
||||
|
||||
public void addChunk(JRDesignQueryChunk chunk) {
|
||||
this.chunks.add(chunk);
|
||||
}
|
||||
|
||||
public void addTextChunk(String text) {
|
||||
JRDesignQueryChunk chunk = new JRDesignQueryChunk();
|
||||
chunk.setType((byte)1);
|
||||
chunk.setText(text);
|
||||
this.chunks.add(chunk);
|
||||
}
|
||||
|
||||
public void addParameterChunk(String text) {
|
||||
JRDesignQueryChunk chunk = new JRDesignQueryChunk();
|
||||
chunk.setType((byte)2);
|
||||
chunk.setText(text);
|
||||
this.chunks.add(chunk);
|
||||
}
|
||||
|
||||
public void addParameterClauseChunk(String text) {
|
||||
JRDesignQueryChunk chunk = new JRDesignQueryChunk();
|
||||
chunk.setType((byte)3);
|
||||
chunk.setText(text);
|
||||
this.chunks.add(chunk);
|
||||
}
|
||||
|
||||
public void addClauseChunk(String[] tokens) {
|
||||
JRDesignQueryChunk chunk = new JRDesignQueryChunk();
|
||||
chunk.setType((byte)4);
|
||||
chunk.setTokens(tokens);
|
||||
this.chunks.add(chunk);
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
Object old = getText();
|
||||
this.chunks = new ArrayList();
|
||||
JRQueryParser.instance().parse(text, this.chunkAdder);
|
||||
getEventSupport().firePropertyChange("text", old, getText());
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
String oldValue = this.language;
|
||||
this.language = language;
|
||||
getPropertyChangeSupport().firePropertyChange("language", oldValue, this.language);
|
||||
}
|
||||
|
||||
public JRPropertyChangeSupport getEventSupport() {
|
||||
synchronized (this) {
|
||||
if (this.propSupport == null)
|
||||
this.propSupport = new JRPropertyChangeSupport(this);
|
||||
}
|
||||
return this.propSupport;
|
||||
}
|
||||
|
||||
protected PropertyChangeSupport getPropertyChangeSupport() {
|
||||
return (PropertyChangeSupport)getEventSupport();
|
||||
}
|
||||
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
getPropertyChangeSupport().addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
public void addPropertyChangeListener(String propName, PropertyChangeListener l) {
|
||||
getPropertyChangeSupport().addPropertyChangeListener(propName, l);
|
||||
}
|
||||
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
getPropertyChangeSupport().removePropertyChangeListener(l);
|
||||
}
|
||||
|
||||
public void removePropertyChangeListener(String propName, PropertyChangeListener l) {
|
||||
getPropertyChangeSupport().removePropertyChangeListener(propName, l);
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
JRDesignQuery clone = (JRDesignQuery)super.clone();
|
||||
if (this.chunks != null) {
|
||||
clone.chunks = new ArrayList(this.chunks.size());
|
||||
for (int i = 0; i < this.chunks.size(); i++)
|
||||
clone.chunks.add(((JRQueryChunk)this.chunks.get(i)).clone());
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import net.sf.jasperreports.engine.base.JRBaseQueryChunk;
|
||||
import net.sf.jasperreports.engine.design.events.JRChangeEventsSupport;
|
||||
import net.sf.jasperreports.engine.design.events.JRPropertyChangeSupport;
|
||||
|
||||
public class JRDesignQueryChunk extends JRBaseQueryChunk implements JRChangeEventsSupport {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
public static final String PROPERTY_TEXT = "text";
|
||||
|
||||
public static final String PROPERTY_TOKENS = "tokens";
|
||||
|
||||
public static final String PROPERTY_TYPE = "type";
|
||||
|
||||
private transient JRPropertyChangeSupport eventSupport;
|
||||
|
||||
public void setType(byte type) {
|
||||
byte old = this.type;
|
||||
this.type = type;
|
||||
getEventSupport().firePropertyChange("type", old, this.type);
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
Object old = this.text;
|
||||
this.text = text;
|
||||
getEventSupport().firePropertyChange("text", old, this.text);
|
||||
}
|
||||
|
||||
public void setTokens(String[] tokens) {
|
||||
Object old = this.tokens;
|
||||
this.tokens = tokens;
|
||||
getEventSupport().firePropertyChange("tokens", old, this.tokens);
|
||||
}
|
||||
|
||||
public JRPropertyChangeSupport getEventSupport() {
|
||||
synchronized (this) {
|
||||
if (this.eventSupport == null)
|
||||
this.eventSupport = new JRPropertyChangeSupport(this);
|
||||
}
|
||||
return this.eventSupport;
|
||||
}
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import net.sf.jasperreports.engine.JRCommonRectangle;
|
||||
import net.sf.jasperreports.engine.JRDefaultStyleProvider;
|
||||
import net.sf.jasperreports.engine.JRExpressionCollector;
|
||||
import net.sf.jasperreports.engine.JRRectangle;
|
||||
import net.sf.jasperreports.engine.JRVisitor;
|
||||
import net.sf.jasperreports.engine.design.events.JRChangeEventsSupport;
|
||||
import net.sf.jasperreports.engine.design.events.JRPropertyChangeSupport;
|
||||
import net.sf.jasperreports.engine.util.JRStyleResolver;
|
||||
|
||||
public class JRDesignRectangle extends JRDesignGraphicElement implements JRRectangle, JRChangeEventsSupport {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
protected Integer radius;
|
||||
|
||||
private transient JRPropertyChangeSupport eventSupport;
|
||||
|
||||
public JRDesignRectangle() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
public JRDesignRectangle(JRDefaultStyleProvider defaultStyleProvider) {
|
||||
super(defaultStyleProvider);
|
||||
}
|
||||
|
||||
public int getRadius() {
|
||||
return JRStyleResolver.getRadius((JRCommonRectangle)this);
|
||||
}
|
||||
|
||||
public Integer getOwnRadius() {
|
||||
return this.radius;
|
||||
}
|
||||
|
||||
public void setRadius(int radius) {
|
||||
setRadius(new Integer(radius));
|
||||
}
|
||||
|
||||
public void setRadius(Integer radius) {
|
||||
Object old = this.radius;
|
||||
this.radius = radius;
|
||||
getEventSupport().firePropertyChange("radius", old, this.radius);
|
||||
}
|
||||
|
||||
public void visit(JRVisitor visitor) {
|
||||
visitor.visitRectangle(this);
|
||||
}
|
||||
|
||||
public void collectExpressions(JRExpressionCollector collector) {
|
||||
collector.collect(this);
|
||||
}
|
||||
|
||||
public JRPropertyChangeSupport getEventSupport() {
|
||||
synchronized (this) {
|
||||
if (this.eventSupport == null)
|
||||
this.eventSupport = new JRPropertyChangeSupport(this);
|
||||
}
|
||||
return this.eventSupport;
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import net.sf.jasperreports.engine.base.JRBaseSubreportReturnValue;
|
||||
import net.sf.jasperreports.engine.design.events.JRChangeEventsSupport;
|
||||
import net.sf.jasperreports.engine.design.events.JRPropertyChangeSupport;
|
||||
|
||||
public class JRDesignSubreportReturnValue extends JRBaseSubreportReturnValue implements JRChangeEventsSupport {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
public static final String PROPERTY_CALCULATION = "calculation";
|
||||
|
||||
public static final String PROPERTY_INCREMENTER_FACTORY_CLASS_NAME = "incrementerFactoryClassName";
|
||||
|
||||
public static final String PROPERTY_SUBREPORT_VARIABLE = "subreportVariable";
|
||||
|
||||
public static final String PROPERTY_TO_VARIABLE = "toVariable";
|
||||
|
||||
private transient JRPropertyChangeSupport eventSupport;
|
||||
|
||||
public void setSubreportVariable(String name) {
|
||||
Object old = this.subreportVariable;
|
||||
this.subreportVariable = name;
|
||||
getEventSupport().firePropertyChange("subreportVariable", old, this.subreportVariable);
|
||||
}
|
||||
|
||||
public void setToVariable(String name) {
|
||||
Object old = this.toVariable;
|
||||
this.toVariable = name;
|
||||
getEventSupport().firePropertyChange("toVariable", old, this.toVariable);
|
||||
}
|
||||
|
||||
public void setCalculation(byte calculation) {
|
||||
byte old = this.calculation;
|
||||
this.calculation = calculation;
|
||||
getEventSupport().firePropertyChange("calculation", old, this.calculation);
|
||||
}
|
||||
|
||||
public void setIncrementerFactoryClassName(String incrementerFactoryClassName) {
|
||||
Object old = this.incrementerFactoryClassName;
|
||||
this.incrementerFactoryClassName = incrementerFactoryClassName;
|
||||
getEventSupport().firePropertyChange("incrementerFactoryClassName", old, this.incrementerFactoryClassName);
|
||||
}
|
||||
|
||||
public JRPropertyChangeSupport getEventSupport() {
|
||||
synchronized (this) {
|
||||
if (this.eventSupport == null)
|
||||
this.eventSupport = new JRPropertyChangeSupport(this);
|
||||
}
|
||||
return this.eventSupport;
|
||||
}
|
||||
}
|
@@ -0,0 +1,700 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import net.sf.jasperreports.engine.JRAlignment;
|
||||
import net.sf.jasperreports.engine.JRBox;
|
||||
import net.sf.jasperreports.engine.JRBoxContainer;
|
||||
import net.sf.jasperreports.engine.JRCommonElement;
|
||||
import net.sf.jasperreports.engine.JRCommonText;
|
||||
import net.sf.jasperreports.engine.JRDefaultStyleProvider;
|
||||
import net.sf.jasperreports.engine.JRFont;
|
||||
import net.sf.jasperreports.engine.JRLineBox;
|
||||
import net.sf.jasperreports.engine.JRPen;
|
||||
import net.sf.jasperreports.engine.JRReportFont;
|
||||
import net.sf.jasperreports.engine.JRStyle;
|
||||
import net.sf.jasperreports.engine.JRTextElement;
|
||||
import net.sf.jasperreports.engine.base.JRBaseLineBox;
|
||||
import net.sf.jasperreports.engine.util.JRBoxUtil;
|
||||
import net.sf.jasperreports.engine.util.JRPenUtil;
|
||||
import net.sf.jasperreports.engine.util.JRStyleResolver;
|
||||
import net.sf.jasperreports.engine.util.LineBoxWrapper;
|
||||
|
||||
public abstract class JRDesignTextElement extends JRDesignElement implements JRTextElement {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
protected Byte horizontalAlignment;
|
||||
|
||||
protected Byte verticalAlignment;
|
||||
|
||||
protected Byte rotation;
|
||||
|
||||
protected Byte lineSpacing;
|
||||
|
||||
protected String markup;
|
||||
|
||||
protected JRLineBox lineBox;
|
||||
|
||||
protected JRReportFont reportFont = null;
|
||||
|
||||
protected String fontName = null;
|
||||
|
||||
protected Boolean isBold = null;
|
||||
|
||||
protected Boolean isItalic = null;
|
||||
|
||||
protected Boolean isUnderline = null;
|
||||
|
||||
protected Boolean isStrikeThrough = null;
|
||||
|
||||
protected Integer fontSize = null;
|
||||
|
||||
protected String pdfFontName = null;
|
||||
|
||||
protected String pdfEncoding = null;
|
||||
|
||||
protected Boolean isPdfEmbedded = null;
|
||||
|
||||
private Byte border;
|
||||
|
||||
private Byte topBorder;
|
||||
|
||||
private Byte leftBorder;
|
||||
|
||||
private Byte bottomBorder;
|
||||
|
||||
private Byte rightBorder;
|
||||
|
||||
private Color borderColor;
|
||||
|
||||
private Color topBorderColor;
|
||||
|
||||
private Color leftBorderColor;
|
||||
|
||||
private Color bottomBorderColor;
|
||||
|
||||
private Color rightBorderColor;
|
||||
|
||||
private Integer padding;
|
||||
|
||||
private Integer topPadding;
|
||||
|
||||
private Integer leftPadding;
|
||||
|
||||
private Integer bottomPadding;
|
||||
|
||||
private Integer rightPadding;
|
||||
|
||||
private Boolean isStyledText;
|
||||
|
||||
protected JRDesignTextElement(JRDefaultStyleProvider defaultStyleProvider) {
|
||||
super(defaultStyleProvider);
|
||||
this.border = null;
|
||||
this.topBorder = null;
|
||||
this.leftBorder = null;
|
||||
this.bottomBorder = null;
|
||||
this.rightBorder = null;
|
||||
this.borderColor = null;
|
||||
this.topBorderColor = null;
|
||||
this.leftBorderColor = null;
|
||||
this.bottomBorderColor = null;
|
||||
this.rightBorderColor = null;
|
||||
this.padding = null;
|
||||
this.topPadding = null;
|
||||
this.leftPadding = null;
|
||||
this.bottomPadding = null;
|
||||
this.rightPadding = null;
|
||||
this.isStyledText = null;
|
||||
this.lineBox = (JRLineBox)new JRBaseLineBox((JRBoxContainer)this);
|
||||
}
|
||||
|
||||
protected JRFont getBaseFont() {
|
||||
if (this.reportFont != null)
|
||||
return (JRFont)this.reportFont;
|
||||
if (this.defaultStyleProvider != null)
|
||||
return (JRFont)this.defaultStyleProvider.getDefaultFont();
|
||||
return null;
|
||||
}
|
||||
|
||||
public byte getMode() {
|
||||
return JRStyleResolver.getMode((JRCommonElement)this, (byte)2);
|
||||
}
|
||||
|
||||
public byte getTextAlignment() {
|
||||
if (this.horizontalAlignment == null) {
|
||||
JRStyle style = getBaseStyle();
|
||||
if (style != null && style.getHorizontalAlignment() != null)
|
||||
return style.getHorizontalAlignment().byteValue();
|
||||
return 1;
|
||||
}
|
||||
return this.horizontalAlignment.byteValue();
|
||||
}
|
||||
|
||||
public void setTextAlignment(byte horizontalAlignment) {
|
||||
setHorizontalAlignment(new Byte(horizontalAlignment));
|
||||
}
|
||||
|
||||
public byte getHorizontalAlignment() {
|
||||
return JRStyleResolver.getHorizontalAlignment((JRAlignment)this);
|
||||
}
|
||||
|
||||
public Byte getOwnHorizontalAlignment() {
|
||||
return this.horizontalAlignment;
|
||||
}
|
||||
|
||||
public void setHorizontalAlignment(byte horizontalAlignment) {
|
||||
setHorizontalAlignment(new Byte(horizontalAlignment));
|
||||
}
|
||||
|
||||
public void setHorizontalAlignment(Byte horizontalAlignment) {
|
||||
Object old = this.horizontalAlignment;
|
||||
this.horizontalAlignment = horizontalAlignment;
|
||||
getEventSupport().firePropertyChange("horizontalAlignment", old, this.horizontalAlignment);
|
||||
}
|
||||
|
||||
public byte getVerticalAlignment() {
|
||||
return JRStyleResolver.getVerticalAlignment((JRAlignment)this);
|
||||
}
|
||||
|
||||
public Byte getOwnVerticalAlignment() {
|
||||
return this.verticalAlignment;
|
||||
}
|
||||
|
||||
public void setVerticalAlignment(byte verticalAlignment) {
|
||||
setVerticalAlignment(new Byte(verticalAlignment));
|
||||
}
|
||||
|
||||
public void setVerticalAlignment(Byte verticalAlignment) {
|
||||
Object old = this.verticalAlignment;
|
||||
this.verticalAlignment = verticalAlignment;
|
||||
getEventSupport().firePropertyChange("verticalAlignment", old, this.verticalAlignment);
|
||||
}
|
||||
|
||||
public byte getRotation() {
|
||||
return JRStyleResolver.getRotation((JRCommonText)this);
|
||||
}
|
||||
|
||||
public Byte getOwnRotation() {
|
||||
return this.rotation;
|
||||
}
|
||||
|
||||
public void setRotation(byte rotation) {
|
||||
setRotation(new Byte(rotation));
|
||||
}
|
||||
|
||||
public void setRotation(Byte rotation) {
|
||||
Object old = this.rotation;
|
||||
this.rotation = rotation;
|
||||
getEventSupport().firePropertyChange("rotation", old, this.rotation);
|
||||
}
|
||||
|
||||
public byte getLineSpacing() {
|
||||
return JRStyleResolver.getLineSpacing((JRCommonText)this);
|
||||
}
|
||||
|
||||
public Byte getOwnLineSpacing() {
|
||||
return this.lineSpacing;
|
||||
}
|
||||
|
||||
public void setLineSpacing(byte lineSpacing) {
|
||||
setLineSpacing(new Byte(lineSpacing));
|
||||
}
|
||||
|
||||
public void setLineSpacing(Byte lineSpacing) {
|
||||
Object old = this.lineSpacing;
|
||||
this.lineSpacing = lineSpacing;
|
||||
getEventSupport().firePropertyChange("lineSpacing", old, this.lineSpacing);
|
||||
}
|
||||
|
||||
public boolean isStyledText() {
|
||||
return "styled".equals(getMarkup());
|
||||
}
|
||||
|
||||
public Boolean isOwnStyledText() {
|
||||
String mkp = getOwnMarkup();
|
||||
return "styled".equals(mkp) ? Boolean.TRUE : ((mkp == null) ? null : Boolean.FALSE);
|
||||
}
|
||||
|
||||
public void setStyledText(boolean isStyledText) {
|
||||
setStyledText(isStyledText ? Boolean.TRUE : Boolean.FALSE);
|
||||
}
|
||||
|
||||
public void setStyledText(Boolean isStyledText) {
|
||||
if (isStyledText == null) {
|
||||
setMarkup((String)null);
|
||||
} else {
|
||||
setMarkup(isStyledText.booleanValue() ? "styled" : "none");
|
||||
}
|
||||
}
|
||||
|
||||
public String getMarkup() {
|
||||
return JRStyleResolver.getMarkup((JRCommonText)this);
|
||||
}
|
||||
|
||||
public String getOwnMarkup() {
|
||||
return this.markup;
|
||||
}
|
||||
|
||||
public void setMarkup(String markup) {
|
||||
Object old = this.markup;
|
||||
this.markup = markup;
|
||||
getEventSupport().firePropertyChange("markup", old, this.markup);
|
||||
}
|
||||
|
||||
public JRBox getBox() {
|
||||
return (JRBox)new LineBoxWrapper(getLineBox());
|
||||
}
|
||||
|
||||
public JRLineBox getLineBox() {
|
||||
return this.lineBox;
|
||||
}
|
||||
|
||||
public void setBox(JRBox box) {
|
||||
JRBoxUtil.setBoxToLineBox(box, this.lineBox);
|
||||
}
|
||||
|
||||
public JRFont getFont() {
|
||||
return (JRFont)this;
|
||||
}
|
||||
|
||||
public void setFont(JRFont font) {
|
||||
setReportFont(font.getReportFont());
|
||||
setFontName(font.getOwnFontName());
|
||||
setBold(font.isOwnBold());
|
||||
setItalic(font.isOwnItalic());
|
||||
setUnderline(font.isOwnUnderline());
|
||||
setStrikeThrough(font.isOwnStrikeThrough());
|
||||
setFontSize(font.getOwnSize());
|
||||
setPdfFontName(font.getOwnPdfFontName());
|
||||
setPdfEncoding(font.getOwnPdfEncoding());
|
||||
setPdfEmbedded(font.isOwnPdfEmbedded());
|
||||
}
|
||||
|
||||
public byte getBorder() {
|
||||
return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getPen());
|
||||
}
|
||||
|
||||
public Byte getOwnBorder() {
|
||||
return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getPen());
|
||||
}
|
||||
|
||||
public void setBorder(byte border) {
|
||||
JRPenUtil.setLinePenFromPen(border, (JRPen)this.lineBox.getPen());
|
||||
}
|
||||
|
||||
public void setBorder(Byte border) {
|
||||
JRPenUtil.setLinePenFromPen(border, (JRPen)this.lineBox.getPen());
|
||||
}
|
||||
|
||||
public Color getBorderColor() {
|
||||
return this.lineBox.getPen().getLineColor();
|
||||
}
|
||||
|
||||
public Color getOwnBorderColor() {
|
||||
return this.lineBox.getPen().getOwnLineColor();
|
||||
}
|
||||
|
||||
public void setBorderColor(Color borderColor) {
|
||||
this.lineBox.getPen().setLineColor(borderColor);
|
||||
}
|
||||
|
||||
public int getPadding() {
|
||||
return this.lineBox.getPadding().intValue();
|
||||
}
|
||||
|
||||
public Integer getOwnPadding() {
|
||||
return this.lineBox.getOwnPadding();
|
||||
}
|
||||
|
||||
public void setPadding(int padding) {
|
||||
this.lineBox.setPadding(padding);
|
||||
}
|
||||
|
||||
public void setPadding(Integer padding) {
|
||||
this.lineBox.setPadding(padding);
|
||||
}
|
||||
|
||||
public byte getTopBorder() {
|
||||
return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getTopPen());
|
||||
}
|
||||
|
||||
public Byte getOwnTopBorder() {
|
||||
return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getTopPen());
|
||||
}
|
||||
|
||||
public void setTopBorder(byte topBorder) {
|
||||
JRPenUtil.setLinePenFromPen(topBorder, (JRPen)this.lineBox.getTopPen());
|
||||
}
|
||||
|
||||
public void setTopBorder(Byte topBorder) {
|
||||
JRPenUtil.setLinePenFromPen(topBorder, (JRPen)this.lineBox.getTopPen());
|
||||
}
|
||||
|
||||
public Color getTopBorderColor() {
|
||||
return this.lineBox.getTopPen().getLineColor();
|
||||
}
|
||||
|
||||
public Color getOwnTopBorderColor() {
|
||||
return this.lineBox.getTopPen().getOwnLineColor();
|
||||
}
|
||||
|
||||
public void setTopBorderColor(Color topBorderColor) {
|
||||
this.lineBox.getTopPen().setLineColor(topBorderColor);
|
||||
}
|
||||
|
||||
public int getTopPadding() {
|
||||
return this.lineBox.getTopPadding().intValue();
|
||||
}
|
||||
|
||||
public Integer getOwnTopPadding() {
|
||||
return this.lineBox.getOwnTopPadding();
|
||||
}
|
||||
|
||||
public void setTopPadding(int topPadding) {
|
||||
this.lineBox.setTopPadding(topPadding);
|
||||
}
|
||||
|
||||
public void setTopPadding(Integer topPadding) {
|
||||
this.lineBox.setTopPadding(topPadding);
|
||||
}
|
||||
|
||||
public byte getLeftBorder() {
|
||||
return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getLeftPen());
|
||||
}
|
||||
|
||||
public Byte getOwnLeftBorder() {
|
||||
return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getLeftPen());
|
||||
}
|
||||
|
||||
public void setLeftBorder(byte leftBorder) {
|
||||
JRPenUtil.setLinePenFromPen(leftBorder, (JRPen)this.lineBox.getLeftPen());
|
||||
}
|
||||
|
||||
public void setLeftBorder(Byte leftBorder) {
|
||||
JRPenUtil.setLinePenFromPen(leftBorder, (JRPen)this.lineBox.getLeftPen());
|
||||
}
|
||||
|
||||
public Color getLeftBorderColor() {
|
||||
return this.lineBox.getLeftPen().getLineColor();
|
||||
}
|
||||
|
||||
public Color getOwnLeftBorderColor() {
|
||||
return this.lineBox.getLeftPen().getOwnLineColor();
|
||||
}
|
||||
|
||||
public void setLeftBorderColor(Color leftBorderColor) {
|
||||
this.lineBox.getLeftPen().setLineColor(leftBorderColor);
|
||||
}
|
||||
|
||||
public int getLeftPadding() {
|
||||
return this.lineBox.getLeftPadding().intValue();
|
||||
}
|
||||
|
||||
public Integer getOwnLeftPadding() {
|
||||
return this.lineBox.getOwnLeftPadding();
|
||||
}
|
||||
|
||||
public void setLeftPadding(int leftPadding) {
|
||||
this.lineBox.setLeftPadding(leftPadding);
|
||||
}
|
||||
|
||||
public void setLeftPadding(Integer leftPadding) {
|
||||
this.lineBox.setLeftPadding(leftPadding);
|
||||
}
|
||||
|
||||
public byte getBottomBorder() {
|
||||
return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getBottomPen());
|
||||
}
|
||||
|
||||
public Byte getOwnBottomBorder() {
|
||||
return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getBottomPen());
|
||||
}
|
||||
|
||||
public void setBottomBorder(byte bottomBorder) {
|
||||
JRPenUtil.setLinePenFromPen(bottomBorder, (JRPen)this.lineBox.getBottomPen());
|
||||
}
|
||||
|
||||
public void setBottomBorder(Byte bottomBorder) {
|
||||
JRPenUtil.setLinePenFromPen(bottomBorder, (JRPen)this.lineBox.getBottomPen());
|
||||
}
|
||||
|
||||
public Color getBottomBorderColor() {
|
||||
return this.lineBox.getBottomPen().getLineColor();
|
||||
}
|
||||
|
||||
public Color getOwnBottomBorderColor() {
|
||||
return this.lineBox.getBottomPen().getOwnLineColor();
|
||||
}
|
||||
|
||||
public void setBottomBorderColor(Color bottomBorderColor) {
|
||||
this.lineBox.getBottomPen().setLineColor(bottomBorderColor);
|
||||
}
|
||||
|
||||
public int getBottomPadding() {
|
||||
return this.lineBox.getBottomPadding().intValue();
|
||||
}
|
||||
|
||||
public Integer getOwnBottomPadding() {
|
||||
return this.lineBox.getOwnBottomPadding();
|
||||
}
|
||||
|
||||
public void setBottomPadding(int bottomPadding) {
|
||||
this.lineBox.setBottomPadding(bottomPadding);
|
||||
}
|
||||
|
||||
public void setBottomPadding(Integer bottomPadding) {
|
||||
this.lineBox.setBottomPadding(bottomPadding);
|
||||
}
|
||||
|
||||
public byte getRightBorder() {
|
||||
return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getRightPen());
|
||||
}
|
||||
|
||||
public Byte getOwnRightBorder() {
|
||||
return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getRightPen());
|
||||
}
|
||||
|
||||
public void setRightBorder(byte rightBorder) {
|
||||
JRPenUtil.setLinePenFromPen(rightBorder, (JRPen)this.lineBox.getRightPen());
|
||||
}
|
||||
|
||||
public void setRightBorder(Byte rightBorder) {
|
||||
JRPenUtil.setLinePenFromPen(rightBorder, (JRPen)this.lineBox.getRightPen());
|
||||
}
|
||||
|
||||
public Color getRightBorderColor() {
|
||||
return this.lineBox.getRightPen().getLineColor();
|
||||
}
|
||||
|
||||
public Color getOwnRightBorderColor() {
|
||||
return this.lineBox.getRightPen().getOwnLineColor();
|
||||
}
|
||||
|
||||
public void setRightBorderColor(Color rightBorderColor) {
|
||||
this.lineBox.getRightPen().setLineColor(rightBorderColor);
|
||||
}
|
||||
|
||||
public int getRightPadding() {
|
||||
return this.lineBox.getRightPadding().intValue();
|
||||
}
|
||||
|
||||
public Integer getOwnRightPadding() {
|
||||
return this.lineBox.getOwnRightPadding();
|
||||
}
|
||||
|
||||
public void setRightPadding(int rightPadding) {
|
||||
this.lineBox.setRightPadding(rightPadding);
|
||||
}
|
||||
|
||||
public void setRightPadding(Integer rightPadding) {
|
||||
this.lineBox.setRightPadding(rightPadding);
|
||||
}
|
||||
|
||||
public JRReportFont getReportFont() {
|
||||
return this.reportFont;
|
||||
}
|
||||
|
||||
public void setReportFont(JRReportFont reportFont) {
|
||||
Object old = this.reportFont;
|
||||
this.reportFont = reportFont;
|
||||
getEventSupport().firePropertyChange("reportFont", old, this.reportFont);
|
||||
}
|
||||
|
||||
public String getFontName() {
|
||||
return JRStyleResolver.getFontName((JRFont)this);
|
||||
}
|
||||
|
||||
public String getOwnFontName() {
|
||||
return this.fontName;
|
||||
}
|
||||
|
||||
public void setFontName(String fontName) {
|
||||
Object old = this.fontName;
|
||||
this.fontName = fontName;
|
||||
getEventSupport().firePropertyChange("fontName", old, this.fontName);
|
||||
}
|
||||
|
||||
public boolean isBold() {
|
||||
return JRStyleResolver.isBold((JRFont)this);
|
||||
}
|
||||
|
||||
public Boolean isOwnBold() {
|
||||
return this.isBold;
|
||||
}
|
||||
|
||||
public void setBold(boolean isBold) {
|
||||
setBold(isBold ? Boolean.TRUE : Boolean.FALSE);
|
||||
}
|
||||
|
||||
public void setBold(Boolean isBold) {
|
||||
Object old = this.isBold;
|
||||
this.isBold = isBold;
|
||||
getEventSupport().firePropertyChange("bold", old, this.isBold);
|
||||
}
|
||||
|
||||
public boolean isItalic() {
|
||||
return JRStyleResolver.isItalic((JRFont)this);
|
||||
}
|
||||
|
||||
public Boolean isOwnItalic() {
|
||||
return this.isItalic;
|
||||
}
|
||||
|
||||
public void setItalic(boolean isItalic) {
|
||||
setItalic(isItalic ? Boolean.TRUE : Boolean.FALSE);
|
||||
}
|
||||
|
||||
public void setItalic(Boolean isItalic) {
|
||||
Object old = this.isItalic;
|
||||
this.isItalic = isItalic;
|
||||
getEventSupport().firePropertyChange("italic", old, this.isItalic);
|
||||
}
|
||||
|
||||
public boolean isUnderline() {
|
||||
return JRStyleResolver.isUnderline((JRFont)this);
|
||||
}
|
||||
|
||||
public Boolean isOwnUnderline() {
|
||||
return this.isUnderline;
|
||||
}
|
||||
|
||||
public void setUnderline(boolean isUnderline) {
|
||||
setUnderline(isUnderline ? Boolean.TRUE : Boolean.FALSE);
|
||||
}
|
||||
|
||||
public void setUnderline(Boolean isUnderline) {
|
||||
Object old = this.isUnderline;
|
||||
this.isUnderline = isUnderline;
|
||||
getEventSupport().firePropertyChange("underline", old, this.isUnderline);
|
||||
}
|
||||
|
||||
public boolean isStrikeThrough() {
|
||||
return JRStyleResolver.isStrikeThrough((JRFont)this);
|
||||
}
|
||||
|
||||
public Boolean isOwnStrikeThrough() {
|
||||
return this.isStrikeThrough;
|
||||
}
|
||||
|
||||
public void setStrikeThrough(boolean isStrikeThrough) {
|
||||
setStrikeThrough(isStrikeThrough ? Boolean.TRUE : Boolean.FALSE);
|
||||
}
|
||||
|
||||
public void setStrikeThrough(Boolean isStrikeThrough) {
|
||||
Object old = this.isStrikeThrough;
|
||||
this.isStrikeThrough = isStrikeThrough;
|
||||
getEventSupport().firePropertyChange("strikeThrough", old, this.isStrikeThrough);
|
||||
}
|
||||
|
||||
public int getFontSize() {
|
||||
return JRStyleResolver.getFontSize((JRFont)this);
|
||||
}
|
||||
|
||||
public Integer getOwnFontSize() {
|
||||
return this.fontSize;
|
||||
}
|
||||
|
||||
public void setFontSize(int fontSize) {
|
||||
setFontSize(new Integer(fontSize));
|
||||
}
|
||||
|
||||
public void setFontSize(Integer fontSize) {
|
||||
Object old = this.fontSize;
|
||||
this.fontSize = fontSize;
|
||||
getEventSupport().firePropertyChange("fontSize", old, this.fontSize);
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return getFontSize();
|
||||
}
|
||||
|
||||
public Integer getOwnSize() {
|
||||
return getOwnFontSize();
|
||||
}
|
||||
|
||||
public void setSize(int size) {
|
||||
setFontSize(size);
|
||||
}
|
||||
|
||||
public void setSize(Integer size) {
|
||||
setFontSize(size);
|
||||
}
|
||||
|
||||
public String getPdfFontName() {
|
||||
return JRStyleResolver.getPdfFontName((JRFont)this);
|
||||
}
|
||||
|
||||
public String getOwnPdfFontName() {
|
||||
return this.pdfFontName;
|
||||
}
|
||||
|
||||
public void setPdfFontName(String pdfFontName) {
|
||||
Object old = this.pdfFontName;
|
||||
this.pdfFontName = pdfFontName;
|
||||
getEventSupport().firePropertyChange("pdfFontName", old, this.pdfFontName);
|
||||
}
|
||||
|
||||
public String getPdfEncoding() {
|
||||
return JRStyleResolver.getPdfEncoding((JRFont)this);
|
||||
}
|
||||
|
||||
public String getOwnPdfEncoding() {
|
||||
return this.pdfEncoding;
|
||||
}
|
||||
|
||||
public void setPdfEncoding(String pdfEncoding) {
|
||||
Object old = this.pdfEncoding;
|
||||
this.pdfEncoding = pdfEncoding;
|
||||
getEventSupport().firePropertyChange("pdfEncoding", old, this.pdfEncoding);
|
||||
}
|
||||
|
||||
public boolean isPdfEmbedded() {
|
||||
return JRStyleResolver.isPdfEmbedded((JRFont)this);
|
||||
}
|
||||
|
||||
public Boolean isOwnPdfEmbedded() {
|
||||
return this.isPdfEmbedded;
|
||||
}
|
||||
|
||||
public void setPdfEmbedded(boolean isPdfEmbedded) {
|
||||
setPdfEmbedded(isPdfEmbedded ? Boolean.TRUE : Boolean.FALSE);
|
||||
}
|
||||
|
||||
public void setPdfEmbedded(Boolean isPdfEmbedded) {
|
||||
Object old = this.isPdfEmbedded;
|
||||
this.isPdfEmbedded = isPdfEmbedded;
|
||||
getEventSupport().firePropertyChange("pdfEmbedded", old, this.isPdfEmbedded);
|
||||
}
|
||||
|
||||
public Color getDefaultLineColor() {
|
||||
return getForecolor();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
if (this.lineBox == null) {
|
||||
this.lineBox = (JRLineBox)new JRBaseLineBox((JRBoxContainer)this);
|
||||
JRBoxUtil.setToBox(this.border, this.topBorder, this.leftBorder, this.bottomBorder, this.rightBorder, this.borderColor, this.topBorderColor, this.leftBorderColor, this.bottomBorderColor, this.rightBorderColor, this.padding, this.topPadding, this.leftPadding, this.bottomPadding, this.rightPadding, this.lineBox);
|
||||
this.border = null;
|
||||
this.topBorder = null;
|
||||
this.leftBorder = null;
|
||||
this.bottomBorder = null;
|
||||
this.rightBorder = null;
|
||||
this.borderColor = null;
|
||||
this.topBorderColor = null;
|
||||
this.leftBorderColor = null;
|
||||
this.bottomBorderColor = null;
|
||||
this.rightBorderColor = null;
|
||||
this.padding = null;
|
||||
this.topPadding = null;
|
||||
this.leftPadding = null;
|
||||
this.bottomPadding = null;
|
||||
this.rightPadding = null;
|
||||
}
|
||||
if (this.isStyledText != null) {
|
||||
this.markup = this.isStyledText.booleanValue() ? "styled" : "none";
|
||||
this.isStyledText = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,312 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import net.sf.jasperreports.engine.JRDefaultStyleProvider;
|
||||
import net.sf.jasperreports.engine.JRExpression;
|
||||
import net.sf.jasperreports.engine.JRExpressionCollector;
|
||||
import net.sf.jasperreports.engine.JRGroup;
|
||||
import net.sf.jasperreports.engine.JRHyperlink;
|
||||
import net.sf.jasperreports.engine.JRHyperlinkHelper;
|
||||
import net.sf.jasperreports.engine.JRHyperlinkParameter;
|
||||
import net.sf.jasperreports.engine.JRTextField;
|
||||
import net.sf.jasperreports.engine.JRVisitor;
|
||||
import net.sf.jasperreports.engine.util.JRStyleResolver;
|
||||
|
||||
public class JRDesignTextField extends JRDesignTextElement implements JRTextField {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
public static final String PROPERTY_ANCHOR_NAME_EXPRESSION = "anchorNameExpression";
|
||||
|
||||
public static final String PROPERTY_BOOKMARK_LEVEL = "bookmarkLevel";
|
||||
|
||||
public static final String PROPERTY_EVALUATION_GROUP = "evaluationGroup";
|
||||
|
||||
public static final String PROPERTY_EVALUATION_TIME = "evaluationTime";
|
||||
|
||||
public static final String PROPERTY_EXPRESSION = "expression";
|
||||
|
||||
protected boolean isStretchWithOverflow = false;
|
||||
|
||||
protected byte evaluationTime = 1;
|
||||
|
||||
protected String pattern = null;
|
||||
|
||||
protected Boolean isBlankWhenNull = null;
|
||||
|
||||
protected byte hyperlinkType = 0;
|
||||
|
||||
protected String linkType;
|
||||
|
||||
protected byte hyperlinkTarget = 1;
|
||||
|
||||
private List hyperlinkParameters;
|
||||
|
||||
protected JRGroup evaluationGroup = null;
|
||||
|
||||
protected JRExpression expression = null;
|
||||
|
||||
protected JRExpression anchorNameExpression = null;
|
||||
|
||||
protected JRExpression hyperlinkReferenceExpression = null;
|
||||
|
||||
protected JRExpression hyperlinkAnchorExpression = null;
|
||||
|
||||
protected JRExpression hyperlinkPageExpression = null;
|
||||
|
||||
private JRExpression hyperlinkTooltipExpression;
|
||||
|
||||
protected int bookmarkLevel = 0;
|
||||
|
||||
public JRDesignTextField() {
|
||||
super((JRDefaultStyleProvider)null);
|
||||
this.hyperlinkParameters = new ArrayList();
|
||||
}
|
||||
|
||||
public JRDesignTextField(JRDefaultStyleProvider defaultStyleProvider) {
|
||||
super(defaultStyleProvider);
|
||||
this.hyperlinkParameters = new ArrayList();
|
||||
}
|
||||
|
||||
public boolean isStretchWithOverflow() {
|
||||
return this.isStretchWithOverflow;
|
||||
}
|
||||
|
||||
public byte getEvaluationTime() {
|
||||
return this.evaluationTime;
|
||||
}
|
||||
|
||||
public String getPattern() {
|
||||
return JRStyleResolver.getPattern(this);
|
||||
}
|
||||
|
||||
public String getOwnPattern() {
|
||||
return this.pattern;
|
||||
}
|
||||
|
||||
public boolean isBlankWhenNull() {
|
||||
return JRStyleResolver.isBlankWhenNull(this);
|
||||
}
|
||||
|
||||
public Boolean isOwnBlankWhenNull() {
|
||||
return this.isBlankWhenNull;
|
||||
}
|
||||
|
||||
public byte getHyperlinkType() {
|
||||
return JRHyperlinkHelper.getHyperlinkType((JRHyperlink)this);
|
||||
}
|
||||
|
||||
public byte getHyperlinkTarget() {
|
||||
return this.hyperlinkTarget;
|
||||
}
|
||||
|
||||
public JRGroup getEvaluationGroup() {
|
||||
return this.evaluationGroup;
|
||||
}
|
||||
|
||||
public JRExpression getExpression() {
|
||||
return this.expression;
|
||||
}
|
||||
|
||||
public JRExpression getAnchorNameExpression() {
|
||||
return this.anchorNameExpression;
|
||||
}
|
||||
|
||||
public JRExpression getHyperlinkReferenceExpression() {
|
||||
return this.hyperlinkReferenceExpression;
|
||||
}
|
||||
|
||||
public JRExpression getHyperlinkAnchorExpression() {
|
||||
return this.hyperlinkAnchorExpression;
|
||||
}
|
||||
|
||||
public JRExpression getHyperlinkPageExpression() {
|
||||
return this.hyperlinkPageExpression;
|
||||
}
|
||||
|
||||
public void setStretchWithOverflow(boolean isStretch) {
|
||||
boolean old = this.isStretchWithOverflow;
|
||||
this.isStretchWithOverflow = isStretch;
|
||||
getEventSupport().firePropertyChange("stretchWithOverflow", old, this.isStretchWithOverflow);
|
||||
}
|
||||
|
||||
public void setEvaluationTime(byte evaluationTime) {
|
||||
byte old = this.evaluationTime;
|
||||
this.evaluationTime = evaluationTime;
|
||||
getEventSupport().firePropertyChange("evaluationTime", old, this.evaluationTime);
|
||||
}
|
||||
|
||||
public void setPattern(String pattern) {
|
||||
Object old = this.pattern;
|
||||
this.pattern = pattern;
|
||||
getEventSupport().firePropertyChange("pattern", old, this.pattern);
|
||||
}
|
||||
|
||||
public void setBlankWhenNull(boolean isBlank) {
|
||||
setBlankWhenNull(isBlank ? Boolean.TRUE : Boolean.FALSE);
|
||||
}
|
||||
|
||||
public void setBlankWhenNull(Boolean isBlank) {
|
||||
Object old = this.isBlankWhenNull;
|
||||
this.isBlankWhenNull = isBlank;
|
||||
getEventSupport().firePropertyChange("blankWhenNull", old, this.isBlankWhenNull);
|
||||
}
|
||||
|
||||
public void setHyperlinkType(byte hyperlinkType) {
|
||||
setLinkType(JRHyperlinkHelper.getLinkType(hyperlinkType));
|
||||
}
|
||||
|
||||
public void setHyperlinkTarget(byte hyperlinkTarget) {
|
||||
byte old = this.hyperlinkTarget;
|
||||
this.hyperlinkTarget = hyperlinkTarget;
|
||||
getEventSupport().firePropertyChange("hyperlinkTarget", old, this.hyperlinkTarget);
|
||||
}
|
||||
|
||||
public void setEvaluationGroup(JRGroup evaluationGroup) {
|
||||
Object old = this.evaluationGroup;
|
||||
this.evaluationGroup = evaluationGroup;
|
||||
getEventSupport().firePropertyChange("evaluationGroup", old, this.evaluationGroup);
|
||||
}
|
||||
|
||||
public void setExpression(JRExpression expression) {
|
||||
Object old = this.expression;
|
||||
this.expression = expression;
|
||||
getEventSupport().firePropertyChange("expression", old, this.expression);
|
||||
}
|
||||
|
||||
public void setAnchorNameExpression(JRExpression anchorNameExpression) {
|
||||
Object old = this.anchorNameExpression;
|
||||
this.anchorNameExpression = anchorNameExpression;
|
||||
getEventSupport().firePropertyChange("anchorNameExpression", old, this.anchorNameExpression);
|
||||
}
|
||||
|
||||
public void setHyperlinkReferenceExpression(JRExpression hyperlinkReferenceExpression) {
|
||||
Object old = this.hyperlinkReferenceExpression;
|
||||
this.hyperlinkReferenceExpression = hyperlinkReferenceExpression;
|
||||
getEventSupport().firePropertyChange("hyperlinkReferenceExpression", old, this.hyperlinkReferenceExpression);
|
||||
}
|
||||
|
||||
public void setHyperlinkAnchorExpression(JRExpression hyperlinkAnchorExpression) {
|
||||
Object old = this.hyperlinkAnchorExpression;
|
||||
this.hyperlinkAnchorExpression = hyperlinkAnchorExpression;
|
||||
getEventSupport().firePropertyChange("hyperlinkAnchorExpression", old, this.hyperlinkAnchorExpression);
|
||||
}
|
||||
|
||||
public void setHyperlinkPageExpression(JRExpression hyperlinkPageExpression) {
|
||||
Object old = this.hyperlinkPageExpression;
|
||||
this.hyperlinkPageExpression = hyperlinkPageExpression;
|
||||
getEventSupport().firePropertyChange("hyperlinkPageExpression", old, this.hyperlinkPageExpression);
|
||||
}
|
||||
|
||||
public void collectExpressions(JRExpressionCollector collector) {
|
||||
collector.collect(this);
|
||||
}
|
||||
|
||||
public void visit(JRVisitor visitor) {
|
||||
visitor.visitTextField(this);
|
||||
}
|
||||
|
||||
public int getBookmarkLevel() {
|
||||
return this.bookmarkLevel;
|
||||
}
|
||||
|
||||
public void setBookmarkLevel(int bookmarkLevel) {
|
||||
int old = this.bookmarkLevel;
|
||||
this.bookmarkLevel = bookmarkLevel;
|
||||
getEventSupport().firePropertyChange("bookmarkLevel", old, this.bookmarkLevel);
|
||||
}
|
||||
|
||||
public String getLinkType() {
|
||||
return this.linkType;
|
||||
}
|
||||
|
||||
public void setLinkType(String type) {
|
||||
Object old = this.linkType;
|
||||
this.linkType = type;
|
||||
getEventSupport().firePropertyChange("linkType", old, this.linkType);
|
||||
}
|
||||
|
||||
public JRHyperlinkParameter[] getHyperlinkParameters() {
|
||||
JRHyperlinkParameter[] parameters;
|
||||
if (this.hyperlinkParameters.isEmpty()) {
|
||||
parameters = null;
|
||||
} else {
|
||||
parameters = new JRHyperlinkParameter[this.hyperlinkParameters.size()];
|
||||
this.hyperlinkParameters.toArray((Object[])parameters);
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public List getHyperlinkParametersList() {
|
||||
return this.hyperlinkParameters;
|
||||
}
|
||||
|
||||
public void addHyperlinkParameter(JRHyperlinkParameter parameter) {
|
||||
this.hyperlinkParameters.add(parameter);
|
||||
getEventSupport().fireCollectionElementAddedEvent("hyperlinkParameters", parameter, this.hyperlinkParameters.size() - 1);
|
||||
}
|
||||
|
||||
public void removeHyperlinkParameter(JRHyperlinkParameter parameter) {
|
||||
int idx = this.hyperlinkParameters.indexOf(parameter);
|
||||
if (idx >= 0) {
|
||||
this.hyperlinkParameters.remove(idx);
|
||||
getEventSupport().fireCollectionElementRemovedEvent("hyperlinkParameters", parameter, idx);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeHyperlinkParameter(String parameterName) {
|
||||
for (ListIterator it = this.hyperlinkParameters.listIterator(); it.hasNext(); ) {
|
||||
JRHyperlinkParameter parameter = it.next();
|
||||
if (parameter.getName() != null && parameter.getName().equals(parameterName)) {
|
||||
it.remove();
|
||||
getEventSupport().fireCollectionElementRemovedEvent("hyperlinkParameters", parameter, it.nextIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
normalizeLinkType();
|
||||
}
|
||||
|
||||
protected void normalizeLinkType() {
|
||||
if (this.linkType == null)
|
||||
this.linkType = JRHyperlinkHelper.getLinkType(this.hyperlinkType);
|
||||
this.hyperlinkType = 0;
|
||||
}
|
||||
|
||||
public JRExpression getHyperlinkTooltipExpression() {
|
||||
return this.hyperlinkTooltipExpression;
|
||||
}
|
||||
|
||||
public void setHyperlinkTooltipExpression(JRExpression hyperlinkTooltipExpression) {
|
||||
Object old = this.hyperlinkTooltipExpression;
|
||||
this.hyperlinkTooltipExpression = hyperlinkTooltipExpression;
|
||||
getEventSupport().firePropertyChange("hyperlinkTooltipExpression", old, this.hyperlinkTooltipExpression);
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
JRDesignTextField clone = (JRDesignTextField)super.clone();
|
||||
if (this.hyperlinkParameters != null) {
|
||||
clone.hyperlinkParameters = new ArrayList(this.hyperlinkParameters.size());
|
||||
for (int i = 0; i < this.hyperlinkParameters.size(); i++)
|
||||
clone.hyperlinkParameters.add(((JRHyperlinkParameter)this.hyperlinkParameters.get(i)).clone());
|
||||
}
|
||||
if (this.expression != null)
|
||||
clone.expression = (JRExpression)this.expression.clone();
|
||||
if (this.anchorNameExpression != null)
|
||||
clone.anchorNameExpression = (JRExpression)this.anchorNameExpression.clone();
|
||||
if (this.hyperlinkReferenceExpression != null)
|
||||
clone.hyperlinkReferenceExpression = (JRExpression)this.hyperlinkReferenceExpression.clone();
|
||||
if (this.hyperlinkAnchorExpression != null)
|
||||
clone.hyperlinkAnchorExpression = (JRExpression)this.hyperlinkAnchorExpression.clone();
|
||||
if (this.hyperlinkPageExpression != null)
|
||||
clone.hyperlinkPageExpression = (JRExpression)this.hyperlinkPageExpression.clone();
|
||||
if (this.hyperlinkTooltipExpression != null)
|
||||
clone.hyperlinkTooltipExpression = (JRExpression)this.hyperlinkTooltipExpression.clone();
|
||||
return clone;
|
||||
}
|
||||
}
|
121
hrmsEjb/net/sf/jasperreports/engine/design/JRDesignVariable.java
Normal file
121
hrmsEjb/net/sf/jasperreports/engine/design/JRDesignVariable.java
Normal file
@@ -0,0 +1,121 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import net.sf.jasperreports.engine.JRExpression;
|
||||
import net.sf.jasperreports.engine.JRGroup;
|
||||
import net.sf.jasperreports.engine.base.JRBaseVariable;
|
||||
import net.sf.jasperreports.engine.design.events.JRChangeEventsSupport;
|
||||
import net.sf.jasperreports.engine.design.events.JRPropertyChangeSupport;
|
||||
|
||||
public class JRDesignVariable extends JRBaseVariable implements JRChangeEventsSupport {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
public static final String PROPERTY_CALCULATION = "calculation";
|
||||
|
||||
public static final String PROPERTY_EXPRESSION = "expression";
|
||||
|
||||
public static final String PROPERTY_INCREMENTER_FACTORY_CLASS_NAME = "incrementerFactoryClassName";
|
||||
|
||||
public static final String PROPERTY_INCREMENT_GROUP = "incrementGroup";
|
||||
|
||||
public static final String PROPERTY_INCREMENT_TYPE = "incrementType";
|
||||
|
||||
public static final String PROPERTY_INITIAL_VALUE_EXPRESSION = "initialValueExpression";
|
||||
|
||||
public static final String PROPERTY_NAME = "name";
|
||||
|
||||
public static final String PROPERTY_RESET_GROUP = "resetGroup";
|
||||
|
||||
public static final String PROPERTY_RESET_TYPE = "resetType";
|
||||
|
||||
public static final String PROPERTY_SYSTEM_DEFINED = "systemDefined";
|
||||
|
||||
public static final String PROPERTY_VALUE_CLASS_NAME = "valueClassName";
|
||||
|
||||
private transient JRPropertyChangeSupport eventSupport;
|
||||
|
||||
public void setName(String name) {
|
||||
String old = this.name;
|
||||
this.name = name;
|
||||
getEventSupport().firePropertyChange("name", old, this.name);
|
||||
}
|
||||
|
||||
public void setValueClass(Class clazz) {
|
||||
setValueClassName(clazz.getName());
|
||||
}
|
||||
|
||||
public void setValueClassName(String className) {
|
||||
Object old = this.valueClassName;
|
||||
this.valueClassName = className;
|
||||
this.valueClass = null;
|
||||
this.valueClassRealName = null;
|
||||
getEventSupport().firePropertyChange("valueClassName", old, this.valueClassName);
|
||||
}
|
||||
|
||||
public void setIncrementerFactoryClass(Class clazz) {
|
||||
setIncrementerFactoryClassName(clazz.getName());
|
||||
}
|
||||
|
||||
public void setIncrementerFactoryClassName(String className) {
|
||||
Object old = this.incrementerFactoryClassName;
|
||||
this.incrementerFactoryClassName = className;
|
||||
this.incrementerFactoryClass = null;
|
||||
this.incrementerFactoryClassRealName = null;
|
||||
getEventSupport().firePropertyChange("incrementerFactoryClassName", old, this.incrementerFactoryClassName);
|
||||
}
|
||||
|
||||
public void setResetType(byte resetType) {
|
||||
byte old = this.resetType;
|
||||
this.resetType = resetType;
|
||||
getEventSupport().firePropertyChange("resetType", old, this.resetType);
|
||||
}
|
||||
|
||||
public void setIncrementType(byte incrementType) {
|
||||
byte old = this.incrementType;
|
||||
this.incrementType = incrementType;
|
||||
getEventSupport().firePropertyChange("incrementType", old, this.incrementType);
|
||||
}
|
||||
|
||||
public void setCalculation(byte calculation) {
|
||||
byte old = this.calculation;
|
||||
this.calculation = calculation;
|
||||
getEventSupport().firePropertyChange("calculation", old, this.calculation);
|
||||
}
|
||||
|
||||
public void setSystemDefined(boolean isSystemDefined) {
|
||||
boolean old = this.isSystemDefined;
|
||||
this.isSystemDefined = isSystemDefined;
|
||||
getEventSupport().firePropertyChange("systemDefined", old, this.isSystemDefined);
|
||||
}
|
||||
|
||||
public void setExpression(JRExpression expression) {
|
||||
Object old = this.expression;
|
||||
this.expression = expression;
|
||||
getEventSupport().firePropertyChange("expression", old, this.expression);
|
||||
}
|
||||
|
||||
public void setInitialValueExpression(JRExpression expression) {
|
||||
Object old = this.initialValueExpression;
|
||||
this.initialValueExpression = expression;
|
||||
getEventSupport().firePropertyChange("initialValueExpression", old, this.initialValueExpression);
|
||||
}
|
||||
|
||||
public void setResetGroup(JRGroup group) {
|
||||
Object old = this.resetGroup;
|
||||
this.resetGroup = group;
|
||||
getEventSupport().firePropertyChange("resetGroup", old, this.resetGroup);
|
||||
}
|
||||
|
||||
public void setIncrementGroup(JRGroup group) {
|
||||
Object old = this.incrementGroup;
|
||||
this.incrementGroup = group;
|
||||
getEventSupport().firePropertyChange("incrementGroup", old, this.incrementGroup);
|
||||
}
|
||||
|
||||
public JRPropertyChangeSupport getEventSupport() {
|
||||
synchronized (this) {
|
||||
if (this.eventSupport == null)
|
||||
this.eventSupport = new JRPropertyChangeSupport(this);
|
||||
}
|
||||
return this.eventSupport;
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import net.sf.jasperreports.engine.JRException;
|
||||
|
||||
public class JRJavacCompiler extends JRAbstractMultiClassCompiler {
|
||||
public String compileClasses(File[] sourceFiles, String classpath) throws JRException {
|
||||
String[] source = new String[sourceFiles.length + 3];
|
||||
source[0] = "javac";
|
||||
source[1] = "-classpath";
|
||||
source[2] = classpath;
|
||||
for (int i = 0; i < sourceFiles.length; i++)
|
||||
source[i + 3] = sourceFiles[i].getPath();
|
||||
try {
|
||||
Process compile = Runtime.getRuntime().exec(source);
|
||||
InputStream errFile = compile.getErrorStream();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int count = 0;
|
||||
do {
|
||||
count = errFile.read(buffer);
|
||||
if (count <= 0)
|
||||
continue;
|
||||
baos.write(buffer, 0, count);
|
||||
} while (count >= 0);
|
||||
if (baos.toString().indexOf("error") != -1)
|
||||
return baos.toString();
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
StringBuffer files = new StringBuffer();
|
||||
for (int j = 0; j < sourceFiles.length; j++) {
|
||||
files.append(sourceFiles[j].getPath());
|
||||
files.append(' ');
|
||||
}
|
||||
throw new JRException("Error compiling report java source files : " + files, e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.reflect.Method;
|
||||
import net.sf.jasperreports.engine.JRException;
|
||||
import net.sf.jasperreports.engine.util.JRClassLoader;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
public class JRJdk13Compiler extends JRAbstractMultiClassCompiler {
|
||||
static final Log log = LogFactory.getLog(JRJdk13Compiler.class);
|
||||
|
||||
private static final int MODERN_COMPILER_SUCCESS = 0;
|
||||
|
||||
static Class array$Ljava$lang$String;
|
||||
|
||||
public String compileClasses(File[] sourceFiles, String classpath) throws JRException {
|
||||
String[] source = new String[sourceFiles.length + 2];
|
||||
for (int i = 0; i < sourceFiles.length; i++)
|
||||
source[i] = sourceFiles[i].getPath();
|
||||
source[sourceFiles.length] = "-classpath";
|
||||
source[sourceFiles.length + 1] = classpath;
|
||||
String errors = null;
|
||||
try {
|
||||
Class clazz = JRClassLoader.loadClassForRealName("com.sun.tools.javac.Main");
|
||||
Object compiler = clazz.newInstance();
|
||||
try {
|
||||
Method compileMethod = clazz.getMethod("compile", new Class[] { (array$Ljava$lang$String == null) ? (array$Ljava$lang$String = class$("[Ljava.lang.String;")) : array$Ljava$lang$String, PrintWriter.class });
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
int result = ((Integer)compileMethod.invoke(compiler, new Object[] { source, new PrintWriter(baos) })).intValue();
|
||||
if (result != 0) {
|
||||
errors = baos.toString();
|
||||
} else if (log.isInfoEnabled() && baos.size() > 0) {
|
||||
log.info(baos.toString());
|
||||
}
|
||||
} catch (NoSuchMethodException ex) {
|
||||
Method compileMethod = clazz.getMethod("compile", new Class[] { (array$Ljava$lang$String == null) ? (array$Ljava$lang$String = class$("[Ljava.lang.String;")) : array$Ljava$lang$String });
|
||||
int result = ((Integer)compileMethod.invoke(compiler, new Object[] { source })).intValue();
|
||||
if (result != 0)
|
||||
errors = "See error messages above.";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
StringBuffer files = new StringBuffer();
|
||||
for (int j = 0; j < sourceFiles.length; j++) {
|
||||
files.append(sourceFiles[j].getPath());
|
||||
files.append(' ');
|
||||
}
|
||||
throw new JRException("Error compiling report java source files : " + files, e);
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
}
|
394
hrmsEjb/net/sf/jasperreports/engine/design/JRJdtCompiler.java
Normal file
394
hrmsEjb/net/sf/jasperreports/engine/design/JRJdtCompiler.java
Normal file
@@ -0,0 +1,394 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import net.sf.jasperreports.engine.JRException;
|
||||
import net.sf.jasperreports.engine.JRRuntimeException;
|
||||
import net.sf.jasperreports.engine.util.JRClassLoader;
|
||||
import net.sf.jasperreports.engine.util.JRProperties;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.eclipse.jdt.core.compiler.IProblem;
|
||||
import org.eclipse.jdt.internal.compiler.ClassFile;
|
||||
import org.eclipse.jdt.internal.compiler.CompilationResult;
|
||||
import org.eclipse.jdt.internal.compiler.Compiler;
|
||||
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
|
||||
import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
|
||||
import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
|
||||
import org.eclipse.jdt.internal.compiler.IProblemFactory;
|
||||
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
|
||||
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
|
||||
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
|
||||
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
|
||||
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
|
||||
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
|
||||
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
|
||||
|
||||
public class JRJdtCompiler extends JRAbstractJavaCompiler {
|
||||
private static final String JDT_PROPERTIES_PREFIX = "org.eclipse.jdt.core.";
|
||||
|
||||
static final Log log = LogFactory.getLog(JRJdtCompiler.class);
|
||||
|
||||
private final ClassLoader classLoader;
|
||||
|
||||
Constructor constrNameEnvAnsBin;
|
||||
|
||||
Constructor constrNameEnvAnsCompUnit;
|
||||
|
||||
boolean is2ArgsConstr;
|
||||
|
||||
Constructor constrNameEnvAnsBin2Args;
|
||||
|
||||
Constructor constrNameEnvAnsCompUnit2Args;
|
||||
|
||||
public JRJdtCompiler() {
|
||||
super(false);
|
||||
boolean bool;
|
||||
this.classLoader = getClassLoader();
|
||||
try {
|
||||
Class classAccessRestriction = loadClass("org.eclipse.jdt.internal.compiler.env.AccessRestriction");
|
||||
this.constrNameEnvAnsBin2Args = NameEnvironmentAnswer.class.getConstructor(new Class[] { IBinaryType.class, classAccessRestriction });
|
||||
this.constrNameEnvAnsCompUnit2Args = NameEnvironmentAnswer.class.getConstructor(new Class[] { ICompilationUnit.class, classAccessRestriction });
|
||||
this.is2ArgsConstr = true;
|
||||
bool = true;
|
||||
} catch (NoSuchMethodException e) {
|
||||
bool = false;
|
||||
} catch (ClassNotFoundException ex) {
|
||||
bool = false;
|
||||
}
|
||||
if (!bool)
|
||||
try {
|
||||
this.constrNameEnvAnsBin = NameEnvironmentAnswer.class.getConstructor(new Class[] { IBinaryType.class });
|
||||
this.constrNameEnvAnsCompUnit = NameEnvironmentAnswer.class.getConstructor(new Class[] { ICompilationUnit.class });
|
||||
this.is2ArgsConstr = false;
|
||||
} catch (NoSuchMethodException ex) {
|
||||
throw new JRRuntimeException("Not able to load JDT classes", ex);
|
||||
}
|
||||
}
|
||||
|
||||
class CompilationUnit implements ICompilationUnit {
|
||||
protected String srcCode;
|
||||
|
||||
protected String className;
|
||||
|
||||
private final JRJdtCompiler this$0;
|
||||
|
||||
public CompilationUnit(String srcCode, String className) {
|
||||
this.srcCode = srcCode;
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
public char[] getFileName() {
|
||||
return this.className.toCharArray();
|
||||
}
|
||||
|
||||
public char[] getContents() {
|
||||
return this.srcCode.toCharArray();
|
||||
}
|
||||
|
||||
public char[] getMainTypeName() {
|
||||
return this.className.toCharArray();
|
||||
}
|
||||
|
||||
public char[][] getPackageName() {
|
||||
return new char[0][0];
|
||||
}
|
||||
}
|
||||
|
||||
protected String compileUnits(JRCompilationUnit[] units, String classpath, File tempDirFile) {
|
||||
StringBuffer problemBuffer = new StringBuffer();
|
||||
INameEnvironment env = getNameEnvironment(units);
|
||||
IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems();
|
||||
Map settings = getJdtSettings();
|
||||
DefaultProblemFactory defaultProblemFactory = new DefaultProblemFactory(Locale.getDefault());
|
||||
ICompilerRequestor requestor = getCompilerRequestor(units, problemBuffer);
|
||||
ICompilationUnit[] compilationUnits = new ICompilationUnit[units.length];
|
||||
for (int i = 0; i < compilationUnits.length; i++)
|
||||
compilationUnits[i] = new CompilationUnit(units[i].getSourceCode(), units[i].getName());
|
||||
Compiler compiler = new Compiler(env, policy, settings, requestor, (IProblemFactory)defaultProblemFactory);
|
||||
compiler.compile(compilationUnits);
|
||||
if (problemBuffer.length() > 0)
|
||||
return problemBuffer.toString();
|
||||
return null;
|
||||
}
|
||||
|
||||
protected INameEnvironment getNameEnvironment(final JRCompilationUnit[] units) {
|
||||
INameEnvironment env = new INameEnvironment() {
|
||||
private final JRCompilationUnit[] val$units;
|
||||
|
||||
private final JRJdtCompiler this$0;
|
||||
|
||||
public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
String sep = "";
|
||||
for (int i = 0; i < compoundTypeName.length; i++) {
|
||||
result.append(sep);
|
||||
result.append(compoundTypeName[i]);
|
||||
sep = ".";
|
||||
}
|
||||
return findType(result.toString());
|
||||
}
|
||||
|
||||
public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
String sep = "";
|
||||
for (int i = 0; i < packageName.length; i++) {
|
||||
result.append(sep);
|
||||
result.append(packageName[i]);
|
||||
sep = ".";
|
||||
}
|
||||
result.append(sep);
|
||||
result.append(typeName);
|
||||
return findType(result.toString());
|
||||
}
|
||||
|
||||
private int getClassIndex(String className) {
|
||||
int classIdx;
|
||||
for (classIdx = 0; classIdx < units.length; classIdx++) {
|
||||
if (className.equals(units[classIdx].getName()))
|
||||
break;
|
||||
}
|
||||
if (classIdx >= units.length)
|
||||
classIdx = -1;
|
||||
return classIdx;
|
||||
}
|
||||
|
||||
private NameEnvironmentAnswer findType(String className) {
|
||||
try {
|
||||
int classIdx = getClassIndex(className);
|
||||
if (classIdx >= 0) {
|
||||
ICompilationUnit compilationUnit = new JRJdtCompiler.CompilationUnit(units[classIdx].getSourceCode(), className);
|
||||
if (JRJdtCompiler.this.is2ArgsConstr)
|
||||
return JRJdtCompiler.this.constrNameEnvAnsCompUnit2Args.newInstance(new Object[] { compilationUnit, null });
|
||||
return JRJdtCompiler.this.constrNameEnvAnsCompUnit.newInstance(new Object[] { compilationUnit });
|
||||
}
|
||||
String resourceName = className.replace('.', '/') + ".class";
|
||||
InputStream is = JRJdtCompiler.this.getResource(resourceName);
|
||||
if (is != null) {
|
||||
byte[] buf = new byte[8192];
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(buf.length);
|
||||
int count;
|
||||
while ((count = is.read(buf, 0, buf.length)) > 0)
|
||||
baos.write(buf, 0, count);
|
||||
baos.flush();
|
||||
byte[] classBytes = baos.toByteArray();
|
||||
char[] fileName = className.toCharArray();
|
||||
ClassFileReader classFileReader = new ClassFileReader(classBytes, fileName, true);
|
||||
if (JRJdtCompiler.this.is2ArgsConstr)
|
||||
return JRJdtCompiler.this.constrNameEnvAnsBin2Args.newInstance(new Object[] { classFileReader, null });
|
||||
return JRJdtCompiler.this.constrNameEnvAnsBin.newInstance(new Object[] { classFileReader });
|
||||
}
|
||||
} catch (IOException exc) {
|
||||
JRJdtCompiler.log.error("Compilation error", exc);
|
||||
} catch (ClassFormatException exc) {
|
||||
JRJdtCompiler.log.error("Compilation error", (Throwable)exc);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new JRRuntimeException("Not able to create NameEnvironmentAnswer", e);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new JRRuntimeException("Not able to create NameEnvironmentAnswer", e);
|
||||
} catch (InstantiationException e) {
|
||||
throw new JRRuntimeException("Not able to create NameEnvironmentAnswer", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new JRRuntimeException("Not able to create NameEnvironmentAnswer", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isPackage(String result) {
|
||||
int classIdx = getClassIndex(result);
|
||||
if (classIdx >= 0)
|
||||
return false;
|
||||
String resourceName = result.replace('.', '/') + ".class";
|
||||
boolean isPackage = true;
|
||||
InputStream is = JRJdtCompiler.this.getResource(resourceName);
|
||||
if (is != null)
|
||||
try {
|
||||
isPackage = (is.read() > 0);
|
||||
} catch (IOException e) {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException iOException) {}
|
||||
} finally {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {}
|
||||
}
|
||||
return isPackage;
|
||||
}
|
||||
|
||||
public boolean isPackage(char[][] parentPackageName, char[] packageName) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
String sep = "";
|
||||
if (parentPackageName != null)
|
||||
for (int i = 0; i < parentPackageName.length; i++) {
|
||||
result.append(sep);
|
||||
result.append(parentPackageName[i]);
|
||||
sep = ".";
|
||||
}
|
||||
if (Character.isUpperCase(packageName[0]))
|
||||
if (!isPackage(result.toString()))
|
||||
return false;
|
||||
result.append(sep);
|
||||
result.append(packageName);
|
||||
return isPackage(result.toString());
|
||||
}
|
||||
|
||||
public void cleanup() {}
|
||||
};
|
||||
return env;
|
||||
}
|
||||
|
||||
protected ICompilerRequestor getCompilerRequestor(final JRCompilationUnit[] units, final StringBuffer problemBuffer) {
|
||||
ICompilerRequestor requestor = new ICompilerRequestor() {
|
||||
private final JRCompilationUnit[] val$units;
|
||||
|
||||
private final StringBuffer val$problemBuffer;
|
||||
|
||||
private final JRJdtCompiler this$0;
|
||||
|
||||
public void acceptResult(CompilationResult result) {
|
||||
String className = ((JRJdtCompiler.CompilationUnit)result.getCompilationUnit()).className;
|
||||
int classIdx;
|
||||
for (classIdx = 0; classIdx < units.length; classIdx++) {
|
||||
if (className.equals(units[classIdx].getName()))
|
||||
break;
|
||||
}
|
||||
if (result.hasErrors()) {
|
||||
String sourceCode = units[classIdx].getSourceCode();
|
||||
IProblem[] problems = JRJdtCompiler.this.getJavaCompilationErrors(result);
|
||||
for (int i = 0; i < problems.length; i++) {
|
||||
IProblem problem = problems[i];
|
||||
problemBuffer.append(i + 1);
|
||||
problemBuffer.append(". ");
|
||||
problemBuffer.append(problem.getMessage());
|
||||
if (problem.getSourceStart() >= 0 && problem.getSourceEnd() >= 0) {
|
||||
int problemStartIndex = sourceCode.lastIndexOf("\n", problem.getSourceStart()) + 1;
|
||||
int problemEndIndex = sourceCode.indexOf("\n", problem.getSourceEnd());
|
||||
if (problemEndIndex < 0)
|
||||
problemEndIndex = sourceCode.length();
|
||||
problemBuffer.append("\n");
|
||||
problemBuffer.append(sourceCode.substring(problemStartIndex, problemEndIndex));
|
||||
problemBuffer.append("\n");
|
||||
int j;
|
||||
for (j = problemStartIndex; j < problem.getSourceStart(); j++)
|
||||
problemBuffer.append(" ");
|
||||
if (problem.getSourceStart() == problem.getSourceEnd()) {
|
||||
problemBuffer.append("^");
|
||||
} else {
|
||||
problemBuffer.append("<");
|
||||
for (j = problem.getSourceStart() + 1; j < problem.getSourceEnd(); j++)
|
||||
problemBuffer.append("-");
|
||||
problemBuffer.append(">");
|
||||
}
|
||||
}
|
||||
problemBuffer.append("\n");
|
||||
}
|
||||
problemBuffer.append(problems.length);
|
||||
problemBuffer.append(" errors\n");
|
||||
}
|
||||
if (problemBuffer.length() == 0) {
|
||||
ClassFile[] resultClassFiles = result.getClassFiles();
|
||||
for (int i = 0; i < resultClassFiles.length; i++)
|
||||
units[classIdx].setCompileData((Serializable)resultClassFiles[i].getBytes());
|
||||
}
|
||||
}
|
||||
};
|
||||
return requestor;
|
||||
}
|
||||
|
||||
protected Map getJdtSettings() {
|
||||
Map settings = new HashMap();
|
||||
settings.put("org.eclipse.jdt.core.compiler.debug.lineNumber", "generate");
|
||||
settings.put("org.eclipse.jdt.core.compiler.debug.sourceFile", "generate");
|
||||
settings.put("org.eclipse.jdt.core.compiler.problem.deprecation", "ignore");
|
||||
List properties = JRProperties.getProperties("org.eclipse.jdt.core.");
|
||||
for (Iterator it = properties.iterator(); it.hasNext(); ) {
|
||||
JRProperties.PropertySuffix property = it.next();
|
||||
String propVal = property.getValue();
|
||||
if (propVal != null && propVal.length() > 0)
|
||||
settings.put(property.getKey(), propVal);
|
||||
}
|
||||
Properties systemProps = System.getProperties();
|
||||
for (Enumeration enumeration = systemProps.propertyNames(); enumeration.hasMoreElements(); ) {
|
||||
String propName = (String)enumeration.nextElement();
|
||||
if (propName.startsWith("org.eclipse.jdt.core.")) {
|
||||
String propVal = systemProps.getProperty(propName);
|
||||
if (propVal != null && propVal.length() > 0)
|
||||
settings.put(propName, propVal);
|
||||
}
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
private ClassLoader getClassLoader() {
|
||||
ClassLoader clsLoader = Thread.currentThread().getContextClassLoader();
|
||||
if (clsLoader != null)
|
||||
try {
|
||||
Class.forName(JRJdtCompiler.class.getName(), true, clsLoader);
|
||||
} catch (ClassNotFoundException e) {
|
||||
clsLoader = null;
|
||||
}
|
||||
if (clsLoader == null)
|
||||
clsLoader = JRClassLoader.class.getClassLoader();
|
||||
return clsLoader;
|
||||
}
|
||||
|
||||
protected InputStream getResource(String resourceName) {
|
||||
if (this.classLoader == null)
|
||||
return JRJdtCompiler.class.getResourceAsStream("/" + resourceName);
|
||||
return this.classLoader.getResourceAsStream(resourceName);
|
||||
}
|
||||
|
||||
protected Class loadClass(String className) throws ClassNotFoundException {
|
||||
if (this.classLoader == null)
|
||||
return Class.forName(className);
|
||||
return this.classLoader.loadClass(className);
|
||||
}
|
||||
|
||||
protected void checkLanguage(String language) throws JRException {
|
||||
if (!"java".equals(language))
|
||||
throw new JRException("Language \"" + language + "\" not supported by this report compiler.\n" + "Expecting \"java\" instead.");
|
||||
}
|
||||
|
||||
protected JRCompilationSourceCode generateSourceCode(JRSourceCompileTask sourceTask) throws JRException {
|
||||
return JRClassGenerator.generateClass(sourceTask);
|
||||
}
|
||||
|
||||
protected String getSourceFileName(String unitName) {
|
||||
return unitName + ".java";
|
||||
}
|
||||
|
||||
protected String getCompilerClass() {
|
||||
return JRJavacCompiler.class.getName();
|
||||
}
|
||||
|
||||
protected IProblem[] getJavaCompilationErrors(CompilationResult result) {
|
||||
try {
|
||||
Method getErrorsMethod = result.getClass().getMethod("getErrors", null);
|
||||
return (IProblem[])getErrorsMethod.invoke(result, null);
|
||||
} catch (SecurityException e) {
|
||||
throw new JRRuntimeException("Error resolving JDT methods", e);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new JRRuntimeException("Error resolving JDT methods", e);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new JRRuntimeException("Error invoking JDT methods", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new JRRuntimeException("Error invoking JDT methods", e);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new JRRuntimeException("Error invoking JDT methods", e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.io.File;
|
||||
import net.sf.jasperreports.engine.JRException;
|
||||
|
||||
public interface JRMultiClassCompiler extends JRClassCompiler {
|
||||
String compileClasses(File[] paramArrayOfFile, String paramString) throws JRException;
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.sf.jasperreports.crosstabs.JRCrosstab;
|
||||
import net.sf.jasperreports.engine.JRDataset;
|
||||
import net.sf.jasperreports.engine.JRException;
|
||||
|
||||
public class JRReportCompileData implements Serializable {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
private Serializable mainDatasetCompileData;
|
||||
|
||||
private Map datasetCompileData = new HashMap();
|
||||
|
||||
private Map crosstabCompileData = new HashMap();
|
||||
|
||||
public void setMainDatasetCompileData(Serializable compileData) {
|
||||
this.mainDatasetCompileData = compileData;
|
||||
}
|
||||
|
||||
public void setDatasetCompileData(JRDataset dataset, Serializable compileData) {
|
||||
if (dataset.isMainDataset()) {
|
||||
setMainDatasetCompileData(compileData);
|
||||
} else {
|
||||
this.datasetCompileData.put(dataset.getName(), compileData);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCrosstabCompileData(int crosstabId, Serializable compileData) {
|
||||
this.crosstabCompileData.put(new Integer(crosstabId), compileData);
|
||||
}
|
||||
|
||||
public Serializable getMainDatasetCompileData() {
|
||||
return this.mainDatasetCompileData;
|
||||
}
|
||||
|
||||
public Serializable getDatasetCompileData(JRDataset dataset) throws JRException {
|
||||
Serializable compileData;
|
||||
if (dataset.isMainDataset()) {
|
||||
compileData = getMainDatasetCompileData();
|
||||
} else {
|
||||
compileData = (Serializable)this.datasetCompileData.get(dataset.getName());
|
||||
if (compileData == null)
|
||||
throw new JRException("Compile data for dataset " + dataset.getName() + " not found in the report.");
|
||||
}
|
||||
return compileData;
|
||||
}
|
||||
|
||||
public Serializable getCrosstabCompileData(JRCrosstab crosstab) throws JRException {
|
||||
Serializable compileData = (Serializable)this.crosstabCompileData.get(new Integer(crosstab.getId()));
|
||||
if (compileData == null)
|
||||
throw new JRException("Compile data for crosstab not found in the report.");
|
||||
return compileData;
|
||||
}
|
||||
}
|
@@ -0,0 +1,94 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.sf.jasperreports.crosstabs.JRCrosstab;
|
||||
import net.sf.jasperreports.crosstabs.design.JRDesignCrosstab;
|
||||
import net.sf.jasperreports.engine.JRDataset;
|
||||
import net.sf.jasperreports.engine.JRExpression;
|
||||
import net.sf.jasperreports.engine.JRExpressionCollector;
|
||||
import net.sf.jasperreports.engine.JRVariable;
|
||||
|
||||
public class JRSourceCompileTask {
|
||||
private JasperDesign jasperDesign;
|
||||
|
||||
private String unitName;
|
||||
|
||||
private JRExpressionCollector expressionCollector;
|
||||
|
||||
private Map parametersMap;
|
||||
|
||||
private Map fieldsMap;
|
||||
|
||||
private Map variablesMap;
|
||||
|
||||
private JRVariable[] variables;
|
||||
|
||||
private List expressions;
|
||||
|
||||
private boolean onlyDefaultEvaluation;
|
||||
|
||||
protected JRSourceCompileTask(JasperDesign jasperDesign, String unitName, JRExpressionCollector expressionCollector, Map parametersMap, Map fieldsMap, Map variablesMap, JRVariable[] variables, boolean onlyDefaultEvaluation) {
|
||||
this.jasperDesign = jasperDesign;
|
||||
this.unitName = unitName;
|
||||
this.expressionCollector = expressionCollector;
|
||||
this.parametersMap = parametersMap;
|
||||
this.fieldsMap = fieldsMap;
|
||||
this.variablesMap = variablesMap;
|
||||
this.variables = variables;
|
||||
this.expressions = expressionCollector.getExpressions();
|
||||
this.onlyDefaultEvaluation = onlyDefaultEvaluation;
|
||||
}
|
||||
|
||||
public JRSourceCompileTask(JasperDesign jasperDesign, JRDesignDataset dataset, JRExpressionCollector expressionCollector, String unitName) {
|
||||
this(jasperDesign, unitName, expressionCollector.getCollector((JRDataset)dataset), dataset.getParametersMap(), dataset.getFieldsMap(), dataset.getVariablesMap(), dataset.getVariables(), false);
|
||||
}
|
||||
|
||||
public JRSourceCompileTask(JasperDesign jasperDesign, JRDesignCrosstab crosstab, JRExpressionCollector expressionCollector, String unitName) {
|
||||
this(jasperDesign, unitName, expressionCollector.getCollector((JRCrosstab)crosstab), crosstab.getParametersMap(), null, crosstab.getVariablesMap(), crosstab.getVariables(), true);
|
||||
}
|
||||
|
||||
public List getExpressions() {
|
||||
return this.expressions;
|
||||
}
|
||||
|
||||
public Map getFieldsMap() {
|
||||
return this.fieldsMap;
|
||||
}
|
||||
|
||||
public JasperDesign getJasperDesign() {
|
||||
return this.jasperDesign;
|
||||
}
|
||||
|
||||
public String[] getImports() {
|
||||
return this.jasperDesign.getImports();
|
||||
}
|
||||
|
||||
public boolean isOnlyDefaultEvaluation() {
|
||||
return this.onlyDefaultEvaluation;
|
||||
}
|
||||
|
||||
public Map getParametersMap() {
|
||||
return this.parametersMap;
|
||||
}
|
||||
|
||||
public String getUnitName() {
|
||||
return this.unitName;
|
||||
}
|
||||
|
||||
public JRVariable[] getVariables() {
|
||||
return this.variables;
|
||||
}
|
||||
|
||||
public Map getVariablesMap() {
|
||||
return this.variablesMap;
|
||||
}
|
||||
|
||||
public Integer getExpressionId(JRExpression expression) {
|
||||
return this.expressionCollector.getExpressionId(expression);
|
||||
}
|
||||
|
||||
public JRExpression getExpression(int expressionId) {
|
||||
return this.expressionCollector.getExpression(expressionId);
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import net.sf.jasperreports.engine.JRException;
|
||||
|
||||
public class JRValidationException extends JRException {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
private final Collection faults;
|
||||
|
||||
public JRValidationException(String message, Object source) {
|
||||
this(createFault(message, source));
|
||||
}
|
||||
|
||||
private static JRValidationFault createFault(String message, Object source) {
|
||||
JRValidationFault fault = new JRValidationFault();
|
||||
fault.setMessage(message);
|
||||
fault.setSource(source);
|
||||
return fault;
|
||||
}
|
||||
|
||||
public JRValidationException(JRValidationFault fault) {
|
||||
this(Arrays.asList(new JRValidationFault[] { fault }));
|
||||
}
|
||||
|
||||
public JRValidationException(Collection faults) {
|
||||
super(appendMessages(faults));
|
||||
this.faults = faults;
|
||||
}
|
||||
|
||||
public Collection getFaults() {
|
||||
return this.faults;
|
||||
}
|
||||
|
||||
protected static String appendMessages(Collection faults) {
|
||||
StringBuffer sbuffer = new StringBuffer();
|
||||
sbuffer.append("Report design not valid : ");
|
||||
int i = 1;
|
||||
for (Iterator it = faults.iterator(); it.hasNext(); i++) {
|
||||
JRValidationFault fault = it.next();
|
||||
sbuffer.append("\n\t " + i + ". " + fault.getMessage());
|
||||
}
|
||||
return sbuffer.toString();
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class JRValidationFault implements Serializable {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
private String message;
|
||||
|
||||
private Object source;
|
||||
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Object getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
public void setSource(Object source) {
|
||||
this.source = source;
|
||||
}
|
||||
}
|
1407
hrmsEjb/net/sf/jasperreports/engine/design/JRVerifier.java
Normal file
1407
hrmsEjb/net/sf/jasperreports/engine/design/JRVerifier.java
Normal file
File diff suppressed because it is too large
Load Diff
633
hrmsEjb/net/sf/jasperreports/engine/design/JasperDesign.java
Normal file
633
hrmsEjb/net/sf/jasperreports/engine/design/JasperDesign.java
Normal file
@@ -0,0 +1,633 @@
|
||||
package net.sf.jasperreports.engine.design;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.sf.jasperreports.crosstabs.JRCrosstab;
|
||||
import net.sf.jasperreports.crosstabs.design.JRDesignCrosstab;
|
||||
import net.sf.jasperreports.engine.JRBand;
|
||||
import net.sf.jasperreports.engine.JRDataset;
|
||||
import net.sf.jasperreports.engine.JRException;
|
||||
import net.sf.jasperreports.engine.JRExpression;
|
||||
import net.sf.jasperreports.engine.JRExpressionCollector;
|
||||
import net.sf.jasperreports.engine.JRField;
|
||||
import net.sf.jasperreports.engine.JRGroup;
|
||||
import net.sf.jasperreports.engine.JROrigin;
|
||||
import net.sf.jasperreports.engine.JRParameter;
|
||||
import net.sf.jasperreports.engine.JRReport;
|
||||
import net.sf.jasperreports.engine.JRReportFont;
|
||||
import net.sf.jasperreports.engine.JRReportTemplate;
|
||||
import net.sf.jasperreports.engine.JRSortField;
|
||||
import net.sf.jasperreports.engine.JRStyle;
|
||||
import net.sf.jasperreports.engine.JRVariable;
|
||||
import net.sf.jasperreports.engine.JRVisitor;
|
||||
import net.sf.jasperreports.engine.base.JRBaseReport;
|
||||
import net.sf.jasperreports.engine.design.events.PropagationChangeListener;
|
||||
import net.sf.jasperreports.engine.util.JRElementsVisitor;
|
||||
import net.sf.jasperreports.engine.util.JRVisitorSupport;
|
||||
|
||||
public class JasperDesign extends JRBaseReport {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
public static final String PROPERTY_BACKGROUND = "background";
|
||||
|
||||
public static final String PROPERTY_BOTTOM_MARGIN = "bottomMargin";
|
||||
|
||||
public static final String PROPERTY_COLUMN_COUNT = "columnCount";
|
||||
|
||||
public static final String PROPERTY_COLUMN_FOOTER = "columnFooter";
|
||||
|
||||
public static final String PROPERTY_COLUMN_HEADER = "columnHeader";
|
||||
|
||||
public static final String PROPERTY_COLUMN_SPACING = "columnSpacing";
|
||||
|
||||
public static final String PROPERTY_COLUMN_WIDTH = "columnWidth";
|
||||
|
||||
public static final String PROPERTY_DATASETS = "datasets";
|
||||
|
||||
public static final String PROPERTY_DEFAULT_FONT = "defaultFont";
|
||||
|
||||
public static final String PROPERTY_DEFAULT_STLYE = "defaultStyle";
|
||||
|
||||
public static final String PROPERTY_DETAIL = "detail";
|
||||
|
||||
public static final String PROPERTY_FLOAT_COLUMN_FOOTER = "floatColumnFooter";
|
||||
|
||||
public static final String PROPERTY_FONTS = "fonts";
|
||||
|
||||
public static final String PROPERTY_FORMAT_FACTORY_CLASS = "formatFactoryClass";
|
||||
|
||||
public static final String PROPERTY_IGNORE_PAGINATION = "ignorePagination";
|
||||
|
||||
public static final String PROPERTY_IMPORTS = "imports";
|
||||
|
||||
public static final String PROPERTY_LANGUAGE = "language";
|
||||
|
||||
public static final String PROPERTY_LAST_PAGE_FOOTER = "lastPageFooter";
|
||||
|
||||
public static final String PROPERTY_LEFT_MARGIN = "leftMargin";
|
||||
|
||||
public static final String PROPERTY_MAIN_DATASET = "mainDataset";
|
||||
|
||||
public static final String PROPERTY_NAME = "name";
|
||||
|
||||
public static final String PROPERTY_NO_DATA = "noData";
|
||||
|
||||
public static final String PROPERTY_ORIENTATION = "orientation";
|
||||
|
||||
public static final String PROPERTY_PAGE_FOOTER = "pageFooter";
|
||||
|
||||
public static final String PROPERTY_PAGE_HEADER = "pageHeader";
|
||||
|
||||
public static final String PROPERTY_PAGE_HEIGHT = "pageHeight";
|
||||
|
||||
public static final String PROPERTY_PAGE_WIDTH = "pageWidth";
|
||||
|
||||
public static final String PROPERTY_PRINT_ORDER = "printOrder";
|
||||
|
||||
public static final String PROPERTY_RIGHT_MARGIN = "rightMargin";
|
||||
|
||||
public static final String PROPERTY_STYLES = "styles";
|
||||
|
||||
public static final String PROPERTY_SUMMARY = "summary";
|
||||
|
||||
public static final String PROPERTY_SUMMARY_NEW_PAGE = "summaryNewPage";
|
||||
|
||||
public static final String PROPERTY_TEMPLATES = "templates";
|
||||
|
||||
public static final String PROPERTY_TITLE = "title";
|
||||
|
||||
public static final String PROPERTY_TITLE_NEW_PAGE = "titleNewPage";
|
||||
|
||||
public static final String PROPERTY_TOP_MARGIN = "topMargin";
|
||||
|
||||
private List templateList = new ArrayList();
|
||||
|
||||
private Map fontsMap = new HashMap();
|
||||
|
||||
private List fontsList = new ArrayList();
|
||||
|
||||
private Map stylesMap = new HashMap();
|
||||
|
||||
private List stylesList = new ArrayList();
|
||||
|
||||
private JRDesignDataset mainDesignDataset;
|
||||
|
||||
private Map datasetMap = new HashMap();
|
||||
|
||||
private List datasetList = new ArrayList();
|
||||
|
||||
public JasperDesign() {
|
||||
setMainDataset(new JRDesignDataset(true));
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
Object old = this.name;
|
||||
this.name = name;
|
||||
this.mainDesignDataset.setName(name);
|
||||
getEventSupport().firePropertyChange("name", old, this.name);
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
Object old = this.language;
|
||||
this.language = language;
|
||||
getEventSupport().firePropertyChange("language", old, this.language);
|
||||
}
|
||||
|
||||
public void setColumnCount(int columnCount) {
|
||||
int old = this.columnCount;
|
||||
this.columnCount = columnCount;
|
||||
getEventSupport().firePropertyChange("columnCount", old, this.columnCount);
|
||||
}
|
||||
|
||||
public void setPrintOrder(byte printOrder) {
|
||||
int old = this.printOrder;
|
||||
this.printOrder = printOrder;
|
||||
getEventSupport().firePropertyChange("printOrder", old, this.printOrder);
|
||||
}
|
||||
|
||||
public void setPageWidth(int pageWidth) {
|
||||
int old = this.pageWidth;
|
||||
this.pageWidth = pageWidth;
|
||||
getEventSupport().firePropertyChange("pageWidth", old, this.pageWidth);
|
||||
}
|
||||
|
||||
public void setPageHeight(int pageHeight) {
|
||||
int old = this.pageHeight;
|
||||
this.pageHeight = pageHeight;
|
||||
getEventSupport().firePropertyChange("pageHeight", old, this.pageHeight);
|
||||
}
|
||||
|
||||
public void setOrientation(byte orientation) {
|
||||
int old = this.orientation;
|
||||
this.orientation = orientation;
|
||||
getEventSupport().firePropertyChange("orientation", old, this.orientation);
|
||||
}
|
||||
|
||||
public void setColumnWidth(int columnWidth) {
|
||||
int old = columnWidth;
|
||||
this.columnWidth = columnWidth;
|
||||
getEventSupport().firePropertyChange("columnWidth", old, this.columnWidth);
|
||||
}
|
||||
|
||||
public void setColumnSpacing(int columnSpacing) {
|
||||
int old = this.columnSpacing;
|
||||
this.columnSpacing = columnSpacing;
|
||||
getEventSupport().firePropertyChange("columnSpacing", old, this.columnSpacing);
|
||||
}
|
||||
|
||||
public void setLeftMargin(int leftMargin) {
|
||||
int old = this.leftMargin;
|
||||
this.leftMargin = leftMargin;
|
||||
getEventSupport().firePropertyChange("leftMargin", old, this.leftMargin);
|
||||
}
|
||||
|
||||
public void setRightMargin(int rightMargin) {
|
||||
int old = this.rightMargin;
|
||||
this.rightMargin = rightMargin;
|
||||
getEventSupport().firePropertyChange("rightMargin", old, this.rightMargin);
|
||||
}
|
||||
|
||||
public void setTopMargin(int topMargin) {
|
||||
int old = this.topMargin;
|
||||
this.topMargin = topMargin;
|
||||
getEventSupport().firePropertyChange("topMargin", old, this.topMargin);
|
||||
}
|
||||
|
||||
public void setBottomMargin(int bottomMargin) {
|
||||
int old = this.bottomMargin;
|
||||
this.bottomMargin = bottomMargin;
|
||||
getEventSupport().firePropertyChange("bottomMargin", old, this.bottomMargin);
|
||||
}
|
||||
|
||||
public void setBackground(JRBand background) {
|
||||
Object old = this.background;
|
||||
this.background = background;
|
||||
setBandOrigin(this.background, (byte)1);
|
||||
getEventSupport().firePropertyChange("background", old, this.background);
|
||||
}
|
||||
|
||||
public void setTitle(JRBand title) {
|
||||
Object old = this.title;
|
||||
this.title = title;
|
||||
setBandOrigin(this.title, (byte)2);
|
||||
getEventSupport().firePropertyChange("title", old, this.title);
|
||||
}
|
||||
|
||||
public void setTitleNewPage(boolean isTitleNewPage) {
|
||||
boolean old = this.isTitleNewPage;
|
||||
this.isTitleNewPage = isTitleNewPage;
|
||||
getEventSupport().firePropertyChange("titleNewPage", old, this.isTitleNewPage);
|
||||
}
|
||||
|
||||
public void setSummary(JRBand summary) {
|
||||
Object old = this.summary;
|
||||
this.summary = summary;
|
||||
setBandOrigin(this.summary, (byte)11);
|
||||
getEventSupport().firePropertyChange("summary", old, this.summary);
|
||||
}
|
||||
|
||||
public void setNoData(JRBand noData) {
|
||||
Object old = this.noData;
|
||||
this.noData = noData;
|
||||
setBandOrigin(this.noData, (byte)12);
|
||||
getEventSupport().firePropertyChange("noData", old, this.noData);
|
||||
}
|
||||
|
||||
public void setSummaryNewPage(boolean isSummaryNewPage) {
|
||||
boolean old = this.isSummaryNewPage;
|
||||
this.isSummaryNewPage = isSummaryNewPage;
|
||||
getEventSupport().firePropertyChange("summaryNewPage", old, this.isSummaryNewPage);
|
||||
}
|
||||
|
||||
public void setFloatColumnFooter(boolean isFloatColumnFooter) {
|
||||
boolean old = this.isFloatColumnFooter;
|
||||
this.isFloatColumnFooter = isFloatColumnFooter;
|
||||
getEventSupport().firePropertyChange("floatColumnFooter", old, this.isFloatColumnFooter);
|
||||
}
|
||||
|
||||
public void setPageHeader(JRBand pageHeader) {
|
||||
Object old = this.pageHeader;
|
||||
this.pageHeader = pageHeader;
|
||||
setBandOrigin(this.pageHeader, (byte)3);
|
||||
getEventSupport().firePropertyChange("pageHeader", old, this.pageHeader);
|
||||
}
|
||||
|
||||
public void setPageFooter(JRBand pageFooter) {
|
||||
Object old = this.pageFooter;
|
||||
this.pageFooter = pageFooter;
|
||||
setBandOrigin(this.pageFooter, (byte)9);
|
||||
getEventSupport().firePropertyChange("pageFooter", old, this.pageFooter);
|
||||
}
|
||||
|
||||
public void setLastPageFooter(JRBand lastPageFooter) {
|
||||
Object old = this.lastPageFooter;
|
||||
this.lastPageFooter = lastPageFooter;
|
||||
setBandOrigin(this.lastPageFooter, (byte)10);
|
||||
getEventSupport().firePropertyChange("lastPageFooter", old, this.lastPageFooter);
|
||||
}
|
||||
|
||||
public void setColumnHeader(JRBand columnHeader) {
|
||||
Object old = this.columnHeader;
|
||||
this.columnHeader = columnHeader;
|
||||
setBandOrigin(this.columnHeader, (byte)4);
|
||||
getEventSupport().firePropertyChange("columnHeader", old, this.columnHeader);
|
||||
}
|
||||
|
||||
public void setColumnFooter(JRBand columnFooter) {
|
||||
Object old = this.columnFooter;
|
||||
this.columnFooter = columnFooter;
|
||||
setBandOrigin(this.columnFooter, (byte)8);
|
||||
getEventSupport().firePropertyChange("columnFooter", old, this.columnFooter);
|
||||
}
|
||||
|
||||
public void setDetail(JRBand detail) {
|
||||
Object old = this.detail;
|
||||
this.detail = detail;
|
||||
setBandOrigin(this.detail, (byte)6);
|
||||
getEventSupport().firePropertyChange("detail", old, this.detail);
|
||||
}
|
||||
|
||||
public void setScriptletClass(String scriptletClass) {
|
||||
this.mainDesignDataset.setScriptletClass(scriptletClass);
|
||||
}
|
||||
|
||||
public void setFormatFactoryClass(String formatFactoryClass) {
|
||||
Object old = this.formatFactoryClass;
|
||||
this.formatFactoryClass = formatFactoryClass;
|
||||
getEventSupport().firePropertyChange("formatFactoryClass", old, this.formatFactoryClass);
|
||||
}
|
||||
|
||||
public void setResourceBundle(String resourceBundle) {
|
||||
this.mainDesignDataset.setResourceBundle(resourceBundle);
|
||||
}
|
||||
|
||||
public void addImport(String value) {
|
||||
if (this.importsSet == null)
|
||||
this.importsSet = new HashSet();
|
||||
if (this.importsSet.add(value))
|
||||
getEventSupport().fireCollectionElementAddedEvent("imports", value, this.importsSet.size() - 1);
|
||||
}
|
||||
|
||||
public void removeImport(String value) {
|
||||
if (this.importsSet != null)
|
||||
if (this.importsSet.remove(value))
|
||||
getEventSupport().fireCollectionElementRemovedEvent("imports", value, -1);
|
||||
}
|
||||
|
||||
public void setDefaultFont(JRReportFont font) {
|
||||
Object old = this.defaultFont;
|
||||
this.defaultFont = font;
|
||||
getEventSupport().firePropertyChange("defaultFont", old, this.defaultFont);
|
||||
}
|
||||
|
||||
public JRReportFont[] getFonts() {
|
||||
JRReportFont[] fontsArray = new JRReportFont[this.fontsList.size()];
|
||||
this.fontsList.toArray((Object[])fontsArray);
|
||||
return fontsArray;
|
||||
}
|
||||
|
||||
public List getFontsList() {
|
||||
return this.fontsList;
|
||||
}
|
||||
|
||||
public Map getFontsMap() {
|
||||
return this.fontsMap;
|
||||
}
|
||||
|
||||
public void addFont(JRReportFont reportFont) throws JRException {
|
||||
if (this.fontsMap.containsKey(reportFont.getName()))
|
||||
throw new JRException("Duplicate declaration of report font : " + reportFont.getName());
|
||||
this.fontsList.add(reportFont);
|
||||
this.fontsMap.put(reportFont.getName(), reportFont);
|
||||
if (reportFont.isDefault())
|
||||
setDefaultFont(reportFont);
|
||||
getEventSupport().fireCollectionElementAddedEvent("fonts", reportFont, this.fontsList.size() - 1);
|
||||
}
|
||||
|
||||
public JRReportFont removeFont(String propName) {
|
||||
return removeFont((JRReportFont)this.fontsMap.get(propName));
|
||||
}
|
||||
|
||||
public JRReportFont removeFont(JRReportFont reportFont) {
|
||||
if (reportFont != null) {
|
||||
if (reportFont.isDefault())
|
||||
setDefaultFont((JRReportFont)null);
|
||||
int idx = this.fontsList.indexOf(reportFont);
|
||||
if (idx >= 0) {
|
||||
this.fontsList.remove(idx);
|
||||
this.fontsMap.remove(reportFont.getName());
|
||||
getEventSupport().fireCollectionElementRemovedEvent("fonts", reportFont, idx);
|
||||
}
|
||||
}
|
||||
return reportFont;
|
||||
}
|
||||
|
||||
public void setDefaultStyle(JRStyle style) {
|
||||
Object old = this.defaultStyle;
|
||||
this.defaultStyle = style;
|
||||
getEventSupport().firePropertyChange("defaultStyle", old, this.defaultStyle);
|
||||
}
|
||||
|
||||
public JRStyle[] getStyles() {
|
||||
JRStyle[] stylesArray = new JRStyle[this.stylesList.size()];
|
||||
this.stylesList.toArray((Object[])stylesArray);
|
||||
return stylesArray;
|
||||
}
|
||||
|
||||
public List getStylesList() {
|
||||
return this.stylesList;
|
||||
}
|
||||
|
||||
public Map getStylesMap() {
|
||||
return this.stylesMap;
|
||||
}
|
||||
|
||||
public void addStyle(JRStyle style) throws JRException {
|
||||
if (this.stylesMap.containsKey(style.getName()))
|
||||
throw new JRException("Duplicate declaration of report style : " + style.getName());
|
||||
this.stylesList.add(style);
|
||||
this.stylesMap.put(style.getName(), style);
|
||||
if (style.isDefault())
|
||||
setDefaultStyle(style);
|
||||
getEventSupport().fireCollectionElementAddedEvent("styles", style, this.stylesList.size() - 1);
|
||||
}
|
||||
|
||||
public JRStyle removeStyle(String styleName) {
|
||||
return removeStyle((JRStyle)this.stylesMap.get(styleName));
|
||||
}
|
||||
|
||||
public JRStyle removeStyle(JRStyle style) {
|
||||
if (style != null) {
|
||||
if (style.isDefault())
|
||||
setDefaultStyle((JRStyle)null);
|
||||
int idx = this.stylesList.indexOf(style);
|
||||
if (idx >= 0) {
|
||||
this.stylesList.remove(idx);
|
||||
this.stylesMap.remove(style.getName());
|
||||
getEventSupport().fireCollectionElementRemovedEvent("styles", style, idx);
|
||||
}
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
public List getParametersList() {
|
||||
return this.mainDesignDataset.getParametersList();
|
||||
}
|
||||
|
||||
public Map getParametersMap() {
|
||||
return this.mainDesignDataset.getParametersMap();
|
||||
}
|
||||
|
||||
public void addParameter(JRParameter parameter) throws JRException {
|
||||
this.mainDesignDataset.addParameter(parameter);
|
||||
}
|
||||
|
||||
public JRParameter removeParameter(String parameterName) {
|
||||
return this.mainDesignDataset.removeParameter(parameterName);
|
||||
}
|
||||
|
||||
public JRParameter removeParameter(JRParameter parameter) {
|
||||
return this.mainDesignDataset.removeParameter(parameter);
|
||||
}
|
||||
|
||||
public void setQuery(JRDesignQuery query) {
|
||||
this.mainDesignDataset.setQuery(query);
|
||||
}
|
||||
|
||||
public List getFieldsList() {
|
||||
return this.mainDesignDataset.getFieldsList();
|
||||
}
|
||||
|
||||
public Map getFieldsMap() {
|
||||
return this.mainDesignDataset.getFieldsMap();
|
||||
}
|
||||
|
||||
public void addField(JRField field) throws JRException {
|
||||
this.mainDesignDataset.addField(field);
|
||||
}
|
||||
|
||||
public JRField removeField(String fieldName) {
|
||||
return this.mainDesignDataset.removeField(fieldName);
|
||||
}
|
||||
|
||||
public JRField removeField(JRField field) {
|
||||
return this.mainDesignDataset.removeField(field);
|
||||
}
|
||||
|
||||
public List getSortFieldsList() {
|
||||
return this.mainDesignDataset.getSortFieldsList();
|
||||
}
|
||||
|
||||
public void addSortField(JRSortField sortField) throws JRException {
|
||||
this.mainDesignDataset.addSortField(sortField);
|
||||
}
|
||||
|
||||
public JRSortField removeSortField(String fieldName) {
|
||||
return this.mainDesignDataset.removeSortField(fieldName);
|
||||
}
|
||||
|
||||
public JRSortField removeSortField(JRSortField sortField) {
|
||||
return this.mainDesignDataset.removeSortField(sortField);
|
||||
}
|
||||
|
||||
public List getVariablesList() {
|
||||
return this.mainDesignDataset.getVariablesList();
|
||||
}
|
||||
|
||||
public Map getVariablesMap() {
|
||||
return this.mainDesignDataset.getVariablesMap();
|
||||
}
|
||||
|
||||
public void addVariable(JRDesignVariable variable) throws JRException {
|
||||
this.mainDesignDataset.addVariable(variable);
|
||||
}
|
||||
|
||||
public JRVariable removeVariable(String variableName) {
|
||||
return this.mainDesignDataset.removeVariable(variableName);
|
||||
}
|
||||
|
||||
public JRVariable removeVariable(JRVariable variable) {
|
||||
return this.mainDesignDataset.removeVariable(variable);
|
||||
}
|
||||
|
||||
public List getGroupsList() {
|
||||
return this.mainDesignDataset.getGroupsList();
|
||||
}
|
||||
|
||||
public Map getGroupsMap() {
|
||||
return this.mainDesignDataset.getGroupsMap();
|
||||
}
|
||||
|
||||
public void addGroup(JRDesignGroup group) throws JRException {
|
||||
this.mainDesignDataset.addGroup(group);
|
||||
}
|
||||
|
||||
public JRGroup removeGroup(String groupName) {
|
||||
return this.mainDesignDataset.removeGroup(groupName);
|
||||
}
|
||||
|
||||
public JRGroup removeGroup(JRGroup group) {
|
||||
return this.mainDesignDataset.removeGroup(group);
|
||||
}
|
||||
|
||||
public Collection getExpressions() {
|
||||
return JRExpressionCollector.collectExpressions((JRReport)this);
|
||||
}
|
||||
|
||||
public JRDataset[] getDatasets() {
|
||||
JRDataset[] datasetArray = new JRDataset[this.datasetList.size()];
|
||||
this.datasetList.toArray((Object[])datasetArray);
|
||||
return datasetArray;
|
||||
}
|
||||
|
||||
public List getDatasetsList() {
|
||||
return this.datasetList;
|
||||
}
|
||||
|
||||
public Map getDatasetMap() {
|
||||
return this.datasetMap;
|
||||
}
|
||||
|
||||
public void addDataset(JRDesignDataset dataset) throws JRException {
|
||||
if (this.datasetMap.containsKey(dataset.getName()))
|
||||
throw new JRException("Duplicate declaration of dataset : " + dataset.getName());
|
||||
this.datasetList.add(dataset);
|
||||
this.datasetMap.put(dataset.getName(), dataset);
|
||||
getEventSupport().fireCollectionElementAddedEvent("datasets", dataset, this.datasetList.size() - 1);
|
||||
}
|
||||
|
||||
public JRDataset removeDataset(String datasetName) {
|
||||
return removeDataset((JRDataset)this.datasetMap.get(datasetName));
|
||||
}
|
||||
|
||||
public JRDataset removeDataset(JRDataset dataset) {
|
||||
if (dataset != null) {
|
||||
int idx = this.datasetList.indexOf(dataset);
|
||||
if (idx >= 0) {
|
||||
this.datasetList.remove(idx);
|
||||
this.datasetMap.remove(dataset.getName());
|
||||
getEventSupport().fireCollectionElementRemovedEvent("datasets", dataset, idx);
|
||||
}
|
||||
}
|
||||
return dataset;
|
||||
}
|
||||
|
||||
public JRDesignDataset getMainDesignDataset() {
|
||||
return this.mainDesignDataset;
|
||||
}
|
||||
|
||||
public void setMainDataset(JRDesignDataset dataset) {
|
||||
Object old = this.background;
|
||||
this.mainDataset = (JRDataset)(this.mainDesignDataset = dataset);
|
||||
this.mainDesignDataset.setName(getName());
|
||||
this.mainDesignDataset.getEventSupport().addPropertyChangeListener((PropertyChangeListener)new PropagationChangeListener(getEventSupport()));
|
||||
getEventSupport().firePropertyChange("mainDataset", old, this.mainDataset);
|
||||
}
|
||||
|
||||
public void preprocess() {
|
||||
for (Iterator it = getCrosstabs().iterator(); it.hasNext(); ) {
|
||||
JRDesignCrosstab crosstab = it.next();
|
||||
crosstab.preprocess();
|
||||
}
|
||||
}
|
||||
|
||||
protected List getCrosstabs() {
|
||||
final List crosstabs = new ArrayList();
|
||||
JRElementsVisitor.visitReport((JRReport)this, (JRVisitor)new JRVisitorSupport() {
|
||||
private final List val$crosstabs;
|
||||
|
||||
private final JasperDesign this$0;
|
||||
|
||||
public void visitCrosstab(JRCrosstab crosstab) {
|
||||
crosstabs.add(crosstab);
|
||||
}
|
||||
});
|
||||
return crosstabs;
|
||||
}
|
||||
|
||||
public void setIgnorePagination(boolean ignorePagination) {
|
||||
boolean old = this.ignorePagination;
|
||||
this.ignorePagination = ignorePagination;
|
||||
getEventSupport().firePropertyChange("ignorePagination", old, this.ignorePagination);
|
||||
}
|
||||
|
||||
public JRExpression getFilterExpression() {
|
||||
return this.mainDesignDataset.getFilterExpression();
|
||||
}
|
||||
|
||||
public void setFilterExpression(JRExpression expression) {
|
||||
this.mainDesignDataset.setFilterExpression(expression);
|
||||
}
|
||||
|
||||
public void addTemplate(JRReportTemplate template) {
|
||||
this.templateList.add(template);
|
||||
getEventSupport().fireCollectionElementAddedEvent("templates", template, this.templateList.size() - 1);
|
||||
}
|
||||
|
||||
public boolean removeTemplate(JRReportTemplate template) {
|
||||
int idx = this.templateList.indexOf(template);
|
||||
if (idx >= 0) {
|
||||
this.templateList.remove(idx);
|
||||
getEventSupport().fireCollectionElementRemovedEvent("templates", template, idx);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public JRReportTemplate[] getTemplates() {
|
||||
return (JRReportTemplate[])this.templateList.toArray((Object[])new JRReportTemplate[this.templateList.size()]);
|
||||
}
|
||||
|
||||
protected void setBandOrigin(JRBand band, byte type) {
|
||||
if (band instanceof JRDesignBand) {
|
||||
JROrigin origin = new JROrigin(type);
|
||||
((JRDesignBand)band).setOrigin(origin);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
package net.sf.jasperreports.engine.design.events;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
|
||||
public class CollectionElementAddedEvent extends PropertyChangeEvent {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
private final int addedIndex;
|
||||
|
||||
public CollectionElementAddedEvent(Object source, String propertyName, Object addedValue, int addedIndex) {
|
||||
super(source, propertyName, null, addedValue);
|
||||
this.addedIndex = addedIndex;
|
||||
}
|
||||
|
||||
public Object getAddedValue() {
|
||||
return getNewValue();
|
||||
}
|
||||
|
||||
public int getAddedIndex() {
|
||||
return this.addedIndex;
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
package net.sf.jasperreports.engine.design.events;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
|
||||
public class CollectionElementRemovedEvent extends PropertyChangeEvent {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
private final int removedIndex;
|
||||
|
||||
public CollectionElementRemovedEvent(Object source, String propertyName, Object removedValue, int removedIndex) {
|
||||
super(source, propertyName, removedValue, null);
|
||||
this.removedIndex = removedIndex;
|
||||
}
|
||||
|
||||
public Object getRemovedValue() {
|
||||
return getOldValue();
|
||||
}
|
||||
|
||||
public int getRemovedIndex() {
|
||||
return this.removedIndex;
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
package net.sf.jasperreports.engine.design.events;
|
||||
|
||||
public interface JRChangeEventsSupport {
|
||||
JRPropertyChangeSupport getEventSupport();
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package net.sf.jasperreports.engine.design.events;
|
||||
|
||||
import java.beans.PropertyChangeSupport;
|
||||
|
||||
public class JRPropertyChangeSupport extends PropertyChangeSupport {
|
||||
private static final long serialVersionUID = 10200L;
|
||||
|
||||
private Object sourceBean;
|
||||
|
||||
public JRPropertyChangeSupport(Object sourceBean) {
|
||||
super(sourceBean);
|
||||
this.sourceBean = sourceBean;
|
||||
}
|
||||
|
||||
public void fireCollectionElementAddedEvent(String propertyName, Object addedValue, int addedIndex) {
|
||||
firePropertyChange(new CollectionElementAddedEvent(this.sourceBean, propertyName, addedValue, addedIndex));
|
||||
}
|
||||
|
||||
public void fireCollectionElementRemovedEvent(String propertyName, Object removedValue, int removedIndex) {
|
||||
firePropertyChange(new CollectionElementRemovedEvent(this.sourceBean, propertyName, removedValue, removedIndex));
|
||||
}
|
||||
|
||||
public void firePropertyChange(String propertyName, float oldValue, float newValue) {
|
||||
if (oldValue == newValue)
|
||||
return;
|
||||
firePropertyChange(propertyName, new Float(oldValue), new Float(newValue));
|
||||
}
|
||||
|
||||
public void firePropertyChange(String propertyName, double oldValue, double newValue) {
|
||||
if (oldValue == newValue)
|
||||
return;
|
||||
firePropertyChange(propertyName, new Double(oldValue), new Double(newValue));
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package net.sf.jasperreports.engine.design.events;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
public class PropagationChangeListener implements PropertyChangeListener {
|
||||
private final JRPropertyChangeSupport propertyChangeSupport;
|
||||
|
||||
public PropagationChangeListener(JRPropertyChangeSupport propertyChangeSupport) {
|
||||
this.propertyChangeSupport = propertyChangeSupport;
|
||||
}
|
||||
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
this.propertyChangeSupport.firePropertyChange(evt);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user