]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.util/src/org/argeo/ArgeoMonitor.java
2 * Copyright (C) 2007-2012 Argeo GmbH
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * Simple monitor abstraction. Inspired by Eclipse IProgressMOnitor, but without
22 public interface ArgeoMonitor
{
24 * Constant indicating an unknown amount of work.
26 public final static int UNKNOWN
= -1;
29 * Notifies that the main task is beginning. This must only be called once
30 * on a given progress monitor instance.
33 * the name (or description) of the main task
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.
40 public void beginTask(String name
, int totalWork
);
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).
50 * Returns whether cancelation of current operation has been requested.
51 * Long-running operations should poll to see if cancelation has been
54 * @return <code>true</code> if cancellation has been requested, and
55 * <code>false</code> otherwise
56 * @see #setCanceled(boolean)
58 public boolean isCanceled();
61 * Sets the cancel state to the given value.
64 * <code>true</code> indicates that cancelation has been
65 * requested (but not necessarily acknowledged);
66 * <code>false</code> clears this flag
69 public void setCanceled(boolean value
);
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.
77 * the name (or description) of the main task
78 * @see #beginTask(java.lang.String, int)
80 public void setTaskName(String name
);
83 * Notifies that a subtask of the main task is beginning. Subtasks are
84 * optional; the main task might not have subtasks.
87 * the name (or description) of the subtask
89 public void subTask(String name
);
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.
97 * a non-negative number of work units just completed
99 public void worked(int work
);