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: AboutActionPlugin.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.preview.actions; 33: 34: import java.awt.Dialog; 35: import java.awt.Frame; 36: import java.awt.Window; 37: import java.util.Locale; 38: import javax.swing.Icon; 39: import javax.swing.KeyStroke; 40: 41: import org.jfree.report.JFreeReportInfo; 42: import org.jfree.report.modules.gui.swing.common.AbstractActionPlugin; 43: import org.jfree.report.modules.gui.swing.common.SwingGuiContext; 44: import org.jfree.report.modules.gui.swing.common.SwingUtil; 45: import org.jfree.report.modules.gui.swing.preview.PreviewPane; 46: import org.jfree.report.modules.gui.swing.preview.SwingPreviewModule; 47: import org.jfree.ui.RefineryUtilities; 48: import org.jfree.ui.about.AboutDialog; 49: import org.jfree.util.ResourceBundleSupport; 50: 51: /** 52: * Creation-Date: 16.11.2006, 16:34:55 53: * 54: * @author Thomas Morgner 55: */ 56: public class AboutActionPlugin extends AbstractActionPlugin 57: implements ControlActionPlugin 58: { 59: private ResourceBundleSupport resources; 60: private AboutDialog aboutFrame; 61: 62: public AboutActionPlugin() 63: { 64: } 65: 66: public boolean initialize(final SwingGuiContext context) 67: { 68: super.initialize(context); 69: resources = new ResourceBundleSupport(context.getLocale(), 70: SwingPreviewModule.BUNDLE_NAME); 71: return true; 72: } 73: 74: protected String getConfigurationPrefix() 75: { 76: return "org.jfree.report.modules.gui.swing.preview.about."; 77: } 78: 79: /** 80: * Returns the display name for the export action. 81: * 82: * @return The display name. 83: */ 84: public String getDisplayName() 85: { 86: return resources.getString("action.about.name"); 87: } 88: 89: /** 90: * Returns the short description for the export action. 91: * 92: * @return The short description. 93: */ 94: public String getShortDescription() 95: { 96: return resources.getString("action.about.description"); 97: } 98: 99: /** 100: * Returns the small icon for the export action. 101: * 102: * @return The icon. 103: */ 104: public Icon getSmallIcon() 105: { 106: final Locale locale = getContext().getLocale(); 107: return getIconTheme().getSmallIcon(locale, "action.about.small-icon"); 108: } 109: 110: /** 111: * Returns the large icon for the export action. 112: * 113: * @return The icon. 114: */ 115: public Icon getLargeIcon() 116: { 117: final Locale locale = getContext().getLocale(); 118: return getIconTheme().getLargeIcon(locale, "action.about.icon"); 119: } 120: 121: /** 122: * Returns the accelerator key for the export action. 123: * 124: * @return The accelerator key. 125: */ 126: public KeyStroke getAcceleratorKey() 127: { 128: return null; 129: } 130: 131: /** 132: * Returns the mnemonic key code. 133: * 134: * @return The code. 135: */ 136: public Integer getMnemonicKey() 137: { 138: return resources.getMnemonic("action.about.mnemonic"); 139: } 140: 141: public boolean configure(final PreviewPane reportPane) 142: { 143: if (aboutFrame == null) 144: { 145: final String title = getDisplayName(); 146: // look where we have been added ... 147: final Window w = SwingUtil.getWindowAncestor(reportPane); 148: if (w instanceof Frame) 149: { 150: aboutFrame = new AboutDialog 151: ((Frame) w, title, JFreeReportInfo.getInstance()); 152: } 153: else if (w instanceof Dialog) 154: { 155: aboutFrame = new AboutDialog 156: ((Dialog) w, title, JFreeReportInfo.getInstance()); 157: } 158: else 159: { 160: aboutFrame = new AboutDialog 161: (title, JFreeReportInfo.getInstance()); 162: } 163: aboutFrame.pack(); 164: RefineryUtilities.centerFrameOnScreen(aboutFrame); 165: } 166: 167: aboutFrame.setVisible(true); 168: aboutFrame.requestFocus(); 169: return true; 170: } 171: 172: }