Reputation: 2157
As I know all Eclipse wizards has linear navigation in this method if Wizard class:
@Override
public void addPages() {
addPage(wizard class);
}
but at the first wizard page I would like to manage the next page. I have enum class at my WizardPage
:
enum SELECTED_ACTION {
CREATE, LOAD_LOCAL, LOAD_REMOTE
}
SELECTED_ACTION action;
and then I try to override next page method:
@Override
public IWizardPage getNextPage() {
IWizardPage nextPage = super.getNextPage();
if (nextPage == null) {
if (action != null && action == action.LOAD_REMOTE) {
nextPage = new RemotePage("");
}
if (action != null && action == action.CREATE) {
nextPage = new TestWixzard();
}
}
return nextPage;
}
with previously added pages:
@Override
public void addPages() {
startPage = new ActionPage("some title");
addPage(new ActionPage(""));
addPage(new RemotePage(""));
addPage(new TestWixzard());
}
but I usually move after ActionPage
to RemotePage
without taking into account which action I did on the ActionPage
. Maybe I did smth wrong, because when I remove at all two next pages I don't see any next button so it is wrong I think. Change action type I can in the ActionPage:
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(1, false);
container.setLayout(layout);
Group group = new Group(container, SWT.BORDER);
group.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
Button local = new Button(group, SWT.RADIO);
local.setText(Messages.SelectSolutionDialog_btn_continue_text);
local.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
switch (e.type) {
case SWT.Selection:
action = SELECTED_ACTION.LOAD_LOCAL;
getContainer().updateButtons();
}
}
});
Button load = new Button(group, SWT.RADIO);
load.setText(Messages.SelectSolutionDialog_btn_load_text);
load.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
switch (e.type) {
case SWT.Selection:
action = SELECTED_ACTION.LOAD_REMOTE;
getContainer().updateButtons();
}
}
});
Button create = new Button(group, SWT.RADIO);
create.setText(Messages.SelectSolutionDialog_btn_new_text);
create.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
switch (e.type) {
case SWT.Selection:
action = SELECTED_ACTION.CREATE;
getContainer().updateButtons();
}
}
});
setControl(container);
setPageComplete(false);
}
Upvotes: 0
Views: 36
Reputation: 111142
Don't try to create new pages in getNextPage
. Create all the pages in the addPages
method and return one of those pages in getNextPage
.
You can get an existing page with:
IWizardPage page = getWizard().getPage("pageName");
where pageName
is the name the constructor of the page specified.
Don't call super.getNextPage
. Instead just determine which page you want next and return that.
Upvotes: 1