01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: package de.uka.ilkd.key.util;
10:
11: /** An interface to some progress reporting mechanism. the {@link
12: * setMaximum(int)} method must always be called first to determine
13: * the number of steps at which the task is finished. After that,
14: * {@link #setProgress} will be called repeatedly to indicate how
15: * far one has got. The progress monitor is assumed to have an
16: * internal state in which it remembers the <code>maximum</code> value
17: * set by the {@link #setMaximum} method.
18: *
19: * <p>A more general alternative would be to have tasks accept
20: * progress listeners, but we probably don't want more than one
21: * progress bar anyway.
22: */
23:
24: public interface ProgressMonitor {
25:
26: /** Set the progress achieved so far. The parameter
27: * <code>progress</code> has to be >=0 and <= to the maximum
28: * value previously set with {@link ProgressMonitor#setMaximum}.
29: *
30: * @param progress number of steps completed */
31: void setProgress(int progress);
32:
33: /** Set the maximum number of steps for this task.
34: *
35: * @param maximum maximum number of steps, >=0.
36: */
37: void setMaximum(int maximum);
38:
39: /** A progress monitor that does nothing. This
40: * is a singleton, use {@link ProgressMonitor.Empty#getInstance} to get one. */
41: public static class Empty implements ProgressMonitor {
42:
43: private Empty() {
44: }
45:
46: private static Empty INSTANCE = new Empty();
47:
48: /** Return a do-nothing progress monitor. */
49: public static Empty getInstance() {
50: return INSTANCE;
51: }
52:
53: public void setProgress(int progress) {
54: }
55:
56: public void setMaximum(int maximum) {
57: }
58:
59: }
60: }
|