Question

I have created a custom wizard with some pages in eclipse plugin. The pages are created by extending the WizardPage. The wizard has Next back Finish and cancel button, and everything works fine.
Now, I want to change the name/text of Finish button to Done. Is it possible to do this in eclipse? Or will I need to provide all the buttons by myself, even this would be fine.

Was it helpful?

Solution

This should do:

@Override
protected void createButtonsForButtonBar(Composite parent) {
    super.createButtonsForButtonBar(parent);

    Button finish = getButton(IDialogConstants.FINISH_ID)
    finish.setText("Done");
    setButtonLayoutData(finish);
}

Here is a related question.

OTHER TIPS

So this is how I was using the wizard:

MyCustomWizard wizard = new MyCustomWizard ("title");
WizardDialog wizardDialog = new WizardDialog(Display.getDefault().getActiveShell(), wizard);
wizardDialog.open();

Now I created a new class, MyCustomDialog extending the WizardDialog:

public class MyCustomDialog extends WizardDialog {

public MyCustomDialog(Shell parentShell, IWizard newWizard) {
    super(parentShell, newWizard);
}

@Override
public void createButtonsForButtonBar(Composite parent){
    super.createButtonsForButtonBar(parent);
    Button finishButton = getButton(IDialogConstants.FINISH_ID);
    finishButton.setText(windowTitle);
}
}

And now I changed the code where I create wizard and wizard dialog as:

MyCustomWizard wizard = new MyCustomWizard ("title");
MyCustomDialog wizardDialog = new MyCustomDialog(Display.getDefault().getActiveShell(), wizard);
wizardDialog.open();

Hope it is useful to someone! :) Thanks for the help @greg-449 and @Baz

There is one more way to change the label of any button. You can override createButton of WizardDialog class as :

@Override
protected Button createButton(Composite parent, int id, String label,
            boolean defaultButton) {
        if (id == IDialogConstants.FINISH_ID) {
            return super.createButton(parent, id,
                    "Done", defaultButton);
        }
        return super.createButton(parent, id, label, defaultButton);
} 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top