不過(guò)還有另外一個(gè)問(wèn)題沒(méi)有解決,就是如果我現(xiàn)在一個(gè)Wizard中有a,b兩個(gè)WizardPage,目前我停留在b WizardPage中,我現(xiàn)在點(diǎn)擊back回到a WizardPage中,然后對(duì)內(nèi)容做了修改,此次我希望再回到b WizardPage的時(shí)候,里面的內(nèi)容也同時(shí)跟著發(fā)生改變,但是僅僅是復(fù)寫(xiě)Wizard的createPageControls()方法是無(wú)法實(shí)現(xiàn),我們通過(guò)查看源代碼,發(fā)現(xiàn)在org.eclipse.jface.wizard.WizardDialog.updateForPage(IWizardPage page)中:
java 代碼
- private void updateForPage(IWizardPage page) {
- // ensure this page belongs to the current wizard
- if (wizard != page.getWizard()) {
- setWizard(page.getWizard());
- }
- // ensure that page control has been created
- // (this allows lazy page control creation)
- if (page.getControl() == null) {
- page.createControl(pageContainer);
- // the page is responsible for ensuring the created control is accessable
- // via getControl.
- Assert.isNotNull(page.getControl());
- // ensure the dialog is large enough for this page
- updateSize(page);
- }
- // make the new page visible
- IWizardPage oldPage = currentPage;
- currentPage = page;
- currentPage.setVisible(true);
- if (oldPage != null) {
- oldPage.setVisible(false);
- }
- // update the dialog controls
- update();
- }
也就是在調(diào)用WizardPage的createControl()方法之前要做一個(gè)判斷page.getControl() == null,因此我們只要將想辦法在調(diào)轉(zhuǎn)到某個(gè)WizardPage的時(shí)候,將其control設(shè)置為null就可以了.于是我們?cè)赼 WizardPage中引起b WizardPage的內(nèi)容發(fā)生改變的方法中添加如下代碼:
java 代碼
- // 對(duì)參數(shù)頁(yè)必須重繪
- IWizardPage page = getNextPage();
- if (page.getControl() != null)
- page.dispose();
然后復(fù)寫(xiě)b WizardPage的dispose方法:
java 代碼
- public void dispose() {
- super.dispose();
- setControl(null);
- }
這樣我們就大功告成了.
安徽新華電腦學(xué)校專(zhuān)業(yè)職業(yè)規(guī)劃師為你提供更多幫助【在線(xiàn)咨詢(xún)】