001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, 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: * AboutActionPlugin.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.modules.gui.base.actions;
030:
031: import java.awt.Dialog;
032: import java.awt.Frame;
033: import java.awt.Window;
034: import java.util.Locale;
035: import javax.swing.Icon;
036: import javax.swing.KeyStroke;
037:
038: import org.jfree.report.JFreeReportInfo;
039: import org.jfree.report.modules.gui.base.PreviewPane;
040: import org.jfree.report.modules.gui.base.SwingPreviewModule;
041: import org.jfree.report.modules.gui.commonswing.AbstractActionPlugin;
042: import org.jfree.report.modules.gui.commonswing.SwingGuiContext;
043: import org.jfree.report.modules.gui.commonswing.SwingUtil;
044: import org.jfree.ui.RefineryUtilities;
045: import org.jfree.ui.about.AboutDialog;
046: import org.jfree.util.ResourceBundleSupport;
047:
048: /**
049: * Creation-Date: 16.11.2006, 16:34:55
050: *
051: * @author Thomas Morgner
052: */
053: public class AboutActionPlugin extends AbstractActionPlugin implements
054: ControlActionPlugin {
055: private ResourceBundleSupport resources;
056: private AboutDialog aboutFrame;
057:
058: public AboutActionPlugin() {
059: }
060:
061: public boolean initialize(final SwingGuiContext context) {
062: super .initialize(context);
063: resources = new ResourceBundleSupport(context.getLocale(),
064: SwingPreviewModule.BUNDLE_NAME);
065: return true;
066: }
067:
068: protected String getConfigurationPrefix() {
069: return "org.jfree.report.modules.gui.base.about."; //$NON-NLS-1$
070: }
071:
072: /**
073: * Returns the display name for the export action.
074: *
075: * @return The display name.
076: */
077: public String getDisplayName() {
078: return resources.getString("action.about.name"); //$NON-NLS-1$
079: }
080:
081: /**
082: * Returns the short description for the export action.
083: *
084: * @return The short description.
085: */
086: public String getShortDescription() {
087: return resources.getString("action.about.description"); //$NON-NLS-1$
088: }
089:
090: /**
091: * Returns the small icon for the export action.
092: *
093: * @return The icon.
094: */
095: public Icon getSmallIcon() {
096: final Locale locale = getContext().getLocale();
097: return getIconTheme().getSmallIcon(locale,
098: "action.about.small-icon"); //$NON-NLS-1$
099: }
100:
101: /**
102: * Returns the large icon for the export action.
103: *
104: * @return The icon.
105: */
106: public Icon getLargeIcon() {
107: final Locale locale = getContext().getLocale();
108: return getIconTheme().getLargeIcon(locale, "action.about.icon"); //$NON-NLS-1$
109: }
110:
111: /**
112: * Returns the accelerator key for the export action.
113: *
114: * @return The accelerator key.
115: */
116: public KeyStroke getAcceleratorKey() {
117: return null;
118: }
119:
120: /**
121: * Returns the mnemonic key code.
122: *
123: * @return The code.
124: */
125: public Integer getMnemonicKey() {
126: return resources.getMnemonic("action.about.mnemonic"); //$NON-NLS-1$
127: }
128:
129: public boolean configure(final PreviewPane reportPane) {
130: if (aboutFrame == null) {
131: final String title = getDisplayName();
132: // look where we have been added ...
133: final Window w = SwingUtil.getWindowAncestor(reportPane);
134: if (w instanceof Frame) {
135: aboutFrame = new AboutDialog((Frame) w, title,
136: JFreeReportInfo.getInstance());
137: } else if (w instanceof Dialog) {
138: aboutFrame = new AboutDialog((Dialog) w, title,
139: JFreeReportInfo.getInstance());
140: } else {
141: aboutFrame = new AboutDialog(title, JFreeReportInfo
142: .getInstance());
143: }
144: aboutFrame.pack();
145: RefineryUtilities.centerFrameOnScreen(aboutFrame);
146: }
147:
148: aboutFrame.setVisible(true);
149: aboutFrame.requestFocus();
150: return true;
151: }
152:
153: }
|