Question

I'm writing a wizard for an Eclipse RCP application. After doing some processing on a file and taking some user input, I don't want to let the user go back to make changes. At this point they must either accept or reject the changes they are about to make to the system.

What I can't seem to find is a method call that lets me override the buttons that display or the user's ability to hit the back button. I'd prefer that it not be there or at least be disabled.

Has anyone found a way to do this using the JFace Wizard and WizardPage?

Usability-wise, am I breaking wizard conventions? Should I consider a different approach to the problem?

Was it helpful?

Solution

You can return null from the getPreviousPage() method in your wizard page implementation.

OTHER TIPS

Expanding on jodonell's answer:

Disabling the back button is harder than it should be, due to non-intuitive behavior in the default implementation of WizardPage.getPreviousPage(). You can call setPreviousPage( null ), and getPreviousPage() still returns the previous page. You need to override the implementation of getPreviousPage() in order to disable the back button:

public abstract class MyWizardPage extends WizardPage {
    private boolean backButtonEnabled = true;

    public void setBackButtonEnabled(boolean enabled) {
        backButtonEnabled = enabled;
        getContainer().updateButtons();
    }

    @Override
    public IWizardPage getPreviousPage() {
        if (!backButtonEnabled) {
            return null;
        }
        return super.getPreviousPage();
    }
}

See my blog post for a few more JFace wizard tips and tricks:

http://nsawadsky.blogspot.com/2011/07/jface-wizard-tips-and-tricks.html

From a UI perspective this seems rather bad. Your users are going to get frustrated if they make a mistake and want to go back and correct it and you don't let them. I think it would be much better to change the application to allow going back rather than looking for ways to prevent it.

There is no way to do this using standard JFace wizard APIs. My team accomplished this by writing a custom WizardDialog. We did this on an Eclipse RCP application and not on an eclipse plugin. Disabling the back button is breaking convention, but our business analysts really wanted the functionality.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top