方法是正確的,如果你是這是
然後你可以add the next page dynamically之前所做的選擇,其他幾頁(也作爲described here)
但是,如果你只有一個動態內容的下一頁,你應該是一個BLE創建於onEnterPage()
method
public void createControl(Composite parent)
{
//
// create the composite to hold the widgets
//
this.composite = new Composite(parent, SWT.NONE);
//
// create the desired layout for this wizard page
//
GridLayout layout = new GridLayout();
layout.numColumns = 4;
this.composite.setLayout(layout);
// set the composite as the control for this page
setControl(this.composite);
}
void onEnterPage()
{
final MacroModel model = ((MacroWizard) getWizard()).model;
String selectedKey = model.selectedKey;
String[] attrs = (String[]) model.macroMap.get(selectedKey);
for (int i = 0; i < attrs.length; i++)
{
String attr = attrs[i];
Label label = new Label(this.composite, SWT.NONE);
label.setText(attr + ":");
new Text(this.composite, SWT.NONE);
}
pack();
}
的內容作爲Eclipse的角落文章Creating JFace Wizards所示:
我們可以覆蓋任何嚮導page.Before的getNextPage方法離開更改向導頁面順序頁面,我們在模型中保存用戶選擇的值。在我們的示例中,根據旅行的選擇,用戶接下來會看到帶有航班的頁面或開車旅行的頁面。
public IWizardPage getNextPage(){
saveDataToModel();
if (planeButton.getSelection()) {
PlanePage page = ((HolidayWizard)getWizard()).planePage;
page.onEnterPage();
return page;
}
// Returns the next page depending on the selected button
if (carButton.getSelection()) {
return ((HolidayWizard)getWizard()).carPage;
}
return null;
}
我們定義做這個初始化爲PlanePage
,onEnterPage()
的方法,我們調用此方法移動到PlanePage
的時候,也就是在第一頁的getNextPage()
方法。
這是一個非常好的模式,感謝您的偉大答案! – rooftop 2012-07-05 18:45:49