source: josm/trunk/src/org/openstreetmap/josm/gui/progress/ProgressMonitor.java@ 2322

Last change on this file since 2322 was 2322, checked in by Gubaer, 15 years ago

Added canceling of DownloadOsmTaskLists
Removed error remembering in the progress dialog

  • Property svn:mime-type set to text/plain
File size: 3.9 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.progress;
3
4/**
5 * Typical usecase is:
6 * <pre>
7 * monitor.beginTask()
8 * try {
9 * .. do some work
10 * monitor.worked()
11 * monitor.subTask()/monitor.intermediateTask()
12 * .. do some work
13 * monitor.worked()
14 * } finally {
15 * monitor.finishTask();
16 * }
17 * </pre>
18 *
19 * {@link #subTask(String)} and {@link #indeterminateSubTask(String)} has nothing to do with logical
20 * structure of the work, they just show task title to the user.
21 *
22 * If task consists of multiple tasks then {@link #createSubTaskMonitor(int, boolean)} may be used. It
23 * will create new ProgressMonitor, then can be passed to the subtask. Subtask doesn't know whether
24 * it runs standalono or as a part of other task. Progressbar will be updated so that total progress is
25 * shown, not just progress of the subtask
26 *
27 * All ProgressMonitor implemenenatations should be thread safe.
28 *
29 */
30public interface ProgressMonitor {
31
32 public interface CancelListener {
33 void operationCanceled();
34 }
35
36 public final int DEFAULT_TICKS = 100;
37
38 /**
39 * Can be used with {@link #worked(int)} and {@link #createSubTaskMonitor(int, boolean)} to
40 * express that the task should use all remaining ticks
41 */
42 public final int ALL_TICKS = -1;
43
44 void beginTask(String title);
45
46 /**
47 * Starts this progress monitor. Must be called excatly once
48 * @param title
49 * @param ticks
50 */
51 void beginTask(String title, int ticks);
52 /**
53 * Finish this progress monitor, close the dialog or inform the parent progress monitor
54 * that it can continue with other tasks. Must be called at least once (if called multiply times
55 * then futher calls are ignored)
56 */
57 void finishTask();
58 /**
59 * Can be used if method receive ProgressMonitor but it's not interested progress monitoring.
60 * Basically replaces {@link #beginTask(String)} and {@link #finishTask()}
61 *
62 * This method can be also used in finally section if method expects that some exception
63 * might prevent it from passing progressMonitor away. If {@link #beginTask(String)} was
64 * already called then this method does nothing.
65 */
66 void invalidate();
67
68 /**
69 *
70 * @param ticks Number of total work units
71 */
72 void setTicksCount(int ticks);
73 /**
74 *
75 * @param ticks Number of work units already done
76 */
77 void setTicks(int ticks);
78
79 int getTicks();
80 int getTicksCount();
81
82 /**
83 * Increase number of already done work units by ticks
84 * @param ticks
85 */
86 void worked(int ticks);
87
88 /**
89 * Subtask that will show progress runing back and forworth
90 * @param title Can be null, in that case task title is not changed
91 */
92 void indeterminateSubTask(String title);
93 /**
94 * Normal subtask
95 * @param title Can be null, in that case task title is not changed
96 */
97 void subTask(String title);
98 /**
99 * Shows additonal text
100 */
101 void setCustomText(String text);
102 /**
103 * Show extra text after normal task title. Hack for ProgressInputStream to show number of kB
104 * already downloaded
105 * @param text
106 */
107 void setExtraText(String text);
108
109 /**
110 * Creates subtasks monitor.
111 * @param ticks Number of work units that should be done when subtask finishes
112 * @param internal If true then subtask can't modify task title/custom text
113 * @return
114 */
115 ProgressMonitor createSubTaskMonitor(int ticks, boolean internal);
116
117 boolean isCancelled();
118 void cancel();
119 void addCancelListener(CancelListener listener);
120 void removeCancelListener(CancelListener listener);
121
122 void setSilent(boolean value);
123
124 /**
125 * Appends a message to the log managed by the progress monitor.
126 *
127 * @param message the log message. Ignored if null or white space only.
128 */
129 void appendLogMessage(String message);
130}
Note: See TracBrowser for help on using the repository browser.