source: trunk/gli/src/org/greenstone/gatherer/shell/GBasicProgressMonitor.java@ 4293

Last change on this file since 4293 was 4293, checked in by jmt12, 21 years ago

Initial revision

  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1/**
2 *#########################################################################
3 *
4 * A component of the Gatherer application, part of the Greenstone digital
5 * library suite from the New Zealand Digital Library Project at the
6 * University of Waikato, New Zealand.
7 *
8 * <BR><BR>
9 *
10 * Author: John Thompson, Greenstone Digital Library, University of Waikato
11 *
12 * <BR><BR>
13 *
14 * Copyright (C) 1999 New Zealand Digital Library Project
15 *
16 * <BR><BR>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * <BR><BR>
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * <BR><BR>
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 *########################################################################
36 */
37
38
39
40
41
42
43package org.greenstone.gatherer.shell;
44/** Title: The Gatherer<br>
45 * Description: The Gatherer: a tool for gathering and enriching digital collections.<br>
46 * Copyright: Copyright (c) 2001<br>
47 * Company: The University of Waikato<br>
48 * Written: / /01<br>
49 * Revised: 12/05/02 - Commented<br>
50 * 29/05/02 - Moved into correct package<br>
51 * @author John Thompson, Greenstone Digital Libraries
52 * @version 2.1 */
53import java.awt.Component;
54import javax.swing.ImageIcon;
55import javax.swing.JLabel;
56import javax.swing.JProgressBar;
57import org.greenstone.gatherer.shell.GShellProgressMonitor;
58import org.greenstone.gatherer.util.Utility;
59/** This is the most basic implementation of <i>GShellProgressMonitor</i> in that it doesn't even attempt to parse the process messages. Instead it has one graphic which is displayed once the start() method is called, and another which appears after the stop().
60 */
61public class GBasicProgressMonitor
62 extends JProgressBar
63 implements GShellProgressMonitor {
64 /** Whether the process has been asked to stop. */
65 private boolean stop = false;
66 /** Constructor **/
67 public GBasicProgressMonitor() {
68 super();
69 //this.setIcon(ready);
70 }
71 /** Don't do anything if we are given a progress bar, we have our own.
72 * @param progress_bar A JProgressBar
73 */
74 public void addProgressBar(JProgressBar progress_bar) {
75 }
76 /** Determine the script exit value according to the progress monitor. This gets around a problem where several script failures actually result with a successful exit value.
77 * @return A <i>int</i> with a value of zero if and only if the script was successful.
78 */
79 public int exitValue() {
80 // Always return true as we don't know any better.
81 return 0;
82 }
83 /** As we are probably accessing this via an interface we need to gain
84 * access to the component itself.
85 */
86 public Component getProgress() {
87 return this;
88 }
89 /** Method to determine the state of the stop flag, which may be set by the visual component that created this monitor.
90 * @return A <strong>boolean</strong> indicating if the process has been asked to stop.
91 */
92 public boolean hasSignalledStop() {
93 return stop;
94 }
95 /** Inform the progress bar that it should programatically increment progress by one step. */
96 public void increment() {
97 // We can't do anything about this.
98 }
99 /** The parse method is how more complex progress bars figure out how far they have progressed. However we don't.
100 * @param line A String representing the latest line of output from
101 * the external process we are monitoring.
102 */
103 public void parse(String line) {
104 }
105 /** Since the creator of this process monitor is actually in the GUI, this class provides the simpliest way to send a cancel process message between the two.
106 * @param state The desired state of the stop flag as a <strong>boolean</strong>.
107 */
108 public void setStop(boolean state) {
109 stop = state;
110 }
111 /** This method tells this class that the job it is showing the progress
112 * for has begun.
113 */
114 public void start() {
115 //this.setIcon(busy);
116 setIndeterminate(true);
117 }
118 /** This method tells this class that the job it is showing the progress
119 * for has come to an end.
120 */
121 public void stop() {
122 //this.setIcon(ready);
123 setIndeterminate(false);
124 }
125}
Note: See TracBrowser for help on using the repository browser.