]> git.argeo.org Git - lgpl/argeo-commons.git/blob - base/runtime/org.argeo.util/src/main/java/org/argeo/ArgeoMonitor.java
Fix issue when locale is not used
[lgpl/argeo-commons.git] / base / runtime / org.argeo.util / src / main / java / org / argeo / ArgeoMonitor.java
1 package org.argeo;
2
3 /**
4 * Simple monitor abstraction. Inspired by Eclipse IProgressMOnitor, but without
5 * dependency to it.
6 */
7 public interface ArgeoMonitor {
8 /**
9 * Constant indicating an unknown amount of work.
10 */
11 public final static int UNKNOWN = -1;
12
13 /**
14 * Notifies that the main task is beginning. This must only be called once
15 * on a given progress monitor instance.
16 *
17 * @param name
18 * the name (or description) of the main task
19 * @param totalWork
20 * the total number of work units into which the main task is
21 * been subdivided. If the value is <code>UNKNOWN</code> the
22 * implementation is free to indicate progress in a way which
23 * doesn't require the total number of work units in advance.
24 */
25 public void beginTask(String name, int totalWork);
26
27 /**
28 * Notifies that the work is done; that is, either the main task is
29 * completed or the user canceled it. This method may be called more than
30 * once (implementations should be prepared to handle this case).
31 */
32 public void done();
33
34 /**
35 * Returns whether cancelation of current operation has been requested.
36 * Long-running operations should poll to see if cancelation has been
37 * requested.
38 *
39 * @return <code>true</code> if cancellation has been requested, and
40 * <code>false</code> otherwise
41 * @see #setCanceled(boolean)
42 */
43 public boolean isCanceled();
44
45 /**
46 * Sets the cancel state to the given value.
47 *
48 * @param value
49 * <code>true</code> indicates that cancelation has been
50 * requested (but not necessarily acknowledged);
51 * <code>false</code> clears this flag
52 * @see #isCanceled()
53 */
54 public void setCanceled(boolean value);
55
56 /**
57 * Sets the task name to the given value. This method is used to restore the
58 * task label after a nested operation was executed. Normally there is no
59 * need for clients to call this method.
60 *
61 * @param name
62 * the name (or description) of the main task
63 * @see #beginTask(java.lang.String, int)
64 */
65 public void setTaskName(String name);
66
67 /**
68 * Notifies that a subtask of the main task is beginning. Subtasks are
69 * optional; the main task might not have subtasks.
70 *
71 * @param name
72 * the name (or description) of the subtask
73 */
74 public void subTask(String name);
75
76 /**
77 * Notifies that a given number of work unit of the main task has been
78 * completed. Note that this amount represents an installment, as opposed to
79 * a cumulative amount of work done to date.
80 *
81 * @param work
82 * a non-negative number of work units just completed
83 */
84 public void worked(int work);
85
86 }