Bug 58985 [Dialogs] WizardDialog.getButton( IDialogConstants.CANCLE_ID ) always returns null
Here's a test case for this bug. Watch the stdout of the program. --WizardDialogBug import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.wizard.IWizard; import org.eclipse.jface.wizard.Wizard; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class WizardDialogBug { public static void main(String[] args) { WizardDialogBug wizardDialogBug = new WizardDialogBug(); wizardDialogBug.run(); } public void run() { Display display = new Display(); Shell shell = new Shell( display, SWT.NONE ); TestWizard wizard = new TestWizard(); TestWizardDialog dialog = new TestWizardDialog( shell, wizard ); dialog.setBlockOnOpen( false ); dialog.open(); while( !shell.isDisposed() ) if( !display.readAndDispatch() ) display.sleep(); display.dispose(); } // test WizardPage public class TestWizardPage extends WizardPage { public TestWizardPage() { super( "TestWizardPage" ); } public void createControl(Composite parent) { Button b = new Button( parent, SWT.PUSH ); b.setText( "Button" ); setControl( b ); } } // test Wizard public class TestWizard extends Wizard { public TestWizard() { super(); setWindowTitle( "TestWizard" ); } public void addPages() { addPage( new TestWizardPage() ); } public boolean performFinish() { return false; } } // test WizardDialog public class TestWizardDialog extends WizardDialog { public TestWizardDialog( Shell shell, IWizard wizard ) { super( shell, wizard ); } public int open() { int rc = super.open(); // by now, all controls should have been created; System.out.println( getButton( IDialogConstants.FINISH_ID ) ); System.out.println( getButton( IDialogConstants.CANCEL_ID ) ); return rc; } } }
bundles/org.eclipse.jface/src/org/eclipse/jface/wizard/WizardDialog.java
}
	/**
	 * Creates the Cancel button for this wizard dialog.
	 * Creates a standard (<code>SWT.PUSH</code>) button and registers for its
	 * selection events. Note that the number of columns in the button bar composite
	 * is incremented. The Cancel button is created specially to give it a 
	 * removeable listener.
	 *
	 * @param parent the parent button bar
	 * @return the new Cancel button
	 */
	private Button createCancelButton(Composite parent) {
		
		((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;
	}
	/**
	 * 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.