Source for org.jfree.report.modules.gui.swing.html.HtmlZipExportActionPlugin

   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: HtmlZipExportActionPlugin.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 HtmlZipExportActionPlugin extends AbstractExportActionPlugin
  49: {
  50:   private static final String EXPORT_DIALOG_KEY = "org.jfree.report.modules.gui.swing.html.zip.ExportDialog";
  51:   private ResourceBundleSupport resources;
  52: 
  53:   public HtmlZipExportActionPlugin()
  54:   {
  55:   }
  56: 
  57:   protected String getConfigurationPrefix()
  58:   {
  59:     return "org.jfree.report.modules.gui.swing.html.export.zip.";
  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.zip.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.zip.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:     return null;
  98:   }
  99: 
 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: }