Reputation: 1396
I have created a new wizard using org.eclipse.ui.newWizard
extension point.
It creates a new file under selected package.
Now I need to show an error message and Not to show the wizard if the user doesn't select a package. My getSelectedPackage()
method returns the currunt package if selected, if not returns null
.
Everything is working as expected except performCancel()
. It is showing the error message and then the wizard dialog as well.
Can anyone suggest me how to conditionally stop displaying the wizard?
public class NewTestScriptWizard extends Wizard implements INewWizard {
public NewTestScriptWizard() {
super();
setNeedsProgressMonitor(true);
if(getSelectedPackage()== null){
MessageDialog
.openError(getShell(), "Error","You must select a package to create a new file");
performCancel();
}
}
Upvotes: 1
Views: 41
Reputation: 111142
There is no way to stop the wizard creation at this point. performCancel
does nothing when called like this.
The only thing to do is display an error message in the first page of the wizard (with setMessage
or setErrorMessage
) and set the page to be incomplete (with setPageComplete(false)
so that only cancel can be pressed.
Upvotes: 1