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
import org.eclipse.jface.dialogs.ControlEnableState;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.operation.ModalContext;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.util.Assert;
/**
 * A dialog to show a wizard to the end user. 
 * <p>
 * In typical usage, the client instantiates this class with 
 * a particular wizard. The dialog serves as the wizard container
 * and orchestrates the presentation of its pages.
 * <p>
 * The standard layout is roughly as follows: 
 * it has an area at the top containing both the
 * wizard's title, description, and image; the actual wizard page
 * appears in the middle; below that is a progress indicator
 * (which is made visible if needed); and at the bottom
 * of the page is message line and a button bar containing 
 * Help, Next, Back, Finish, and Cancel buttons (or some subset).
 * </p>
 * <p>
 * Clients may subclass <code>WizardDialog</code>, although this
 * is rarely required.
 * </p>
 */
public class WizardDialog extends TitleAreaDialog implements IWizardContainer2 {