View | Details | Raw Unified | Return to bug 64937 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/progress/BlockedJobsDialog.java (-1 / +1 lines)
Lines 201-207 Link Here
201
				public IStatus runInUIThread(IProgressMonitor monitor) {
201
				public IStatus runInUIThread(IProgressMonitor monitor) {
202
					if (singleton == null)
202
					if (singleton == null)
203
						return Status.CANCEL_STATUS;
203
						return Status.CANCEL_STATUS;
204
					if (ProgressManagerUtil.rescheduleIfModalShellOpen(this))
204
					if (ProgressManagerUtil.rescheduleIfModalShellOpen(this,null))
205
						return Status.CANCEL_STATUS;
205
						return Status.CANCEL_STATUS;
206
					singleton.open();
206
					singleton.open();
207
					return Status.OK_STATUS;
207
					return Status.OK_STATUS;
(-)Eclipse UI/org/eclipse/ui/internal/progress/ProgressManager.java (-1 / +2 lines)
Lines 823-830 Link Here
823
			public IStatus runInUIThread(IProgressMonitor monitor) {
823
			public IStatus runInUIThread(IProgressMonitor monitor) {
824
				setUserInterfaceActive(true);
824
				setUserInterfaceActive(true);
825
825
826
				if (ProgressManagerUtil.rescheduleIfModalShellOpen(this))
826
				if (ProgressManagerUtil.rescheduleIfModalShellOpen(this,dialog))
827
					return Status.CANCEL_STATUS;
827
					return Status.CANCEL_STATUS;
828
				dialog.setOpenOnRun(true);
828
				dialog.open();
829
				dialog.open();
829
				return Status.OK_STATUS;
830
				return Status.OK_STATUS;
830
			}
831
			}
(-)Eclipse UI/org/eclipse/ui/internal/progress/ProgressManagerUtil.java (-6 / +19 lines)
Lines 201-216 Link Here
201
	}
201
	}
202
	/**
202
	/**
203
	 * If there are any modal shells open reschedule openJob to wait until they
203
	 * If there are any modal shells open reschedule openJob to wait until they
204
	 * are closed. Return true if it rescheduled, false if there is nothing
204
	 * are closed. If the operation in jobsDialog is running then open
205
	 * blocking it.
205
	 * regardless as it is not being blocked by the jobs dialog.
206
	 * Return true if it rescheduled, false if there is nothing blocking it.
206
	 * 
207
	 * 
207
	 * @param openJob
208
	 * @param openJob
208
	 * @return boolean. true if the job was rescheduled due to modal dialogs.
209
	 * @param jobsDialog The dialog that is running a job. If it is still
210
	 * ticking then open away as it is not being blocked by the open dialog.
211
	 * May be <code>null</code>.
212
	 * @return boolean. true if the job was rescheduled due to modal dialogs
213
	 * or if it should not open at all as the operation is done.
209
	 */
214
	 */
210
	public static boolean rescheduleIfModalShellOpen(Job openJob) {
215
	public static boolean rescheduleIfModalShellOpen(Job openJob,ProgressMonitorJobsDialog jobsDialog) {
211
		Shell modal = getModalShell();
216
		Shell modal = getModalShell();
212
		if (modal == null)
217
		if (modal == null)
213
			return false;
218
			return false;
219
		
220
		//If ticks are going on don't block.
221
		if(jobsDialog != null){
222
			if(jobsDialog.isAlreadyClosed())//Just abort if it is closed
223
				return true;
224
			if(jobsDialog.isTicking())//open if it is still alive
225
				return false;		
226
		}
214
227
215
		//try again in a few seconds
228
		//try again in a few seconds
216
		openJob.schedule(PlatformUI.getWorkbench().getProgressService()
229
		openJob.schedule(PlatformUI.getWorkbench().getProgressService()
Lines 288-294 Link Here
288
		end.x += windowLocation.x;
301
		end.x += windowLocation.x;
289
		end.y += windowLocation.y;
302
		end.y += windowLocation.y;
290
		RectangleAnimation animation = new RectangleAnimation(internalWindow
303
		RectangleAnimation animation = new RectangleAnimation(internalWindow
291
				.getShell(), startPosition, end);
304
				.getShell(), startPosition, end, 250);
292
		animation.schedule();
305
		animation.schedule();
293
	}
306
	}
294
307
Lines 311-317 Link Here
311
		region.x += windowLocation.x;
324
		region.x += windowLocation.x;
312
		region.y += windowLocation.y;
325
		region.y += windowLocation.y;
313
		RectangleAnimation animation = new RectangleAnimation(internalWindow
326
		RectangleAnimation animation = new RectangleAnimation(internalWindow
314
				.getShell(), region, endPosition);
327
				.getShell(), region, endPosition, 250);
315
		animation.schedule();
328
		animation.schedule();
316
	}
329
	}
317
}
330
}
(-)Eclipse UI/org/eclipse/ui/internal/progress/ProgressMonitorFocusJobDialog.java (-1 / +1 lines)
Lines 347-353 Link Here
347
					return Status.CANCEL_STATUS;
347
					return Status.CANCEL_STATUS;
348
				
348
				
349
				//now open the progress dialog if nothing else is
349
				//now open the progress dialog if nothing else is
350
				if(ProgressManagerUtil.rescheduleIfModalShellOpen(this))
350
				if(ProgressManagerUtil.rescheduleIfModalShellOpen(this,ProgressMonitorFocusJobDialog.this))
351
					return Status.CANCEL_STATUS;
351
					return Status.CANCEL_STATUS;
352
352
353
				//Do not bother if the parent is disposed
353
				//Do not bother if the parent is disposed
(-)Eclipse UI/org/eclipse/ui/internal/progress/ProgressMonitorJobsDialog.java (+164 lines)
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
				if(superMonitor instanceof IProgressMonitorWithBlocking)
361
					((IProgressMonitorWithBlocking) superMonitor).clearBlocked();
362
363
			}
364
			
365
			/* (non-Javadoc)
366
			 * @see org.eclipse.core.runtime.IProgressMonitorWithBlocking#setBlocked(org.eclipse.core.runtime.IStatus)
367
			 */
368
			public void setBlocked(IStatus reason) {
369
				if(superMonitor instanceof IProgressMonitorWithBlocking)
370
					((IProgressMonitorWithBlocking) superMonitor).setBlocked(reason);
371
372
			}
373
			
374
		};
375
	}
376
	
377
	/* (non-Javadoc)
378
	 * @see org.eclipse.jface.dialogs.ProgressMonitorDialog#getProgressMonitor()
379
	 */
380
	public IProgressMonitor getProgressMonitor() {
381
		if(wrapperedMonitor == null)
382
			createWrapperedMonitor();
383
		return wrapperedMonitor;
384
	}
385
	
386
	/* (non-Javadoc)
387
	 * @see org.eclipse.jface.dialogs.ProgressMonitorDialog#close()
388
	 */
389
	public boolean close() {
390
		boolean result = super.close();
391
		if(result){//As this sometimes delayed cache if it was already closed
392
			alreadyClosed = true;
393
			watchingTicks = false;
394
		}
395
		return result;
396
	}
397
	/**
398
	 * Return <code>true</true> if the close() method was already called.
399
	 * @return the closed state
400
	 */
401
	public boolean isAlreadyClosed() {
402
		return alreadyClosed;
239
	}
403
	}
240
}
404
}

Return to bug 64937