[英]How to dynamically add JFace WizardPage
I'm currently trying to implement an "import wizard" for an application using JFace Wizard. 我目前正在尝试使用JFace向导为应用程序实现“导入向导”。
Basically I have to add the next page "just in time" based upon the input from the user, as each "step" within the wizard is depends upon the previous ones. 基本上,我必须根据用户的输入添加下一页“及时”,因为向导中的每个“步骤”都取决于前一个。
So, in the constructor of WizardImport I would add the first page, using: 因此,在WizardImport的构造函数中,我将使用以下命令添加第一页:
addPage(new WizardImportSourcePage(data));
Within this page (WizardImportSourcePage) I would then like to add the next page, depending upon the chosen source, eg: 然后,我要在此页面(WizardImportSourcePage)中添加下一页,具体取决于所选的来源,例如:
btnCsv.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
data.getWizard().addPage(new WizardImportSourcePage(data));
setPageComplete(true);
}
});
As you can see all of this happens in the appropriate Listener. 如您所见,所有这些都发生在适当的侦听器中。 Unfortunately this doesn't work.
不幸的是,这不起作用。 The Wizard is missing the "Next" button, but only shows the "Finish" button, as it doesn't know anything about the next page until the button is actually being pressed.
该向导缺少“下一步”按钮,但仅显示“完成”按钮,因为在实际按下该按钮之前,它对下一页一无所知。 I've already tried to invoke
updateButtons()
, but it didn't change anything. 我已经尝试调用
updateButtons()
,但是它没有任何改变。
So, any suggestions how to make it work? 那么,有什么建议可以使它起作用吗? What would be the right way to build the wizard pages dynamically?
动态构建向导页面的正确方法是什么? Most tutorials seem to assume that the pages are created in the beginning and only the ordering is changed using
getNextPage()
. 大多数教程似乎都假定页面是在开始时创建的,只有使用
getNextPage()
才能更改顺序。
In your code extending Wizard
you can override 在代码扩展
Wizard
您可以覆盖
public IWizardPage getNextPage(IWizardPage page)
which lets you decide which page to return next given the current wizard page (there is also a getPreviousPage
. 在给定当前向导页面的情况下,它可以让您决定下一个要返回的页面(还有一个
getPreviousPage
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.