16
16
import org .eclipse .core .runtime .IProgressMonitor ;
17
17
import org .eclipse .core .runtime .IStatus ;
18
18
import org .eclipse .core .runtime .NullProgressMonitor ;
19
+ import org .eclipse .core .runtime .Status ;
20
+ import org .eclipse .jface .util .Policy ;
19
21
import org .eclipse .swt .SWT ;
20
22
import org .eclipse .swt .graphics .Image ;
21
23
import org .eclipse .swt .widgets .Composite ;
@@ -154,9 +156,13 @@ public IProgressMonitor getProgressMonitor() {
154
156
@ Override
155
157
public void beginTask (String name , int totalWork ) {
156
158
if (taskStarted != null ) {
157
- throw new IllegalStateException (
159
+ /// TODO: maybe even logging is too much as long as every SubMonitor.convert()
160
+ /// illegally calls beginTask as second time.
161
+ Exception e = new IllegalStateException (
158
162
"beginTask should only be called once per instance. At least call done() before further invocations" , //$NON-NLS-1$
159
163
taskStarted );
164
+ Policy .getLog ().log (Status .warning (e .getLocalizedMessage (), e ));
165
+ done (); // workaround client error
160
166
}
161
167
taskStarted = new IllegalStateException (
162
168
"beginTask(" + name + ", " + totalWork + ") was called here previously" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -199,9 +205,6 @@ public void setCanceled(boolean value) {
199
205
200
206
@ Override
201
207
public void setTaskName (String name ) {
202
- if (taskStarted == null ) {
203
- throw new IllegalStateException ("call to beginTask() missing" ); //$NON-NLS-1$
204
- }
205
208
progressDelegate .setTaskName (name );
206
209
207
210
}
@@ -215,7 +218,8 @@ public void subTask(String name) {
215
218
@ Override
216
219
public void worked (int work ) {
217
220
if (taskStarted == null ) {
218
- throw new IllegalStateException ("call to beginTask() missing" ); //$NON-NLS-1$
221
+ Exception e = new IllegalStateException ("call to beginTask() missing" ); //$NON-NLS-1$
222
+ Policy .getLog ().log (Status .warning (e .getLocalizedMessage (), e ));
219
223
}
220
224
progressDelegate .worked (work );
221
225
}
0 commit comments