Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "FAQ How do I specify the order of pages in a wizard?"

 
m
Line 6: Line 6:
 
<tt>addPages</tt> method and add all of your pages at once. This snippet
 
<tt>addPages</tt> method and add all of your pages at once. This snippet
 
is from <tt>AddingWizard</tt> in the FAQ Examples plug-in:
 
is from <tt>AddingWizard</tt> in the FAQ Examples plug-in:
 +
 
<pre>
 
<pre>
 
   public class AddingWizard extends Wizard {
 
   public class AddingWizard extends Wizard {
Line 20: Line 21:
 
   }
 
   }
 
</pre>
 
</pre>
 
 
  
 
If you want to change the behavior of the wizard, depending on the
 
If you want to change the behavior of the wizard, depending on the
Line 32: Line 31:
 
which are called when the user clicks on '''Next''' or  
 
which are called when the user clicks on '''Next''' or  
 
'''Back''' button.
 
'''Back''' button.
 
 
 
  
 
Even with dynamic wizards, you must create at least one page  
 
Even with dynamic wizards, you must create at least one page  
Line 42: Line 38:
 
the wizard is opened.  Otherwise, the '''Next''' and  
 
the wizard is opened.  Otherwise, the '''Next''' and  
 
'''Back''' buttons will appear only if more than one page is in the page list.
 
'''Back''' buttons will appear only if more than one page is in the page list.
 
 
 
 
 
 
  
 
== See Also: ==
 
== See Also: ==
 
+
*[[FAQ_What_is_a_wizard%3F]]
 
+
*[[FAQ_How_do_I_specify_the_order_of_pages_in_a_wizard%3F]]
[[FAQ_What_is_a_wizard%3F]]
+
 
+
 
+
[[FAQ_How_do_I_specify_the_order_of_pages_in_a_wizard%3F]]
+
  
 
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>
 
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>

Revision as of 22:37, 29 May 2006

In its simplest and most common form, a wizard is made up of a static, ordered list of pages. A wizard adds pages to the list by using the Wizard.addPage method, and the Next and Back buttons simply cycle through this ordered list. For a wizard with a static set of pages, you can simply override the addPages method and add all of your pages at once. This snippet is from AddingWizard in the FAQ Examples plug-in:

   public class AddingWizard extends Wizard {
      private AddingWizardPage page1, page2;
      ...
      public void addPages() {
         page1 = new AddingWizardPage("Page1", 
            "Please enter the first number");
         addPage(page1);
         page2 = new AddingWizardPage("Page2", 
            "Enter another number");
         addPage(page2);
      }
   }

If you want to change the behavior of the wizard, depending on the values that are entered, you can dynamically create new pages or change the page order after the wizard is opened. Pages must still be added to the wizard by using the addPage method, but the progression of pages through the wizard can change, depending on the user&#146;s input. This ordering is changed by overriding the wizard methods getNextPage and getPreviousPage, which are called when the user clicks on Next or Back button.

Even with dynamic wizards, you must create at least one page before the wizard is opened. If only one page is added at the beginning, but more pages will be added later on, you will need to call Wizard.setForcePreviousAndNextButtons(true) before the wizard is opened. Otherwise, the Next and Back buttons will appear only if more than one page is in the page list.

See Also:


This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.

Back to the top