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/wizard/WizardDialog.java
((GridLayout) parent.getLayout()).numColumns++;
		Button button = new Button(parent, SWT.PUSH);
		button.setText(IDialogConstants.CANCEL_LABEL);
		setButtonLayoutData(button);
		button.setFont(parent.getFont());
		button.setData(new Integer(IDialogConstants.CANCEL_ID));
		button.addSelectionListener(cancelListener);
		return button;
	}
	/**
	 * Return the cancel button if the id is a the cancel id.
	 * @param id the button id
	 * @return the button corresponding to the button id
	 */
	protected Button getButton(int id)
	{
		if(id == IDialogConstants.CANCEL_ID)
			return cancelButton;
		return super.getButton(id);
	}
	
	/**
	 * The <code>WizardDialog</code> implementation of this <code>Window</code>
	 * method calls call <code>IWizard.addPages</code> to allow the current
	 * wizard to add extra pages, then <code>super.createContents</code> to create
	 * the controls. It then calls <code>IWizard.createPageControls</code>
	 * to allow the wizard to pre-create their page controls prior to opening,
	 * so that the wizard opens to the correct size. And finally it
	 * shows the first page.