Bug 271530 [Wizards] Wizard progress label not cleared between runnables
I have a wizard that has multiple p2 IUs in a list, and when the user selects one I need to call p2 to get a provisioning plan (a semi-long-running operation) to determine if Finish should be disabled. To do this, I call WizardPage.getContainer().run() and fork an IRunnableWithProgress to call a p2 method with a progress monitor. I noticed several times that when I made a selection in the list the progress monitor label would flash before progress would start to appear. I clicked quickly several times and was able to read that the label was actually an error message from p2. I then set a breakpoint, and found that the error is visible *before* entry into my IRunnableWithProgress. It was actually a failure from the last time that p2 was called, i.e. in a separate runnable the last time I clicked. I tried to narrow this down, but the best I could find is that the wizard dialog never calls through to ProgressMonitorPart.updateLabel() before running - so when a new runnable starts, the monitor will display text from the previous monitor before calling the new one. If the new monitor isn't updated immediately, the old text will appear until the new monitor does something. You can reproduce with the following code. The second time you call it, the progress label will say "Testing!" immediately even though the monitor hasn't been called yet. getContainer().run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { Thread.sleep(5000); } catch (Exception e) { // ignore } monitor.beginTask("Testing!", 100); } });
bundles/org.eclipse.jface/src/org/eclipse/jface/wizard/WizardDialog.java
*            the map (key type: <code>String</code>, element type:
	 *            <code>Boolean</code>)
	 * @param key
	 *            the key
	 * @see #saveEnableStateAndSet
	 */
	private void restoreEnableState(Control w, Map h, String key) {
		if (w != null) {
			Boolean b = (Boolean) h.get(key);
			if (b != null) {
				w.setEnabled(b.booleanValue());
			}
		}
	}
	/**
	 * Restores the enabled/disabled state of the wizard dialog's buttons and
	 * the tree of controls for the currently showing page.
	 * 
	 * @param state
	 *            a map containing the saved state as returned by
	 *            <code>saveUIState</code>
	 * @see #saveUIState
	 */
	private void restoreUIState(Map state) {
		restoreEnableState(backButton, state, "back"); 
		restoreEnableState(nextButton, state, "next"); 
		restoreEnableState(finishButton, state, "finish"); 
		restoreEnableState(cancelButton, state, "cancel"); 
		restoreEnableState(helpButton, state, "help"); 
		Object pageValue = state.get("page");