001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: * See the GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License along with this
019: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: *
022: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023: * in the United States and other countries.]
024: *
025: * ------------
026: * ConfigurationReferenceGenerator.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.modules.misc.referencedoc;
030:
031: import java.io.IOException;
032: import java.net.URL;
033: import javax.swing.table.TableModel;
034: import javax.xml.parsers.ParserConfigurationException;
035:
036: import org.jfree.report.JFreeReport;
037: import org.jfree.report.JFreeReportBoot;
038: import org.jfree.report.TableDataFactory;
039: import org.jfree.report.modules.output.pageable.pdf.PdfReportUtil;
040: import org.jfree.report.modules.output.table.html.HtmlReportUtil;
041: import org.jfree.report.modules.parser.base.ReportGenerator;
042: import org.jfree.util.ObjectUtilities;
043: import org.xml.sax.SAXException;
044:
045: /**
046: * Creation-Date: 02.10.2007, 20:00:26
047: *
048: * @author Thomas Morgner
049: */
050: public class ConfigurationReferenceGenerator {
051: /**
052: * The report definition file.
053: */
054: private static final String REFERENCE_REPORT = "ConfigReferenceReport.xml"; //$NON-NLS-1$
055:
056: /**
057: * DefaultConstructor.
058: */
059: private ConfigurationReferenceGenerator() {
060: }
061:
062: /**
063: * Returns the DataSourceReferenceTableModel.
064: *
065: * @return the tablemodel for the reference documentation.
066: */
067: public static TableModel createData() throws IOException,
068: ParserConfigurationException, SAXException {
069: return new ConfigReferenceTableModel();
070: }
071:
072: /**
073: * The starting point for the application.
074: *
075: * @param args ignored.
076: */
077: public static void main(final String[] args) {
078: JFreeReportBoot.getInstance().start();
079: final ReportGenerator gen = ReportGenerator.getInstance();
080: final URL reportURL = ObjectUtilities.getResourceRelative(
081: REFERENCE_REPORT, DataSourceReferenceGenerator.class);
082: if (reportURL == null) {
083: System.err
084: .println("The report was not found in the classpath"); //$NON-NLS-1$
085: System.err.println("File: " + REFERENCE_REPORT); //$NON-NLS-1$
086: System.exit(1);
087: return;
088: }
089:
090: final JFreeReport report;
091: try {
092: report = gen.parseReport(reportURL);
093: } catch (Exception e) {
094: System.err.println("The report could not be parsed."); //$NON-NLS-1$
095: System.err.println("File: " + REFERENCE_REPORT); //$NON-NLS-1$
096: e.printStackTrace(System.err);
097: System.exit(1);
098: return;
099: }
100: try {
101: report.setDataFactory(new TableDataFactory(
102: "default", createData())); //$NON-NLS-1$
103: HtmlReportUtil.createStreamHTML(report, System
104: .getProperty("user.home") //$NON-NLS-1$
105: + "/configuration-reference.html"); //$NON-NLS-1$
106: PdfReportUtil.createPDF(report, System
107: .getProperty("user.home") //$NON-NLS-1$
108: + "/configuration-reference.pdf"); //$NON-NLS-1$
109: } catch (Exception e) {
110: System.err.println("The report processing failed."); //$NON-NLS-1$
111: System.err.println("File: " + REFERENCE_REPORT); //$NON-NLS-1$
112: e.printStackTrace(System.err);
113: System.exit(1);
114: }
115: }
116: }
|