Source Code Cross Referenced for IReportCompiler.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » iReport 2.0.5 » it.businesslogic.ireport 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Copyright (C) 2005 - 2008 JasperSoft Corporation.  All rights reserved.
0003:         * http://www.jaspersoft.com.
0004:         *
0005:         * Unless you have purchased a commercial license agreement from JasperSoft,
0006:         * the following license terms apply:
0007:         *
0008:         * This program is free software; you can redistribute it and/or modify
0009:         * it under the terms of the GNU General Public License version 2 as published by
0010:         * the Free Software Foundation.
0011:         *
0012:         * This program is distributed WITHOUT ANY WARRANTY; and without the
0013:         * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0014:         * See the GNU General Public License for more details.
0015:         *
0016:         * You should have received a copy of the GNU General Public License
0017:         * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
0018:         * or write to:
0019:         *
0020:         * Free Software Foundation, Inc.,
0021:         * 59 Temple Place - Suite 330,
0022:         * Boston, MA  USA  02111-1307
0023:         *
0024:         *
0025:         *
0026:         *
0027:         * IReportCompiler.java
0028:         *
0029:         * Created on 6 giugno 2003, 0.44
0030:         *
0031:         */
0032:
0033:        package it.businesslogic.ireport;
0034:
0035:        import be.savat.components.PagesFrame;
0036:        import it.businesslogic.ireport.compiler.ErrorsCollector;
0037:        import it.businesslogic.ireport.compiler.ExtendedJRJdtCompiler;
0038:        import it.businesslogic.ireport.gui.*;
0039:        import it.businesslogic.ireport.gui.MainFrame;
0040:        import it.businesslogic.ireport.gui.locale.TimeZoneWrapper;
0041:        import it.businesslogic.ireport.gui.logpane.*;
0042:        import it.businesslogic.ireport.connection.*;
0043:        import it.businesslogic.ireport.gui.queryexecuters.QueryExecuterDef;
0044:        import it.businesslogic.ireport.util.*;
0045:        import it.businesslogic.ireport.compiler.xml.SourceLocation;
0046:        import it.businesslogic.ireport.compiler.xml.SourceTraceDigester;
0047:        import java.lang.reflect.InvocationTargetException;
0048:        import java.util.*;
0049:        import java.io.*;
0050:        import java.net.MalformedURLException;
0051:        import java.net.URL;
0052:        import java.net.URLClassLoader;
0053:        import javax.persistence.EntityManager;
0054:        import javax.swing.JOptionPane;
0055:        import javax.swing.SwingUtilities;
0056:        import javax.xml.parsers.ParserConfigurationException;
0057:
0058:        import net.sf.jasperreports.engine.*;
0059:        import net.sf.jasperreports.engine.design.JRJdtCompiler;
0060:        import net.sf.jasperreports.engine.design.JRValidationException;
0061:        import net.sf.jasperreports.engine.design.JRValidationFault;
0062:        import net.sf.jasperreports.engine.design.JasperDesign;
0063:        import net.sf.jasperreports.engine.query.JRJpaQueryExecuterFactory;
0064:        import net.sf.jasperreports.engine.util.JRSaver;
0065:        import net.sf.jasperreports.engine.util.JRSwapFile;
0066:        import net.sf.jasperreports.olap.JRMondrianQueryExecuterFactory;
0067:        import net.sf.jasperreports.engine.export.*;
0068:        import net.sf.jasperreports.engine.query.JRHibernateQueryExecuterFactory;
0069:        import net.sf.jasperreports.engine.util.JRProperties;
0070:        import net.sf.jasperreports.engine.xml.JRXmlDigesterFactory;
0071:        import net.sf.jasperreports.engine.xml.JRXmlLoader;
0072:        import net.sf.jasperreports.view.JasperViewer;
0073:        import org.hibernate.Transaction;
0074:        import org.hibernate.classic.Session;
0075:        import org.xml.sax.SAXException;
0076:
0077:        /**
0078:         * Please note that this class is totally different from the old IReportCompiler.class
0079:         * shipped with iReport 1.
0080:         * @author  Administrator
0081:         */
0082:        public class IReportCompiler implements  Runnable,
0083:                JRExportProgressMonitor {
0084:
0085:            public static final int CMD_COMPILE = 0x01;
0086:            public static final int CMD_EXPORT = 0x02;
0087:            public static final int CMD_COMPILE_SCRIPTLET = 0x04;
0088:
0089:            public static final String OUTPUT_DIRECTORY = "OUTPUT_DIRECTORY";
0090:            public static final String OUTPUT_FORMAT = "OUTPUT_FORMAT";
0091:            public static final String USE_EMPTY_DATASOURCE = "USE_EMPTY_DATASOURCE";
0092:            public static final String USE_CONNECTION = "USE_CONNECTION";
0093:            public static final String CONNECTION = "CONNECTION";
0094:            public static final String SCRIPTLET_OUTPUT_DIRECTORY = "SCRIPTLET_OUTPUT_DIRECTORY";
0095:            public static final String COMPILER = "COMPILER";
0096:            public static final String EMPTY_DATASOURCE_RECORDS = "EMPTY_DATASOURCE_RECORDS";
0097:
0098:            private String constTabTitle = "";
0099:            private javax.swing.JList threadList = null;
0100:
0101:            static PrintStream myPrintStream = null;
0102:            int filledpage = 0;
0103:
0104:            private String status = "Starting";
0105:            private IReportConnection iReportConnection;
0106:            private int statusLevel = 0;
0107:
0108:            private JReportFrame jrf;
0109:
0110:            private int maxBufferSize = 100000;
0111:
0112:            private MainFrame mainFrame;
0113:
0114:            private int command;
0115:
0116:            private HashMap properties;
0117:
0118:            private Thread thread;
0119:
0120:            private LogTextArea logTextArea = null;
0121:
0122:            private String javaFile = "";
0123:            static private StringBuffer outputBuffer = new StringBuffer();
0124:
0125:            /**
0126:             * added by Felix Firgau
0127:             */
0128:            private static Vector compileListener = new Vector();
0129:
0130:            /** Creates a new instance of IReportCompiler */
0131:            public IReportCompiler() {
0132:                properties = new HashMap();
0133:                command = 0;
0134:
0135:                try {
0136:                    maxBufferSize = Integer.parseInt(System.getProperty(
0137:                            "ireport.maxbufsize", "100000"));
0138:                } catch (Exception ex) {
0139:                    maxBufferSize = 1000000;
0140:                }
0141:            }
0142:
0143:            public void stopThread() {
0144:                command = 0;
0145:                if (thread != null && thread.isAlive()) {
0146:                    try {
0147:                        thread.interrupt();
0148:                    } catch (Exception ex) {
0149:                        ex.printStackTrace();
0150:                    }
0151:                }
0152:                removeThread();
0153:
0154:                getLogTextArea().setTitle("Killed" + constTabTitle);
0155:                getLogTextArea().setRemovable(true);
0156:                System.gc();
0157:                System.gc();
0158:            }
0159:
0160:            /** When an object implementing interface <code>Runnable</code> is used
0161:             * to create a thread, starting the thread causes the object's
0162:             * <code>run</code> method to be called in that separately executing
0163:             * thread.
0164:             * <p>
0165:             * The general contract of the method <code>run</code> is that it may
0166:             * take any action whatsoever.
0167:             *
0168:             * @see     java.lang.Thread#run()
0169:             *
0170:             */
0171:            public void run() {
0172:
0173:                if (threadList != null)
0174:                    synchronized (threadList) {
0175:                        javax.swing.DefaultListModel dlm = (javax.swing.DefaultListModel) threadList
0176:                                .getModel();
0177:                        dlm.addElement(this );
0178:                        threadList.updateUI();
0179:                    }
0180:
0181:                PrintStream out = System.out;
0182:                PrintStream err = System.err;
0183:
0184:                try {
0185:
0186:                    SourceTraceDigester digester = null;
0187:                    ErrorsCollector errorsCollector = new ErrorsCollector();
0188:
0189:                    File f_report_title = new File(this .getJrf().getReport()
0190:                            .getFilename());
0191:                    constTabTitle = " [" + f_report_title.getName() + "]";
0192:
0193:                    String queryLanguage = this .jrf.getReport()
0194:                            .getQueryLanguage();
0195:
0196:                    logTextArea = getMainFrame().getLogPane().createNewLog();
0197:                    status = I18n.getString("iReportCompiler.status.starting",
0198:                            "Starting");
0199:
0200:                    logTextArea.setTitle(status + constTabTitle);
0201:
0202:                    String backupJRClasspath = net.sf.jasperreports.engine.util.JRProperties
0203:                            .getProperty(net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASSPATH);
0204:                    // System.getProperty("jasper.reports.compile.class.path");
0205:                    String backupSystemClasspath = System
0206:                            .getProperty("java.class.path");
0207:
0208:                    // Try to look for a good QueryExecutor...
0209:                    Vector configuredExecuters = MainFrame.getMainInstance()
0210:                            .getQueryExecuters();
0211:                    for (int k = 0; k < configuredExecuters.size(); ++k) {
0212:                        QueryExecuterDef qe = (QueryExecuterDef) configuredExecuters
0213:                                .get(k);
0214:                        if (qe.getLanguage().equals(queryLanguage)) {
0215:                            net.sf.jasperreports.engine.util.JRProperties
0216:                                    .setProperty(
0217:                                            "net.sf.jasperreports.query.executer.factory."
0218:                                                    + qe.getLanguage(), qe
0219:                                                    .getClassName());
0220:                            getLogTextArea()
0221:                                    .logOnConsole(
0222:                                            I18n
0223:                                                    .getFormattedString(
0224:                                                            "iReportCompiler.settingQueryExecuter",
0225:                                                            "Setting {0} as Query Executer Factory for language: {1}\n",
0226:                                                            new Object[] {
0227:                                                                    qe
0228:                                                                            .getClassName(),
0229:                                                                    ""
0230:                                                                            + qe
0231:                                                                                    .getLanguage() }));
0232:
0233:                            break;
0234:                        }
0235:
0236:                    }
0237:
0238:                    boolean compilation_ok = true;
0239:                    long start = System.currentTimeMillis();
0240:                    // Redirect output stream....
0241:
0242:                    if (myPrintStream == null)
0243:                        myPrintStream = new PrintStream(new FilteredStream(
0244:                                new ByteArrayOutputStream()));
0245:
0246:                    if (out != myPrintStream)
0247:                        System.setOut(myPrintStream);
0248:                    if (err != myPrintStream)
0249:                        System.setErr(myPrintStream);
0250:
0251:                    outputBuffer = new StringBuffer();
0252:
0253:                    //by Egon - DEBUG: Something is wrong here, please check. ok? thx.
0254:                    //1 - Line 148 - srcScriptletFileName = C:\jasperreports-0.5.3\demo\samples\jasper\FirstJasper.jrxmScriptlet.java -> scriptlet filename
0255:                    //2 - Line 157 - Misc.nvl( new File(fileName).getParent(), ".") =>  .  -> report directory
0256:
0257:                    // Add an entry in the thread list...
0258:                    //by Egon - DEBUG: C:\jasperreports-0.5.3\demo\samples\jasper\FirstJasper.jrxml
0259:                    String fileName = jrf.getReport().getFilename();
0260:
0261:                    //by Egon - DEBUG: C:\jasperreports-0.5.3\demo\samples\jasper\FirstJasper.jrxml
0262:                    String srcFileName = jrf.getReport().getFilename();
0263:                    //by Egon - DEBUG: C:\jasperreports-0.5.3\demo\samples\jasper\FirstJasper.jasper
0264:                    fileName = Misc.changeFileExtension(fileName, "jasper");
0265:
0266:                    File f = new File(fileName);
0267:                    if (properties.get(this .OUTPUT_DIRECTORY) != null) {
0268:                        //by Egon - DEBUG: .\FirstJasper.jasper
0269:                        fileName = (String) properties
0270:                                .get(this .OUTPUT_DIRECTORY);
0271:                        if (!fileName.endsWith(f.separator)) {
0272:                            fileName += f.separator;
0273:                        }
0274:                        fileName += f.getName();
0275:                    }
0276:
0277:                    //by Egon - DEBUG: C:\jasperreports-0.5.3\demo\samples\jasper\FirstJasper.jrxml
0278:                    String scriptletFileName = jrf.getReport().getFilename();
0279:                    //by Egon - DEBUG: C:\jasperreports-0.5.3\demo\samples\jasper\FirstJasper.jrxml
0280:                    String srcScriptletFileName = jrf.getReport().getFilename();
0281:                    //by Egon - DEBUG: .\FirstJasper.
0282:                    //fileName = Misc.changeFileExtension(fileName,"");
0283:                    //by Egon - DEBUG: C:\jasperreports-0.5.3\demo\samples\jasper\FirstJasper.jrxmScriptlet.java
0284:                    scriptletFileName = srcScriptletFileName.substring(0,
0285:                            scriptletFileName.length() - 1)
0286:                            + "Scriptlet.java";
0287:                    //1 - by Egon - DEBUG: C:\jasperreports-0.5.3\demo\samples\jasper\FirstJasper.jrxmScriptlet.java
0288:                    srcScriptletFileName = scriptletFileName;
0289:
0290:                    File f2 = new File(scriptletFileName);
0291:                    if (properties.get(this .SCRIPTLET_OUTPUT_DIRECTORY) != null) {
0292:                        scriptletFileName = (String) properties
0293:                                .get(this .SCRIPTLET_OUTPUT_DIRECTORY)
0294:                                + f2.separatorChar + f2.getName();
0295:                    }
0296:
0297:                    String reportDirectory = new File(jrf.getReport()
0298:                            .getFilename()).getParent();
0299:                    //String classpath = System.getProperty("jasper.reports.compile.class.path");
0300:                    String classpath = net.sf.jasperreports.engine.util.JRProperties
0301:                            .getProperty(net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASSPATH);
0302:
0303:                    if (classpath != null) {
0304:                        classpath += File.pathSeparator + reportDirectory;
0305:                        //System.setProperty("jasper.reports.compile.class.path", classpath);
0306:                        net.sf.jasperreports.engine.util.JRProperties
0307:                                .setProperty(
0308:                                        net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASSPATH,
0309:                                        classpath);
0310:                    } else if (System.getProperty("java.class.path") != null) {
0311:                        classpath = System.getProperty("java.class.path");
0312:                        classpath += File.pathSeparator + reportDirectory;
0313:                        System.setProperty("java.class.path", classpath);
0314:                    }
0315:                    reportDirectory = reportDirectory.replace('\\', '/');
0316:                    if (!reportDirectory.endsWith("/")) {
0317:                        reportDirectory += "/";//the file path separator must be present
0318:                    }
0319:                    if (!reportDirectory.startsWith("/")) {
0320:                        reportDirectory = "/" + reportDirectory;//it's important to JVM 1.4.2 especially if contains windows drive letter
0321:                    }
0322:                    ReportClassLoader reportClassLoader = new ReportClassLoader(
0323:                            mainFrame.getReportClassLoader());
0324:                    reportClassLoader.setRelodablePaths(reportDirectory);
0325:                    reportClassLoader.rescanLibDirectory();
0326:
0327:                    /******************/
0328:
0329:                    try {
0330:                        Thread.currentThread().setContextClassLoader(
0331:                                new URLClassLoader(new URL[] { new URL(
0332:                                        "file://" + reportDirectory) },
0333:                                        reportClassLoader));
0334:
0335:                    } catch (MalformedURLException mue) {
0336:                        mue.printStackTrace();
0337:                    }
0338:
0339:                    /******************/
0340:
0341:                    //.setContextClassLoader(reportClassLoader);
0342:                    if ((command & CMD_COMPILE_SCRIPTLET) != 0) {
0343:                        status = I18n.getString(
0344:                                "iReportCompiler.status.compilingScriptlet",
0345:                                "Compiling scriptlet");
0346:                        updateThreadList();
0347:                        start = System.currentTimeMillis();
0348:
0349:                        // Compile the scriptlet class...
0350:
0351:                        //String tempDirStr = System.getProperty("jasper.reports.compile.temp");
0352:                        String tempDirStr = net.sf.jasperreports.engine.util.JRProperties
0353:                                .getProperty(net.sf.jasperreports.engine.util.JRProperties.COMPILER_TEMP_DIR);
0354:
0355:                        String oldCompileTemp = tempDirStr;
0356:                        if (tempDirStr == null
0357:                                || tempDirStr.length() == 0
0358:                                || mainFrame
0359:                                        .isUsingCurrentFilesDirectoryForCompiles()) {
0360:                            tempDirStr = mainFrame
0361:                                    .getTranslatedCompileDirectory();
0362:                        }
0363:                        File tempDirFile = new File(tempDirStr);
0364:                        javaFile = srcScriptletFileName;
0365:                        javaFile = (new File(tempDirFile, javaFile)).getPath();
0366:
0367:                        javaFile = jrf.getReport().getScriptletFileName();
0368:
0369:                        if (Misc.getLastWriteTime(javaFile) > Misc
0370:                                .getLastWriteTime(Misc.changeFileExtension(
0371:                                        javaFile, "class"))) {
0372:                            getLogTextArea()
0373:                                    .logOnConsole(
0374:                                            "<font face=\"SansSerif\" size=\"3\" color=\"#000000\">"
0375:                                                    + I18n
0376:                                                            .getFormattedString(
0377:                                                                    "iReportCompiler.compilingScriptlet",
0378:                                                                    "Compiling scriptlet source file... {0}",
0379:                                                                    new Object[] { javaFile })
0380:                                                    + "</font>", true);
0381:                            try {
0382:                                //JasperCompileManager.compileReportToFile(srcFileName, fileName);
0383:                                net.sf.jasperreports.engine.design.JRJdk13Compiler compiler = new net.sf.jasperreports.engine.design.JRJdk13Compiler();
0384:                                String errors = compiler.compileClass(new File(
0385:                                        javaFile), Misc.getClassPath());
0386:                                if (errors != null && errors.length() > 0) {
0387:                                    getLogTextArea()
0388:                                            .logOnConsole(
0389:                                                    "<font face=\"SansSerif\"  size=\"3\" color=\"#CC0000\"><b>"
0390:                                                            + I18n
0391:                                                                    .getFormattedString(
0392:                                                                            "iReportCompiler.errorsCompilingScriptlet",
0393:                                                                            "Errors compiling {0}!",
0394:                                                                            new Object[] { javaFile })
0395:                                                            + "</b></font>",
0396:                                                    true);
0397:                                    getLogTextArea().logOnConsole(errors);
0398:                                    compilation_ok = false;
0399:                                }
0400:                            }
0401:                            /*
0402:                            catch (Exception jrex)
0403:                            {
0404:
0405:                               getLogTextArea().logOnConsole("<font face=\"SansSerif\"  size=\"3\" color=\"#CC0000\"><b>Errors compiling "+scriptletFileName+"!</b></font>",true);
0406:                               //1. load the java file
0407:                               Vector source = new Vector();
0408:                               try
0409:                               {
0410:                                  java.io.BufferedReader is = new java.io.BufferedReader(new java.io.FileReader( javaFile ));
0411:                                  while (true)
0412:                                  {
0413:                                     String line = is.readLine();
0414:                                     if (line == null) break;
0415:                                     source.addElement(line);
0416:                                  }
0417:                                  is.close();
0418:                               } catch (Exception ioex)
0419:                               {
0420:                                  // No file readed....
0421:                               }
0422:                               //2. write exception in a string
0423:                               StringWriter sw = new StringWriter(0);
0424:                               jrex.printStackTrace(new PrintWriter(sw));
0425:
0426:                               System.out.println("\n\n\n");
0427:                               myPrintStream.flush();
0428:                               parseException( outputBuffer+sw.getBuffer()+"", source);
0429:
0430:                            }
0431:                             */
0432:                            catch (Exception ex) {
0433:                                getLogTextArea()
0434:                                        .logOnConsole(
0435:                                                "<font face=\"SansSerif\"  size=\"3\" color=\"#CC0000\"><b>"
0436:                                                        + I18n
0437:                                                                .getString(
0438:                                                                        "iReportCompiler.errorsCompilingScriptletJavaSource",
0439:                                                                        "Error compiling the Scriptlet java source!")
0440:                                                        + "</b></font>", true);
0441:                                StringWriter sw = new StringWriter(0);
0442:                                ex.printStackTrace(new PrintWriter(sw));
0443:                                myPrintStream.flush();
0444:                                parseException(outputBuffer.toString()
0445:                                        + sw.getBuffer() + "", null);
0446:                                compilation_ok = false;
0447:                            } catch (Throwable ext) {
0448:                                getLogTextArea()
0449:                                        .logOnConsole(
0450:                                                "<font face=\"SansSerif\"  size=\"3\" color=\"#CC0000\"><b>"
0451:                                                        + I18n
0452:                                                                .getString(
0453:                                                                        "iReportCompiler.errorsCompilingScriptletJavaSource",
0454:                                                                        "Error compiling the Scriptlet java source!")
0455:                                                        + "</b></font>", true);
0456:                                StringWriter sw = new StringWriter(0);
0457:                                ext.printStackTrace(new PrintWriter(sw));
0458:                                myPrintStream.flush();
0459:                                parseException(outputBuffer.toString()
0460:                                        + sw.getBuffer() + "", null);
0461:                                compilation_ok = false;
0462:                            } finally {
0463:                                if (mainFrame
0464:                                        .isUsingCurrentFilesDirectoryForCompiles()) {
0465:                                    /*
0466:                                    if( oldCompileTemp != null )
0467:                                    {
0468:                                      System.setProperty("jasper.reports.compile.temp", oldCompileTemp);
0469:                                    }
0470:                                    else
0471:                                    {
0472:                                      System.setProperty("jasper.reports.compile.temp", "");
0473:                                    }
0474:                                     */
0475:                                }//end if using current files directory for compiles
0476:                            }//end finally
0477:                            getLogTextArea().logOnConsole(
0478:                                    outputBuffer.toString());
0479:                            outputBuffer = new StringBuffer();
0480:                            getLogTextArea()
0481:                                    .logOnConsole(
0482:                                            "<font face=\"SansSerif\"  size=\"3\" color=\"#0000CC\"><b>"
0483:                                                    + I18n
0484:                                                            .getFormattedString(
0485:                                                                    "iReportCompiler.compilationRunningTime",
0486:                                                                    "Compilation running time: {0,number}!",
0487:                                                                    new Object[] { new Long(
0488:                                                                            System
0489:                                                                                    .currentTimeMillis()
0490:                                                                                    - start) })
0491:                                                    + "</b></font><hr>", true);
0492:                        }
0493:                    }
0494:
0495:                    if (!compilation_ok) {
0496:
0497:                        fireCompileListner(this , CL_COMPILE_FAIL,
0498:                                CLS_COMPILE_SCRIPTLET_FAIL);
0499:                        removeThread();
0500:                        return;
0501:                    }
0502:
0503:                    if ((command & CMD_COMPILE) != 0) {
0504:                        status = I18n.getString(
0505:                                "iReportCompiler.status.compilingReport",
0506:                                "Compiling report");
0507:                        updateThreadList();
0508:
0509:                        //System.setProperty("jasper.reports.compile.keep.java.file", "true");
0510:
0511:                        if (mainFrame.getProperties().getProperty(
0512:                                "KeepJavaFile", "true").equals("false")) {
0513:                            net.sf.jasperreports.engine.util.JRProperties
0514:                                    .setProperty(
0515:                                            net.sf.jasperreports.engine.util.JRProperties.COMPILER_KEEP_JAVA_FILE,
0516:                                            false);
0517:                        } else {
0518:                            net.sf.jasperreports.engine.util.JRProperties
0519:                                    .setProperty(
0520:                                            net.sf.jasperreports.engine.util.JRProperties.COMPILER_KEEP_JAVA_FILE,
0521:                                            true);
0522:                        }
0523:
0524:                        //System.setProperty("jasper.reports.compile.temp", "C:\\");
0525:                        // Compile report....
0526:                        javaFile = this .jrf.getReport().getName() + ".java";
0527:
0528:                        //String tempDirStr = System.getProperty("jasper.reports.compile.temp");
0529:                        String tempDirStr = net.sf.jasperreports.engine.util.JRProperties
0530:                                .getProperty(net.sf.jasperreports.engine.util.JRProperties.COMPILER_TEMP_DIR);
0531:
0532:                        String oldCompileTemp = tempDirStr;
0533:                        if (tempDirStr == null
0534:                                || tempDirStr.length() == 0
0535:                                || mainFrame
0536:                                        .isUsingCurrentFilesDirectoryForCompiles()) {
0537:                            tempDirStr = mainFrame
0538:                                    .getTranslatedCompileDirectory();
0539:                        }
0540:                        File tempDirFile = new File(tempDirStr);
0541:                        javaFile = (new File(tempDirFile, javaFile)).getPath();
0542:
0543:                        URL img_url_comp = this 
0544:                                .getClass()
0545:                                .getResource(
0546:                                        "/it/businesslogic/ireport/icons/comp1_mini.jpg");
0547:
0548:                        if (jrf.getReport().getReportChanges() > 0) {
0549:                            getLogTextArea()
0550:                                    .logOnConsole(
0551:                                            I18n
0552:                                                    .getString(
0553:                                                            "messages.unsavedChanges",
0554:                                                            "The report still has unsaved changes"),
0555:                                            JOptionPane.WARNING_MESSAGE);
0556:                        }
0557:
0558:                        getLogTextArea()
0559:                                .logOnConsole(
0560:                                        "<font face=\"SansSerif\" size=\"3\" color=\"#000000\"><img align=\"right\" src=\""
0561:                                                + img_url_comp
0562:                                                + "\"> &nbsp;"
0563:                                                + I18n
0564:                                                        .getFormattedString(
0565:                                                                "iReportCompiler.compilingToFile",
0566:                                                                "Compiling to file... {0} -> {1}",
0567:                                                                new Object[] {
0568:                                                                        fileName,
0569:                                                                        javaFile })
0570:                                                + "</font>", true);
0571:
0572:                        //String old_jr_classpath = Misc.nvl( System.getProperty("jasper.reports.compile.class.path"), "");
0573:                        //String old_defaul_compiler = Misc.nvl( System.getProperty("jasper.reports.compiler.class"), "");
0574:                        String old_jr_classpath = Misc
0575:                                .nvl(
0576:                                        net.sf.jasperreports.engine.util.JRProperties
0577:                                                .getProperty(net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASSPATH),
0578:                                        "");
0579:                        String old_defaul_compiler = Misc
0580:                                .nvl(
0581:                                        net.sf.jasperreports.engine.util.JRProperties
0582:                                                .getProperty(net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASS),
0583:                                        "");
0584:
0585:                        try {
0586:                            if (mainFrame
0587:                                    .isUsingCurrentFilesDirectoryForCompiles()) {
0588:                                //System.setProperty("jasper.reports.compile.temp", tempDirStr);
0589:                                net.sf.jasperreports.engine.util.JRProperties
0590:                                        .setProperty(
0591:                                                net.sf.jasperreports.engine.util.JRProperties.COMPILER_TEMP_DIR,
0592:                                                tempDirStr);
0593:
0594:                            }
0595:
0596:                            //System.setProperty("jasper.reports.compile.class.path", Misc.nvl( new File(fileName).getParent(), ".")  + File.pathSeparator  + Misc.getClassPath());
0597:                            net.sf.jasperreports.engine.util.JRProperties
0598:                                    .setProperty(
0599:                                            net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASSPATH,
0600:                                            Misc.nvl(new File(fileName)
0601:                                                    .getParent(), ".")
0602:                                                    + File.pathSeparator
0603:                                                    + Misc.getClassPath());
0604:
0605:                            //System.out.println("CP:" + System.getProperty("jasper.reports.compile.class.path"));
0606:                            //System.out.println("\nOLDCP:" +old_jr_classpath);
0607:
0608:                            String compiler_name = I18n.getString(
0609:                                    "iReportCompiler.defaultCompiler",
0610:                                    "JasperReports default compiler");
0611:                            String compiler_code = mainFrame.getProperties()
0612:                                    .getProperty("DefaultCompiler");
0613:
0614:                            JRJdtCompiler jdtCompiler = null;
0615:                            if (this .getProperties().get(COMPILER) != null) {
0616:                                //System.setProperty("jasper.reports.compiler.class", ""+this.getProperties().get(COMPILER) );
0617:                                net.sf.jasperreports.engine.util.JRProperties
0618:                                        .setProperty(
0619:                                                net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASS,
0620:                                                ""
0621:                                                        + this .getProperties()
0622:                                                                .get(COMPILER));
0623:                                compiler_name = I18n
0624:                                        .getFormattedString(
0625:                                                "iReportCompiler.specialLanguageCompiler",
0626:                                                "Special language compiler ({0})",
0627:                                                new Object[] { this 
0628:                                                        .getProperties().get(
0629:                                                                COMPILER) });
0630:                            } else if (compiler_code != null
0631:                                    && !compiler_code.equals("0")
0632:                                    && !compiler_code.equals("")) {
0633:                                if (compiler_code.equals("1")) {
0634:                                    //System.setProperty("jasper.reports.compiler.class","net.sf.jasperreports.engine.design.JRJdk13Compiler"  );
0635:                                    net.sf.jasperreports.engine.util.JRProperties
0636:                                            .setProperty(
0637:                                                    net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASS,
0638:                                                    "net.sf.jasperreports.engine.design.JRJdk13Compiler");
0639:                                    compiler_name = I18n.getString(
0640:                                            "iReportCompiler.javaCompiler",
0641:                                            "Java Compiler");
0642:                                } else if (compiler_code.equals("2")) {
0643:                                    //System.setProperty("jasper.reports.compiler.class","net.sf.jasperreports.engine.design.JRJdtCompiler"  );
0644:
0645:                                    //net.sf.jasperreports.engine.util.JRProperties.setProperty(net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASS, "net.sf.jasperreports.engine.design.JRJdtCompiler" ); //"net.sf.jasperreports.engine.design.JRJdtCompiler"
0646:                                    net.sf.jasperreports.engine.util.JRProperties
0647:                                            .setProperty(
0648:                                                    net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASS,
0649:                                                    "it.businesslogic.ireport.compiler.ExtendedJRJdtCompiler");
0650:                                    compiler_name = I18n.getString(
0651:                                            "iReportCompiler.jdtCompiler",
0652:                                            "JDT Compiler");
0653:                                    //Thread.currentThread().setContextClassLoader( reportClassLoader );
0654:                                    //ClassLoader cl = getClassLoader();
0655:                                    //System.out.println(  Thread.getC );
0656:
0657:                                    jdtCompiler = new ExtendedJRJdtCompiler();
0658:                                } else if (compiler_code.equals("3")) {
0659:                                    //System.setProperty("jasper.reports.compiler.class","net.sf.jasperreports.engine.design.JRBshCompiler"  );
0660:                                    net.sf.jasperreports.engine.util.JRProperties
0661:                                            .setProperty(
0662:                                                    net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASS,
0663:                                                    "net.sf.jasperreports.compilers.JRBshCompiler");
0664:                                    compiler_name = I18n
0665:                                            .getString(
0666:                                                    "iReportCompiler.beanShellCompiler",
0667:                                                    "BeanShell Compiler");
0668:                                } else if (compiler_code.equals("4")) {
0669:                                    //System.setProperty("jasper.reports.compiler.class","net.sf.jasperreports.engine.design.JRJikesCompiler"  );
0670:                                    net.sf.jasperreports.engine.util.JRProperties
0671:                                            .setProperty(
0672:                                                    net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASS,
0673:                                                    "net.sf.jasperreports.engine.design.JRJikesCompiler");
0674:                                    compiler_name = I18n.getString(
0675:                                            "iReportCompiler.jikesCompiler",
0676:                                            "Jikes Compiler");
0677:                                }
0678:                            } else {
0679:                                //System.setProperty("jasper.reports.compiler.class","" );
0680:                                //net.sf.jasperreports.engine.util.JRProperties.setProperty(net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASS, "" );
0681:
0682:                                //Force to use the iReport compiler....
0683:                                net.sf.jasperreports.engine.util.JRProperties
0684:                                        .setProperty(
0685:                                                net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASS,
0686:                                                "it.businesslogic.ireport.compiler.ExtendedJRJdtCompiler");
0687:
0688:                                //Thread.currentThread().setContextClassLoader( reportClassLoader );
0689:                                //ClassLoader cl = getClassLoader();
0690:                                //System.out.println(  cl );
0691:                                jdtCompiler = new ExtendedJRJdtCompiler();
0692:                            }
0693:
0694:                            // getLogTextArea().logOnConsole("<font face=\"SansSerif\"  size=\"3\" color=\"#000000\"><b>Using compiler "+ compiler_name  + " (" + System.getProperty("jasper.reports.compiler.class","" ) +")</b></font>",true);
0695:                            start = System.currentTimeMillis();
0696:
0697:                            digester = IReportCompiler.createDigester();
0698:                            JasperDesign jd = IReportCompiler.loadJasperDesign(
0699:                                    new FileInputStream(srcFileName), digester);
0700:
0701:                            if (jdtCompiler != null) {
0702:                                ((ExtendedJRJdtCompiler) jdtCompiler)
0703:                                        .setDigester(digester);
0704:                                ((ExtendedJRJdtCompiler) jdtCompiler)
0705:                                        .setErrorHandler(errorsCollector);
0706:
0707:                                JasperReport finalJR = jdtCompiler
0708:                                        .compileReport(jd);
0709:
0710:                                if (errorsCollector.getProblemItems().size() > 0
0711:                                        || finalJR == null) {
0712:
0713:                                    throw new JRException("");
0714:                                }
0715:                                JRSaver.saveObject(finalJR, fileName);
0716:
0717:                                //System.out.println("Report saved..." + finalJR + " " + errorsCollector.getProblemItems().size());
0718:                            } else {
0719:                                JasperCompileManager.compileReportToFile(jd,
0720:                                        fileName);
0721:                            }
0722:
0723:                            if (errorsCollector != null) {
0724:                                getJrf().setReportProblems(
0725:                                        errorsCollector.getProblemItems());
0726:                                MainFrame.getMainInstance().getLogPane()
0727:                                        .getProblemsPanel()
0728:                                        .updateProblemsList();
0729:                            }
0730:
0731:                        } catch (JRValidationException e) {
0732:                            compilation_ok = false;
0733:
0734:                            for (Iterator it = e.getFaults().iterator(); it
0735:                                    .hasNext();) {
0736:                                JRValidationFault fault = (JRValidationFault) it
0737:                                        .next();
0738:                                Object source = fault.getSource();
0739:                                SourceLocation sl = digester
0740:                                        .getLocation(source);
0741:                                if (sl == null) {
0742:                                    errorsCollector.getProblemItems().add(
0743:                                            new ProblemItem(
0744:                                                    ProblemItem.WARNING, fault
0745:                                                            .getMessage(), sl,
0746:                                                    null));
0747:                                } else {
0748:                                    errorsCollector.getProblemItems().add(
0749:                                            new ProblemItem(
0750:                                                    ProblemItem.WARNING, fault
0751:                                                            .getMessage(), sl,
0752:                                                    sl.getXPath()));
0753:                                    System.out.println(fault + " "
0754:                                            + fault.getMessage() + "\nLine: "
0755:                                            + sl.getLineNumber() + ", Column: "
0756:                                            + sl.getColumnNumber()
0757:                                            + " JRXML Element: "
0758:                                            + sl.getXPath());
0759:                                }
0760:
0761:                                //
0762:                            }
0763:                            getJrf().setReportProblems(
0764:                                    errorsCollector.getProblemItems());
0765:                            MainFrame.getMainInstance().getLogPane()
0766:                                    .getProblemsPanel().updateProblemsList();
0767:
0768:                            StringWriter sw = new StringWriter(0);
0769:                            e.printStackTrace(new PrintWriter(sw));
0770:                            System.out.println("\n\n\n");
0771:                            myPrintStream.flush();
0772:                            parseException(outputBuffer.toString()
0773:                                    + sw.getBuffer() + "", null);
0774:
0775:                        } catch (JRException jrex) {
0776:                            if (errorsCollector != null
0777:                                    && errorsCollector.getProblemItems() != null) {
0778:                                getJrf().setReportProblems(
0779:                                        errorsCollector.getProblemItems());
0780:                                MainFrame.getMainInstance().getLogPane()
0781:                                        .getProblemsPanel()
0782:                                        .updateProblemsList();
0783:                            }
0784:
0785:                            compilation_ok = false;
0786:                            getLogTextArea()
0787:                                    .logOnConsole(
0788:                                            "<font face=\"SansSerif\"  size=\"3\" color=\"#CC0000\"><b>"
0789:                                                    + I18n
0790:                                                            .getFormattedString(
0791:                                                                    "iReportCompiler.errorsCompiling",
0792:                                                                    "Errors compiling {0}!",
0793:                                                                    new Object[] { fileName })
0794:                                                    + "</b></font>", true);
0795:
0796:                            /*
0797:                            //1. load the java file
0798:                            Vector source = new Vector();
0799:                            try
0800:                            {
0801:                            java.io.BufferedReader is = new java.io.BufferedReader(new java.io.FileReader( javaFile ));
0802:                            while (true)
0803:                            {
0804:                            String line = is.readLine();
0805:                            if (line == null) break;
0806:                            source.addElement(line);
0807:                            }
0808:                            is.close();
0809:
0810:                            } catch (Exception ioex)
0811:                            {
0812:                            // No file readed....
0813:                            }
0814:                            //2. write exception in a string
0815:                             
0816:                             */
0817:                            StringWriter sw = new StringWriter(0);
0818:                            jrex.printStackTrace(new PrintWriter(sw));
0819:
0820:                            System.out.println("\n\n\n");
0821:                            myPrintStream.flush();
0822:                            parseException(outputBuffer.toString()
0823:                                    + sw.getBuffer() + "", null);
0824:
0825:                        } catch (Exception ex) {
0826:                            getLogTextArea()
0827:                                    .logOnConsole(
0828:                                            "<font face=\"SansSerif\"  size=\"3\" color=\"#CC0000\"><b>"
0829:                                                    + I18n
0830:                                                            .getString(
0831:                                                                    "iReportCompiler.errorsCompilingReportJavaSource",
0832:                                                                    "Error compiling the report java source!")
0833:                                                    + "</b></font>", true);
0834:                            StringWriter sw = new StringWriter(0);
0835:                            ex.printStackTrace(new PrintWriter(sw));
0836:                            myPrintStream.flush();
0837:                            parseException(outputBuffer.toString()
0838:                                    + sw.getBuffer() + "", null);
0839:                            compilation_ok = false;
0840:                        } catch (Throwable ext) {
0841:                            getLogTextArea()
0842:                                    .logOnConsole(
0843:                                            "<font face=\"SansSerif\"  size=\"3\" color=\"#CC0000\"><b>"
0844:                                                    + I18n
0845:                                                            .getString(
0846:                                                                    "iReportCompiler.errorsCompilingReportJavaSource",
0847:                                                                    "Error compiling the report java source!")
0848:                                                    + "</b></font>", true);
0849:                            StringWriter sw = new StringWriter(0);
0850:                            ext.printStackTrace(new PrintWriter(sw));
0851:                            myPrintStream.flush();
0852:                            parseException(outputBuffer.toString()
0853:                                    + sw.getBuffer() + "", null);
0854:                            compilation_ok = false;
0855:                        } finally {
0856:                            //System.setProperty("jasper.reports.compile.class.path", old_jr_classpath);
0857:                            net.sf.jasperreports.engine.util.JRProperties
0858:                                    .setProperty(
0859:                                            net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASSPATH,
0860:                                            old_jr_classpath);
0861:                            //System.setProperty("jasper.reports.compiler.class", old_defaul_compiler);
0862:                            net.sf.jasperreports.engine.util.JRProperties
0863:                                    .setProperty(
0864:                                            net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASS,
0865:                                            old_defaul_compiler);
0866:
0867:                            if (mainFrame
0868:                                    .isUsingCurrentFilesDirectoryForCompiles()) {
0869:                                if (oldCompileTemp != null) {
0870:                                    System.setProperty(
0871:                                            "jasper.reports.compile.temp",
0872:                                            oldCompileTemp);
0873:                                    net.sf.jasperreports.engine.util.JRProperties
0874:                                            .setProperty(
0875:                                                    net.sf.jasperreports.engine.util.JRProperties.COMPILER_TEMP_DIR,
0876:                                                    oldCompileTemp);
0877:                                } else {
0878:                                    System.setProperty(
0879:                                            "jasper.reports.compile.temp", "");
0880:                                    net.sf.jasperreports.engine.util.JRProperties
0881:                                            .setProperty(
0882:                                                    net.sf.jasperreports.engine.util.JRProperties.COMPILER_TEMP_DIR,
0883:                                                    "");
0884:                                }
0885:
0886:                                File javaSrcFile = new File(javaFile);
0887:                                if (javaSrcFile.exists())
0888:                                    if (mainFrame.getProperties().getProperty(
0889:                                            "KeepJavaFile", "true").equals(
0890:                                            "false")) {
0891:                                        javaSrcFile.delete();
0892:                                    }
0893:                            }//end if using current files directory for compiles
0894:                        }//end finally
0895:                        getLogTextArea().logOnConsole(outputBuffer.toString());
0896:                        outputBuffer = new StringBuffer();
0897:                        getLogTextArea()
0898:                                .logOnConsole(
0899:                                        "<font face=\"SansSerif\"  size=\"3\" color=\"#0000CC\"><b>"
0900:                                                + I18n
0901:                                                        .getFormattedString(
0902:                                                                "iReportCompiler.compilationRunningTime",
0903:                                                                "Compilation running time: {0,number}!",
0904:                                                                new Object[] { new Long(
0905:                                                                        System
0906:                                                                                .currentTimeMillis()
0907:                                                                                - start) })
0908:                                                + "</b></font><hr>", true);
0909:
0910:                        if (errorsCollector != null
0911:                                && errorsCollector.getProblemItems().size() > 0) {
0912:                            try {
0913:                                SwingUtilities.invokeAndWait(new Runnable() {
0914:                                    public void run() {
0915:                                        MainFrame
0916:                                                .getMainInstance()
0917:                                                .getLogPane()
0918:                                                .setActiveLogComponent(
0919:                                                        MainFrame
0920:                                                                .getMainInstance()
0921:                                                                .getLogPane()
0922:                                                                .getProblemsPanel());
0923:                                    }
0924:                                });
0925:                            } catch (InvocationTargetException ex) {
0926:                                ex.printStackTrace();
0927:                            } catch (InterruptedException ex) {
0928:                                ex.printStackTrace();
0929:                            }
0930:                        }
0931:                    }
0932:
0933:                    if (!compilation_ok) {
0934:
0935:                        fireCompileListner(this , CL_COMPILE_FAIL,
0936:                                CLS_COMPILE_SOURCE_FAIL);
0937:                        removeThread();
0938:                        return;
0939:                    }
0940:
0941:                    if ((command & CMD_EXPORT) != 0) {
0942:
0943:                        status = I18n.getString(
0944:                                "iReportCompiler.status.generatingReport",
0945:                                "Generating report");
0946:                        updateThreadList();
0947:
0948:                        // Compile report....
0949:                        JasperPrint print = null;
0950:                        URL img_url = this 
0951:                                .getClass()
0952:                                .getResource(
0953:                                        "/it/businesslogic/ireport/icons/rundb1_mini.jpg");
0954:
0955:                        getLogTextArea()
0956:                                .logOnConsole(
0957:                                        "<font face=\"SansSerif\" size=\"3\" color=\"#000000\"><img align=\"right\" src=\""
0958:                                                + img_url
0959:                                                + "\"> &nbsp;"
0960:                                                + I18n
0961:                                                        .getString(
0962:                                                                "iReportCompiler.fillingReport",
0963:                                                                "Filling report...")
0964:                                                + "</font>", true);
0965:
0966:                        statusLevel = 5;
0967:                        Map hm = it.businesslogic.ireport.gui.prompt.Prompter
0968:                                .promptForParameters(this .getJrf().getReport());
0969:
0970:                        hm.put("REPORT_LOCALE", Misc
0971:                                .getLocaleFromString(mainFrame.getProperties()
0972:                                        .getProperty("reportLocale")));
0973:
0974:                        img_url = this .getClass().getResource(
0975:                                "/it/businesslogic/ireport/icons/world.png");
0976:                        getLogTextArea()
0977:                                .logOnConsole(
0978:                                        "<font face=\"SansSerif\" size=\"3\" color=\"#000000\"><img align=\"right\" src=\""
0979:                                                + img_url
0980:                                                + "\"> &nbsp;"
0981:                                                + I18n
0982:                                                        .getFormattedString(
0983:                                                                "iReportCompiler.locale",
0984:                                                                "Locale: <b>{0}</b>",
0985:                                                                new Object[] { Misc
0986:                                                                        .getLocaleFromString(
0987:                                                                                mainFrame
0988:                                                                                        .getProperties()
0989:                                                                                        .getProperty(
0990:                                                                                                "reportLocale"))
0991:                                                                        .getDisplayName() })
0992:                                                + "</font>", true);
0993:
0994:                        String reportTimeZoneId = mainFrame.getProperties()
0995:                                .getProperty("reportTimeZoneId");
0996:                        String timeZoneName = I18n.getString(
0997:                                "timezone.default", "Default");
0998:                        if (reportTimeZoneId != null
0999:                                && reportTimeZoneId.length() > 0) {
1000:                            java.util.TimeZone tz = java.util.TimeZone
1001:                                    .getTimeZone(reportTimeZoneId);
1002:                            hm.put("REPORT_TIME_ZONE", tz);
1003:                            timeZoneName = new TimeZoneWrapper(tz) + "";
1004:                        }
1005:
1006:                        img_url = this .getClass().getResource(
1007:                                "/it/businesslogic/ireport/icons/timezone.png");
1008:                        getLogTextArea()
1009:                                .logOnConsole(
1010:                                        "<font face=\"SansSerif\" size=\"3\" color=\"#000000\"><img align=\"right\" src=\""
1011:                                                + img_url
1012:                                                + "\"> &nbsp;"
1013:                                                + I18n
1014:                                                        .getFormattedString(
1015:                                                                "iReportCompiler.timeZone",
1016:                                                                "Time zone: <b>{0}</b>",
1017:                                                                new Object[] { timeZoneName })
1018:                                                + "</font>", true);
1019:
1020:                        int reportMaxCount = 0;
1021:                        try {
1022:                            reportMaxCount = Integer.parseInt(mainFrame
1023:                                    .getProperties().getProperty("maxRecords",
1024:                                            "0"));
1025:                        } catch (Exception ex) {
1026:                        }
1027:
1028:                        if (reportMaxCount > 0) {
1029:                            img_url = this 
1030:                                    .getClass()
1031:                                    .getResource(
1032:                                            "/it/businesslogic/ireport/icons/file-info.png");
1033:                            getLogTextArea()
1034:                                    .logOnConsole(
1035:                                            "<font face=\"SansSerif\" size=\"3\" color=\"#000000\"><img align=\"right\" src=\""
1036:                                                    + img_url
1037:                                                    + "\"> &nbsp;"
1038:                                                    + I18n
1039:                                                            .getFormattedString(
1040:                                                                    "iReportCompiler.maxRecords",
1041:                                                                    "Max number of records: <b>{0,number}</b>",
1042:                                                                    new Object[] { new Integer(
1043:                                                                            reportMaxCount) })
1044:                                                    + "</font>", true);
1045:
1046:                            hm.put("REPORT_MAX_COUNT", new Integer(
1047:                                    reportMaxCount));
1048:                        }
1049:
1050:                        // Thread.currentThread().setContextClassLoader( reportClassLoader );
1051:
1052:                        if (it.businesslogic.ireport.gui.MainFrame
1053:                                .getMainInstance().isIgnorePagination()) {
1054:                            hm.put("IS_IGNORE_PAGINATION", Boolean.TRUE);
1055:                            img_url = this 
1056:                                    .getClass()
1057:                                    .getResource(
1058:                                            "/it/businesslogic/ireport/icons/file-info.png");
1059:                            getLogTextArea()
1060:                                    .logOnConsole(
1061:                                            "<font face=\"SansSerif\" size=\"3\" color=\"#000000\"><img align=\"right\" src=\""
1062:                                                    + img_url
1063:                                                    + "\"> &nbsp;"
1064:                                                    + I18n
1065:                                                            .getString(
1066:                                                                    "iReportCompiler.ignoringPagination",
1067:                                                                    "Ignoring pagination")
1068:                                                    + "</font>", true);
1069:
1070:                        }
1071:                        if (it.businesslogic.ireport.gui.MainFrame
1072:                                .getMainInstance().isUseReportVirtualizer()) {
1073:                            try {
1074:
1075:                                net.sf.jasperreports.engine.JRVirtualizer virtualizer = null;
1076:                                String rvName = mainFrame.getProperties()
1077:                                        .getProperty("ReportVirtualizer",
1078:                                                "JRFileVirtualizer");
1079:                                String vrTmpDirectory = mainFrame
1080:                                        .getProperties()
1081:                                        .getProperty(
1082:                                                "ReportVirtualizerDirectory",
1083:                                                mainFrame
1084:                                                        .getTranslatedCompileDirectory());
1085:                                int vrSize = Integer
1086:                                        .parseInt(mainFrame
1087:                                                .getProperties()
1088:                                                .getProperty(
1089:                                                        "ReportVirtualizerSize",
1090:                                                        "100"));
1091:
1092:                                String msg = "";
1093:
1094:                                if (rvName.equals("JRGzipVirtualizer")) {
1095:                                    msg = I18n
1096:                                            .getFormattedString(
1097:                                                    "iReportCompiler.JRGzipVirtualizer",
1098:                                                    "JRGzipVirtualizer Size: {0,number}<br>",
1099:                                                    new Object[] { new Integer(
1100:                                                            vrSize) });
1101:                                    virtualizer = new net.sf.jasperreports.engine.fill.JRGzipVirtualizer(
1102:                                            vrSize);
1103:                                } else if (rvName
1104:                                        .equals("JRSwapFileVirtualizer")) {
1105:                                    msg = I18n
1106:                                            .getFormattedString(
1107:                                                    "iReportCompiler.JRSwapFileVirtualizer",
1108:                                                    "JRSwapFileVirtualizer Size: {0,number} Swap directory: {1};<br>"
1109:                                                            + "  ReportVirtualizerBlockSize: {2}<br>ReportVirtualizerGrownCount: {3}<br>",
1110:                                                    new Object[] {
1111:                                                            new Integer(vrSize),
1112:                                                            vrTmpDirectory,
1113:                                                            mainFrame
1114:                                                                    .getProperties()
1115:                                                                    .getProperty(
1116:                                                                            "ReportVirtualizerBlockSize",
1117:                                                                            "100"),
1118:                                                            mainFrame
1119:                                                                    .getProperties()
1120:                                                                    .getProperty(
1121:                                                                            "ReportVirtualizerGrownCount",
1122:                                                                            "100") });
1123:
1124:                                    //msg = " JRSwapFileVirtualizer " + " Size: " + vrSize +" Swap directory: " + vrTmpDirectory +";<br>";
1125:                                    //msg += " ReportVirtualizerBlockSize: " + mainFrame.getProperties().getProperty("ReportVirtualizerBlockSize","100")+"<br>";
1126:                                    //msg += " ReportVirtualizerGrownCount: " + mainFrame.getProperties().getProperty("ReportVirtualizerGrownCount","100")+"<br>";
1127:
1128:                                    JRSwapFile swapFile = new JRSwapFile(
1129:                                            vrTmpDirectory,
1130:                                            Integer
1131:                                                    .parseInt(mainFrame
1132:                                                            .getProperties()
1133:                                                            .getProperty(
1134:                                                                    "ReportVirtualizerBlockSize",
1135:                                                                    "100")),
1136:                                            Integer
1137:                                                    .parseInt(mainFrame
1138:                                                            .getProperties()
1139:                                                            .getProperty(
1140:                                                                    "ReportVirtualizerGrownCount",
1141:                                                                    "100")));
1142:                                    virtualizer = new net.sf.jasperreports.engine.fill.JRSwapFileVirtualizer(
1143:                                            vrSize, swapFile);
1144:                                } else // default if (rvName.equals("JRFileVirtualizer"))
1145:                                {
1146:                                    msg = I18n
1147:                                            .getFormattedString(
1148:                                                    "iReportCompiler.JRFileVirtualizer",
1149:                                                    "JRFileVirtualizer Size: {0,number} Swap directory: {1};<br>",
1150:                                                    new Object[] {
1151:                                                            new Integer(vrSize),
1152:                                                            vrTmpDirectory });
1153:                                    virtualizer = new net.sf.jasperreports.engine.fill.JRFileVirtualizer(
1154:                                            vrSize, vrTmpDirectory);
1155:                                }
1156:
1157:                                img_url = this 
1158:                                        .getClass()
1159:                                        .getResource(
1160:                                                "/it/businesslogic/ireport/icons/file-info.png");
1161:                                getLogTextArea()
1162:                                        .logOnConsole(
1163:                                                "<font face=\"SansSerif\" size=\"3\" color=\"#000000\"><img align=\"right\" src=\""
1164:                                                        + img_url
1165:                                                        + "\"> &nbsp;"
1166:                                                        + I18n
1167:                                                                .getString(
1168:                                                                        "iReportCompiler.usingVirtualizer",
1169:                                                                        "Using report virtualizer... ")
1170:                                                        + msg + "</font>", true);
1171:
1172:                                hm.put("REPORT_VIRTUALIZER", virtualizer);
1173:
1174:                            } catch (Throwable ex) {
1175:                                getLogTextArea()
1176:                                        .logOnConsole(
1177:                                                "<font face=\"SansSerif\" size=\"3\" color=\"#660000\">"
1178:                                                        + I18n
1179:                                                                .getString(
1180:                                                                        "iReportCompiler.virtualizerNotAvailable",
1181:                                                                        "WARNING: Report virtualizer not available.")
1182:                                                        + "</font>", true);
1183:
1184:                            }
1185:                        }
1186:
1187:                        start = System.currentTimeMillis();
1188:
1189:                        if (properties.get(USE_EMPTY_DATASOURCE) != null
1190:                                && properties.get(USE_EMPTY_DATASOURCE).equals(
1191:                                        "true")) {
1192:                            try {
1193:                                int records = 1;
1194:                                try {
1195:
1196:                                    records = ((Integer) properties
1197:                                            .get(EMPTY_DATASOURCE_RECORDS))
1198:                                            .intValue();
1199:                                } catch (Exception ex) {
1200:                                    records = 1;
1201:                                }
1202:
1203:                                print = JasperFillManager.fillReport(fileName,
1204:                                        hm, new JREmptyDataSource(records));
1205:
1206:                            } catch (OutOfMemoryError ex) {
1207:                                getLogTextArea().logOnConsole(
1208:                                        I18n.getString(
1209:                                                "iReportCompiler.outOfMemory",
1210:                                                "Out of memory exception!\n"));
1211:                            } catch (Exception ex) {
1212:                                getLogTextArea()
1213:                                        .logOnConsole(
1214:                                                I18n
1215:                                                        .getFormattedString(
1216:                                                                "iReportCompiler.errorFillingPrint",
1217:                                                                "Error filling print... {0}\n",
1218:                                                                new Object[] { ex
1219:                                                                        .getMessage() }));
1220:
1221:                                ex.printStackTrace();
1222:                                getLogTextArea().logOnConsole(
1223:                                        outputBuffer.toString());
1224:                                outputBuffer = new StringBuffer();
1225:                            }
1226:                        } else if (properties.get(USE_CONNECTION) != null
1227:                                && properties.get(USE_CONNECTION)
1228:                                        .equals("true")) {
1229:                            IReportConnection connection = (IReportConnection) properties
1230:                                    .get(CONNECTION);
1231:
1232:                            try {
1233:
1234:                                hm = connection.getSpecialParameters(hm);
1235:
1236:                                //changed by Felix Firgau for subclassing
1237:                                hm = MainFrame.getMainInstance()
1238:                                        .getSpecialParameters(hm,
1239:                                                this .jrf.getReport());
1240:
1241:                                if (connection.isJDBCConnection()) {
1242:                                    print = JasperFillManager.fillReport(
1243:                                            fileName, hm, connection
1244:                                                    .getConnection());
1245:                                } else if (connection.isJRDataSource()) {
1246:                                    JRDataSource ds = null;
1247:                                    if (connection instanceof  JRDataSourceProviderConnection) {
1248:
1249:                                        JasperReport jasper_report_obj = JasperManager
1250:                                                .loadReport(fileName);
1251:                                        ds = (JRDataSource) ((JRDataSourceProviderConnection) connection)
1252:                                                .getJRDataSource(jasper_report_obj);
1253:
1254:                                        if (ds == null)
1255:                                            return;
1256:                                        print = JasperFillManager.fillReport(
1257:                                                jasper_report_obj, hm, ds);
1258:
1259:                                        try {
1260:                                            ((JRDataSourceProviderConnection) connection)
1261:                                                    .disposeDataSource();
1262:                                        } catch (Exception ex) {
1263:
1264:                                            getLogTextArea()
1265:                                                    .logOnConsole(
1266:                                                            I18n
1267:                                                                    .getFormattedString(
1268:                                                                            "iReportCompiler.errorClosingDatasource",
1269:                                                                            "Error closing datasource: {0}\n",
1270:                                                                            new Object[] { ex
1271:                                                                                    .getMessage() }));
1272:
1273:                                        }
1274:                                    } else {
1275:                                        ds = (JRDataSource) connection
1276:                                                .getJRDataSource();
1277:                                        print = JasperFillManager.fillReport(
1278:                                                fileName, hm, ds);
1279:                                    }
1280:                                } else {
1281:                                    if (connection instanceof  JRHibernateConnection) {
1282:                                        Session session = null;
1283:                                        Transaction transaction = null;
1284:                                        System.out.println();
1285:                                        getLogTextArea()
1286:                                                .logOnConsole(
1287:                                                        I18n
1288:                                                                .getString(
1289:                                                                        "iReportCompiler.HibernateSessionOpened",
1290:                                                                        "Hibernate session opened"));
1291:
1292:                                        try {
1293:                                            session = ((JRHibernateConnection) connection)
1294:                                                    .createSession();
1295:                                            transaction = session
1296:                                                    .beginTransaction();
1297:                                            hm
1298:                                                    .put(
1299:                                                            JRHibernateQueryExecuterFactory.PARAMETER_HIBERNATE_SESSION,
1300:                                                            session);
1301:                                            print = JasperFillManager
1302:                                                    .fillReport(fileName, hm);
1303:
1304:                                        } catch (Exception ex) {
1305:                                            throw ex;
1306:                                        } finally {
1307:                                            if (transaction != null)
1308:                                                try {
1309:                                                    transaction.rollback();
1310:                                                } catch (Exception ex) {
1311:                                                }
1312:                                            if (transaction != null)
1313:                                                try {
1314:                                                    session.close();
1315:                                                } catch (Exception ex) {
1316:                                                }
1317:                                        }
1318:                                    } else if (connection instanceof  EJBQLConnection) {
1319:                                        EntityManager em = null;
1320:                                        try {
1321:
1322:                                            getLogTextArea()
1323:                                                    .logOnConsole(
1324:                                                            I18n
1325:                                                                    .getString(
1326:                                                                            "iReportCompiler.CreatingEntityManager",
1327:                                                                            "Creating entity manager"));
1328:
1329:                                            em = ((EJBQLConnection) connection)
1330:                                                    .getEntityManager();
1331:                                            hm
1332:                                                    .put(
1333:                                                            JRJpaQueryExecuterFactory.PARAMETER_JPA_ENTITY_MANAGER,
1334:                                                            em);
1335:                                            //Thread.currentThread().setContextClassLoader( reportClassLoader );
1336:                                            print = JasperFillManager
1337:                                                    .fillReport(fileName, hm);
1338:
1339:                                        } catch (Exception ex) {
1340:                                            throw ex;
1341:                                        } finally {
1342:                                            getLogTextArea()
1343:                                                    .logOnConsole(
1344:                                                            I18n
1345:                                                                    .getString(
1346:                                                                            "iReportCompiler.ClosingEntityManager",
1347:                                                                            "Closing entity manager"));
1348:                                            ((EJBQLConnection) connection)
1349:                                                    .closeEntityManager();
1350:                                        }
1351:                                    } else if (connection instanceof  MondrianConnection) {
1352:                                        mondrian.olap.Connection mCon = null;
1353:                                        try {
1354:                                            getLogTextArea()
1355:                                                    .logOnConsole(
1356:                                                            I18n
1357:                                                                    .getString(
1358:                                                                            "iReportCompiler.OpeningMondrianConnection",
1359:                                                                            "Opening Mondrian connection"));
1360:                                            mCon = ((MondrianConnection) connection)
1361:                                                    .getMondrianConnection();
1362:                                            hm
1363:                                                    .put(
1364:                                                            JRMondrianQueryExecuterFactory.PARAMETER_MONDRIAN_CONNECTION,
1365:                                                            mCon);
1366:                                            //Thread.currentThread().setContextClassLoader( reportClassLoader );
1367:                                            print = JasperFillManager
1368:                                                    .fillReport(fileName, hm);
1369:
1370:                                        } catch (Exception ex) {
1371:                                            throw ex;
1372:                                        } finally {
1373:                                            getLogTextArea()
1374:                                                    .logOnConsole(
1375:                                                            I18n
1376:                                                                    .getString(
1377:                                                                            "iReportCompiler.ClosingMondrianConnection",
1378:                                                                            "Closing Mondrian connection"));
1379:                                            ((MondrianConnection) connection)
1380:                                                    .closeMondrianConnection();
1381:                                        }
1382:                                    } else // Query Executor mode...
1383:                                    {
1384:                                        //Thread.currentThread().setContextClassLoader( reportClassLoader );
1385:                                        print = JasperFillManager.fillReport(
1386:                                                fileName, hm);
1387:                                    }
1388:                                }
1389:
1390:                            } catch (Exception ex) {
1391:                                getLogTextArea()
1392:                                        .logOnConsole(
1393:                                                I18n
1394:                                                        .getFormattedString(
1395:                                                                "iReportCompiler.errorFillingPrint",
1396:                                                                "Error filling print... {0}\n",
1397:                                                                new Object[] { ex
1398:                                                                        .getMessage() }));
1399:                                ex.printStackTrace();
1400:                                getLogTextArea().logOnConsole(
1401:                                        outputBuffer.toString());
1402:                                outputBuffer = new StringBuffer();
1403:                            } catch (Throwable ext) {
1404:                                getLogTextArea()
1405:                                        .logOnConsole(
1406:                                                I18n
1407:                                                        .getFormattedString(
1408:                                                                "iReportCompiler.errorFillingPrint",
1409:                                                                "Error filling print... {0}\n",
1410:                                                                new Object[] { ext
1411:                                                                        + " "
1412:                                                                        + ext
1413:                                                                                .getCause() }));
1414:                                ext.printStackTrace();
1415:                                getLogTextArea().logOnConsole(
1416:                                        outputBuffer.toString());
1417:                                outputBuffer = new StringBuffer();
1418:                            } finally {
1419:                                connection.disposeSpecialParameters(hm);
1420:                                if (connection != null
1421:                                        && connection instanceof  JRDataSourceProviderConnection) {
1422:                                    try {
1423:                                        ((JRDataSourceProviderConnection) connection)
1424:                                                .disposeDataSource();
1425:                                    } catch (Exception ex) {
1426:                                        getLogTextArea()
1427:                                                .logOnConsole(
1428:                                                        I18n
1429:                                                                .getFormattedString(
1430:                                                                        "iReportCompiler.errorClosingDatasource",
1431:                                                                        "Error closing datasource: {0}\n",
1432:                                                                        new Object[] { ex
1433:                                                                                .getMessage() }));
1434:                                    }
1435:
1436:                                }
1437:
1438:                            }
1439:                        }
1440:                        net.sf.jasperreports.view.JRViewer jrv = null;
1441:                        net.sf.jasperreports.engine.JRExporter exporter = null;
1442:
1443:                        getLogTextArea().logOnConsole(outputBuffer.toString());
1444:                        outputBuffer = new StringBuffer();
1445:
1446:                        if (print != null) {
1447:                            getLogTextArea()
1448:                                    .logOnConsole(
1449:                                            "<font face=\"SansSerif\"  size=\"3\" color=\"#0000CC\">"
1450:                                                    + I18n
1451:                                                            .getFormattedString(
1452:                                                                    "iReportCompiler.fillingRunningTime",
1453:                                                                    "<b>Report fill running time: {0,number}!</b> (pages generated: {1,number})",
1454:                                                                    new Object[] {
1455:                                                                            new Long(
1456:                                                                                    System
1457:                                                                                            .currentTimeMillis()
1458:                                                                                            - start),
1459:                                                                            new Integer(
1460:                                                                                    ((List) print
1461:                                                                                            .getPages())
1462:                                                                                            .size()) })
1463:                                                    + "</font><hr>", true);
1464:
1465:                            status = I18n.getString(
1466:                                    "iReportCompiler.status.exportingReport",
1467:                                    "Exporting report");
1468:                            updateThreadList();
1469:
1470:                            start = System.currentTimeMillis();
1471:                            String format = Misc.nvl(properties
1472:                                    .get(OUTPUT_FORMAT), "pdf");
1473:                            String viewer_program = "";
1474:
1475:                            //getLogTextArea().logOnConsole(properties.get(OUTPUT_FORMAT) + "Exporting\n");
1476:                            getLogTextArea().logOnConsole(
1477:                                    outputBuffer.toString());
1478:                            outputBuffer = new StringBuffer();
1479:
1480:                            String exportingMessage = "";
1481:
1482:                            try {
1483:
1484:                                if (format.equalsIgnoreCase("pdf")) {
1485:                                    exporter = new net.sf.jasperreports.engine.export.JRPdfExporter();
1486:
1487:                                    if (this .getMainFrame().getProperties()
1488:                                            .getProperty("PDF_IS_ENCRYPTED") != null) {
1489:                                        //exporter.setParameter( JRPdfExporterParameter.IS_ENCRYPTED, new Boolean( this.getMainFrame().getProperties().getProperty("PDF_IS_ENCRYPTED") ) );
1490:                                        JRProperties
1491:                                                .setProperty(
1492:                                                        JRPdfExporterParameter.PROPERTY_ENCRYPTED,
1493:                                                        this 
1494:                                                                .getMainFrame()
1495:                                                                .getProperties()
1496:                                                                .getProperty(
1497:                                                                        "PDF_IS_ENCRYPTED"));
1498:                                    }
1499:                                    if (this .getMainFrame().getProperties()
1500:                                            .getProperty("PDF_IS_128_BIT_KEY") != null) {
1501:                                        //exporter.setParameter( JRPdfExporterParameter.IS_128_BIT_KEY, new Boolean( this.getMainFrame().getProperties().getProperty("PDF_IS_128_BIT_KEY") ) );
1502:                                        JRProperties
1503:                                                .setProperty(
1504:                                                        JRPdfExporterParameter.PROPERTY_128_BIT_KEY,
1505:                                                        this 
1506:                                                                .getMainFrame()
1507:                                                                .getProperties()
1508:                                                                .getProperty(
1509:                                                                        "PDF_IS_128_BIT_KEY"));
1510:                                    }
1511:                                    if (this .getMainFrame().getProperties()
1512:                                            .getProperty("PDF_USER_PASSWORD") != null) {
1513:                                        //exporter.setParameter( JRPdfExporterParameter.USER_PASSWORD, this.getMainFrame().getProperties().getProperty("PDF_USER_PASSWORD"));
1514:                                        JRProperties
1515:                                                .setProperty(
1516:                                                        JRPdfExporterParameter.PROPERTY_USER_PASSWORD,
1517:                                                        this 
1518:                                                                .getMainFrame()
1519:                                                                .getProperties()
1520:                                                                .getProperty(
1521:                                                                        "PDF_USER_PASSWORD"));
1522:                                    }
1523:                                    if (this .getMainFrame().getProperties()
1524:                                            .getProperty("PDF_OWNER_PASSWORD") != null) {
1525:                                        //exporter.setParameter( JRPdfExporterParameter.OWNER_PASSWORD, this.getMainFrame().getProperties().getProperty("PDF_OWNER_PASSWORD"));
1526:                                        JRProperties
1527:                                                .setProperty(
1528:                                                        JRPdfExporterParameter.PROPERTY_OWNER_PASSWORD,
1529:                                                        this 
1530:                                                                .getMainFrame()
1531:                                                                .getProperties()
1532:                                                                .getProperty(
1533:                                                                        "PDF_OWNER_PASSWORD"));
1534:                                    }
1535:                                    if (this .getMainFrame().getProperties()
1536:                                            .getProperty("PDF_PERMISSIONS") != null) {
1537:                                        exporter
1538:                                                .setParameter(
1539:                                                        JRPdfExporterParameter.PERMISSIONS,
1540:                                                        new Integer(
1541:                                                                this 
1542:                                                                        .getMainFrame()
1543:                                                                        .getProperties()
1544:                                                                        .getProperty(
1545:                                                                                "PDF_PERMISSIONS")));
1546:                                    }
1547:
1548:                                    if (this 
1549:                                            .getMainFrame()
1550:                                            .getProperties()
1551:                                            .getProperty(
1552:                                                    JRPdfExporterParameter.PROPERTY_COMPRESSED) != null
1553:                                            && this 
1554:                                                    .getMainFrame()
1555:                                                    .getProperties()
1556:                                                    .getProperty(
1557:                                                            JRPdfExporterParameter.PROPERTY_COMPRESSED)
1558:                                                    .length() > 0) {
1559:                                        JRProperties
1560:                                                .setProperty(
1561:                                                        JRPdfExporterParameter.PROPERTY_COMPRESSED,
1562:                                                        this 
1563:                                                                .getMainFrame()
1564:                                                                .getProperties()
1565:                                                                .getProperty(
1566:                                                                        JRPdfExporterParameter.PROPERTY_COMPRESSED));
1567:                                    }
1568:
1569:                                    if (this 
1570:                                            .getMainFrame()
1571:                                            .getProperties()
1572:                                            .getProperty(
1573:                                                    JRPdfExporterParameter.PROPERTY_CREATE_BATCH_MODE_BOOKMARKS) != null
1574:                                            && this 
1575:                                                    .getMainFrame()
1576:                                                    .getProperties()
1577:                                                    .getProperty(
1578:                                                            JRPdfExporterParameter.PROPERTY_CREATE_BATCH_MODE_BOOKMARKS)
1579:                                                    .length() > 0) {
1580:                                        JRProperties
1581:                                                .setProperty(
1582:                                                        JRPdfExporterParameter.PROPERTY_CREATE_BATCH_MODE_BOOKMARKS,
1583:                                                        this 
1584:                                                                .getMainFrame()
1585:                                                                .getProperties()
1586:                                                                .getProperty(
1587:                                                                        JRPdfExporterParameter.PROPERTY_CREATE_BATCH_MODE_BOOKMARKS));
1588:                                    }
1589:
1590:                                    if (this 
1591:                                            .getMainFrame()
1592:                                            .getProperties()
1593:                                            .getProperty(
1594:                                                    JRPdfExporterParameter.PROPERTY_PDF_VERSION) != null
1595:                                            && this 
1596:                                                    .getMainFrame()
1597:                                                    .getProperties()
1598:                                                    .getProperty(
1599:                                                            JRPdfExporterParameter.PROPERTY_PDF_VERSION)
1600:                                                    .length() > 0) {
1601:                                        JRProperties
1602:                                                .setProperty(
1603:                                                        JRPdfExporterParameter.PROPERTY_PDF_VERSION,
1604:                                                        this 
1605:                                                                .getMainFrame()
1606:                                                                .getProperties()
1607:                                                                .getProperty(
1608:                                                                        JRPdfExporterParameter.PROPERTY_PDF_VERSION));
1609:                                    }
1610:
1611:                                    if (this .getMainFrame().getProperties()
1612:                                            .getProperty("METADATA_TITLE") != null
1613:                                            && this .getMainFrame()
1614:                                                    .getProperties()
1615:                                                    .getProperty(
1616:                                                            "METADATA_TITLE")
1617:                                                    .length() > 0) {
1618:                                        exporter
1619:                                                .setParameter(
1620:                                                        JRPdfExporterParameter.METADATA_TITLE,
1621:                                                        this 
1622:                                                                .getMainFrame()
1623:                                                                .getProperties()
1624:                                                                .getProperty(
1625:                                                                        "METADATA_TITLE"));
1626:                                    }
1627:
1628:                                    if (this .getMainFrame().getProperties()
1629:                                            .getProperty("METADATA_AUTHOR") != null
1630:                                            && this .getMainFrame()
1631:                                                    .getProperties()
1632:                                                    .getProperty(
1633:                                                            "METADATA_AUTHOR")
1634:                                                    .length() > 0) {
1635:                                        exporter
1636:                                                .setParameter(
1637:                                                        JRPdfExporterParameter.METADATA_AUTHOR,
1638:                                                        this 
1639:                                                                .getMainFrame()
1640:                                                                .getProperties()
1641:                                                                .getProperty(
1642:                                                                        "METADATA_AUTHOR"));
1643:                                    }
1644:
1645:                                    if (this .getMainFrame().getProperties()
1646:                                            .getProperty("METADATA_SUBJECT") != null
1647:                                            && this .getMainFrame()
1648:                                                    .getProperties()
1649:                                                    .getProperty(
1650:                                                            "METADATA_SUBJECT")
1651:                                                    .length() > 0) {
1652:                                        exporter
1653:                                                .setParameter(
1654:                                                        JRPdfExporterParameter.METADATA_SUBJECT,
1655:                                                        this 
1656:                                                                .getMainFrame()
1657:                                                                .getProperties()
1658:                                                                .getProperty(
1659:                                                                        "METADATA_SUBJECT"));
1660:                                    }
1661:
1662:                                    if (this .getMainFrame().getProperties()
1663:                                            .getProperty("METADATA_KEYWORDS") != null
1664:                                            && this 
1665:                                                    .getMainFrame()
1666:                                                    .getProperties()
1667:                                                    .getProperty(
1668:                                                            "METADATA_KEYWORDS")
1669:                                                    .length() > 0) {
1670:                                        exporter
1671:                                                .setParameter(
1672:                                                        JRPdfExporterParameter.METADATA_KEYWORDS,
1673:                                                        this 
1674:                                                                .getMainFrame()
1675:                                                                .getProperties()
1676:                                                                .getProperty(
1677:                                                                        "METADATA_KEYWORDS"));
1678:                                    }
1679:
1680:                                    if (this .getMainFrame().getProperties()
1681:                                            .getProperty("METADATA_CREATOR") != null
1682:                                            && this .getMainFrame()
1683:                                                    .getProperties()
1684:                                                    .getProperty(
1685:                                                            "METADATA_CREATOR")
1686:                                                    .length() > 0) {
1687:                                        exporter
1688:                                                .setParameter(
1689:                                                        JRPdfExporterParameter.METADATA_CREATOR,
1690:                                                        this 
1691:                                                                .getMainFrame()
1692:                                                                .getProperties()
1693:                                                                .getProperty(
1694:                                                                        "METADATA_CREATOR"));
1695:                                    }
1696:
1697:                                    if (this 
1698:                                            .getMainFrame()
1699:                                            .getProperties()
1700:                                            .getProperty(
1701:                                                    JRPdfExporterParameter.PROPERTY_FORCE_LINEBREAK_POLICY) != null
1702:                                            && this 
1703:                                                    .getMainFrame()
1704:                                                    .getProperties()
1705:                                                    .getProperty(
1706:                                                            JRPdfExporterParameter.PROPERTY_FORCE_LINEBREAK_POLICY)
1707:                                                    .length() > 0) {
1708:                                        JRProperties
1709:                                                .setProperty(
1710:                                                        JRPdfExporterParameter.PROPERTY_FORCE_LINEBREAK_POLICY,
1711:                                                        this 
1712:                                                                .getMainFrame()
1713:                                                                .getProperties()
1714:                                                                .getProperty(
1715:                                                                        JRPdfExporterParameter.PROPERTY_FORCE_LINEBREAK_POLICY));
1716:                                    }
1717:
1718:                                    if (this 
1719:                                            .getMainFrame()
1720:                                            .getProperties()
1721:                                            .getProperty(
1722:                                                    JRPdfExporterParameter.PROPERTY_FORCE_SVG_SHAPES) != null
1723:                                            && this 
1724:                                                    .getMainFrame()
1725:                                                    .getProperties()
1726:                                                    .getProperty(
1727:                                                            JRPdfExporterParameter.PROPERTY_FORCE_SVG_SHAPES)
1728:                                                    .length() > 0) {
1729:                                        JRProperties
1730:                                                .setProperty(
1731:                                                        JRPdfExporterParameter.PROPERTY_FORCE_SVG_SHAPES,
1732:                                                        this 
1733:                                                                .getMainFrame()
1734:                                                                .getProperties()
1735:                                                                .getProperty(
1736:                                                                        JRPdfExporterParameter.PROPERTY_FORCE_SVG_SHAPES));
1737:                                    }
1738:
1739:                                    if (this 
1740:                                            .getMainFrame()
1741:                                            .getProperties()
1742:                                            .getProperty(
1743:                                                    JRPdfExporterParameter.PROPERTY_PDF_JAVASCRIPT) != null
1744:                                            && this 
1745:                                                    .getMainFrame()
1746:                                                    .getProperties()
1747:                                                    .getProperty(
1748:                                                            JRPdfExporterParameter.PROPERTY_PDF_JAVASCRIPT)
1749:                                                    .length() > 0) {
1750:                                        JRProperties
1751:                                                .setProperty(
1752:                                                        JRPdfExporterParameter.PROPERTY_PDF_JAVASCRIPT,
1753:                                                        this 
1754:                                                                .getMainFrame()
1755:                                                                .getProperties()
1756:                                                                .getProperty(
1757:                                                                        JRPdfExporterParameter.PROPERTY_PDF_JAVASCRIPT));
1758:                                    }
1759:
1760:                                    fileName = Misc.changeFileExtension(
1761:                                            fileName, "pdf");
1762:                                    exportingMessage = I18n
1763:                                            .getFormattedString(
1764:                                                    "iReportCompiler.exportingMessage.pdf",
1765:                                                    "Exporting pdf to file (using iText)...  {0}!",
1766:                                                    new Object[] { fileName });
1767:                                    viewer_program = mainFrame.getProperties()
1768:                                            .getProperty("ExternalPDFViewer");
1769:                                } else if (format.equalsIgnoreCase("csv")) {
1770:                                    exporter = new net.sf.jasperreports.engine.export.JRCsvExporter();
1771:
1772:                                    if (this .getMainFrame().getProperties()
1773:                                            .getProperty("CSV_FIELD_DELIMITER") != null) {
1774:                                        //exporter.setParameter( JRCsvExporterParameter.FIELD_DELIMITER, this.getMainFrame().getProperties().getProperty("CSV_FIELD_DELIMITER") );
1775:                                        JRProperties
1776:                                                .setProperty(
1777:                                                        JRCsvExporterParameter.PROPERTY_FIELD_DELIMITER,
1778:                                                        this 
1779:                                                                .getMainFrame()
1780:                                                                .getProperties()
1781:                                                                .getProperty(
1782:                                                                        "CSV_FIELD_DELIMITER"));
1783:                                    }
1784:
1785:                                    if (this 
1786:                                            .getMainFrame()
1787:                                            .getProperties()
1788:                                            .getProperty(
1789:                                                    JRCsvExporterParameter.PROPERTY_RECORD_DELIMITER) != null
1790:                                            && this 
1791:                                                    .getMainFrame()
1792:                                                    .getProperties()
1793:                                                    .getProperty(
1794:                                                            JRCsvExporterParameter.PROPERTY_RECORD_DELIMITER)
1795:                                                    .length() > 0) {
1796:                                        //exporter.setParameter( JRCsvExporterParameter.FIELD_DELIMITER, this.getMainFrame().getProperties().getProperty("CSV_FIELD_DELIMITER") );
1797:                                        JRProperties
1798:                                                .setProperty(
1799:                                                        JRCsvExporterParameter.PROPERTY_RECORD_DELIMITER,
1800:                                                        this 
1801:                                                                .getMainFrame()
1802:                                                                .getProperties()
1803:                                                                .getProperty(
1804:                                                                        JRCsvExporterParameter.PROPERTY_RECORD_DELIMITER));
1805:                                    }
1806:
1807:                                    fileName = Misc.changeFileExtension(
1808:                                            fileName, "csv");
1809:                                    exportingMessage = I18n
1810:                                            .getFormattedString(
1811:                                                    "iReportCompiler.exportingMessage.csv",
1812:                                                    "Exporting CSV to file... {0}!",
1813:                                                    new Object[] { fileName });
1814:                                    viewer_program = Misc.nvl(mainFrame
1815:                                            .getProperties().getProperty(
1816:                                                    "ExternalCSVViewer"), "");
1817:                                } else if (format.equalsIgnoreCase("html")) {
1818:                                    exporter = new net.sf.jasperreports.engine.export.JRHtmlExporter();
1819:
1820:                                    if (this 
1821:                                            .getMainFrame()
1822:                                            .getProperties()
1823:                                            .getProperty("HTML_IMAGES_DIR_NAME") != null) {
1824:                                        exporter
1825:                                                .setParameter(
1826:                                                        JRHtmlExporterParameter.IMAGES_DIR_NAME,
1827:                                                        this 
1828:                                                                .getMainFrame()
1829:                                                                .getProperties()
1830:                                                                .getProperty(
1831:                                                                        "HTML_IMAGES_DIR_NAME"));
1832:                                    }
1833:                                    if (this 
1834:                                            .getMainFrame()
1835:                                            .getProperties()
1836:                                            .getProperty(
1837:                                                    "HTML_IS_OUTPUT_IMAGES_TO_DIR") != null) {
1838:                                        exporter
1839:                                                .setParameter(
1840:                                                        JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR,
1841:                                                        new Boolean(
1842:                                                                this 
1843:                                                                        .getMainFrame()
1844:                                                                        .getProperties()
1845:                                                                        .getProperty(
1846:                                                                                "HTML_IS_OUTPUT_IMAGES_TO_DIR")));
1847:                                    }
1848:                                    if (this .getMainFrame().getProperties()
1849:                                            .getProperty("HTML_IMAGES_URI") != null) {
1850:                                        exporter
1851:                                                .setParameter(
1852:                                                        JRHtmlExporterParameter.IMAGES_URI,
1853:                                                        this 
1854:                                                                .getMainFrame()
1855:                                                                .getProperties()
1856:                                                                .getProperty(
1857:                                                                        "HTML_IMAGES_URI"));
1858:                                    }
1859:                                    if (this .getMainFrame().getProperties()
1860:                                            .getProperty("HTML_HTML_HEADER") != null) {
1861:                                        exporter
1862:                                                .setParameter(
1863:                                                        JRHtmlExporterParameter.HTML_HEADER,
1864:                                                        this 
1865:                                                                .getMainFrame()
1866:                                                                .getProperties()
1867:                                                                .getProperty(
1868:                                                                        "HTML_HTML_HEADER"));
1869:                                    }
1870:                                    if (this .getMainFrame().getProperties()
1871:                                            .getProperty(
1872:                                                    "HTML_BETWEEN_PAGES_HTML") != null) {
1873:                                        exporter
1874:                                                .setParameter(
1875:                                                        JRHtmlExporterParameter.BETWEEN_PAGES_HTML,
1876:                                                        this 
1877:                                                                .getMainFrame()
1878:                                                                .getProperties()
1879:                                                                .getProperty(
1880:                                                                        "HTML_BETWEEN_PAGES_HTML"));
1881:                                    }
1882:                                    if (this .getMainFrame().getProperties()
1883:                                            .getProperty("HTML_HTML_FOOTER") != null) {
1884:                                        exporter
1885:                                                .setParameter(
1886:                                                        JRHtmlExporterParameter.HTML_FOOTER,
1887:                                                        this 
1888:                                                                .getMainFrame()
1889:                                                                .getProperties()
1890:                                                                .getProperty(
1891:                                                                        "HTML_HTML_FOOTER"));
1892:                                    }
1893:                                    if (this 
1894:                                            .getMainFrame()
1895:                                            .getProperties()
1896:                                            .getProperty(
1897:                                                    "HTML_IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS") != null) {
1898:                                        //exporter.setParameter( JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, new Boolean(this.getMainFrame().getProperties().getProperty("HTML_IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS")));
1899:                                        JRProperties
1900:                                                .setProperty(
1901:                                                        JRHtmlExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,
1902:                                                        this 
1903:                                                                .getMainFrame()
1904:                                                                .getProperties()
1905:                                                                .getProperty(
1906:                                                                        "HTML_IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS"));
1907:                                    }
1908:                                    if (this 
1909:                                            .getMainFrame()
1910:                                            .getProperties()
1911:                                            .getProperty(
1912:                                                    "HTML_IS_WHITE_PAGE_BACKGROUND") != null) {
1913:                                        //exporter.setParameter( JRHtmlExporterParameter.IS_WHITE_PAGE_BACKGROUND, new Boolean(this.getMainFrame().getProperties().getProperty("HTML_IS_WHITE_PAGE_BACKGROUND")) );
1914:                                        JRProperties
1915:                                                .setProperty(
1916:                                                        JRHtmlExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND,
1917:                                                        this 
1918:                                                                .getMainFrame()
1919:                                                                .getProperties()
1920:                                                                .getProperty(
1921:                                                                        "HTML_IS_WHITE_PAGE_BACKGROUND"));
1922:                                    }
1923:                                    if (this 
1924:                                            .getMainFrame()
1925:                                            .getProperties()
1926:                                            .getProperty(
1927:                                                    "HTML_IS_USING_IMAGES_TO_ALIGN") != null) {
1928:                                        //exporter.setParameter( JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, new Boolean(this.getMainFrame().getProperties().getProperty("HTML_IS_USING_IMAGES_TO_ALIGN")) );
1929:                                        JRProperties
1930:                                                .setProperty(
1931:                                                        JRHtmlExporterParameter.PROPERTY_USING_IMAGES_TO_ALIGN,
1932:                                                        this 
1933:                                                                .getMainFrame()
1934:                                                                .getProperties()
1935:                                                                .getProperty(
1936:                                                                        "HTML_IS_USING_IMAGES_TO_ALIGN"));
1937:                                    }
1938:
1939:                                    if (this 
1940:                                            .getMainFrame()
1941:                                            .getProperties()
1942:                                            .getProperty(
1943:                                                    JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD) != null
1944:                                            && this 
1945:                                                    .getMainFrame()
1946:                                                    .getProperties()
1947:                                                    .getProperty(
1948:                                                            JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD)
1949:                                                    .length() > 0) {
1950:                                        //exporter.setParameter( JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, new Boolean(this.getMainFrame().getProperties().getProperty("HTML_IS_USING_IMAGES_TO_ALIGN")) );
1951:                                        JRProperties
1952:                                                .setProperty(
1953:                                                        JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD,
1954:                                                        this 
1955:                                                                .getMainFrame()
1956:                                                                .getProperties()
1957:                                                                .getProperty(
1958:                                                                        JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD));
1959:                                    }
1960:                                    if (this 
1961:                                            .getMainFrame()
1962:                                            .getProperties()
1963:                                            .getProperty(
1964:                                                    JRHtmlExporterParameter.PROPERTY_SIZE_UNIT) != null
1965:                                            && this 
1966:                                                    .getMainFrame()
1967:                                                    .getProperties()
1968:                                                    .getProperty(
1969:                                                            JRHtmlExporterParameter.PROPERTY_SIZE_UNIT)
1970:                                                    .length() > 0) {
1971:                                        //exporter.setParameter( JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, new Boolean(this.getMainFrame().getProperties().getProperty("HTML_IS_USING_IMAGES_TO_ALIGN")) );
1972:                                        JRProperties
1973:                                                .setProperty(
1974:                                                        JRHtmlExporterParameter.PROPERTY_SIZE_UNIT,
1975:                                                        this 
1976:                                                                .getMainFrame()
1977:                                                                .getProperties()
1978:                                                                .getProperty(
1979:                                                                        JRHtmlExporterParameter.PROPERTY_SIZE_UNIT));
1980:                                    }
1981:                                    if (this 
1982:                                            .getMainFrame()
1983:                                            .getProperties()
1984:                                            .getProperty(
1985:                                                    JRHtmlExporterParameter.PROPERTY_FRAMES_AS_NESTED_TABLES) != null
1986:                                            && this 
1987:                                                    .getMainFrame()
1988:                                                    .getProperties()
1989:                                                    .getProperty(
1990:                                                            JRHtmlExporterParameter.PROPERTY_FRAMES_AS_NESTED_TABLES)
1991:                                                    .length() > 0) {
1992:                                        //exporter.setParameter( JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, new Boolean(this.getMainFrame().getProperties().getProperty("HTML_IS_USING_IMAGES_TO_ALIGN")) );
1993:                                        JRProperties
1994:                                                .setProperty(
1995:                                                        JRHtmlExporterParameter.PROPERTY_FRAMES_AS_NESTED_TABLES,
1996:                                                        this 
1997:                                                                .getMainFrame()
1998:                                                                .getProperties()
1999:                                                                .getProperty(
2000:                                                                        JRHtmlExporterParameter.PROPERTY_FRAMES_AS_NESTED_TABLES));
2001:                                    }
2002:
2003:                                    fileName = Misc.changeFileExtension(
2004:                                            fileName, "html");
2005:                                    exportingMessage = I18n
2006:                                            .getFormattedString(
2007:                                                    "iReportCompiler.exportingMessage.html",
2008:                                                    "Exporting HTML to file... {0}!",
2009:                                                    new Object[] { fileName });
2010:
2011:                                    viewer_program = Misc.nvl(mainFrame
2012:                                            .getProperties().getProperty(
2013:                                                    "ExternalHTMLViewer"), "");
2014:                                } else if (format.equalsIgnoreCase("xls")
2015:                                        || format.equalsIgnoreCase("xls2")) {
2016:
2017:                                    if (format.equalsIgnoreCase("xls")) {
2018:                                        exporter = new net.sf.jasperreports.engine.export.JRXlsExporter();
2019:                                        exportingMessage = I18n
2020:                                                .getFormattedString(
2021:                                                        "iReportCompiler.exportingMessage.xls",
2022:                                                        "Exporting xls to file (using POI)... {0}!",
2023:                                                        new Object[] { fileName });
2024:                                    } else {
2025:                                        exporter = new net.sf.jasperreports.engine.export.JExcelApiExporter();
2026:                                        exportingMessage = I18n
2027:                                                .getFormattedString(
2028:                                                        "iReportCompiler.exportingMessage.xls2",
2029:                                                        "Exporting xls to file (using JExcelApi)... {0}!",
2030:                                                        new Object[] { fileName });
2031:                                    }
2032:
2033:                                    if (this 
2034:                                            .getMainFrame()
2035:                                            .getProperties()
2036:                                            .getProperty(
2037:                                                    "XLS_IS_ONE_PAGE_PER_SHEET") != null) {
2038:                                        //exporter.setParameter( JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, new Boolean( this.getMainFrame().getProperties().getProperty("XLS_IS_ONE_PAGE_PER_SHEET")) );
2039:                                        JRProperties
2040:                                                .setProperty(
2041:                                                        JRXlsExporterParameter.PROPERTY_ONE_PAGE_PER_SHEET,
2042:                                                        this 
2043:                                                                .getMainFrame()
2044:                                                                .getProperties()
2045:                                                                .getProperty(
2046:                                                                        "XLS_IS_ONE_PAGE_PER_SHEET"));
2047:                                    }
2048:                                    if (this 
2049:                                            .getMainFrame()
2050:                                            .getProperties()
2051:                                            .getProperty(
2052:                                                    "XLS_IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS") != null) {
2053:                                        //exporter.setParameter( JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, new Boolean(this.getMainFrame().getProperties().getProperty("XLS_IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS")));
2054:                                        JRProperties
2055:                                                .setProperty(
2056:                                                        JRXlsExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,
2057:                                                        this 
2058:                                                                .getMainFrame()
2059:                                                                .getProperties()
2060:                                                                .getProperty(
2061:                                                                        "XLS_IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS"));
2062:                                    }
2063:                                    if (this 
2064:                                            .getMainFrame()
2065:                                            .getProperties()
2066:                                            .getProperty(
2067:                                                    "XLS_IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS") != null) {
2068:                                        //exporter.setParameter( JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, new Boolean(this.getMainFrame().getProperties().getProperty("XLS_IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS")));
2069:                                        JRProperties
2070:                                                .setProperty(
2071:                                                        JRXlsExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS,
2072:                                                        this 
2073:                                                                .getMainFrame()
2074:                                                                .getProperties()
2075:                                                                .getProperty(
2076:                                                                        "XLS_IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS"));
2077:                                    }
2078:                                    if (this 
2079:                                            .getMainFrame()
2080:                                            .getProperties()
2081:                                            .getProperty(
2082:                                                    "XLS_IS_WHITE_PAGE_BACKGROUND") != null) {
2083:                                        //exporter.setParameter( JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, new Boolean(this.getMainFrame().getProperties().getProperty("XLS_IS_WHITE_PAGE_BACKGROUND")) );
2084:                                        JRProperties
2085:                                                .setProperty(
2086:                                                        JRXlsExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND,
2087:                                                        this 
2088:                                                                .getMainFrame()
2089:                                                                .getProperties()
2090:                                                                .getProperty(
2091:                                                                        "XLS_IS_WHITE_PAGE_BACKGROUND"));
2092:                                    }
2093:                                    //                  if (this.getMainFrame().getProperties().getProperty("XLS_IS_AUTO_DETECT_CELL_TYPE") != null)
2094:                                    //                  { 
2095:                                    //                      //exporter.setParameter( JRXlsExporterParameter.IS_DETECT_CELL_TYPE, new Boolean(this.getMainFrame().getProperties().getProperty("XLS_IS_DETECT_CELL_TYPE")) );
2096:                                    //                      JRProperties.setProperty(JRXlsExporterParameter.PROPERTY_DETECT_CELL_TYPE,  this.getMainFrame().getProperties().getProperty("XLS_IS_DETECT_CELL_TYPE"));
2097:                                    //                  }
2098:
2099:                                    if (this 
2100:                                            .getMainFrame()
2101:                                            .getProperties()
2102:                                            .getProperty(
2103:                                                    JExcelApiExporterParameter.PROPERTY_DETECT_CELL_TYPE) != null
2104:                                            && this 
2105:                                                    .getMainFrame()
2106:                                                    .getProperties()
2107:                                                    .getProperty(
2108:                                                            JExcelApiExporterParameter.PROPERTY_DETECT_CELL_TYPE)
2109:                                                    .length() > 0) {
2110:                                        //exporter.setParameter( JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, new Boolean(this.getMainFrame().getProperties().getProperty("HTML_IS_USING_IMAGES_TO_ALIGN")) );
2111:                                        JRProperties
2112:                                                .setProperty(
2113:                                                        JExcelApiExporterParameter.PROPERTY_DETECT_CELL_TYPE,
2114:                                                        this 
2115:                                                                .getMainFrame()
2116:                                                                .getProperties()
2117:                                                                .getProperty(
2118:                                                                        JExcelApiExporterParameter.PROPERTY_DETECT_CELL_TYPE));
2119:                                    }
2120:
2121:                                    if (this 
2122:                                            .getMainFrame()
2123:                                            .getProperties()
2124:                                            .getProperty(
2125:                                                    JExcelApiExporterParameter.PROPERTY_CREATE_CUSTOM_PALETTE) != null
2126:                                            && this 
2127:                                                    .getMainFrame()
2128:                                                    .getProperties()
2129:                                                    .getProperty(
2130:                                                            JExcelApiExporterParameter.PROPERTY_CREATE_CUSTOM_PALETTE)
2131:                                                    .length() > 0) {
2132:                                        //exporter.setParameter( JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, new Boolean(this.getMainFrame().getProperties().getProperty("HTML_IS_USING_IMAGES_TO_ALIGN")) );
2133:                                        JRProperties
2134:                                                .setProperty(
2135:                                                        JExcelApiExporterParameter.PROPERTY_CREATE_CUSTOM_PALETTE,
2136:                                                        this 
2137:                                                                .getMainFrame()
2138:                                                                .getProperties()
2139:                                                                .getProperty(
2140:                                                                        JExcelApiExporterParameter.PROPERTY_CREATE_CUSTOM_PALETTE));
2141:                                    }
2142:
2143:                                    if (this 
2144:                                            .getMainFrame()
2145:                                            .getProperties()
2146:                                            .getProperty(
2147:                                                    JExcelApiExporterParameter.PROPERTY_FONT_SIZE_FIX_ENABLED) != null
2148:                                            && this 
2149:                                                    .getMainFrame()
2150:                                                    .getProperties()
2151:                                                    .getProperty(
2152:                                                            JExcelApiExporterParameter.PROPERTY_FONT_SIZE_FIX_ENABLED)
2153:                                                    .length() > 0) {
2154:                                        //exporter.setParameter( JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, new Boolean(this.getMainFrame().getProperties().getProperty("HTML_IS_USING_IMAGES_TO_ALIGN")) );
2155:                                        JRProperties
2156:                                                .setProperty(
2157:                                                        JExcelApiExporterParameter.PROPERTY_FONT_SIZE_FIX_ENABLED,
2158:                                                        this 
2159:                                                                .getMainFrame()
2160:                                                                .getProperties()
2161:                                                                .getProperty(
2162:                                                                        JExcelApiExporterParameter.PROPERTY_FONT_SIZE_FIX_ENABLED));
2163:                                    }
2164:
2165:                                    if (this 
2166:                                            .getMainFrame()
2167:                                            .getProperties()
2168:                                            .getProperty(
2169:                                                    JExcelApiExporterParameter.PROPERTY_MAXIMUM_ROWS_PER_SHEET) != null
2170:                                            && this 
2171:                                                    .getMainFrame()
2172:                                                    .getProperties()
2173:                                                    .getProperty(
2174:                                                            JExcelApiExporterParameter.PROPERTY_MAXIMUM_ROWS_PER_SHEET)
2175:                                                    .length() > 0) {
2176:                                        //exporter.setParameter( JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, new Boolean(this.getMainFrame().getProperties().getProperty("HTML_IS_USING_IMAGES_TO_ALIGN")) );
2177:                                        JRProperties
2178:                                                .setProperty(
2179:                                                        JExcelApiExporterParameter.PROPERTY_MAXIMUM_ROWS_PER_SHEET,
2180:                                                        this 
2181:                                                                .getMainFrame()
2182:                                                                .getProperties()
2183:                                                                .getProperty(
2184:                                                                        JExcelApiExporterParameter.PROPERTY_MAXIMUM_ROWS_PER_SHEET));
2185:                                    }
2186:
2187:                                    if (this 
2188:                                            .getMainFrame()
2189:                                            .getProperties()
2190:                                            .getProperty(
2191:                                                    JExcelApiExporterParameter.PROPERTY_IGNORE_GRAPHICS) != null
2192:                                            && this 
2193:                                                    .getMainFrame()
2194:                                                    .getProperties()
2195:                                                    .getProperty(
2196:                                                            JExcelApiExporterParameter.PROPERTY_IGNORE_GRAPHICS)
2197:                                                    .length() > 0) {
2198:                                        //exporter.setParameter( JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, new Boolean(this.getMainFrame().getProperties().getProperty("HTML_IS_USING_IMAGES_TO_ALIGN")) );
2199:                                        JRProperties
2200:                                                .setProperty(
2201:                                                        JExcelApiExporterParameter.PROPERTY_IGNORE_GRAPHICS,
2202:                                                        this 
2203:                                                                .getMainFrame()
2204:                                                                .getProperties()
2205:                                                                .getProperty(
2206:                                                                        JExcelApiExporterParameter.PROPERTY_IGNORE_GRAPHICS));
2207:                                    }
2208:
2209:                                    if (this 
2210:                                            .getMainFrame()
2211:                                            .getProperties()
2212:                                            .getProperty(
2213:                                                    JExcelApiExporterParameter.PROPERTY_COLLAPSE_ROW_SPAN) != null
2214:                                            && this 
2215:                                                    .getMainFrame()
2216:                                                    .getProperties()
2217:                                                    .getProperty(
2218:                                                            JExcelApiExporterParameter.PROPERTY_COLLAPSE_ROW_SPAN)
2219:                                                    .length() > 0) {
2220:                                        //exporter.setParameter( JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, new Boolean(this.getMainFrame().getProperties().getProperty("HTML_IS_USING_IMAGES_TO_ALIGN")) );
2221:                                        JRProperties
2222:                                                .setProperty(
2223:                                                        JExcelApiExporterParameter.PROPERTY_COLLAPSE_ROW_SPAN,
2224:                                                        this 
2225:                                                                .getMainFrame()
2226:                                                                .getProperties()
2227:                                                                .getProperty(
2228:                                                                        JExcelApiExporterParameter.PROPERTY_COLLAPSE_ROW_SPAN));
2229:                                    }
2230:
2231:                                    if (this 
2232:                                            .getMainFrame()
2233:                                            .getProperties()
2234:                                            .getProperty(
2235:                                                    JExcelApiExporterParameter.PROPERTY_IGNORE_CELL_BORDER) != null
2236:                                            && this 
2237:                                                    .getMainFrame()
2238:                                                    .getProperties()
2239:                                                    .getProperty(
2240:                                                            JExcelApiExporterParameter.PROPERTY_IGNORE_CELL_BORDER)
2241:                                                    .length() > 0) {
2242:                                        //exporter.setParameter( JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, new Boolean(this.getMainFrame().getProperties().getProperty("HTML_IS_USING_IMAGES_TO_ALIGN")) );
2243:                                        JRProperties
2244:                                                .setProperty(
2245:                                                        JExcelApiExporterParameter.PROPERTY_IGNORE_CELL_BORDER,
2246:                                                        this 
2247:                                                                .getMainFrame()
2248:                                                                .getProperties()
2249:                                                                .getProperty(
2250:                                                                        JExcelApiExporterParameter.PROPERTY_IGNORE_CELL_BORDER));
2251:                                    }
2252:
2253:                                    fileName = Misc.changeFileExtension(
2254:                                            fileName, "xls");
2255:                                    viewer_program = Misc.nvl(mainFrame
2256:                                            .getProperties().getProperty(
2257:                                                    "ExternalXLSViewer"), "");
2258:
2259:                                } else if (format.equalsIgnoreCase("java2D")) {
2260:
2261:                                    //exporter = new  net.sf.jasperreports.engine.export.JRGraphics2DExporter();
2262:                                    //exportingMessage = " ";
2263:                                    exportingMessage = I18n
2264:                                            .getString(
2265:                                                    "iReportCompiler.exportingMessage.java2D",
2266:                                                    "Exporting to Java2D...");
2267:                                    viewer_program = null;
2268:                                } else if (format.equalsIgnoreCase("jrviewer")) {
2269:                                    exportingMessage = I18n
2270:                                            .getString(
2271:                                                    "iReportCompiler.exportingMessage.jrviewer",
2272:                                                    "Viewing with JasperReports Viewer");
2273:                                    exporter = null;
2274:                                    viewer_program = null;
2275:                                } else if (format.equalsIgnoreCase("txt")) {
2276:                                    exporter = new it.businesslogic.ireport.export.JRTxtExporter();
2277:
2278:                                    if (this .getMainFrame().getProperties()
2279:                                            .getProperty("TXT_PAGE_ROWS") != null) {
2280:                                        exporter
2281:                                                .setParameter(
2282:                                                        it.businesslogic.ireport.export.JRTxtExporterParameter.PAGE_ROWS,
2283:                                                        this 
2284:                                                                .getMainFrame()
2285:                                                                .getProperties()
2286:                                                                .getProperty(
2287:                                                                        "TXT_PAGE_ROWS"));
2288:                                    }
2289:                                    if (this .getMainFrame().getProperties()
2290:                                            .getProperty("TXT_PAGE_COLUMNS") != null) {
2291:                                        exporter
2292:                                                .setParameter(
2293:                                                        it.businesslogic.ireport.export.JRTxtExporterParameter.PAGE_COLUMNS,
2294:                                                        this 
2295:                                                                .getMainFrame()
2296:                                                                .getProperties()
2297:                                                                .getProperty(
2298:                                                                        "TXT_PAGE_COLUMNS"));
2299:                                    }
2300:                                    if (this .getMainFrame().getProperties()
2301:                                            .getProperty("TXT_ADD_FORM_FEED") != null) {
2302:                                        exporter
2303:                                                .setParameter(
2304:                                                        it.businesslogic.ireport.export.JRTxtExporterParameter.ADD_FORM_FEED,
2305:                                                        new Boolean(
2306:                                                                this 
2307:                                                                        .getMainFrame()
2308:                                                                        .getProperties()
2309:                                                                        .getProperty(
2310:                                                                                "TXT_ADD_FORM_FEED")));
2311:                                    }
2312:
2313:                                    fileName = Misc.changeFileExtension(
2314:                                            fileName, "txt");
2315:                                    exportingMessage = I18n
2316:                                            .getFormattedString(
2317:                                                    "iReportCompiler.exportingMessage.txt",
2318:                                                    "Exporting txt (iReport) to file... {0}!",
2319:                                                    new Object[] { fileName });
2320:                                    viewer_program = Misc.nvl(mainFrame
2321:                                            .getProperties().getProperty(
2322:                                                    "ExternalTXTViewer"), "");
2323:                                } else if (format.equalsIgnoreCase("txtjr")) {
2324:                                    exporter = new net.sf.jasperreports.engine.export.JRTextExporter();
2325:
2326:                                    if (this .getMainFrame().getProperties()
2327:                                            .getProperty("JRTXT_PAGE_WIDTH") != null) {
2328:                                        exporter
2329:                                                .setParameter(
2330:                                                        net.sf.jasperreports.engine.export.JRTextExporterParameter.PAGE_WIDTH,
2331:                                                        new Integer(
2332:                                                                this 
2333:                                                                        .getMainFrame()
2334:                                                                        .getProperties()
2335:                                                                        .getProperty(
2336:                                                                                "JRTXT_PAGE_WIDTH")));
2337:                                    }
2338:                                    if (this .getMainFrame().getProperties()
2339:                                            .getProperty("JRTXT_PAGE_HEIGHT") != null) {
2340:                                        exporter
2341:                                                .setParameter(
2342:                                                        net.sf.jasperreports.engine.export.JRTextExporterParameter.PAGE_HEIGHT,
2343:                                                        new Integer(
2344:                                                                this 
2345:                                                                        .getMainFrame()
2346:                                                                        .getProperties()
2347:                                                                        .getProperty(
2348:                                                                                "JRTXT_PAGE_HEIGHT")));
2349:                                    }
2350:                                    if (this .getMainFrame().getProperties()
2351:                                            .getProperty(
2352:                                                    "JRTXT_CHARACTER_WIDTH") != null) {
2353:                                        exporter
2354:                                                .setParameter(
2355:                                                        net.sf.jasperreports.engine.export.JRTextExporterParameter.CHARACTER_WIDTH,
2356:                                                        new Integer(
2357:                                                                this 
2358:                                                                        .getMainFrame()
2359:                                                                        .getProperties()
2360:                                                                        .getProperty(
2361:                                                                                "JRTXT_CHARACTER_WIDTH")));
2362:                                    }
2363:                                    if (this .getMainFrame().getProperties()
2364:                                            .getProperty(
2365:                                                    "JRTXT_CHARACTER_HEIGHT") != null) {
2366:                                        exporter
2367:                                                .setParameter(
2368:                                                        net.sf.jasperreports.engine.export.JRTextExporterParameter.CHARACTER_HEIGHT,
2369:                                                        new Integer(
2370:                                                                this 
2371:                                                                        .getMainFrame()
2372:                                                                        .getProperties()
2373:                                                                        .getProperty(
2374:                                                                                "JRTXT_CHARACTER_HEIGHT")));
2375:                                    }
2376:                                    if (this .getMainFrame().getProperties()
2377:                                            .getProperty(
2378:                                                    "JRTXT_BETWEEN_PAGES_TEXT") != null) {
2379:                                        exporter
2380:                                                .setParameter(
2381:                                                        net.sf.jasperreports.engine.export.JRTextExporterParameter.BETWEEN_PAGES_TEXT,
2382:                                                        this 
2383:                                                                .getMainFrame()
2384:                                                                .getProperties()
2385:                                                                .getProperty(
2386:                                                                        "JRTXT_BETWEEN_PAGES_TEXT"));
2387:                                    }
2388:
2389:                                    fileName = Misc.changeFileExtension(
2390:                                            fileName, "txt");
2391:                                    exportingMessage = I18n
2392:                                            .getFormattedString(
2393:                                                    "iReportCompiler.exportingMessage.txtjr",
2394:                                                    "Exporting txt (jasperReports) to file... {0}!",
2395:                                                    new Object[] { fileName });
2396:                                    viewer_program = Misc.nvl(mainFrame
2397:                                            .getProperties().getProperty(
2398:                                                    "ExternalTXTViewer"), "");
2399:                                } else if (format.equalsIgnoreCase("rtf")) {
2400:                                    exporter = new net.sf.jasperreports.engine.export.JRRtfExporter();
2401:
2402:                                    fileName = Misc.changeFileExtension(
2403:                                            fileName, "rtf");
2404:                                    exportingMessage = I18n
2405:                                            .getFormattedString(
2406:                                                    "iReportCompiler.exportingMessage.rtf",
2407:                                                    "Exporting RTF to file... {0}!",
2408:                                                    new Object[] { fileName });
2409:                                    viewer_program = Misc.nvl(mainFrame
2410:                                            .getProperties().getProperty(
2411:                                                    "ExternalRTFViewer"), "");
2412:                                } else if (format.equalsIgnoreCase("odf")) {
2413:                                    exporter = new net.sf.jasperreports.engine.export.oasis.JROdtExporter();
2414:
2415:                                    fileName = Misc.changeFileExtension(
2416:                                            fileName, "odf");
2417:                                    exportingMessage = I18n
2418:                                            .getFormattedString(
2419:                                                    "iReportCompiler.exportingMessage.odf",
2420:                                                    "Exporting OpenOffice documento to file... {0}!",
2421:                                                    new Object[] { fileName });
2422:                                    viewer_program = Misc.nvl(mainFrame
2423:                                            .getProperties().getProperty(
2424:                                                    "ExternalODFViewer"), "");
2425:                                } else if (format.equalsIgnoreCase("swf")) {
2426:                                    exporter = new it.businesslogic.ireport.export.FlashExporter();
2427:                                    fileName = Misc.changeFileExtension(
2428:                                            fileName, "swf");
2429:                                    exportingMessage = I18n
2430:                                            .getFormattedString(
2431:                                                    "iReportCompiler.exportingMessage.swf",
2432:                                                    "Exporting Flash to file... {0}!",
2433:                                                    new Object[] { fileName });
2434:                                    viewer_program = Misc.nvl(mainFrame
2435:                                            .getProperties().getProperty(
2436:                                                    "ExternalHTMLViewer"), "");
2437:                                }
2438:
2439:                                img_url = this 
2440:                                        .getClass()
2441:                                        .getResource(
2442:                                                "/it/businesslogic/ireport/icons/printer_mini.png");
2443:
2444:                                getLogTextArea().logOnConsole(
2445:                                        "<font face=\"SansSerif\"  size=\"3\"><img align=\"right\" src=\""
2446:                                                + img_url + "\"> &nbsp;"
2447:                                                + exportingMessage + "</font>",
2448:                                        true);
2449:
2450:                                if (exporter != null) {
2451:                                    exporter
2452:                                            .setParameter(
2453:                                                    JRExporterParameter.OUTPUT_FILE_NAME,
2454:                                                    fileName);
2455:                                    exporter.setParameter(
2456:                                            JRExporterParameter.JASPER_PRINT,
2457:                                            print);
2458:                                    exporter
2459:                                            .setParameter(
2460:                                                    JRExporterParameter.PROGRESS_MONITOR,
2461:                                                    this );
2462:
2463:                                    String reportEncoding = Misc.nvl(mainFrame
2464:                                            .getProperties().getProperty(
2465:                                                    "CHARACTER_ENCODING"), "");
2466:                                    if (reportEncoding.trim().length() > 0) {
2467:                                        //exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, reportEncoding);
2468:                                        JRProperties
2469:                                                .setProperty(
2470:                                                        JRExporterParameter.PROPERTY_CHARACTER_ENCODING,
2471:                                                        reportEncoding);
2472:                                    }
2473:
2474:                                    String offsetX = Misc.nvl(mainFrame
2475:                                            .getProperties().getProperty(
2476:                                                    "OFFSET_X"), "");
2477:                                    if (offsetX.trim().length() > 0) {
2478:                                        try {
2479:                                            exporter
2480:                                                    .setParameter(
2481:                                                            JRExporterParameter.OFFSET_X,
2482:                                                            new Integer(offsetX));
2483:                                        } catch (Exception ex) {
2484:                                        }
2485:                                    }
2486:
2487:                                    String offsetY = Misc.nvl(mainFrame
2488:                                            .getProperties().getProperty(
2489:                                                    "OFFSET_Y"), "");
2490:                                    if (offsetY.trim().length() > 0) {
2491:                                        try {
2492:                                            exporter
2493:                                                    .setParameter(
2494:                                                            JRExporterParameter.OFFSET_Y,
2495:                                                            new Integer(offsetY));
2496:                                        } catch (Exception ex) {
2497:                                        }
2498:                                    }
2499:
2500:                                    exporter.exportReport();
2501:                                    getLogTextArea().logOnConsole(
2502:                                            outputBuffer.toString());
2503:                                    outputBuffer = new StringBuffer();
2504:                                } else if (format.equalsIgnoreCase("java2D")) {
2505:                                    if (print.getPages().size() == 0) {
2506:                                        try {
2507:                                            SwingUtilities
2508:                                                    .invokeLater(new Runnable() {
2509:                                                        public void run() {
2510:                                                            JOptionPane
2511:                                                                    .showMessageDialog(
2512:                                                                            MainFrame
2513:                                                                                    .getMainInstance(),
2514:                                                                            I18n
2515:                                                                                    .getString(
2516:                                                                                            "documentHasNoPages",
2517:                                                                                            "The document has no pages"));
2518:                                                        }
2519:                                                    });
2520:                                        } catch (Exception ex) {
2521:                                        }
2522:                                    } else {
2523:                                        PagesFrame pd = new PagesFrame(print);
2524:                                        pd.setVisible(true);
2525:                                    }
2526:                                } else if (format.equalsIgnoreCase("jrviewer")) {
2527:                                    //jrv = new net.sf.jasperreports.view.JRViewer(print);
2528:                                    if (print.getPages().size() == 0) {
2529:                                        try {
2530:                                            SwingUtilities
2531:                                                    .invokeLater(new Runnable() {
2532:                                                        public void run() {
2533:                                                            JOptionPane
2534:                                                                    .showMessageDialog(
2535:                                                                            MainFrame
2536:                                                                                    .getMainInstance(),
2537:                                                                            I18n
2538:                                                                                    .getString(
2539:                                                                                            "documentHasNoPages",
2540:                                                                                            "The document has no pages"));
2541:                                                        }
2542:                                                    });
2543:                                        } catch (Exception ex) {
2544:                                        }
2545:                                    } else {
2546:                                        JasperViewer jasperViewer = new JasperViewer(
2547:                                                print, false);
2548:                                        jasperViewer
2549:                                                .setTitle("iReport JasperViewer");
2550:                                        jasperViewer.setVisible(true);
2551:
2552:                                    }
2553:                                    //net.sf.jasperreports.view.JasperViewer.viewReport( print, false);
2554:                                }
2555:                            } catch (Throwable ex2) {
2556:
2557:                                getLogTextArea()
2558:                                        .logOnConsole(
2559:                                                I18n
2560:                                                        .getFormattedString(
2561:                                                                "iReportCompiler.errorExportingPrint",
2562:                                                                "Error exporting print... {0}\n",
2563:                                                                new Object[] { ex2
2564:                                                                        .getMessage() }));
2565:                                ex2.printStackTrace();
2566:                                getLogTextArea().logOnConsole(
2567:                                        outputBuffer.toString());
2568:                                outputBuffer = new StringBuffer();
2569:
2570:                            }
2571:
2572:                            getLogTextArea()
2573:                                    .logOnConsole(
2574:                                            "<font face=\"SansSerif\"  size=\"3\" color=\"#0000CC\"><b>"
2575:                                                    + I18n
2576:                                                            .getFormattedString(
2577:                                                                    "iReportCompiler.exportRunningTime",
2578:                                                                    "Export running time: {0,number}!",
2579:                                                                    new Object[] {
2580:                                                                            new Long(
2581:                                                                                    System
2582:                                                                                            .currentTimeMillis()
2583:                                                                                            - start),
2584:                                                                            new Integer(
2585:                                                                                    ((List) print
2586:                                                                                            .getPages())
2587:                                                                                            .size()) })
2588:                                                    + "</b></font><hr>", true);
2589:
2590:                            // Export using the rigth program....
2591:
2592:                            Runtime rt = Runtime.getRuntime();
2593:                            if (viewer_program == null
2594:                                    || viewer_program.equals("")) {
2595:
2596:                                if (format.equalsIgnoreCase("jrviewer")
2597:                                        || format.equalsIgnoreCase("java2D")) {
2598:
2599:                                } else
2600:                                    getLogTextArea()
2601:                                            .logOnConsole(
2602:                                                    "<font face=\"SansSerif\"  size=\"3\">"
2603:                                                            + I18n
2604:                                                                    .getString(
2605:                                                                            "iReportCompiler.noExternalViewer",
2606:                                                                            "No external viewer specified for this type of print. Set it in the options frame!")
2607:                                                            + "</font>", true);
2608:
2609:                            } else {
2610:                                try {
2611:                                    String execute_string = viewer_program
2612:                                            + " \"" + fileName + "\"";
2613:                                    getLogTextArea()
2614:                                            .logOnConsole(
2615:                                                    "<font face=\"SansSerif\"  size=\"3\">"
2616:                                                            + I18n
2617:                                                                    .getFormattedString(
2618:                                                                            "iReportCompiler.executingString",
2619:                                                                            "Executing: {0}",
2620:                                                                            new Object[] { execute_string })
2621:                                                            + "</font>", true);
2622:                                    rt.exec(execute_string);
2623:                                } catch (Exception ex) {
2624:
2625:                                    getLogTextArea().logOnConsole(
2626:                                            "Error viewing report...\n");
2627:                                    ex.printStackTrace();
2628:                                    getLogTextArea().logOnConsole(
2629:                                            outputBuffer.toString());
2630:                                    outputBuffer = new StringBuffer();
2631:                                }
2632:                                //getLogTextArea().logOnConsole("Finished...\n");
2633:                            }
2634:                        } else {
2635:                            getLogTextArea()
2636:                                    .logOnConsole(
2637:                                            "<font face=\"SansSerif\"  size=\"3\">"
2638:                                                    + I18n
2639:                                                            .getString(
2640:                                                                    "iReportCompiler.printNotFilled",
2641:                                                                    "Print not filled. Try to use an EmptyDataSource...")
2642:                                                    + "</font>", true);
2643:                            getLogTextArea().logOnConsole("\n");
2644:                        }
2645:                    }
2646:
2647:                    fireCompileListner(this , CL_COMPILE_OK, CLS_COMPILE_OK);
2648:                    removeThread();
2649:
2650:                    if (backupJRClasspath != null) {
2651:                        //System.setProperty("jasper.reports.compile.class.path",backupJRClasspath);
2652:                        net.sf.jasperreports.engine.util.JRProperties
2653:                                .setProperty(
2654:                                        net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASSPATH,
2655:                                        backupJRClasspath);
2656:                    } else {
2657:                        //System.getProperties().remove("jasper.reports.compile.class.path");
2658:                        net.sf.jasperreports.engine.util.JRProperties
2659:                                .restoreProperties();
2660:                    }
2661:
2662:                    if (backupSystemClasspath != null)
2663:                        System.setProperty("java.class.path",
2664:                                backupSystemClasspath);
2665:                    else
2666:                        System.getProperties().remove("java.class.path");
2667:
2668:                } finally {
2669:                    System.gc();
2670:                    System.setOut(out);
2671:                    System.setErr(err);
2672:                    System.gc();
2673:                }
2674:
2675:            }
2676:
2677:            public void removeThread() {
2678:                if (threadList != null)
2679:                    synchronized (threadList) {
2680:                        javax.swing.DefaultListModel dlm = (javax.swing.DefaultListModel) threadList
2681:                                .getModel();
2682:                        dlm.removeElement(this );
2683:                        threadList.updateUI();
2684:                        getLogTextArea().setTitle(
2685:                                I18n.getString(
2686:                                        "iReportCompiler.status.finished",
2687:                                        "Finished")
2688:                                        + constTabTitle);
2689:                        getLogTextArea().setRemovable(true);
2690:                    }
2691:
2692:            }
2693:
2694:            /** Getter for property command.
2695:             * @return Value of property command.
2696:             *
2697:             */
2698:            public int getCommand() {
2699:                return command;
2700:            }
2701:
2702:            /** Setter for property command.
2703:             * @param command New value of property command.
2704:             *
2705:             */
2706:            public void setCommand(int command) {
2707:                this .command = command;
2708:            }
2709:
2710:            /** Getter for property iReportConnection.
2711:             * @return Value of property iReportConnection.
2712:             *
2713:             */
2714:            public it.businesslogic.ireport.IReportConnection getIReportConnection() {
2715:                return iReportConnection;
2716:            }
2717:
2718:            /** Setter for property iReportConnection.
2719:             * @param iReportConnection New value of property iReportConnection.
2720:             *
2721:             */
2722:            public void setIReportConnection(
2723:                    it.businesslogic.ireport.IReportConnection iReportConnection) {
2724:                this .iReportConnection = iReportConnection;
2725:            }
2726:
2727:            /** Getter for property jrf.
2728:             * @return Value of property jrf.
2729:             *
2730:             */
2731:            public JReportFrame getJrf() {
2732:                return jrf;
2733:            }
2734:
2735:            /** Setter for property jrf.
2736:             * @param jrf New value of property jrf.
2737:             *
2738:             */
2739:            public void setJrf(JReportFrame jrf) {
2740:                this .jrf = jrf;
2741:            }
2742:
2743:            /** Getter for property mainFrame.
2744:             * @return Value of property mainFrame.
2745:             *
2746:             */
2747:            public MainFrame getMainFrame() {
2748:                return mainFrame;
2749:            }
2750:
2751:            /** Setter for property mainFrame.
2752:             * @param mainFrame New value of property mainFrame.
2753:             *
2754:             */
2755:            public void setMainFrame(MainFrame mainFrame) {
2756:                this .mainFrame = mainFrame;
2757:            }
2758:
2759:            /** Getter for property properties.
2760:             * @return Value of property properties.
2761:             *
2762:             */
2763:            public HashMap getProperties() {
2764:                return properties;
2765:            }
2766:
2767:            /** Setter for property properties.
2768:             * @param properties New value of property properties.
2769:             *
2770:             */
2771:            public void setProperties(HashMap properties) {
2772:                this .properties = properties;
2773:            }
2774:
2775:            public String toString() {
2776:                return status;
2777:            }
2778:
2779:            class FilteredStream extends FilterOutputStream {
2780:                public FilteredStream(OutputStream aStream) {
2781:                    super (aStream);
2782:                }
2783:
2784:                public void write(byte b[]) throws IOException {
2785:                    String aString = new String(b);
2786:                    outputBuffer.append(aString);
2787:
2788:                    if (outputBuffer.length() > maxBufferSize) // 5000000
2789:                    {
2790:                        outputBuffer = outputBuffer.delete(0, outputBuffer
2791:                                .length()
2792:                                - maxBufferSize);
2793:                    }
2794:                }
2795:
2796:                public void write(byte b[], int off, int len)
2797:                        throws IOException {
2798:                    String aString = new String(b, off, len);
2799:                    outputBuffer.append(aString);
2800:                    if (outputBuffer.length() > maxBufferSize) {
2801:                        outputBuffer = outputBuffer.delete(0, outputBuffer
2802:                                .length()
2803:                                - maxBufferSize);
2804:                    }
2805:                    //getLogTextArea().logOnConsole(aString);
2806:                }
2807:            }
2808:
2809:            public void start() {
2810:                this .thread = new Thread(this );
2811:
2812:                //using the report directory to load classes and resources
2813:                try {
2814:                    String reportDirectory = new File(jrf.getReport()
2815:                            .getFilename()).getParent();
2816:
2817:                    //set classpath
2818:                    //String classpath = System.getProperty("jasper.reports.compile.class.path");
2819:                    String classpath = net.sf.jasperreports.engine.util.JRProperties
2820:                            .getProperty(net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASSPATH);
2821:
2822:                    if (classpath != null) {
2823:
2824:                        classpath += File.pathSeparator + reportDirectory;
2825:                        //System.setProperty("jasper.reports.compile.class.path", classpath);
2826:                        net.sf.jasperreports.engine.util.JRProperties
2827:                                .setProperty(
2828:                                        net.sf.jasperreports.engine.util.JRProperties.COMPILER_CLASSPATH,
2829:                                        classpath);
2830:
2831:                    } else if (System.getProperty("java.class.path") != null) {
2832:
2833:                        classpath = System.getProperty("java.class.path");
2834:                        classpath += File.pathSeparator + reportDirectory;
2835:                        System.setProperty("java.class.path", classpath);
2836:                    }
2837:
2838:                    // Add all the hidden files.... (needed only by JWS)
2839:                    if (MainFrame.getMainInstance().isUsingWS()) {
2840:                        try {
2841:                            Enumeration e = MainFrame.getMainInstance()
2842:                                    .getReportClassLoader().getResources(
2843:                                            "META-INF/MANIFEST.MF");
2844:                            while (e.hasMoreElements()) {
2845:                                URL url = (URL) e.nextElement();
2846:                                String newJar = "" + url.getFile();
2847:
2848:                                if (newJar.endsWith("!/META-INF/MANIFEST.MF")) {
2849:                                    newJar = newJar
2850:                                            .substring(0, newJar.length()
2851:                                                    - "!/META-INF/MANIFEST.MF"
2852:                                                            .length());
2853:
2854:                                    newJar = java.net.URLDecoder.decode(newJar,
2855:                                            "UTF-8");
2856:
2857:                                    MainFrame.getMainInstance().logOnConsole(
2858:                                            "JX:" + newJar);
2859:
2860:                                    newJar = newJar.replace('\\', '/');
2861:                                    if (newJar.startsWith("file://")) {
2862:                                        newJar = newJar.substring(7);
2863:                                    }
2864:
2865:                                    if (newJar.startsWith("file:")) {
2866:                                        newJar = newJar.substring(5);
2867:                                    }
2868:
2869:                                    if (!newJar.startsWith("/")) {
2870:                                        newJar = "/" + newJar;//it's important to JVM 1.4.2 especially if contains windows drive letter
2871:                                    }
2872:                                }
2873:
2874:                                if (classpath.indexOf(newJar
2875:                                        + File.pathSeparator) < 0
2876:                                        && !classpath.endsWith(newJar)) {
2877:                                    classpath += File.pathSeparator + newJar;
2878:                                }
2879:                            }
2880:                        } catch (Exception exc) {
2881:                            MainFrame.getMainInstance().logOnConsole(
2882:                                    "exception ex:" + exc.getMessage());
2883:                            exc.printStackTrace();
2884:                        }
2885:                        System.setProperty("java.class.path", classpath);
2886:                    }
2887:                    //MainFrame.getMainInstance().logOnConsole("CLASSPATH" + classpath);
2888:
2889:                    //include report directory for resource search path
2890:                    reportDirectory = reportDirectory.replace('\\', '/');
2891:                    if (!reportDirectory.endsWith("/")) {
2892:                        reportDirectory += "/";//the file path separator must be present
2893:                    }
2894:                    if (!reportDirectory.startsWith("/")) {
2895:                        reportDirectory = "/" + reportDirectory;//it's important to JVM 1.4.2 especially if contains windows drive letter
2896:                    }
2897:
2898:                    thread
2899:                            .setContextClassLoader(new URLClassLoader(
2900:                                    new URL[] { new URL("file://"
2901:                                            + reportDirectory) }, MainFrame
2902:                                            .getMainInstance()
2903:                                            .getReportClassLoader()));
2904:
2905:                } catch (MalformedURLException mue) {
2906:                    mue.printStackTrace();
2907:                }
2908:
2909:                this .thread.start();
2910:            }
2911:
2912:            public void parseException(String exception, Vector sourceLines) {
2913:
2914:                // Create a single outString...
2915:                String outString = "";
2916:
2917:                // For each row, looking for a file name followed by a row number...
2918:                //javax.swing.JOptionPane.showMessageDialog(null,exception);
2919:                StringTokenizer st = new StringTokenizer(exception, "\n");
2920:                while (st.hasMoreElements()) {
2921:
2922:                    String line = st.nextToken();
2923:                    if (line.startsWith(this .javaFile)) {
2924:                        // The next line is an expression error....
2925:                        //getLogTextArea().logOnConsole(line+"\n");
2926:                        outString += Misc.toHTML(line + "\n");
2927:                        String lineNumber = line.substring(this .javaFile
2928:                                .length() + 1);
2929:                        lineNumber = lineNumber.substring(0, lineNumber
2930:                                .indexOf(':'));
2931:                        int ln = Integer.parseInt(lineNumber);
2932:                        if (ln >= 3)
2933:                            ln -= 3;
2934:
2935:                        // Take the element name....
2936:
2937:                        String reference = "";
2938:                        if (sourceLines.size() >= ln) {
2939:
2940:                            String lineCode = (String) sourceLines
2941:                                    .elementAt(ln);
2942:                            //getLogTextArea().logOnConsole( "Line: " + ln + "> " + lineCode+"\n");
2943:                            if (lineCode.indexOf("            case") == 0
2944:                                    && lineCode.indexOf(" : // ") > 0) {
2945:                                // We have found the comment where jasperReport puts the expression ref.
2946:                                reference = lineCode.substring(
2947:                                        lineCode.indexOf(" : // ") + 6).trim();
2948:                            }
2949:                        }
2950:
2951:                        if (st.hasMoreElements()) {
2952:                            try {
2953:                                String error_line = st.nextToken();
2954:                                if (error_line.startsWith("found")) {
2955:                                    //getLogTextArea().logOnConsole( error_line+"\n");
2956:                                    outString += Misc.toHTML(error_line + "\n");
2957:                                    error_line = st.nextToken();
2958:                                }
2959:                                if (error_line.startsWith("required")) {
2960:                                    //getLogTextArea().logOnConsole( error_line+"\n");
2961:                                    outString += Misc.toHTML(error_line + "\n");
2962:                                    error_line = st.nextToken();
2963:                                }
2964:                                if (error_line.startsWith("symbol")) {
2965:                                    //getLogTextArea().logOnConsole( error_line+"\n");
2966:                                    outString += Misc.toHTML(error_line + "\n");
2967:                                    error_line = st.nextToken();
2968:                                }
2969:                                if (error_line.startsWith("location")) {
2970:                                    //getLogTextArea().logOnConsole( error_line+"\n");
2971:                                    outString += Misc.toHTML(error_line + "\n");
2972:                                    error_line = st.nextToken();
2973:                                }
2974:
2975:                                // Find the link....
2976:                                // Count space at begin of line...
2977:                                String html = "";
2978:                                for (int i = 0; i < error_line.length(); ++i) {
2979:                                    if (error_line.charAt(i) == ' ') {
2980:                                        html += "&nbsp;";
2981:                                    } else
2982:                                        break;
2983:                                }
2984:                                error_line = error_line.trim();
2985:                                html += "<a href=\"http://error:"
2986:                                        + jrf.getWindowID() + "/" + reference
2987:                                        + "\">" + Misc.toHTML(error_line)
2988:                                        + "</a>";
2989:                                //getLogTextArea().logOnConsole( html,true);
2990:                                outString += html;
2991:                            } catch (Exception ex) {
2992:                                //getLogTextArea().logOnConsole( "Error parsing\n!");
2993:                                outString += Misc.toHTML("Error parsing\n!");
2994:                            }
2995:                        }
2996:                    } else if (line.startsWith("Warning :")
2997:                            && line.indexOf("y=") > 0
2998:                            && line.indexOf("height=") > 0
2999:                            && line.indexOf("band-height=") > 0) {
3000:                        //getLogTextArea().logOnConsole("<a href=\"http://warning\">"+Misc.toHTML(line)+"</a>",true);
3001:                        outString += "<a href=\"http://warning:"
3002:                                + jrf.getWindowID() + "\">" + Misc.toHTML(line)
3003:                                + "</a>";
3004:                    } else {
3005:                        //getLogTextArea().logOnConsole(line+"\n");
3006:                        outString += Misc.toHTML(line + "\n");
3007:                    }
3008:                }
3009:                getLogTextArea().logOnConsole(outString, true);
3010:                //getLogTextArea().logOnConsole( "<a href=\"http://problem\">*****<hr><font face=\"Courier New\" size=\"3\">"+ exception +"</a>", true);
3011:                outputBuffer = new StringBuffer();
3012:
3013:            }
3014:
3015:            public javax.swing.JComponent searchButton(
3016:                    javax.swing.JComponent root, String text) {
3017:                if (root instanceof  javax.swing.JButton
3018:                        && ((javax.swing.JButton) root).getText() != null
3019:                        && ((javax.swing.JButton) root).getText().equals(text))
3020:                    return root;
3021:                for (int i = 0; i < root.getComponentCount(); ++i) {
3022:
3023:                    if (root.getComponent(i) instanceof  javax.swing.JComponent) {
3024:                        getLogTextArea().logOnConsole(
3025:                                ""
3026:                                        + ((javax.swing.JComponent) root
3027:                                                .getComponent(i)) + "\n");
3028:                        javax.swing.JComponent res = searchButton(
3029:                                (javax.swing.JComponent) root.getComponent(i),
3030:                                text);
3031:                        if (res != null)
3032:                            return res;
3033:                    }
3034:                }
3035:                return null;
3036:            }
3037:
3038:            public void afterPageExport() {
3039:
3040:                filledpage++;
3041:                if (command == 0) {
3042:
3043:                }
3044:
3045:            }
3046:
3047:            public javax.swing.JList getThreadList() {
3048:                return threadList;
3049:            }
3050:
3051:            public void setThreadList(javax.swing.JList threadList) {
3052:                this .threadList = threadList;
3053:            }
3054:
3055:            public void updateThreadList() {
3056:                getLogTextArea().setTitle(status + constTabTitle);
3057:                try {
3058:
3059:                    if (threadList != null)
3060:                        javax.swing.SwingUtilities
3061:                                .invokeAndWait(new java.lang.Runnable() {
3062:                                    public void run() {
3063:                                        synchronized (threadList) {
3064:                                            threadList.updateUI();
3065:                                        }
3066:                                    }
3067:                                });
3068:                } catch (Exception ex) {
3069:                }
3070:            }
3071:
3072:            private ClassLoader getClassLoader() {
3073:                ClassLoader classLoader = Thread.currentThread()
3074:                        .getContextClassLoader();
3075:
3076:                if (classLoader != null) {
3077:                    //try
3078:                    //{
3079:                    //	Class.forName(net.sf.jasperreports.engine.design.JRJdtCompiler.class.getName(), true, Thread.currentThread().getContextClassLoader());
3080:                    //}
3081:                    //catch (ClassNotFoundException e)
3082:                    //{
3083:                    //	classLoader = null;
3084:                    //	//if (log.isWarnEnabled())
3085:                    //	//	log.warn("Failure using Thread.currentThread().getContextClassLoader() in JRJdtCompiler class. Using JRJdtCompiler.class.getClassLoader() instead.");
3086:                    //}
3087:                }
3088:
3089:                if (classLoader == null) {
3090:                    //classLoader = JRClassLoader.class.getClassLoader();
3091:                }
3092:
3093:                return classLoader;
3094:            }
3095:
3096:            public LogTextArea getLogTextArea() {
3097:                return logTextArea;
3098:            }
3099:
3100:            public void setLogTextArea(LogTextArea logTextArea) {
3101:                this .logTextArea = logTextArea;
3102:            }
3103:
3104:            /**
3105:             * added by Felix Firgau
3106:             */
3107:            public static final int CL_COMPILE_OK = 1;
3108:            public static final int CL_COMPILE_FAIL = 2;
3109:
3110:            public static final String CLS_COMPILE_OK = "compileok";
3111:            public static final String CLS_COMPILE_SCRIPTLET_FAIL = "scriptletfail";
3112:            public static final String CLS_COMPILE_SOURCE_FAIL = "sourcefail";
3113:
3114:            /**
3115:             * (FF) addCompileListener to notify about compiling actions
3116:             * @param listener ActionListener
3117:             */
3118:            public static void addCompileListener(
3119:                    java.awt.event.ActionListener listener) {
3120:                if (!compileListener.contains(listener))
3121:                    compileListener.add(listener);
3122:            }
3123:
3124:            /**
3125:             * (FF) removeCompileListener removes notification
3126:             * @param listener ActionListener
3127:             */
3128:            public static void removeCompileListener(
3129:                    java.awt.event.ActionListener listener) {
3130:                compileListener.remove(listener);
3131:            }
3132:
3133:            /**
3134:             * (FF) fireCompileListner fires compiling action notifications
3135:             * @param id int
3136:             * @param status String
3137:             */
3138:            public static void fireCompileListner(
3139:                    IReportCompiler ireportCompiler, int id, String status) {
3140:                java.awt.event.ActionListener[] list = (java.awt.event.ActionListener[]) compileListener
3141:                        .toArray(new java.awt.event.ActionListener[compileListener
3142:                                .size()]);
3143:
3144:                java.awt.event.ActionEvent e = new java.awt.event.ActionEvent(
3145:                        ireportCompiler, id, status);
3146:                for (int i = 0; i < list.length; i++) {
3147:                    java.awt.event.ActionListener listener = list[i];
3148:                    listener.actionPerformed(e);
3149:                }
3150:            }
3151:
3152:            //End FF
3153:
3154:            public static JasperDesign loadJasperDesign(InputStream fileStream,
3155:                    SourceTraceDigester digester) throws JRException {
3156:                JRXmlLoader xmlLoader = new JRXmlLoader(digester);
3157:
3158:                try {
3159:                    JasperDesign jasperDesign = xmlLoader.loadXML(fileStream);
3160:                    return jasperDesign;
3161:                } finally {
3162:                    try {
3163:                        fileStream.close();
3164:                    } catch (IOException e) {
3165:                        // ignore
3166:                    }
3167:                }
3168:            }
3169:
3170:            public static SourceTraceDigester createDigester()
3171:                    throws JRException {
3172:                SourceTraceDigester digester = new SourceTraceDigester();
3173:                try {
3174:                    JRXmlDigesterFactory.configureDigester(digester);
3175:                } catch (SAXException e) {
3176:                    throw new JRException(e);
3177:                } catch (ParserConfigurationException e) {
3178:                    throw new JRException(e);
3179:                }
3180:                return digester;
3181:            }
3182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.