]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.util/src/org/argeo/ArgeoMonitor.java
[maven-release-plugin] prepare release argeo-commons-2.1.12
[lgpl/argeo-commons.git] / org.argeo.util / src / org / argeo / ArgeoMonitor.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo;
17
18 /**
19 * Simple monitor abstraction. Inspired by Eclipse IProgressMOnitor, but without
20 * dependency to it.
21 */
22 public interface ArgeoMonitor {
23 /**
24 * Constant indicating an unknown amount of work.
25 */
26 public final static int UNKNOWN = -1;
27
28 /**
29 * Notifies that the main task is beginning. This must only be called once
30 * on a given progress monitor instance.
31 *
32 * @param name
33 * the name (or description) of the main task
34 * @param totalWork
35 * the total number of work units into which the main task is
36 * been subdivided. If the value is <code>UNKNOWN</code> the
37 * implementation is free to indicate progress in a way which
38 * doesn't require the total number of work units in advance.
39 */
40 public void beginTask(String name, int totalWork);
41
42 /**
43 * Notifies that the work is done; that is, either the main task is
44 * completed or the user canceled it. This method may be called more than
45 * once (implementations should be prepared to handle this case).
46 */
47 public void done();
48
49 /**
50 * Returns whether cancelation of current operation has been requested.
51 * Long-running operations should poll to see if cancelation has been
52 * requested.
53 *
54 * @return <code>true</code> if cancellation has been requested, and
55 * <code>false</code> otherwise
56 * @see #setCanceled(boolean)
57 */
58 public boolean isCanceled();
59
60 /**
61 * Sets the cancel state to the given value.
62 *
63 * @param value
64 * <code>true</code> indicates that cancelation has been
65 * requested (but not necessarily acknowledged);
66 * <code>false</code> clears this flag
67 * @see #isCanceled()
68 */
69 public void setCanceled(boolean value);
70
71 /**
72 * Sets the task name to the given value. This method is used to restore the
73 * task label after a nested operation was executed. Normally there is no
74 * need for clients to call this method.
75 *
76 * @param name
77 * the name (or description) of the main task
78 * @see #beginTask(java.lang.String, int)
79 */
80 public void setTaskName(String name);
81
82 /**
83 * Notifies that a subtask of the main task is beginning. Subtasks are
84 * optional; the main task might not have subtasks.
85 *
86 * @param name
87 * the name (or description) of the subtask
88 */
89 public void subTask(String name);
90
91 /**
92 * Notifies that a given number of work unit of the main task has been
93 * completed. Note that this amount represents an installment, as opposed to
94 * a cumulative amount of work done to date.
95 *
96 * @param work
97 * a non-negative number of work units just completed
98 */
99 public void worked(int work);
100
101 }