001: /*
002: * To change this template, choose Tools | Templates
003: * and open the template in the editor.
004: */
005:
006: package it.businesslogic.ireport.export;
007:
008: import it.businesslogic.ireport.util.JavaProcessExecuter;
009: import java.io.File;
010: import java.io.IOException;
011: import java.util.Vector;
012: import java.util.logging.Level;
013: import java.util.logging.Logger;
014:
015: /**
016: *
017: * @author gtoffoli
018: */
019: public class FlashExporterExecuter extends JavaProcessExecuter {
020:
021: private String jrprintFile = null;
022: private String outputFile = null;
023:
024: public FlashExporterExecuter() {
025: super ();
026:
027: // Add all the jars in the Flex SDK lib directory...
028: if (System.getenv("FLEX_SDK_HOME") != null) {
029: File f = new File(System.getenv("FLEX_SDK_HOME"));
030: File[] jars = f.listFiles();
031: for (int i = 0; i < jars.length; ++i) {
032: if (jars[i].getName().toLowerCase().endsWith(".jar")) {
033: getClasspathEntries().add(0, jars[i].getPath());
034: }
035: }
036: }
037:
038: Vector cp = it.businesslogic.ireport.gui.MainFrame
039: .getMainInstance().getClasspath();
040: for (int i = 0; i < cp.size(); ++i) {
041: File f = new File(cp.elementAt(i) + "");
042: if (!f.exists())
043: continue;
044: try {
045: getClasspathEntries().add(f.getCanonicalPath());
046: } catch (Exception ex) {
047: System.out.println("Invalid path: " + f);
048: }
049: }
050:
051: // Add all the other jars...
052: String irHome = it.businesslogic.ireport.gui.MainFrame
053: .getMainInstance().IREPORT_HOME_DIR;
054: if (irHome == null)
055: irHome = System.getProperty("ireport.home", ".");
056:
057: File f_classes = new File(irHome, "classes");
058: if (f_classes.exists()) {
059: try {
060: getClasspathEntries().add(f_classes.getCanonicalPath());
061: } catch (IOException ex) {
062: Logger.getLogger(FlashExporterExecuter.class.getName())
063: .log(Level.SEVERE, null, ex);
064: }
065: }
066:
067: File lib_dir = new File(irHome, "lib");
068: if (lib_dir.exists()) {
069: // Add all the jars here...
070: File[] jars = lib_dir.listFiles();
071: for (int i = 0; i < jars.length; ++i) {
072: if (jars[i].getName().toLowerCase().endsWith(".jar")
073: || jars[i].getName().toLowerCase().endsWith(
074: ".zip")) {
075:
076: try {
077: getClasspathEntries().add(
078: jars[i].getCanonicalPath());
079: } catch (Exception ex) {
080: System.out.println("Invalid path: " + jars[i]);
081: }
082: }
083: }
084: }
085:
086: setMainClass("it.businesslogic.ireport.export.FlashExporter");
087:
088: }
089:
090: public String getJrprintFile() {
091: return jrprintFile;
092: }
093:
094: public void setJrprintFile(String jrprintFile) {
095: this .jrprintFile = jrprintFile;
096: }
097:
098: public String getOutputFile() {
099: return outputFile;
100: }
101:
102: public void setOutputFile(String outputFile) {
103: this .outputFile = outputFile;
104: }
105:
106: @Override
107: public void execute() throws IOException {
108:
109: getParameters().clear();
110: getParameters().add(getJrprintFile());
111: getParameters().add(getOutputFile());
112:
113: super.execute();
114: }
115:
116: }
|