Reputation: 3294
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.
Upvotes: 4
Views: 3895
Reputation: 29
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);
}
Upvotes: 0
Reputation: 3294
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
Upvotes: 2