01: /*
02: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
07: *
08: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
09: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
10: * the license for the specific language governing your rights and limitations.
11: *
12: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
13: */
14: package org.pentaho.reportdesigner.crm.report.reportexporter.jfreereport;
15:
16: import org.jetbrains.annotations.NotNull;
17: import org.jfree.report.JFreeReport;
18: import org.jfree.report.JFreeReportBoot;
19: import org.jfree.report.TableDataFactory;
20: import org.jfree.report.modules.gui.base.PreviewFrame;
21: import org.pentaho.reportdesigner.crm.report.ReportDialogConstants;
22: import org.pentaho.reportdesigner.crm.report.model.Report;
23: import org.pentaho.reportdesigner.crm.report.reportexporter.ReportCreationException;
24:
25: import javax.swing.table.TableModel;
26:
27: /**
28: * User: Martin
29: * Date: 28.10.2005
30: * Time: 08:37:52
31: */
32: public class JFreeReportCreator {
33:
34: public JFreeReportCreator() {
35: }
36:
37: public void createReport(@NotNull
38: Report report, @NotNull
39: TableModel tableModel) throws ReportCreationException {
40: JFreeReportVisitor reportVisitor = new JFreeReportVisitor();
41: report.accept(null, reportVisitor);
42: JFreeReport jFreeReport = reportVisitor.getJFreeReport();
43:
44: if (jFreeReport.getDataFactory() instanceof NullDataFactory) {
45: jFreeReport.setDataFactory(new TableDataFactory(
46: ReportDialogConstants.DEFAULT_DATA_FACTORY,
47: tableModel));
48: }
49:
50: JFreeReportBoot.getInstance().start();
51:
52: PreviewFrame preview = new PreviewFrame(jFreeReport);
53: preview.pack();
54: preview.setVisible(true);
55: }
56:
57: }
|