Frames | No Frames |
1: /** 2: * ======================================== 3: * JFreeReport : a free Java report library 4: * ======================================== 5: * 6: * Project Info: http://reporting.pentaho.org/ 7: * 8: * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. 9: * 10: * This library is free software; you can redistribute it and/or modify it under the terms 11: * of the GNU Lesser General Public License as published by the Free Software Foundation; 12: * either version 2.1 of the License, or (at your option) any later version. 13: * 14: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 15: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16: * See the GNU Lesser General Public License for more details. 17: * 18: * You should have received a copy of the GNU Lesser General Public License along with this 19: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20: * Boston, MA 02111-1307, USA. 21: * 22: * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 23: * in the United States and other countries.] 24: * 25: * ------------ 26: * $Id: HtmlFileExportActionPlugin.java 3525 2007-10-16 11:43:48Z tmorgner $ 27: * ------------ 28: * (C) Copyright 2000-2005, by Object Refinery Limited. 29: * (C) Copyright 2005-2007, by Pentaho Corporation. 30: */ 31: 32: package org.jfree.report.modules.gui.swing.html; 33: 34: import javax.swing.Icon; 35: import javax.swing.KeyStroke; 36: 37: import org.jfree.report.ReportConfigurationException; 38: import org.jfree.report.flow.ReportJob; 39: import org.jfree.report.modules.gui.swing.common.AbstractExportActionPlugin; 40: import org.jfree.report.modules.gui.swing.common.SwingGuiContext; 41: import org.jfree.util.ResourceBundleSupport; 42: 43: /** 44: * Creation-Date: 30.11.2006, 12:19:00 45: * 46: * @author Thomas Morgner 47: */ 48: public class HtmlFileExportActionPlugin extends AbstractExportActionPlugin 49: { 50: private ResourceBundleSupport resources; 51: private static final String EXPORT_DIALOG_KEY = "org.jfree.report.modules.gui.swing.html.file.ExportDialog"; 52: 53: public HtmlFileExportActionPlugin() 54: { 55: } 56: 57: protected String getConfigurationPrefix() 58: { 59: return "org.jfree.report.modules.gui.swing.html.export.file."; 60: } 61: 62: public boolean initialize(final SwingGuiContext context) 63: { 64: super.initialize(context); 65: resources = new ResourceBundleSupport(context.getLocale(), 66: SwingHtmlModule.BUNDLE_NAME); 67: return true; 68: } 69: 70: /** 71: * Returns the display name for the export action. 72: * 73: * @return The display name. 74: */ 75: public String getDisplayName() 76: { 77: return resources.getString("action.export-to-html.file.name"); 78: } 79: 80: /** 81: * Returns the short description for the export action. 82: * 83: * @return The short description. 84: */ 85: public String getShortDescription() 86: { 87: return resources.getString("action.export-to-html.file.description"); 88: } 89: 90: /** 91: * Returns the small icon for the export action. 92: * 93: * @return The icon. 94: */ 95: public Icon getSmallIcon() 96: { 97: // final Locale locale = getContext().getLocale(); 98: // return getIconTheme().getSmallIcon(locale, "action.export-to-html.small-icon"); 99: return null; 100: } 101: 102: /** 103: * Returns the large icon for the export action. 104: * 105: * @return The icon. 106: */ 107: public Icon getLargeIcon() 108: { 109: // final Locale locale = getContext().getLocale(); 110: // return getIconTheme().getLargeIcon(locale, "action.export-to-html.icon"); 111: return null; 112: } 113: 114: /** 115: * Returns the accelerator key for the export action. 116: * 117: * @return The accelerator key. 118: */ 119: public KeyStroke getAcceleratorKey() 120: { 121: return resources.getOptionalKeyStroke("action.export-to-html.file.accelerator"); 122: } 123: 124: /** 125: * Returns the mnemonic key code. 126: * 127: * @return The code. 128: */ 129: public Integer getMnemonicKey() 130: { 131: return resources.getOptionalMnemonic("action.export-to-html.file.mnemonic"); 132: } 133: 134: /** 135: * Exports a report. 136: * 137: * @param report the report. 138: * @return A boolean. 139: */ 140: public boolean performExport(final ReportJob job) 141: { 142: if (performShowExportDialog(job, EXPORT_DIALOG_KEY) == false) 143: { 144: return false; 145: } 146: 147: try 148: { 149: final HtmlFileExportTask task = new HtmlFileExportTask(job); 150: final Thread worker = new Thread(task); 151: setStatusText("Started Job"); 152: worker.start(); 153: return true; 154: } 155: catch (ReportConfigurationException e) 156: { 157: setStatusText("Failed to configure the export task."); 158: return false; 159: } 160: } 161: }