comparison org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.d @ 12:bc29606a740c

Added dwt-addons in original directory structure of eclipse.org
author Frank Benoit <benoit@tionex.de>
date Sat, 14 Mar 2009 18:23:29 +0100
parents
children 8594250b1d1c
comparison
equal deleted inserted replaced
11:43904fec5dca 12:bc29606a740c
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 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/
13 module org.eclipse.core.runtime.IProgressMonitor;
14
15 import java.lang.all;
16
17 /**
18 * The <code>IProgressMonitor</code> interface is implemented
19 * by objects that monitor the progress of an activity; the methods
20 * in this interface are invoked by code that performs the activity.
21 * <p>
22 * All activity is broken down into a linear sequence of tasks against
23 * which progress is reported. When a task begins, a <code>beginTask(String, int)
24 * </code> notification is reported, followed by any number and mixture of
25 * progress reports (<code>worked()</code>) and subtask notifications
26 * (<code>subTask(String)</code>). When the task is eventually completed, a
27 * <code>done()</code> notification is reported. After the <code>done()</code>
28 * notification, the progress monitor cannot be reused; i.e., <code>
29 * beginTask(String, int)</code> cannot be called again after the call to
30 * <code>done()</code>.
31 * </p>
32 * <p>
33 * A request to cancel an operation can be signaled using the
34 * <code>setCanceled</code> method. Operations taking a progress
35 * monitor are expected to poll the monitor (using <code>isCanceled</code>)
36 * periodically and abort at their earliest convenience. Operation can however
37 * choose to ignore cancelation requests.
38 * </p>
39 * <p>
40 * Since notification is synchronous with the activity itself, the listener should
41 * provide a fast and robust implementation. If the handling of notifications would
42 * involve blocking operations, or operations which might throw uncaught exceptions,
43 * the notifications should be queued, and the actual processing deferred (or perhaps
44 * delegated to a separate thread).
45 * </p><p>
46 * This interface can be used without OSGi running.
47 * </p><p>
48 * Clients may implement this interface.
49 * </p>
50 */
51 public interface IProgressMonitor {
52
53 /** Constant indicating an unknown amount of work.
54 */
55 public static const int UNKNOWN = -1;
56
57 /**
58 * Notifies that the main task is beginning. This must only be called once
59 * on a given progress monitor instance.
60 *
61 * @param name the name (or description) of the main task
62 * @param totalWork the total number of work units into which
63 * the main task is been subdivided. If the value is <code>UNKNOWN</code>
64 * the implementation is free to indicate progress in a way which
65 * doesn't require the total number of work units in advance.
66 */
67 public void beginTask(String name, int totalWork);
68
69 /**
70 * Notifies that the work is done; that is, either the main task is completed
71 * or the user canceled it. This method may be called more than once
72 * (implementations should be prepared to handle this case).
73 */
74 public void done();
75
76 /**
77 * Internal method to handle scaling correctly. This method
78 * must not be called by a client. Clients should
79 * always use the method </code>worked(int)</code>.
80 *
81 * @param work the amount of work done
82 */
83 public void internalWorked(double work);
84
85 /**
86 * Returns whether cancelation of current operation has been requested.
87 * Long-running operations should poll to see if cancelation
88 * has been requested.
89 *
90 * @return <code>true</code> if cancellation has been requested,
91 * and <code>false</code> otherwise
92 * @see #setCanceled(bool)
93 */
94 public bool isCanceled();
95
96 /**
97 * Sets the cancel state to the given value.
98 *
99 * @param value <code>true</code> indicates that cancelation has
100 * been requested (but not necessarily acknowledged);
101 * <code>false</code> clears this flag
102 * @see #isCanceled()
103 */
104 public void setCanceled(bool value);
105
106 /**
107 * Sets the task name to the given value. This method is used to
108 * restore the task label after a nested operation was executed.
109 * Normally there is no need for clients to call this method.
110 *
111 * @param name the name (or description) of the main task
112 * @see #beginTask(java.lang.String, int)
113 */
114 public void setTaskName(String name);
115
116 /**
117 * Notifies that a subtask of the main task is beginning.
118 * Subtasks are optional; the main task might not have subtasks.
119 *
120 * @param name the name (or description) of the subtask
121 */
122 public void subTask(String name);
123
124 /**
125 * Notifies that a given number of work unit of the main task
126 * has been completed. Note that this amount represents an
127 * installment, as opposed to a cumulative amount of work done
128 * to date.
129 *
130 * @param work a non-negative number of work units just completed
131 */
132 public void worked(int work);
133 }