Reputation: 282
i am trying to create a jface wizard. In my wizard i have my "startpage". The options i choose in my "startpage" depending on how many pages will follow. But in my opinion its not possible to do that. Because the addPages() method getting called after the wizard was started. The addPage() method is private. But i need to add my pages there, because when i do it somewhere else, the createControl(Composite parent) don't getting called.
Is there any solution how to solve that problem? I thought about writing a own method sth. like this:
public void addNewPage() {
Page page = new Page("pagename");
page.createControl(parent);
page.setDescription("");}
...
But it doesn't work. Do you guys have any solution for my problem?
Upvotes: 0
Views: 353
Reputation: 71
You can do so by overriding org.eclipse.jface.wizard.Wizard.getNextPage
to return a new page if conditions are met (conditionForMorePages
in the snippet below):
@Override
public IWizardPage getNextPage() {
IWizardPage nextPage = super.getNextPage(page);
if (nextPage == null) {
if (conditionForMorePages){
// we need an additional page.
IWizardPage nextPage = new MyAdditionalPage();
}
}
return nextPage;
}
If your wizard start with only one page, "back" and "next" buttons do not appear by default. If there is a chance you have more steps coming up dynamically, you want to display the navigation buttons. You can do so by setting the proper flag using the API
public void setForcePreviousAndNextButtons(boolean b)
Upvotes: 0
Reputation: 111142
You could add all your pages in the wizard addPages
and then override getNextPage
to control which pages is displayed when Next is pressed.
If that is not enough you can always write your own implementation of the IWizard
interface.
Upvotes: 1