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: ReportProgressBar.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.common; 33: 34: import java.text.MessageFormat; 35: import java.util.Locale; 36: import java.util.ResourceBundle; 37: import javax.swing.JProgressBar; 38: import javax.swing.SwingUtilities; 39: 40: import org.jfree.report.event.ReportProgressEvent; 41: import org.jfree.report.event.ReportProgressListener; 42: import org.jfree.report.modules.gui.common.GuiCommonModule; 43: 44: public class ReportProgressBar extends JProgressBar 45: { 46: private class ScreenUpdateRunnable implements Runnable 47: { 48: private int page; 49: private int activity; 50: private int currentRow; 51: 52: private ScreenUpdateRunnable (final int activity, 53: final int currentRow, 54: final int page) 55: { 56: this.activity = activity; 57: this.currentRow = currentRow; 58: this.page = page; 59: } 60: 61: public void run () 62: { 63: //updatePassMessage(activity, currentRow, page); 64: setValue(currentRow); 65: } 66: } 67: 68: private class ReportProgressHandler implements ReportProgressListener 69: { 70: private ReportProgressHandler() 71: { 72: } 73: 74: public void reportProcessingStarted(final ReportProgressEvent event) 75: { 76: postUpdate(event); 77: } 78: 79: public void reportProcessingUpdate(final ReportProgressEvent event) 80: { 81: postUpdate(event); 82: } 83: 84: public void reportProcessingFinished(final ReportProgressEvent event) 85: { 86: postUpdate(event); 87: } 88: 89: private void postUpdate (final ReportProgressEvent event) 90: { 91: final ScreenUpdateRunnable runnable = new ScreenUpdateRunnable 92: (event.getActivity(), event.getRow(), event.getPage()); 93: if (SwingUtilities.isEventDispatchThread()) 94: { 95: runnable.run(); 96: } 97: else 98: { 99: SwingUtilities.invokeLater(runnable); 100: } 101: } 102: } 103: 104: /** 105: * The reuseable message format for the page label. 106: */ 107: private MessageFormat pageMessageFormatter; 108: /** 109: * The reuseable message format for the pass label. 110: */ 111: private MessageFormat currentRowFormatter; 112: /** 113: * a text which describes the layouting process. 114: */ 115: private String layoutText; 116: /** 117: * a text that describes the export phase of the report processing. 118: */ 119: private String outputText; 120: 121: /** 122: * Localised resources. 123: */ 124: private ResourceBundle resources; 125: 126: /** 127: * Creates a horizontal progress bar that displays a border but no progress string. The 128: * initial and minimum values are 0, and the maximum is 100. 129: * 130: * @see #setOrientation 131: * @see #setBorderPainted 132: * @see #setStringPainted 133: * @see #setString 134: * @see #setIndeterminate 135: */ 136: public ReportProgressBar (final Locale locale) 137: { 138: setLocale(locale); 139: initialize(); 140: } 141: 142: /** 143: * Creates a horizontal progress bar that displays a border but no progress 144: * string. The initial and minimum values are 0, and the maximum is 100. 145: * 146: * @see #setOrientation 147: * @see #setBorderPainted 148: * @see #setStringPainted 149: * @see #setString 150: * @see #setIndeterminate 151: */ 152: public ReportProgressBar() 153: { 154: setLocale(Locale.getDefault()); 155: initialize(); 156: } 157: 158: private void initialize() 159: { 160: resources = ResourceBundle.getBundle(GuiCommonModule.RESOURCE_BASE_NAME); 161: pageMessageFormatter = new MessageFormat 162: (resources.getString("progress-dialog.page-label")); 163: currentRowFormatter = new MessageFormat 164: (resources.getString("progress-dialog.current-row-label")); 165: } 166: }