Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -844,21 +844,28 @@ public void busyCursorWhile(final IRunnableWithProgress runnable)
*/
private void busyCursorWhile(Runnable dialogWaitRunnable, ProgressMonitorJobsDialog dialog) {
// Create the job that will open the dialog after a delay.
scheduleProgressMonitorJob(dialog);
final Display display = PlatformUI.getWorkbench().getDisplay();
if (display == null) {
return;
Job showDialogJob = scheduleProgressMonitorJob(dialog);
try {
final Display display = PlatformUI.getWorkbench().getDisplay();
if (display == null) {
return;
}
// Show a busy cursor until the dialog opens.
BusyIndicator.showWhile(display, dialogWaitRunnable);
} finally {
// In case the dialog hasn't popped up yet, cancel it so it doesn't pop up after
// the operation finishes or unwinds with an exception.
showDialogJob.cancel();
}
// Show a busy cursor until the dialog opens.
BusyIndicator.showWhile(display, dialogWaitRunnable);
}

/**
* Schedules the job that will open the progress monitor dialog.
*
* @param dialog the dialog to open
* @return the job that was scheduled to open the dialog
*/
private void scheduleProgressMonitorJob(final ProgressMonitorJobsDialog dialog) {
private Job scheduleProgressMonitorJob(final ProgressMonitorJobsDialog dialog) {
final WorkbenchJob updateJob = new WorkbenchJob(ProgressMessages.ProgressManager_openJobName) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
Expand All @@ -871,7 +878,7 @@ public IStatus runInUIThread(IProgressMonitor monitor) {
};
updateJob.setSystem(true);
updateJob.schedule(getLongOperationTime());

return updateJob;
}

/**
Expand Down Expand Up @@ -974,11 +981,19 @@ public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable
// Backward compatible code.
final ProgressMonitorJobsDialog dialog = new ProgressMonitorJobsDialog(
ProgressManagerUtil.getDefaultParent());
dialog.setOpenOnRun(false);
if (!shouldRunInBackground()) {
scheduleProgressMonitorJob(dialog);
if (shouldRunInBackground()) {
dialog.setOpenOnRun(false);
dialog.run(fork, cancelable, runnable);
} else {
Job showDialogJob = scheduleProgressMonitorJob(dialog);
try {
dialog.run(fork, cancelable, runnable);
} finally {
// In case the dialog hasn't popped up yet, cancel it so it doesn't pop up after
// the operation finishes or unwinds with an exception.
showDialogJob.cancel();
}
}
dialog.run(fork, cancelable, runnable);
return;
}

Expand Down
Loading