Lines 9-14
Link Here
|
9 |
**********************************************************************/ |
9 |
**********************************************************************/ |
10 |
package org.eclipse.ui.internal.progress; |
10 |
package org.eclipse.ui.internal.progress; |
11 |
import java.lang.reflect.InvocationTargetException; |
11 |
import java.lang.reflect.InvocationTargetException; |
|
|
12 |
|
13 |
import org.eclipse.core.runtime.IProgressMonitor; |
14 |
import org.eclipse.core.runtime.IProgressMonitorWithBlocking; |
12 |
import org.eclipse.core.runtime.IStatus; |
15 |
import org.eclipse.core.runtime.IStatus; |
13 |
import org.eclipse.swt.SWT; |
16 |
import org.eclipse.swt.SWT; |
14 |
import org.eclipse.swt.events.SelectionAdapter; |
17 |
import org.eclipse.swt.events.SelectionAdapter; |
Lines 34-49
Link Here
|
34 |
*/ |
37 |
*/ |
35 |
public class ProgressMonitorJobsDialog extends ProgressMonitorDialog { |
38 |
public class ProgressMonitorJobsDialog extends ProgressMonitorDialog { |
36 |
private NewProgressViewer viewer; |
39 |
private NewProgressViewer viewer; |
|
|
40 |
|
41 |
//These are booleans that are used to check if the runnable in |
42 |
//the receiver is still progressing. When watchingTicks is true |
43 |
//and change to task name or incrementing of values will set |
44 |
//tickOccured to true. |
45 |
private boolean watchingTicks = false; |
46 |
private boolean tickOccured = false; |
47 |
|
37 |
/** |
48 |
/** |
38 |
* The height of the viewer. Set when the details button is selected. |
49 |
* The height of the viewer. Set when the details button is selected. |
39 |
*/ |
50 |
*/ |
40 |
private int viewerHeight = -1; |
51 |
private int viewerHeight = -1; |
41 |
Composite viewerComposite; |
52 |
Composite viewerComposite; |
42 |
private Button detailsButton; |
53 |
private Button detailsButton; |
|
|
54 |
protected IProgressMonitorWithBlocking wrapperedMonitor; |
43 |
|
55 |
|
44 |
//Cache initial enablement in case the enablement state is set |
56 |
//Cache initial enablement in case the enablement state is set |
45 |
//before the button is created |
57 |
//before the button is created |
46 |
private boolean enableDetailsButton = true; |
58 |
private boolean enableDetailsButton = true; |
|
|
59 |
|
60 |
//Keep track of whether or not this was already closed. |
61 |
private boolean alreadyClosed = false; |
47 |
/** |
62 |
/** |
48 |
* Create a new instance of the receiver. |
63 |
* Create a new instance of the receiver. |
49 |
* |
64 |
* |
Lines 236-240
Link Here
|
236 |
detailsButton.setEnabled(false); |
251 |
detailsButton.setEnabled(false); |
237 |
} |
252 |
} |
238 |
super.run(fork, cancelable, runnable); |
253 |
super.run(fork, cancelable, runnable); |
|
|
254 |
} |
255 |
|
256 |
|
257 |
/** |
258 |
* Return true if bother watchingTicks and ticksOccured is true. |
259 |
* If not watchingTicks already start after this is called. |
260 |
* @return boolean <code>true</code> if tickOccured has been set. |
261 |
*/ |
262 |
public boolean isTicking(){ |
263 |
|
264 |
if(watchingTicks){ |
265 |
if(tickOccured){//If we have the tick reset the state |
266 |
watchingTicks = false; |
267 |
tickOccured = false; |
268 |
return true; |
269 |
} |
270 |
return false; |
271 |
} |
272 |
watchingTicks = true; |
273 |
return false; |
274 |
} |
275 |
|
276 |
/** |
277 |
* Create a monitor for the receiver that wrappers the superclasses monitor. |
278 |
* |
279 |
*/ |
280 |
public void createWrapperedMonitor() { |
281 |
wrapperedMonitor = new IProgressMonitorWithBlocking(){ |
282 |
|
283 |
IProgressMonitor superMonitor = ProgressMonitorJobsDialog.super.getProgressMonitor(); |
284 |
/* (non-Javadoc) |
285 |
* @see org.eclipse.core.runtime.IProgressMonitor#beginTask(java.lang.String, int) |
286 |
*/ |
287 |
public void beginTask(String name, int totalWork) { |
288 |
superMonitor.beginTask(name,totalWork); |
289 |
checkTicking(); |
290 |
} |
291 |
|
292 |
/** |
293 |
* Check if a tick occurred. |
294 |
*/ |
295 |
private void checkTicking() { |
296 |
if(watchingTicks) |
297 |
tickOccured = true; |
298 |
} |
299 |
|
300 |
/* (non-Javadoc) |
301 |
* @see org.eclipse.core.runtime.IProgressMonitor#done() |
302 |
*/ |
303 |
public void done() { |
304 |
superMonitor.done(); |
305 |
checkTicking(); |
306 |
} |
307 |
|
308 |
/* (non-Javadoc) |
309 |
* @see org.eclipse.core.runtime.IProgressMonitor#internalWorked(double) |
310 |
*/ |
311 |
public void internalWorked(double work) { |
312 |
superMonitor.internalWorked(work); |
313 |
checkTicking(); |
314 |
} |
315 |
|
316 |
/* (non-Javadoc) |
317 |
* @see org.eclipse.core.runtime.IProgressMonitor#isCanceled() |
318 |
*/ |
319 |
public boolean isCanceled() { |
320 |
return superMonitor.isCanceled(); |
321 |
} |
322 |
|
323 |
/* (non-Javadoc) |
324 |
* @see org.eclipse.core.runtime.IProgressMonitor#setCanceled(boolean) |
325 |
*/ |
326 |
public void setCanceled(boolean value) { |
327 |
superMonitor.setCanceled(value); |
328 |
|
329 |
} |
330 |
|
331 |
/* (non-Javadoc) |
332 |
* @see org.eclipse.core.runtime.IProgressMonitor#setTaskName(java.lang.String) |
333 |
*/ |
334 |
public void setTaskName(String name) { |
335 |
superMonitor.setTaskName(name); |
336 |
checkTicking(); |
337 |
|
338 |
} |
339 |
|
340 |
/* (non-Javadoc) |
341 |
* @see org.eclipse.core.runtime.IProgressMonitor#subTask(java.lang.String) |
342 |
*/ |
343 |
public void subTask(String name) { |
344 |
superMonitor.subTask(name); |
345 |
checkTicking(); |
346 |
} |
347 |
|
348 |
/* (non-Javadoc) |
349 |
* @see org.eclipse.core.runtime.IProgressMonitor#worked(int) |
350 |
*/ |
351 |
public void worked(int work) { |
352 |
superMonitor.worked(work); |
353 |
checkTicking(); |
354 |
|
355 |
} |
356 |
/* (non-Javadoc) |
357 |
* @see org.eclipse.core.runtime.IProgressMonitorWithBlocking#clearBlocked() |
358 |
*/ |
359 |
public void clearBlocked() { |
360 |
//We want to open on blocking too |
361 |
if(superMonitor instanceof IProgressMonitorWithBlocking) |
362 |
((IProgressMonitorWithBlocking) superMonitor).clearBlocked(); |
363 |
|
364 |
} |
365 |
|
366 |
/* (non-Javadoc) |
367 |
* @see org.eclipse.core.runtime.IProgressMonitorWithBlocking#setBlocked(org.eclipse.core.runtime.IStatus) |
368 |
*/ |
369 |
public void setBlocked(IStatus reason) { |
370 |
checkTicking(); |
371 |
if(superMonitor instanceof IProgressMonitorWithBlocking) |
372 |
((IProgressMonitorWithBlocking) superMonitor).setBlocked(reason); |
373 |
|
374 |
} |
375 |
|
376 |
}; |
377 |
} |
378 |
|
379 |
/* (non-Javadoc) |
380 |
* @see org.eclipse.jface.dialogs.ProgressMonitorDialog#getProgressMonitor() |
381 |
*/ |
382 |
public IProgressMonitor getProgressMonitor() { |
383 |
if(wrapperedMonitor == null) |
384 |
createWrapperedMonitor(); |
385 |
return wrapperedMonitor; |
386 |
} |
387 |
|
388 |
/* (non-Javadoc) |
389 |
* @see org.eclipse.jface.dialogs.ProgressMonitorDialog#close() |
390 |
*/ |
391 |
public boolean close() { |
392 |
boolean result = super.close(); |
393 |
if(result){//As this sometimes delayed cache if it was already closed |
394 |
alreadyClosed = true; |
395 |
watchingTicks = false; |
396 |
} |
397 |
return result; |
398 |
} |
399 |
/** |
400 |
* Return <code>true</true> if the close() method was already called. |
401 |
* @return the closed state |
402 |
*/ |
403 |
public boolean isAlreadyClosed() { |
404 |
return alreadyClosed; |
239 |
} |
405 |
} |
240 |
} |
406 |
} |