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: HtmlZipExportActionPlugin.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.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 HtmlZipExportActionPlugin extends AbstractExportActionPlugin
049    {
050      private static final String EXPORT_DIALOG_KEY = "org.jfree.report.modules.gui.swing.html.zip.ExportDialog";
051      private ResourceBundleSupport resources;
052    
053      public HtmlZipExportActionPlugin()
054      {
055      }
056    
057      protected String getConfigurationPrefix()
058      {
059        return "org.jfree.report.modules.gui.swing.html.export.zip.";
060      }
061    
062      public boolean initialize(final 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.zip.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.zip.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        return null;
098      }
099    
100      /**
101       * Returns the large icon for the export action.
102       *
103       * @return The icon.
104       */
105      public Icon getLargeIcon()
106      {
107        return null;
108      }
109    
110      /**
111       * Returns the accelerator key for the export action.
112       *
113       * @return The accelerator key.
114       */
115      public KeyStroke getAcceleratorKey()
116      {
117        return resources.getOptionalKeyStroke("action.export-to-html.zip.accelerator");
118      }
119    
120      /**
121       * Returns the mnemonic key code.
122       *
123       * @return The code.
124       */
125      public Integer getMnemonicKey()
126      {
127        return resources.getOptionalMnemonic("action.export-to-html.zip.mnemonic");
128      }
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 HtmlZipExportTask task = new HtmlZipExportTask(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    
159    }