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
/**
	 * Returns the button created when <code>createButton</code> is called 
	 * with an ID of <code>IDialogConstants.OK_ID</code>.  If <code>createButton</code> 
	 * was never called with this parameter, or if <code>createButton</code> is 
	 * overridden, <code>getOKButton</code> will return <code>null</code>.
	 * 
	 * @return the OK button or <code>null</code>
	 * 
	 * @see #createButton(Composite, int, String, boolean)
	 * @since 2.0
	 * @deprecated Use <code>getButton(IDialogConstants.OK_ID)</code> instead.
	 * 		This method will be removed soon.
	 */
	protected Button getOKButton() {
		return getButton(IDialogConstants.OK_ID);
	}
	/**
	 * Initializes the computation of horizontal and vertical dialog units
	 * based on the size of current font.
	 * <p>
	 * This method must be called before any of the dialog unit based
	 * conversion methods are called.
	 * </p>
	 *
	 * @param control a control from which to obtain the current font
	 */
	protected void initializeDialogUnits(Control control) {
		
		GC gc = new GC(control);
		gc.setFont(JFaceResources.getDialogFont());