001 /** 002 * ======================================== 003 * JFreeReport : a free Java report library 004 * ======================================== 005 * 006 * Project Info: http://reporting.pentaho.org/ 007 * 008 * (C) Copyright 2000-2007, by Object Refinery Limited, 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 * $Id: PdfExportActionPlugin.java 3525 2007-10-16 11:43:48Z tmorgner $ 027 * ------------ 028 * (C) Copyright 2000-2005, by Object Refinery Limited. 029 * (C) Copyright 2005-2007, by Pentaho Corporation. 030 */ 031 032 package org.jfree.report.modules.gui.swing.pdf; 033 034 import javax.swing.Icon; 035 import javax.swing.KeyStroke; 036 037 import org.jfree.report.ReportConfigurationException; 038 import org.jfree.report.flow.ReportJob; 039 import org.jfree.report.modules.gui.swing.common.AbstractExportActionPlugin; 040 import org.jfree.report.modules.gui.swing.common.SwingGuiContext; 041 import org.jfree.util.ResourceBundleSupport; 042 043 /** 044 * Creation-Date: 02.12.2006, 15:27:01 045 * 046 * @author Thomas Morgner 047 */ 048 public class PdfExportActionPlugin extends AbstractExportActionPlugin 049 { 050 private ResourceBundleSupport resources; 051 private static final String EXPORT_DIALOG_KEY = 052 "org.jfree.report.modules.gui.swing.pdf.ExportDialog"; 053 054 public PdfExportActionPlugin() 055 { 056 } 057 058 protected String getConfigurationPrefix() 059 { 060 return "org.jfree.report.modules.gui.swing.pdf.export."; 061 } 062 063 public boolean initialize(final SwingGuiContext context) 064 { 065 super.initialize(context); 066 resources = new ResourceBundleSupport(context.getLocale(), 067 SwingPdfModule.BUNDLE_NAME); 068 return true; 069 } 070 071 /** 072 * Returns the display name for the export action. 073 * 074 * @return The display name. 075 */ 076 public String getDisplayName() 077 { 078 return resources.getString("action.export-to-pdf.name"); 079 } 080 081 /** 082 * Returns the short description for the export action. 083 * 084 * @return The short description. 085 */ 086 public String getShortDescription() 087 { 088 return resources.getString("action.export-to-pdf.description"); 089 } 090 091 /** 092 * Returns the small icon for the export action. 093 * 094 * @return The icon. 095 */ 096 public Icon getSmallIcon() 097 { 098 return null; 099 } 100 101 /** 102 * Returns the large icon for the export action. 103 * 104 * @return The icon. 105 */ 106 public Icon getLargeIcon() 107 { 108 return null; 109 } 110 111 /** 112 * Returns the accelerator key for the export action. 113 * 114 * @return The accelerator key. 115 */ 116 public KeyStroke getAcceleratorKey() 117 { 118 return resources.getOptionalKeyStroke("action.export-to-pdf.accelerator"); 119 } 120 121 /** 122 * Returns the mnemonic key code. 123 * 124 * @return The code. 125 */ 126 public Integer getMnemonicKey() 127 { 128 return resources.getOptionalMnemonic("action.export-to-pdf.mnemonic"); 129 } 130 131 /** 132 * Exports a report. 133 * 134 * @param report the report. 135 * @return A boolean. 136 */ 137 public boolean performExport(final ReportJob job) 138 { 139 if (performShowExportDialog(job, EXPORT_DIALOG_KEY) == false) 140 { 141 return false; 142 } 143 144 try 145 { 146 final PdfExportTask task = new PdfExportTask(job); 147 final Thread worker = new Thread(task); 148 setStatusText("Started Job"); 149 worker.start(); 150 return true; 151 } 152 catch (ReportConfigurationException e) 153 { 154 setStatusText("Failed to configure the export task."); 155 return false; 156 } 157 } 158 }