KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > runtime > NullProgressMonitor


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.core.runtime;
12
13 /**
14  * A default progress monitor implementation suitable for
15  * subclassing.
16  * <p>
17  * This implementation supports cancelation. The default
18  * implementations of the other methods do nothing.
19  * </p><p>
20  * This class can be used without OSGi running.
21  * </p>
22  */

23 public class NullProgressMonitor implements IProgressMonitor {
24
25     /**
26      * Indicates whether cancel has been requested.
27      */

28     private boolean cancelled = false;
29
30     /**
31      * Constructs a new progress monitor.
32      */

33     public NullProgressMonitor() {
34         super();
35     }
36
37     /**
38      * This implementation does nothing.
39      * Subclasses may override this method to do interesting
40      * processing when a task begins.
41      *
42      * @see IProgressMonitor#beginTask(String, int)
43      */

44     public void beginTask(String JavaDoc name, int totalWork) {
45         // do nothing
46
}
47
48     /**
49      * This implementation does nothing.
50      * Subclasses may override this method to do interesting
51      * processing when a task is done.
52      *
53      * @see IProgressMonitor#done()
54      */

55     public void done() {
56         // do nothing
57
}
58
59     /**
60      * This implementation does nothing.
61      * Subclasses may override this method.
62      *
63      * @see IProgressMonitor#internalWorked(double)
64      */

65     public void internalWorked(double work) {
66         // do nothing
67
}
68
69     /**
70      * This implementation returns the value of the internal
71      * state variable set by <code>setCanceled</code>.
72      * Subclasses which override this method should
73      * override <code>setCanceled</code> as well.
74      *
75      * @see IProgressMonitor#isCanceled()
76      * @see IProgressMonitor#setCanceled(boolean)
77      */

78     public boolean isCanceled() {
79         return cancelled;
80     }
81
82     /**
83      * This implementation sets the value of an internal state variable.
84      * Subclasses which override this method should override
85      * <code>isCanceled</code> as well.
86      *
87      * @see IProgressMonitor#isCanceled()
88      * @see IProgressMonitor#setCanceled(boolean)
89      */

90     public void setCanceled(boolean cancelled) {
91         this.cancelled = cancelled;
92     }
93
94     /**
95      * This implementation does nothing.
96      * Subclasses may override this method to do something
97      * with the name of the task.
98      *
99      * @see IProgressMonitor#setTaskName(String)
100      */

101     public void setTaskName(String JavaDoc name) {
102         // do nothing
103
}
104
105     /**
106      * This implementation does nothing.
107      * Subclasses may override this method to do interesting
108      * processing when a subtask begins.
109      *
110      * @see IProgressMonitor#subTask(String)
111      */

112     public void subTask(String JavaDoc name) {
113         // do nothing
114
}
115
116     /**
117      * This implementation does nothing.
118      * Subclasses may override this method to do interesting
119      * processing when some work has been completed.
120      *
121      * @see IProgressMonitor#worked(int)
122      */

123     public void worked(int work) {
124         // do nothing
125
}
126 }
127
Popular Tags