View Javadoc
1   /*
2    * Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
3    * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
4    *
5    * This program and the accompanying materials are made available under the
6    * terms of the Eclipse Distribution License v. 1.0 which is available at
7    * https://www.eclipse.org/org/documents/edl-v10.php.
8    *
9    * SPDX-License-Identifier: BSD-3-Clause
10   */
11  
12  package org.eclipse.jgit.lib;
13  
14  /**
15   * A progress reporting interface.
16   */
17  public interface ProgressMonitor {
18  	/** Constant indicating the total work units cannot be predicted. */
19  	int UNKNOWN = 0;
20  
21  	/**
22  	 * Advise the monitor of the total number of subtasks.
23  	 * <p>
24  	 * This should be invoked at most once per progress monitor interface.
25  	 *
26  	 * @param totalTasks
27  	 *            the total number of tasks the caller will need to complete
28  	 *            their processing.
29  	 */
30  	void start(int totalTasks);
31  
32  	/**
33  	 * Begin processing a single task.
34  	 *
35  	 * @param title
36  	 *            title to describe the task. Callers should publish these as
37  	 *            stable string constants that implementations could match
38  	 *            against for translation support.
39  	 * @param totalWork
40  	 *            total number of work units the application will perform;
41  	 *            {@link #UNKNOWN} if it cannot be predicted in advance.
42  	 */
43  	void beginTask(String title, int totalWork);
44  
45  	/**
46  	 * Denote that some work units have been completed.
47  	 * <p>
48  	 * This is an incremental update; if invoked once per work unit the correct
49  	 * value for our argument is <code>1</code>, to indicate a single unit of
50  	 * work has been finished by the caller.
51  	 *
52  	 * @param completed
53  	 *            the number of work units completed since the last call.
54  	 */
55  	void update(int completed);
56  
57  	/**
58  	 * Finish the current task, so the next can begin.
59  	 */
60  	void endTask();
61  
62  	/**
63  	 * Check for user task cancellation.
64  	 *
65  	 * @return true if the user asked the process to stop working.
66  	 */
67  	boolean isCancelled();
68  }