001 /*
002 * This class is part of DocWhatsUp, a bug profiling and -reporting lib.
003 *
004 * Copyright (C)
005 *
006 * This library is free software; you can redistribute it and/or modify it
007 * under the terms of the GNU General Public License as published by the
008 * Free Software Foundation; either version 2 of the License, or (at your
009 * option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful, but
012 * WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
014 * Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License along
017 * with this program; if not, write to the Free Software Foundation, Inc.,
018 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019 *
020 * EXTENSION:
021 * Linking DocWhatsUp statically or dynamically with other modules is making a
022 * combined work based on DocWhatsUp. Thus, the terms and conditions of the
023 * GNU General Public License cover the whole combination.
024 *
025 * As a special exception, the copyright holder of DocWhatsUp give you
026 * permission to link DocWhatsUp with independent modules that communicate with
027 * DocWhatsUp solely through the DocWhatsUp.java interface, regardless of the
028 * license terms of these independent modules, and to copy and distribute the
029 * resulting combined work under terms of your choice, provided that
030 * every copy of the combined work is accompanied by a complete copy of
031 * the source code of DocWhatsUp (the version of DocWhatsUp used to produce the
032 * combined work), being distributed under the terms of the GNU General
033 * Public License plus this exception. An independent module is a module
034 * which is not derived from or based on DocWhatsUp.
035
036 * Note that people who make modified versions of DocWhatsUp are not obligated
037 * to grant this special exception for their modified versions; it is
038 * their choice whether to do so. The GNU General Public License gives
039 * permission to release a modified version without this exception; this
040 * exception also makes it possible to release a modified version which
041 * carries forward this exception.
042 *
043 * Author: Philipp Bartsch; codeshaker@gmx.net
044 */
045
046 package org.shaker.dwu;
047
048 import java.awt.BorderLayout;
049
050 import javax.swing.JPanel;
051 import javax.swing.JProgressBar;
052 import javax.swing.JWindow;
053
054 /**
055 * This class provides a progress window, that iterates on every succeful
056 * submission during a mail transport session.
057 *
058 * @author <A HREF="mailto:codeshaker@gmx.net">
059 * Philipp Bartsch (codeshaker@gmx.net)</A>,
060 * <A HREF="../../../../gpl.txt">GPL License</A>
061 */
062 final class ProgressKit
063 extends JWindow {
064
065 /**The progressbar itself*/
066 private final static JProgressBar bar = new JProgressBar (JProgressBar
067 .HORIZONTAL);
068 /**
069 * Constructs a JWindow and the embedded progressbar.
070 */
071 ProgressKit () {
072 super();
073 bar.setStringPainted(true);
074 bar.setBorderPainted(false);
075 bar.setFont(GUIFactory.ARIAL_10P);
076 ((JPanel)getContentPane()).setBorder(GUIFactory.BLACKLN);
077 getContentPane().add(bar,
078 BorderLayout.SOUTH);
079 ToolBox.setSmartSize(this,
080 200,
081 20);
082 }
083
084 /**
085 * Iterates the progressbar.
086 */
087 void increase() {
088 bar.setValue(bar.getValue()+1);
089 bar.repaint();
090 }
091
092 /**
093 * Resets the progressbar (to 0).
094 */
095 void reset() {
096 bar.setValue(0);
097 }
098
099 /**
100 * Sets the progressbar maximum. The maximum is equal to the number of submittable bug reports.
101 *
102 * @param newMaximum the maximum
103 */
104 void setProgressMax(final int newMaximum) {
105 bar.setMaximum(newMaximum);
106 }
107
108 /**
109 * Sets the progressbar description. The description is displayed within the bar.
110 *
111 * @param message the message
112 */
113 void setLabel(final String message) {
114 bar.setString(message);
115 }
116 }
|