简体   繁体   English

如何通过JFace Eclipse向导页面执行自定义导航?

[英]How to perform custom navigation through JFace Eclipse Wizard pages?

I have Eclipse JFace wizard with five pages. 我有五个页面的Eclipse JFace向导。 In the first, I have check buttons to select which pages are to be shown - if you check all, you will pass through the whole wizard, but you can also select only specific pages, and then only that pages will be shown. 首先,我有一个选择按钮以选择要显示的页面-如果全部选中,将遍历整个向导,但是您也可以仅选择特定页面,然后仅显示那些页面。

So far, I used iterator with enum objects representing each page. 到目前为止,我将迭代器与代表每个页面的枚举对象一起使用。 I called next object of iterator in getNextPage function and its if..else cases to return certain pages in proper order. 我在getNextPage函数及其if..else情况下调用了迭代器的下一个对象,以正确的顺序返回某些页面。 The problem is, getNextPage is called not only when Next button is pressed, but also when pageComplete event firing, etc. so iterator does not update its cursor when I want, and it ends up to fast. 问题是,不仅要在按下“ 下一步”按钮时调用getNextPage ,而且还要在触发getNextPage事件等时调用getNextPage ,所以迭代器不会在需要时不更新其光标,并且最终速度很快。 This is snippet of my assumption: 这是我的假设的摘要:

else if(page == FirstPage )
{
    // iterator contains SelectedAction - enum objects representing pages
    this.pageIterator = page.getWizardPagesList().iterator();

    if(pageIterator.hasNext())
    {
        return selectedActionToPage(pageIterator.next());
    }
}
else
{
    if(pageIterator.hasNext())
    {
        SelectedAction action = pageIterator.next();
        if(!pageIterator.hasNext())
        {
         // we check if current page was last one
            setFinished(true);
            setLastPage(selectedActionToPage(action));
        }
        // selectedActionToPage converts enum object to WizardPage class
        return selectedActionToPage(action);
    }
    else if((pageIterator != null) && !pageIterator.hasNext())
    {
        return page;
    }
}
return page;

Especially, things I want to know are: 特别是,我想知道的是:

First, is there any other way to capture Next button click? 首先,还有其他方法可以捕获“ 下一步”按钮单击吗? I know there is NextPressed method in WizardDialog class, but I don't know how to call its instance from my Wizard class, or WizardPage. 我知道WizardDialog类中有NextPressed方法,但是我不知道如何从我的Wizard类或WizardPage中调用其实例。 Second, is there other way to customize navigation through pages, to go to specified pages? 其次,还有其他方法可以自定义页面导航,以转到指定页面吗?

No, you should not try to intercept the Next button click that logic is private to the wizard dialog and you should not be trying to interfere with it, 不,您不应该尝试拦截“下一步”按钮,因为该逻辑是向导对话框的私有属性,并且您不应该试图干预它,

You can either override the WizardPage : 您可以覆盖WizardPage

public IWizardPage getNextPage()

method or you can override the Wizard 方法,或者您可以覆盖Wizard

public IWizardPage getNextPage(IWizardPage page)

You may also need to override the matching getPreviousPage method. 您可能还需要覆盖匹配的getPreviousPage方法。 You must make your code work regardless of when the method is called. 无论何时调用该方法,都必须使代码正常工作。 You are given the information about which is the current page, your code should use that to determine the next page. 您将获得有关当前页面的信息,您的代码应使用该信息来确定下一页。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM