Can you disable the back button in a JFace wizard?
Asked Answered
S

4

7

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?

Smoothen answered 5/9, 2008 at 13:48 Comment(0)
K
12

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

Konikow answered 5/9, 2008 at 13:51 Comment(0)
S
7

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

Saturn answered 21/7, 2011 at 18:6 Comment(0)
H
3

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.

Hazelton answered 5/9, 2008 at 13:57 Comment(0)
B
0

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.

Bible answered 18/9, 2008 at 13:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.