comparison org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.d @ 105:bbe49769ec18

...
author Frank Benoit <benoit@tionex.de>
date Sun, 08 Nov 2009 12:42:30 +0100
parents 8594250b1d1c
children
comparison
equal deleted inserted replaced
104:88652073d1c2 105:bbe49769ec18
2 * Copyright (c) 2000, 2006 IBM Corporation and others. 2 * Copyright (c) 2000, 2006 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials 3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0 4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/ 10 *******************************************************************************/
13 module org.eclipse.core.runtime.IProgressMonitor; 11 // Port to the D programming language:
12 // Frank Benoit <benoit@tionex.de>
13 module org.eclipse.core.runtimeIProgressMonitor;
14 14
15 import java.lang.all; 15 import java.lang.all;
16 import java.lang.String; 16
17 17
18 /** 18 /**
19 * The <code>IProgressMonitor</code> interface is implemented 19 * The <code>IProgressMonitor</code> interface is implemented
20 * by objects that monitor the progress of an activity; the methods 20 * by objects that monitor the progress of an activity; the methods
21 * in this interface are invoked by code that performs the activity. 21 * in this interface are invoked by code that performs the activity.
22 * <p> 22 * <p>
23 * All activity is broken down into a linear sequence of tasks against 23 * All activity is broken down into a linear sequence of tasks against
24 * which progress is reported. When a task begins, a <code>beginTask(String, int) 24 * which progress is reported. When a task begins, a <code>beginTask(String, int)
25 * </code> notification is reported, followed by any number and mixture of 25 * </code> notification is reported, followed by any number and mixture of
26 * progress reports (<code>worked()</code>) and subtask notifications 26 * progress reports (<code>worked()</code>) and subtask notifications
27 * (<code>subTask(String)</code>). When the task is eventually completed, a 27 * (<code>subTask(String)</code>). When the task is eventually completed, a
28 * <code>done()</code> notification is reported. After the <code>done()</code> 28 * <code>done()</code> notification is reported. After the <code>done()</code>
29 * notification, the progress monitor cannot be reused; i.e., <code> 29 * notification, the progress monitor cannot be reused; i.e., <code>
30 * beginTask(String, int)</code> cannot be called again after the call to 30 * beginTask(String, int)</code> cannot be called again after the call to
31 * <code>done()</code>. 31 * <code>done()</code>.
32 * </p> 32 * </p>
33 * <p> 33 * <p>
34 * A request to cancel an operation can be signaled using the 34 * A request to cancel an operation can be signaled using the
35 * <code>setCanceled</code> method. Operations taking a progress 35 * <code>setCanceled</code> method. Operations taking a progress
36 * monitor are expected to poll the monitor (using <code>isCanceled</code>) 36 * monitor are expected to poll the monitor (using <code>isCanceled</code>)
37 * periodically and abort at their earliest convenience. Operation can however 37 * periodically and abort at their earliest convenience. Operation can however
38 * choose to ignore cancelation requests. 38 * choose to ignore cancelation requests.
39 * </p> 39 * </p>
40 * <p> 40 * <p>
41 * Since notification is synchronous with the activity itself, the listener should 41 * Since notification is synchronous with the activity itself, the listener should
42 * provide a fast and robust implementation. If the handling of notifications would 42 * provide a fast and robust implementation. If the handling of notifications would
43 * involve blocking operations, or operations which might throw uncaught exceptions, 43 * involve blocking operations, or operations which might throw uncaught exceptions,
44 * the notifications should be queued, and the actual processing deferred (or perhaps 44 * the notifications should be queued, and the actual processing deferred (or perhaps
45 * delegated to a separate thread). 45 * delegated to a separate thread).
46 * </p><p> 46 * </p><p>
47 * This interface can be used without OSGi running. 47 * This interface can be used without OSGi running.
48 * </p><p> 48 * </p><p>
51 */ 51 */
52 public interface IProgressMonitor { 52 public interface IProgressMonitor {
53 53
54 /** Constant indicating an unknown amount of work. 54 /** Constant indicating an unknown amount of work.
55 */ 55 */
56 public static const int UNKNOWN = -1; 56 public final static int UNKNOWN = -1;
57 57
58 /** 58 /**
59 * Notifies that the main task is beginning. This must only be called once 59 * Notifies that the main task is beginning. This must only be called once
60 * on a given progress monitor instance. 60 * on a given progress monitor instance.
61 * 61 *
62 * @param name the name (or description) of the main task 62 * @param name the name (or description) of the main task
63 * @param totalWork the total number of work units into which 63 * @param totalWork the total number of work units into which
64 * the main task is been subdivided. If the value is <code>UNKNOWN</code> 64 * the main task is been subdivided. If the value is <code>UNKNOWN</code>
65 * the implementation is free to indicate progress in a way which 65 * the implementation is free to indicate progress in a way which
66 * doesn't require the total number of work units in advance. 66 * doesn't require the total number of work units in advance.
67 */ 67 */
68 public void beginTask(String name, int totalWork); 68 public void beginTask(String name, int totalWork);
69 69
70 /** 70 /**
71 * Notifies that the work is done; that is, either the main task is completed 71 * Notifies that the work is done; that is, either the main task is completed
72 * or the user canceled it. This method may be called more than once 72 * or the user canceled it. This method may be called more than once
73 * (implementations should be prepared to handle this case). 73 * (implementations should be prepared to handle this case).
74 */ 74 */
75 public void done(); 75 public void done();
76 76
77 /** 77 /**
78 * Internal method to handle scaling correctly. This method 78 * Internal method to handle scaling correctly. This method
79 * must not be called by a client. Clients should 79 * must not be called by a client. Clients should
80 * always use the method </code>worked(int)</code>. 80 * always use the method </code>worked(int)</code>.
81 * 81 *
82 * @param work the amount of work done 82 * @param work the amount of work done
83 */ 83 */
84 public void internalWorked(double work); 84 public void internalWorked(double work);
85 85
86 /** 86 /**
88 * Long-running operations should poll to see if cancelation 88 * Long-running operations should poll to see if cancelation
89 * has been requested. 89 * has been requested.
90 * 90 *
91 * @return <code>true</code> if cancellation has been requested, 91 * @return <code>true</code> if cancellation has been requested,
92 * and <code>false</code> otherwise 92 * and <code>false</code> otherwise
93 * @see #setCanceled(bool) 93 * @see #setCanceled(boolean)
94 */ 94 */
95 public bool isCanceled(); 95 public bool isCanceled();
96 96
97 /** 97 /**
98 * Sets the cancel state to the given value. 98 * Sets the cancel state to the given value.
99 * 99 *
100 * @param value <code>true</code> indicates that cancelation has 100 * @param value <code>true</code> indicates that cancelation has
101 * been requested (but not necessarily acknowledged); 101 * been requested (but not necessarily acknowledged);
102 * <code>false</code> clears this flag 102 * <code>false</code> clears this flag
103 * @see #isCanceled() 103 * @see #isCanceled()
104 */ 104 */
105 public void setCanceled(bool value); 105 public void setCanceled(bool value);
106 106
107 /** 107 /**
108 * Sets the task name to the given value. This method is used to 108 * Sets the task name to the given value. This method is used to
109 * restore the task label after a nested operation was executed. 109 * restore the task label after a nested operation was executed.
110 * Normally there is no need for clients to call this method. 110 * Normally there is no need for clients to call this method.
111 * 111 *
112 * @param name the name (or description) of the main task 112 * @param name the name (or description) of the main task
113 * @see #beginTask(java.lang.String, int) 113 * @see #beginTask(java.lang.String, int)
114 */ 114 */