我有如下向导页面-
单击下一步按钮时,进度条显示如下-
如果取消进度栏活动,我想让用户保持与单击下一个按钮的页面相同。我该如何实现?
我正在执行以下操作,以显示WizardPage2的进度条
@Override
public void setVisible(boolean visible) {
if (visible) {
InterfacePage interfacePage = (InterfacePage) (getWizard().getPage("NewInterfacePage"));
String interfaceId = interfacePage.getInterfaceID();
try {
getContainer().run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor arg0) throws InvocationTargetException, InterruptedException {
int amount = 10;
arg0.beginTask("Fetching details from External System...", 10);
for (int i = 0; i < amount; i++) {
arg0.internalWorked(1);
Thread.sleep(2000);
if (arg0.isCanceled()) {
cancelled = true;
break;
}
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
super.setVisible(visible);
}
在页面之间制作进度条的最佳方法是重写getNextPage
类的Wizard
方法。 getNextPage
可以返回null
以停止更改。
@Override
public IWizardPage getNextPage(final IWizardPage page)
{
if (!(page instanceof YourFirstPage)) // Next page from first page?
return super.getNextPage(page);
// Moving from first to second page, run the progress
try
{
getContainer().run .....
}
catch (InvocationTargetException ex)
{
// TODO deal with error
}
catch (InterruptedException ex)
{
// Cancelled
return null; // Stay on same page
}
return super.getNextPage(page);
}