Bug 60227 [Progress] support for clients implementing IRunnableContext
Clients which implement IRunnableContext directly need some support so that they can also show the BlockedJobsDialog. These clients currently typically run an operation as follows (for example SearchDialog): ModalContext.run(runnable, fork, getProgressMonitor(), getShell().getDisplay ()); One idea is to provide them with a helper that creates a progress monitor that handles setBlocked by showing the BlockedJobsDialog. For example, IProgressService.getProgressMonitorFor(IProgressMonitor); The wrapper could be implemented as shown below. It could probably reuse some of the WorkbenchWizardBlockedHandler. Once this support is in place the WorkbenchWindow should leverage this support. public class BlockedJobsAwareProgressMonitor extends ProgressMonitorWrapper { private BlockedJobsDialog blockedDialog; private Shell shell; private String currentTask; protected BlockedJobsAwareProgressMonitor(Shell shell, IProgressMonitor monitor) { super(monitor); this.shell = shell; } public void clearBlocked() { if (blockedDialog == null) return; blockedDialog.close(); blockedDialog = null; } public void setBlocked(IStatus reason) { showBlocked(shell, this, reason, currentTask); } public void showBlocked(Shell parentShell, IProgressMonitor blockingMonitor, IStatus blockingStatus, String blockedName) { if (blockedName == null) blockedName = parentShell.getText(); blockedDialog = new BlockedJobsDialog(parentShell, blockingMonitor, blockingStatus); blockedDialog.setBlockedTaskName(blockedName); blockedDialog.open(); } public void beginTask(String name, int totalWork) { super.beginTask(name, totalWork); currentTask = name; } }
bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/Dialog.java
* All other button presses are ignored. Subclasses may override
	 * to handle other buttons, but should call <code>super.buttonPressed</code>
	 * if the default handling of the ok and cancel buttons is desired.
	 * </p>
	 *
	 * @param buttonId the id of the button that was pressed (see
	 *  <code>IDialogConstants.*_ID</code> constants)
	 */
	protected void buttonPressed(int buttonId) {
		if (IDialogConstants.OK_ID == buttonId)
			okPressed();
		else if (IDialogConstants.CANCEL_ID == buttonId)
			cancelPressed();
	}
	/**
	 * Notifies that the cancel button of this dialog has been pressed.
	 * <p>
	 * The <code>Dialog</code> implementation of this framework method sets
	 * this dialog's return code to <code>Window.CANCEL</code>
	 * and closes the dialog. Subclasses may override if desired.
	 * </p>
	 */
	protected void cancelPressed() {
		setReturnCode(CANCEL);
		close();
	}
	/**
	 * Returns the number of pixels corresponding to the
	 * height of the given number of characters.
	 * <p>