Skip to content

Commit

Permalink
Show progress indicator of "Run configurations..." after 800 ms
Browse files Browse the repository at this point in the history
Wait a while before showing the progress indicator in the dialog "Run
configurations...". This avoids the flickering that happens when the
task is completed in under 800 ms (which is the current norm in
PlatformUI.getWorkbench().getProgressService().getLongOperationTime())

Contributes to eclipse-pde/eclipse.pde#679
  • Loading branch information
fedejeanne committed Sep 13, 2023
1 parent 418fcfc commit f50e586
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.UIJob;
import org.eclipse.ui.progress.WorkbenchJob;
import org.osgi.framework.FrameworkUtil;

Expand Down Expand Up @@ -1374,9 +1375,13 @@ public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable
if (cancelable) {
fProgressMonitorPart.attachToCancelComponent(null);
}
fProgressMonitorPart.getParent().setVisible(true);

fActiveRunningOperations++;

UIJob showProgressMonitorPart = createJobToShowProgressMonitorPart();
// only show the progress bar if necessary after 1 second
showProgressMonitorPart.schedule(PlatformUI.getWorkbench().getProgressService().getLongOperationTime());

//do work here collecting enabled states, otherwise to get these states we would need to
//perform the validation of the dialog again, which is expensive and would cause flashing of widgets.
Control[] children = ((Composite)fButtonComp.getChildren()[0]).getChildren();
Expand All @@ -1391,6 +1396,8 @@ public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable
ModalContext.run(runnable, fork, fProgressMonitorPart, getShell().getDisplay());
}
finally {
showProgressMonitorPart.cancel();

fActiveRunningOperations--;
updateRunnnableControls(true, prev);
if (getShell() != null) {
Expand All @@ -1409,6 +1416,17 @@ public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable
}
}

private UIJob createJobToShowProgressMonitorPart() {
return UIJob.create(IInternalDebugCoreConstants.EMPTY_STRING, __ -> {
// only show the progress monitor if there are still active operations by the
// time this job is executed
if (fActiveRunningOperations > 0) {
fProgressMonitorPart.getParent().setVisible(true);
}
return Status.OK_STATUS;
});
}

/**
* Updates the enablement of the runnable controls to appear disabled as a job is running
* @param enabled the desired enable status of the dialog area, revert//apply buttons, and
Expand Down

0 comments on commit f50e586

Please sign in to comment.