Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Wizard with 2 pages: how can I get information of the first page ?
Wizard with 2 pages: how can I get information of the first page ? [message #459170] Tue, 02 August 2005 20:39 Go to next message
Olivier is currently offline OlivierFriend
Messages: 24
Registered: July 2009
Junior Member
Hi,

I want to write a wizard plug in with two pages.
The first page, the user fills the form (I have one SWT Text) and I
want to display in the second page in another SWT Text what the user has
typed in the SWT Text.

How can I do that ?

public class UDDIWizard extends Wizard implements INewWizard{
public void addPages() {
page = new UDDIWizardPage1("Page 1");
addPage(page);
page = new UDDIWizardPage2("Page 2");
addPage(page);
}
}

public class UDDIWizardPage1 extends WizardPage{
private Text wsdlText;
public void createControl(Composite parent) {
...
wsdlText = new Text(controls, SWT.BORDER | SWT.SINGLE);
...
}

public class UDDIWizardPage2 extends WizardPage {
public void createControl(Composite parent) {
new Text(controls, SWT.NONE).setText(?????????);

}

Thanks.

Olivier
Re: Wizard with 2 pages: how can I get information of the first page ? [message #459171 is a reply to message #459170] Wed, 03 August 2005 06:11 Go to previous messageGo to next message
WojT is currently offline WojTFriend
Messages: 11
Registered: July 2009
Junior Member
> Hi,
>
> I want to write a wizard plug in with two pages.
> The first page, the user fills the form (I have one SWT Text) and I
> want to display in the second page in another SWT Text what the user has
> typed in the SWT Text.

Use some model which can store your data between pages.
Like this:
class Model{
String text;
setText(){...};
getText(){...};
}

>
> How can I do that ?
>
> public class UDDIWizard extends Wizard implements INewWizard{

Model model = new Model();
> public void addPages() {
> page = new UDDIWizardPage1("Page 1");
page.setModel(model);
> addPage(page);
> page = new UDDIWizardPage2("Page 2");
page.setModel(model);
> addPage(page);
> }
> }
>
> public class UDDIWizardPage1 extends WizardPage{
> private Text wsdlText;
private Model model;
> public void createControl(Composite parent) {
> ..
> wsdlText = new Text(controls, SWT.BORDER | SWT.SINGLE);

public IWizardPage getNextPage(){
model.setText(wsdlText.getText());
}

public void setModel(Model model){
this.model = model;
}
> ..
> }
>
> public class UDDIWizardPage2 extends WizardPage {
> public void createControl(Composite parent) {

String text = model.getText();
> new Text(controls, SWT.NONE).setText(text);


>
> }

public void setModel(Model model){
this.model = model;
}


I think that should work....

...::WojT::..
Re: Wizard with 2 pages: how can I get information of the first page ? [message #459174 is a reply to message #459171] Wed, 03 August 2005 08:44 Go to previous messageGo to next message
Olivier is currently offline OlivierFriend
Messages: 24
Registered: July 2009
Junior Member
Thanks for your answer.

But it doesn't work, the second page is built when the addPages() method
of the Wizard class is invoked and the user hasn't yet typed in the first
page.

So it displays a null pointer or the default value specified in the Model
class.

If anyone has the solution of my problem...

Thanks.

Olivier
Re: Wizard with 2 pages: how can I get information of the first page ? [message #459176 is a reply to message #459174] Wed, 03 August 2005 08:48 Go to previous messageGo to next message
Stefan Langer is currently offline Stefan LangerFriend
Messages: 236
Registered: July 2009
Senior Member
Olivier wrote:
> Thanks for your answer.
>
> But it doesn't work, the second page is built when the addPages() method
> of the Wizard class is invoked and the user hasn't yet typed in the
> first page.
>
> So it displays a null pointer or the default value specified in the
> Model class.
>
> If anyone has the solution of my problem...
>
> Thanks.
>
> Olivier
>
What is wrong with the model returning a default value such as an empty
textfield. Since the firstpage hasn't been filled yet there can possibly
be no value in the model.

Don't forget to persist the model and restore it inbetween platform
invocations.

Regards
Stefan
Re: Wizard with 2 pages: how can I get information of the first page ? [message #459177 is a reply to message #459176] Wed, 03 August 2005 08:57 Go to previous message
Vincent Etter is currently offline Vincent EtterFriend
Messages: 72
Registered: July 2009
Member
Hi !

I had the same problem : I wanted to show the user what he had selected
during the wizard on the last page so I looked for a method which is
only called when the page is displayed and filled my controls in it. The
method I found is canFlipToNextPage() :

public void createControl(Composite parent) {
this.parent = parent;
control = new Composite(parent, SWT.NONE);
FormLayout layout = new FormLayout();
layout.marginHeight = 15;
layout.marginWidth = 15;
control.setLayout(layout);

setControl(control);
}

public boolean canFlipToNextPage() {
this.backupItem = ((AddFolderWizard)
getWizard()).setFilter.getBackupItem();
control.dispose();
createControl(parent);
createControls();
control.pack();
control.update();

return false;
}

private void createControls() {
// dialog title
Label label = new Label(control, SWT.NONE);

label.setText(Messages.getString("AddFolderWizard.finishPage.abstract.title "));
//$NON-NLS-1$
FormData data = new FormData();
data.top = new FormAttachment(0, 0);
data.left = new FormAttachment(0, 0);
label.setLayoutData(data);

...
}

I dispose and rebuild the controls because there was a refresh
problem... Hope it will help ;) !
Previous Topic:How to prevent dialogs from being closed on ESC pressed
Next Topic:How to remove a control from a composite?
Goto Forum:
  


Current Time: Sat Apr 20 02:42:31 GMT 2024

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

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

Back to the top