| 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: PrintActionPlugin.java 10756 2009-12-02 15:58:24Z 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.printing; |
| 33 |
|
| 34 |
import java.util.Locale; |
| 35 |
import javax.swing.Icon; |
| 36 |
import javax.swing.KeyStroke; |
| 37 |
|
| 38 |
import org.jfree.report.flow.ReportJob; |
| 39 |
import org.jfree.report.modules.gui.swing.common.AbstractActionPlugin; |
| 40 |
import org.jfree.report.modules.gui.swing.common.ExportActionPlugin; |
| 41 |
import org.jfree.report.modules.gui.swing.common.SwingGuiContext; |
| 42 |
import org.pentaho.reporting.libraries.base.util.ResourceBundleSupport; |
| 43 |
|
| 44 |
/** |
| 45 |
* Creation-Date: 16.11.2006, 16:31:23 |
| 46 |
* |
| 47 |
* @author Thomas Morgner |
| 48 |
*/ |
| 49 |
public class PrintActionPlugin extends AbstractActionPlugin |
| 50 |
implements ExportActionPlugin |
| 51 |
{ |
| 52 |
private ResourceBundleSupport resources; |
| 53 |
|
| 54 |
public PrintActionPlugin() |
| 55 |
{ |
| 56 |
} |
| 57 |
|
| 58 |
protected String getConfigurationPrefix() |
| 59 |
{ |
| 60 |
return "org.jfree.report.modules.gui.swing.printing.print."; |
| 61 |
} |
| 62 |
|
| 63 |
public boolean initialize(SwingGuiContext context) |
| 64 |
{ |
| 65 |
super.initialize(context); |
| 66 |
resources = new ResourceBundleSupport(context.getLocale(), |
| 67 |
SwingPrintingModule.BUNDLE_NAME); |
| 68 |
return true; |
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* Returns the display name for the export action. |
| 73 |
* |
| 74 |
* @return The display name. |
| 75 |
*/ |
| 76 |
public String getDisplayName() |
| 77 |
{ |
| 78 |
return resources.getString("action.print.name"); |
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* Returns the short description for the export action. |
| 83 |
* |
| 84 |
* @return The short description. |
| 85 |
*/ |
| 86 |
public String getShortDescription() |
| 87 |
{ |
| 88 |
return resources.getString("action.print.description"); |
| 89 |
} |
| 90 |
|
| 91 |
/** |
| 92 |
* Returns the small icon for the export action. |
| 93 |
* |
| 94 |
* @return The icon. |
| 95 |
*/ |
| 96 |
public Icon getSmallIcon() |
| 97 |
{ |
| 98 |
final Locale locale = getContext().getLocale(); |
| 99 |
return getIconTheme().getSmallIcon(locale, "action.print.small-icon"); |
| 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.print.icon"); |
| 111 |
} |
| 112 |
|
| 113 |
/** |
| 114 |
* Returns the accelerator key for the export action. |
| 115 |
* |
| 116 |
* @return The accelerator key. |
| 117 |
*/ |
| 118 |
public KeyStroke getAcceleratorKey() |
| 119 |
{ |
| 120 |
return resources.getKeyStroke("action.print.accelerator"); |
| 121 |
} |
| 122 |
|
| 123 |
/** |
| 124 |
* Returns the mnemonic key code. |
| 125 |
* |
| 126 |
* @return The code. |
| 127 |
*/ |
| 128 |
public Integer getMnemonicKey() |
| 129 |
{ |
| 130 |
return resources.getMnemonic("action.print.mnemonic"); |
| 131 |
} |
| 132 |
|
| 133 |
/** |
| 134 |
* Exports a report. |
| 135 |
* |
| 136 |
* @param job the report. |
| 137 |
* @return A boolean. |
| 138 |
*/ |
| 139 |
public boolean performExport(final ReportJob job) |
| 140 |
{ |
| 141 |
final PrintTask task = new PrintTask(job); |
| 142 |
final Thread worker = new Thread(task); |
| 143 |
setStatusText("Started Job"); |
| 144 |
worker.start(); |
| 145 |
return true; |
| 146 |
} |
| 147 |
} |