Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Wizard questions
Wizard questions [message #335022] Tue, 17 March 2009 01:15 Go to next message
Amit Mookerjee is currently offline Amit MookerjeeFriend
Messages: 47
Registered: July 2009
Member
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] Tue, 17 March 2009 03:21 Go to previous messageGo to next message
Ben Vitale is currently offline Ben VitaleFriend
Messages: 247
Registered: July 2009
Senior Member
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 13: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 13:14 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
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 19:51 Go to previous message
Amit Mookerjee is currently offline Amit MookerjeeFriend
Messages: 47
Registered: July 2009
Member
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 Jul 03 10:23:03 GMT 2024

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

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

Back to the top