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: * DefaultReportController.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.modules.gui.base;
030:
031: import java.awt.BorderLayout;
032: import java.beans.PropertyChangeEvent;
033: import java.beans.PropertyChangeListener;
034: import javax.swing.JComponent;
035: import javax.swing.JMenu;
036: import javax.swing.JPanel;
037:
038: public class DefaultReportController extends JPanel implements
039: ReportController {
040: private class EnabledUpdateHandler implements
041: PropertyChangeListener {
042: protected EnabledUpdateHandler() {
043: }
044:
045: /**
046: * This method gets called when a bound property is changed.
047: *
048: * @param evt A PropertyChangeEvent object describing the event source and the property
049: * that has changed.
050: */
051:
052: public void propertyChange(final PropertyChangeEvent evt) {
053: if (PreviewPane.PAGINATING_PROPERTY.equals(evt
054: .getPropertyName()) == false) {
055: return;
056: }
057: DefaultReportController.this .setEnabled(Boolean.FALSE
058: .equals(evt.getNewValue()));
059: }
060: }
061:
062: private static final JMenu[] EMPTY_MENU = new JMenu[0];
063: private EnabledUpdateHandler enabledUpdateHandler;
064:
065: /**
066: * Creates a new <code>JPanel</code> with a double buffer and a flow layout.
067: */
068: public DefaultReportController() {
069: enabledUpdateHandler = new EnabledUpdateHandler();
070: }
071:
072: /**
073: * Returns the graphical representation of the controler. This component will be added
074: * between the menu bar and the toolbar.
075: * <p/>
076: * Changes to this property are not detected automaticly, you have to call
077: * "refreshControler" whenever you want to display a completly new control panel.
078: *
079: * @return the controler component.
080: */
081: public JComponent getControlPanel() {
082: return this ;
083: }
084:
085: /**
086: * The default implementation has no menus.
087: *
088: * @return an empty array.
089: */
090: public JMenu[] getMenus() {
091: return EMPTY_MENU;
092: }
093:
094: /**
095: * Returns the location for the report controler, one of BorderLayout.NORTH,
096: * BorderLayout.SOUTH, BorderLayout.EAST or BorderLayout.WEST.
097: *
098: * @return the location;
099: */
100: public String getControllerLocation() {
101: return BorderLayout.NORTH;
102: }
103:
104: /**
105: * Defines, whether the controler component is placed between the report pane and the
106: * toolbar.
107: *
108: * @return true, if this is a inne component.
109: */
110: public boolean isInnerComponent() {
111: return false;
112: }
113:
114: public void initialize(final PreviewPane pane) {
115: pane.addPropertyChangeListener(PreviewPane.PAGINATING_PROPERTY,
116: enabledUpdateHandler);
117: setEnabled(pane.isPaginating() == false);
118: }
119: }
|