Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Wizard questions
Wizard questions [message #335022] Mon, 16 March 2009 21:15 Go to next message
Eclipse UserFriend
I am developing a wizard with two pages. The layout of page 2 depends on
the selection(s) made in page 1. If the user goes back to page 1 and
changes his selection, I want page 2 to be regenerated - essentially
invoke the 'createControl' method of page 2. What is the recommended way
of doing this?

I tried overriding the 'setVisible' method of the page to update my
widgets but it does not completely address my problem since in some cases
I may have to change the widget layout (e.g. add additional combo boxes)
of my page.

Thanks.

Amit Mookerjee
Re: Wizard questions [message #335025 is a reply to message #335022] Mon, 16 March 2009 23:21 Go to previous messageGo to next message
Eclipse UserFriend
If you prefer to do widget swapping, org.eclipse.ui.part.PageBook class
may be useful here.

Another approach, if you only have a few variants of page#2 (say 2a and
2b), is to actually have separate pages for the variants, and override
getNextPage on your Wizard class, to answer the correct page depending
on the selection. Might be tricky if you are planning on NOT wiping out
the data in the second page(s) when they change selection.

Just some ideas.

Ben

Amit Mookerjee wrote:
> I am developing a wizard with two pages. The layout of page 2 depends on
> the selection(s) made in page 1. If the user goes back to page 1 and
> changes his selection, I want page 2 to be regenerated - essentially
> invoke the 'createControl' method of page 2. What is the recommended way
> of doing this?
>
> I tried overriding the 'setVisible' method of the page to update my
> widgets but it does not completely address my problem since in some
> cases I may have to change the widget layout (e.g. add additional combo
> boxes) of my page.
> Thanks.
>
> Amit Mookerjee
>
>
>
Re: Wizard questions [message #335030 is a reply to message #335022] Tue, 17 March 2009 09:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

On 3/16/2009 9:15 PM, Amit Mookerjee wrote:
> I am developing a wizard with two pages. The layout of page 2 depends on
> the selection(s) made in page 1. If the user goes back to page 1 and
> changes his selection, I want page 2 to be regenerated - essentially
> invoke the 'createControl' method of page 2. What is the recommended way
> of doing this?

One way would be to use a org.eclipse.swt.custom.StackLayout on the
second page to contain the two different Composites. That way you can
easily change the topControl based on the first page's state.
The Javadoc for StackLayout has a code example that demonstrates its usage.

Hope this helps,
Eric
Re: Wizard questions [message #335106 is a reply to message #335022] Mon, 23 March 2009 09:14 Go to previous messageGo to next message
Eclipse UserFriend
Amit Mookerjee wrote:
> I am developing a wizard with two pages. The layout of page 2 depends on
> the selection(s) made in page 1. If the user goes back to page 1 and
> changes his selection, I want page 2 to be regenerated - essentially
> invoke the 'createControl' method of page 2. What is the recommended way
> of doing this?
>
> I tried overriding the 'setVisible' method of the page to update my
> widgets but it does not completely address my problem since in some
> cases I may have to change the widget layout (e.g. add additional combo
> boxes) of my page.
> Thanks.

A third idea is to override setPreviousPage of page 2 of the
corresponding wizard page and to dispose the control in case of your
conditions, e.g.

@Override
public void setPreviousPage(IWizardPage page) {
Control ctrl = getControl();
if (ctrl != null) {
if (needNewPage()) {
ctrl.dispose();
setControl(null);
setPageComplete(false);
...
}
}
...
super.setPreviousPage(page);
}

To make this approach reasonable I suggest to provide something like

public abstract class LazyWizard extends Wizard {

@Override
public void createPageControls(Composite pageContainer) {
// Do nothing to ensure that pages are lazily created!
}

}

as the base class of your wizard to prevent that your pages are all
created, if the wizard starts to run.

HTH & Greetings from Bremen,

Daniel Krügler
Re: Wizard questions [message #335254 is a reply to message #335106] Fri, 27 March 2009 15:51 Go to previous message
Eclipse UserFriend
Daniel,
Thanks for the suggestion. I solved the problem by dynamically creating a
new page (if required) in the 'getNextPage' method of page 1. This seems
to work pretty well for my wizard.

Thanks for the help.

Amit
Previous Topic:eclipse-Automated-Tests-3.4.zip produces compile errors
Next Topic:Project clean event?
Goto Forum:
  


Current Time: Wed Apr 30 18:36:27 EDT 2025

Powered by FUDForum. Page generated in 0.05706 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top