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: HtmlFileExportActionPlugin.java,v 1.4 2007/06/10 15:54:22 taqua Exp $
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.html;
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: 30.11.2006, 12:19:00
045 *
046 * @author Thomas Morgner
047 */
048 public class HtmlFileExportActionPlugin extends AbstractExportActionPlugin
049 {
050 private ResourceBundleSupport resources;
051 private static final String EXPORT_DIALOG_KEY = "org.jfree.report.modules.gui.swing.html.file.ExportDialog";
052
053 public HtmlFileExportActionPlugin()
054 {
055 }
056
057 protected String getConfigurationPrefix()
058 {
059 return "org.jfree.report.modules.gui.swing.html.export.file.";
060 }
061
062 public boolean initialize(SwingGuiContext context)
063 {
064 super.initialize(context);
065 resources = new ResourceBundleSupport(context.getLocale(),
066 SwingHtmlModule.BUNDLE_NAME);
067 return true;
068 }
069
070 /**
071 * Returns the display name for the export action.
072 *
073 * @return The display name.
074 */
075 public String getDisplayName()
076 {
077 return resources.getString("action.export-to-html.file.name");
078 }
079
080 /**
081 * Returns the short description for the export action.
082 *
083 * @return The short description.
084 */
085 public String getShortDescription()
086 {
087 return resources.getString("action.export-to-html.file.description");
088 }
089
090 /**
091 * Returns the small icon for the export action.
092 *
093 * @return The icon.
094 */
095 public Icon getSmallIcon()
096 {
097 // final Locale locale = getContext().getLocale();
098 // return getIconTheme().getSmallIcon(locale, "action.export-to-html.small-icon");
099 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(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 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 }