GP-628 - Dialogs - fixed timing bug that caused the progress dialog to

sometimes not show progress
This commit is contained in:
dragonmacher 2021-01-29 13:03:37 -05:00
parent a20d77a27b
commit d8166ff6ec
3 changed files with 18 additions and 3 deletions

View file

@ -339,15 +339,17 @@ public class TaskDialog extends DialogComponentProvider implements TaskMonitor {
@Override
public void initialize(long max) {
monitorComponent.initialize(max);
if (!supportsProgress) {
return;
}
if (!monitorComponent.isShowing()) {
// Note: it is not clear why we only wish to show progress if the monitor is not
// visible. This seems wrong. If someone knows, please update this code.
installProgressMonitor();
}
monitorComponent.initialize(max);
}
@Override
@ -364,6 +366,17 @@ public class TaskDialog extends DialogComponentProvider implements TaskMonitor {
public void setIndeterminate(boolean indeterminate) {
supportsProgress = !indeterminate;
monitorComponent.setIndeterminate(indeterminate);
// Assumption: if the client calls this method to show progress, then we should honor
// that request. If we find that nested monitor usage causes dialogs to incorrectly
// toggle monitors, then we need to update those clients to use a wrapping style
// monitor that prevents the behavior.
if (supportsProgress) {
installProgressMonitor();
}
else {
installActivityDisplay();
}
}
@Override

View file

@ -47,6 +47,8 @@ class TaskRunner {
void run() {
BasicTaskMonitor internalMonitor = new BasicTaskMonitor();
internalMonitor.setIndeterminate(!task.hasProgress());
internalMonitor.setCancelEnabled(task.canCancel());
WrappingTaskMonitor monitor = new WrappingTaskMonitor(internalMonitor);
startTaskThread(monitor);
showTaskDialog(monitor);

View file

@ -68,10 +68,10 @@ public class WrappingTaskMonitor implements TaskMonitor {
delegate.removeCancelledListener(l);
}
newDelegate.setIndeterminate(delegate.isIndeterminate());
newDelegate.initialize(delegate.getMaximum());
newDelegate.setProgress(delegate.getProgress());
newDelegate.setMessage(delegate.getMessage());
newDelegate.setIndeterminate(delegate.isIndeterminate());
newDelegate.setCancelEnabled(delegate.isCancelEnabled());
this.delegate = newDelegate;