Skip to content

Commit

Permalink
Impl of ProgressProvider#forMonitor
Browse files Browse the repository at this point in the history
  • Loading branch information
laeubi committed Apr 27, 2022
1 parent 6dc15f1 commit e982546
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -575,17 +575,22 @@ public IProgressMonitor createMonitor(Job job) {

@Override
public IProgressMonitor getDefaultMonitor() {
return monitorFor(null);
}

@Override
public IProgressMonitor monitorFor(IProgressMonitor monitor) {
// only need a default monitor for operations the UI thread
// and only if there is a display
Display display;
if (PlatformUI.isWorkbenchRunning() && !PlatformUI.getWorkbench().isStarting()) {
display = PlatformUI.getWorkbench().getDisplay();
if (!display.isDisposed() && (display.getThread() == Thread.currentThread())) {
return new EventLoopProgressMonitor(new NullProgressMonitor());
}
return new EventLoopProgressMonitor(IProgressMonitor.nullSafe(monitor));
}
return super.getDefaultMonitor();
}
return IProgressMonitor.nullSafe(monitor);
}

/**
* Returns a monitor for the job. Checks if we cached a monitor for this job
Expand Down

0 comments on commit e982546

Please sign in to comment.