Add a progress monitor inteface and some simple implementions of it
[egit/charleso.git] / org.spearce.jgit / src / org / spearce / jgit / lib / AbstractProgressMonitor.java
blob5bb164746dc1fd6a452624175395e6d5884293f2
1 /*
2 * Copyright (C) 2007 Robin Rosenberg
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License, version 2, as published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
17 package org.spearce.jgit.lib;
19 /**
20 * Base class for progress monitors. This class tracks progress
21 * but does not report it anywhere;
23 public abstract class AbstractProgressMonitor implements ProgressMonitor {
25 private int total;
26 private int worked;
27 private String task;
28 private boolean done;
30 public void done() {
31 done = true;
32 worked = total;
33 report();
36 public boolean isDone() {
37 return done;
40 public boolean isCancelled() {
41 return false;
44 public void setCancelled(final boolean cancelled) {
45 // empty
48 public void setTask(final String task) {
49 this.task = task;
50 report();
53 public void worked(final int amount) {
54 worked += amount;
55 report();
58 public void beginTask(final String task, final int total) {
59 this.task = task;
60 this.total = total;
61 report();
64 /**
65 * Report progress
67 abstract protected void report();
69 public String getTask() {
70 return task;
73 public int getWorked() {
74 return worked;
77 public void setTotalWork(final int work) {
78 total = work;
81 public int getTotal() {
82 return total;