diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java index 9d30a075382..df34fb35e33 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java @@ -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; @@ -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(); @@ -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) { @@ -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