1 11 package org.eclipse.ui.internal.ide.dialogs; 12 13 import org.eclipse.jface.wizard.IWizardPage; 14 import org.eclipse.jface.wizard.Wizard; 15 import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; 16 import org.eclipse.ui.internal.ide.dialogs.MultiStepConfigureWizardPage.WizardStepContainer; 17 18 31 public abstract class MultiStepWizard extends Wizard { 32 private MultiStepWizardDialog wizardDialog; 33 34 private MultiStepReviewWizardPage reviewPage; 35 36 private MultiStepConfigureWizardPage configPage; 37 38 41 protected MultiStepWizard() { 42 super(); 43 setNeedsProgressMonitor(true); 44 } 45 46 51 protected abstract void addCustomPages(); 52 53 56 public final void addPages() { 57 super.addPages(); 58 addCustomPages(); 59 60 reviewPage = new MultiStepReviewWizardPage( 61 "multiStepReviewWizardPage", this); reviewPage.setTitle(getReviewPageTitle()); 63 reviewPage.setDescription(getReviewPageDescription()); 64 this.addPage(reviewPage); 65 66 configPage = new MultiStepConfigureWizardPage( 67 "multiStepConfigureWizardPage"); configPage.setTitle(getConfigurePageTitle()); 69 configPage.setDescription(getConfigurePageDescription()); 70 configPage.setWizardDialog(wizardDialog); 71 this.addPage(configPage); 72 } 73 74 77 public boolean canFinish() { 78 if (getContainer().getCurrentPage() == reviewPage) { 79 return canFinishOnReviewPage(); 80 } else if (isConfigureStepMode()) { 81 return getStepContainer().canWizardFinish(); 82 } else { 83 return false; 84 } 85 } 86 87 94 protected abstract boolean canFinishOnReviewPage(); 95 96 99 public void dispose() { 100 super.dispose(); 101 wizardDialog = null; 102 } 103 104 108 protected abstract String getConfigurePageTitle(); 109 110 114 protected abstract String getConfigurePageDescription(); 115 116 120 protected abstract String getReviewPageTitle(); 121 122 134 protected String getFinishStepLabel(WizardStep[] steps) { 135 return IDEWorkbenchMessages.MultiStepWizard_finishLabel; 136 } 137 138 141 public final IWizardPage getPreviousPage(IWizardPage page) { 142 if (page == configPage) { 143 return null; 144 } else { 145 return super.getPreviousPage(page); 146 } 147 } 148 149 153 protected abstract String getReviewPageDescription(); 154 155 159 WizardStepContainer getStepContainer() { 160 return configPage.getStepContainer(); 161 } 162 163 169 abstract boolean handleMissingStepWizard(WizardStep step); 170 171 174 boolean isConfigureStepMode() { 175 return getContainer().getCurrentPage() == configPage; 176 } 177 178 181 public final boolean performCancel() { 182 if (isConfigureStepMode()) { 183 return getStepContainer().performCancel(); 184 } else { 185 return true; 186 } 187 } 188 189 192 public boolean performFinish() { 193 if (getContainer().getCurrentPage() == reviewPage) { 196 getContainer().showPage(configPage); 197 return false; 198 } 199 200 return true; 204 } 205 206 209 public final WizardStep[] getSteps() { 210 if (reviewPage != null) { 211 return reviewPage.getSteps(); 212 } else { 213 return new WizardStep[0]; 214 } 215 } 216 217 222 public final void setSteps(WizardStep[] steps) { 223 if (reviewPage != null) { 224 reviewPage.setSteps(steps); 225 } 226 if (configPage != null) { 227 configPage.setSteps(steps); 228 } 229 } 230 231 235 void setWizardDialog(MultiStepWizardDialog dialog) { 236 wizardDialog = dialog; 237 if (configPage != null) { 238 configPage.setWizardDialog(wizardDialog); 239 } 240 } 241 } 242 | Popular Tags |