简体   繁体   中英

How to dynamically add JFace WizardPage

I'm currently trying to implement an "import wizard" for an application using JFace Wizard.

Basically I have to add the next page "just in time" based upon the input from the user, as each "step" within the wizard is depends upon the previous ones.

So, in the constructor of WizardImport I would add the first page, using:

    addPage(new WizardImportSourcePage(data));

Within this page (WizardImportSourcePage) I would then like to add the next page, depending upon the chosen source, eg:

    btnCsv.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent arg0) {

            data.getWizard().addPage(new WizardImportSourcePage(data));

            setPageComplete(true);

        }
    });

As you can see all of this happens in the appropriate Listener. Unfortunately this doesn't work. The Wizard is missing the "Next" button, but only shows the "Finish" button, as it doesn't know anything about the next page until the button is actually being pressed. I've already tried to invoke updateButtons() , but it didn't change anything.

So, any suggestions how to make it work? What would be the right way to build the wizard pages dynamically? Most tutorials seem to assume that the pages are created in the beginning and only the ordering is changed using getNextPage() .

In your code extending Wizard you can override

public IWizardPage getNextPage(IWizardPage page)

which lets you decide which page to return next given the current wizard page (there is also a getPreviousPage .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM