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

Last change on this file since 8353 was 8243, checked in by mdewsnip, 20 years ago

Removed all occurrences of classes explicitly importing other classes in the same package.

  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 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 */
37package org.greenstone.gatherer.shell;
38
39
40import java.awt.Component;
41import java.util.ArrayList;
42import javax.swing.JProgressBar;
43
44/** 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().
45 */
46public class GBasicProgressMonitor
47 extends JProgressBar
48 implements GShellProgressMonitor {
49 /** Whether the process has been asked to stop. */
50 private boolean stop = false;
51 /** Constructor **/
52 public GBasicProgressMonitor() {
53 super();
54 }
55 /** Don't do anything if we are given a progress bar, we have our own.
56 * @param progress_bar A JProgressBar
57 */
58 public void addProgressBar(JProgressBar progress_bar) {
59 }
60 /** 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.
61 * @return A <i>int</i> with a value of zero if and only if the script was successful.
62 */
63 public int exitValue() {
64 // Always return true as we don't know any better.
65 return 0;
66 }
67 /** As we are probably accessing this via an interface we need to gain
68 * access to the component itself.
69 */
70 public Component getProgress() {
71 return this;
72 }
73
74 public JProgressBar getSharedProgress() {
75 return null;
76 }
77
78 public void messageOnProgressBar(String message)
79 {
80 if ((message!=null) & (message!="")) {
81 setString(message);
82 }
83 else {
84 setString(null);
85 }
86 }
87
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 queue a queue which at the moment should contain a single GShellEvent
101 */
102 public void process(ArrayList queue) {
103 }
104
105 public void reset() {};
106
107 public void saving() {
108 }
109
110 /** 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.
111 * @param state The desired state of the stop flag as a <strong>boolean</strong>.
112 */
113 public void setStop(boolean state) {
114 stop = state;
115 }
116 /** This method tells this class that the job it is showing the progress
117 * for has begun.
118 */
119 public void start() {
120 setIndeterminate(true);
121 }
122 /** This method tells this class that the job it is showing the progress
123 * for has come to an end.
124 */
125 public void stop() {
126 setIndeterminate(false);
127 }
128}
Note: See TracBrowser for help on using the repository browser.