从WizardsPage1导航到下一页面时,如果单击进度栏取消按钮,如何强制用户保持在同一页面上?

问题描述 投票:0回答:1

我有如下向导页面-

enter image description here

单击下一步按钮时,进度条显示如下-

enter image description here

如果取消进度栏活动,我想让用户保持与单击下一个按钮的页面相同。我该如何实现?

我正在执行以下操作,以显示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);
    }
java eclipse-plugin swt wizard
1个回答
1
投票

在页面之间制作进度条的最佳方法是重写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);
}
© www.soinside.com 2019 - 2024. All rights reserved.