What event can i use between Wizard Pages to load new data to default fields? [message #275358] |
Sun, 07 November 2004 10:59  |
Eclipse User |
|
|
|
Originally posted by: stephanie.acm.org
I'm new to using swt and also to using eclipse to write wizard plugins. I
apologize if this question has been asked earlier.
I am writing a preview page which serves to give the user a summary of
what they are about to create when they click finish. I need to be able
to pre-populate this preview page with data from an external source and it
needs to happen after "next" is clicked on the previous wizard page. What
event do I modify to do this?
Iis there a postcreate method or anything that I can use to set up my next
wizard page from the previous wizard page, or some sort of load event?
Please Help!
Many thanks in advance,
Steph
|
|
|
|
|
|
|
|
|
Re: What event can i use between Wizard Pages to load new data to default fields? [message #276081 is a reply to message #276067] |
Wed, 17 November 2004 09:07  |
Eclipse User |
|
|
|
The problem with this solution is that getNextPage() is also called when
determining the enablement of buttons so you may be doing extra work in
some cases. If this is not an issue, then the solution is adequate. In
the CVS plugin, our preloading may contact the server so we need to
ensure that it only happens when necessay. Hence, we have developed some
additional infrastructure for wizards.
All the CVS wizards that require the ability to preload pages implement
the following interface:
public interface ICVSWizard extends IWizard {
public IWizardPage getNextPage(
IWizardPage page,
boolean aboutToShow);
}
The aboutToShow boolean is provided to the wizard to indicate whether
the page is being queried because it is about to be shown or because it
is being queries for button enablement state.
All CVS wizard pages are sublcasses of CVSWizardPage and override the
following two methods from WizardPage to pass the proper boolean if the
containing wizard is an ICVSWizard:
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.WizardPage#getNextPage()
*/
public IWizardPage getNextPage() {
ICVSWizard w = getCVSWizard();
if (w != null) {
return w.getNextPage(this,
true /* about to show */);
}
return super.getNextPage();
}
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.WizardPage#canFlipToNextPage()
*/
public boolean canFlipToNextPage() {
ICVSWizard w = getCVSWizard();
if (w != null) {
return isPageComplete() &&
w.getNextPage(this,
false /* about to show */) != null;
}
return super.canFlipToNextPage();
}
The getCVSWizard() method just does an instanceof check on the wizard
returned by getWizard() and either returns the wizard cast to an
ICVSWizard or null if the wizard does not implement the interface.
The wizard that implements ICVSWizard can now determine if the page is
being requested because it is about to be shown or because enablement of
buttons is being checked.
If you want to see how it is used, these classes can be found in the
org.eclipse.team.cvs.ui plugin from Eclipse 3.0 or beyond.
Michael
S.Hazlewood wrote:
> slubicki wrote:
>
>> In your wizard page you can override setVisible(boolean). So you
>> would have
>
> something like this:
>
>> public void setVisible(boolean visible) {
>> if (visible) {
>> // insert your update code here
>> }
>> }
>
>
>> - D. Slubicki
>
>
> I had the same question - and someone was kind enough to email me the
> solution as follows:
>
> override the getNextPage method on your wizard for the particular page
> that you're going to load with the logic you want to execute before
> loading.
>
> for example:
>
> public IWizardPage getNextPage(IWizard page) {
> if (page instanceof WizardPageA) {
> IWizardPage b = super.getNextPage(page);
> if (b instanceof IWizardPageB){
> IWizardPageB myPage = (IWizardPageB) b;
> myPage.performedSomeTreatment();
> return myPage;
> }
> }
> return super.getNextPage(page);
> }
>
|
|
|
Powered by
FUDForum. Page generated in 0.12529 seconds