Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you disable the back button in a JFace wizard?

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?

like image 250
Tony Lenzi Avatar asked Sep 05 '08 13:09

Tony Lenzi


3 Answers

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

like image 192
jodonnell Avatar answered Nov 01 '22 06:11

jodonnell


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

like image 37
Nick Sawadsky Avatar answered Nov 01 '22 07:11

Nick Sawadsky


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.

like image 29
Chris Upchurch Avatar answered Nov 01 '22 05:11

Chris Upchurch