1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2012 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.history.util;
\r
15 * A custom progress monitor interface for long operations (not using
\r
16 * Eclipse IProgressMonitor to avoid dependency on Eclipse runtime plug-ins).
\r
18 * @author Tuukka Lehtonen
\r
20 public interface ProgressMonitor {
\r
23 * Notifies that the main task is beginning. This must only be called once
\r
24 * on a given progress monitor instance.
\r
26 * @param name the name (or description) of the main task
\r
27 * @param totalWork the total number of work units into which
\r
28 * the main task is been subdivided. If the value is <code>UNKNOWN</code>
\r
29 * the implementation is free to indicate progress in a way which
\r
30 * doesn't require the total number of work units in advance.
\r
32 public void beginTask(String name, int totalWork);
\r
35 * Returns whether cancelation of current operation has been requested.
\r
36 * Long-running operations should poll to see if cancelation
\r
37 * has been requested.
\r
39 * @return <code>true</code> if cancellation has been requested,
\r
40 * and <code>false</code> otherwise
\r
42 public boolean isCanceled();
\r
45 * Sets the task name to the given value. This method is used to
\r
46 * restore the task label after a nested operation was executed.
\r
47 * Normally there is no need for clients to call this method.
\r
49 * @param name the name (or description) of the main task
\r
50 * @see #beginTask(java.lang.String, int)
\r
52 public void setTaskName(String name);
\r
55 * Notifies that a subtask of the main task is beginning.
\r
56 * Subtasks are optional; the main task might not have subtasks.
\r
58 * @param name the name (or description) of the subtask
\r
60 public void subTask(String name);
\r
63 * Notifies that a given number of work unit of the main task
\r
64 * has been completed. Note that this amount represents an
\r
65 * installment, as opposed to a cumulative amount of work done
\r
68 * @param work a non-negative number of work units just completed
\r
70 public void worked(int work);
\r
73 * @author Tuukka Lehtonen
\r
75 public static class Stub implements ProgressMonitor {
\r
77 public void beginTask(String name, int totalWork) {
\r
80 public boolean isCanceled() {
\r
84 public void setTaskName(String name) {
\r
87 public void subTask(String name) {
\r
90 public void worked(int work) {
\r