1 11 package org.eclipse.jface.wizard; 12 13 import org.eclipse.jface.dialogs.DialogPage; 14 import org.eclipse.jface.dialogs.IDialogSettings; 15 import org.eclipse.jface.resource.ImageDescriptor; 16 import org.eclipse.core.runtime.Assert; 17 import org.eclipse.swt.graphics.Image; 18 import org.eclipse.swt.widgets.Shell; 19 20 56 public abstract class WizardPage extends DialogPage implements IWizardPage { 57 58 61 private String name; 62 63 67 private IWizard wizard = null; 68 69 72 private boolean isPageComplete = true; 73 74 78 private IWizardPage previousPage = null; 79 80 86 protected WizardPage(String pageName) { 87 this(pageName, null, (ImageDescriptor) null); 88 } 89 90 99 protected WizardPage(String pageName, String title, 100 ImageDescriptor titleImage) { 101 super(title, titleImage); 102 Assert.isNotNull(pageName); name = pageName; 104 } 105 106 114 public boolean canFlipToNextPage() { 115 return isPageComplete() && getNextPage() != null; 116 } 117 118 125 protected IWizardContainer getContainer() { 126 if (wizard == null) { 127 return null; 128 } 129 return wizard.getContainer(); 130 } 131 132 137 protected IDialogSettings getDialogSettings() { 138 if (wizard == null) { 139 return null; 140 } 141 return wizard.getDialogSettings(); 142 } 143 144 147 public Image getImage() { 148 Image result = super.getImage(); 149 150 if (result == null && wizard != null) { 151 return wizard.getDefaultPageImage(); 152 } 153 154 return result; 155 } 156 157 160 public String getName() { 161 return name; 162 } 163 164 168 public IWizardPage getNextPage() { 169 if (wizard == null) { 170 return null; 171 } 172 return wizard.getNextPage(this); 173 } 174 175 180 public IWizardPage getPreviousPage() { 181 if (previousPage != null) { 182 return previousPage; 183 } 184 185 if (wizard == null) { 186 return null; 187 } 188 189 return wizard.getPreviousPage(this); 190 } 191 192 199 public Shell getShell() { 200 201 IWizardContainer container = getContainer(); 202 if (container == null) { 203 return null; 204 } 205 206 return container.getShell(); 208 } 209 210 213 public IWizard getWizard() { 214 return wizard; 215 } 216 217 223 protected boolean isCurrentPage() { 224 return (getContainer() != null && this == getContainer() 225 .getCurrentPage()); 226 } 227 228 233 public boolean isPageComplete() { 234 return isPageComplete; 235 } 236 237 242 public void setDescription(String description) { 243 super.setDescription(description); 244 if (isCurrentPage()) { 245 getContainer().updateTitleBar(); 246 } 247 } 248 249 254 public void setErrorMessage(String newMessage) { 255 super.setErrorMessage(newMessage); 256 if (isCurrentPage()) { 257 getContainer().updateMessage(); 258 } 259 } 260 261 266 public void setImageDescriptor(ImageDescriptor image) { 267 super.setImageDescriptor(image); 268 if (isCurrentPage()) { 269 getContainer().updateTitleBar(); 270 } 271 } 272 273 278 public void setMessage(String newMessage, int newType) { 279 super.setMessage(newMessage, newType); 280 if (isCurrentPage()) { 281 getContainer().updateMessage(); 282 } 283 } 284 285 296 public void setPageComplete(boolean complete) { 297 isPageComplete = complete; 298 if (isCurrentPage()) { 299 getContainer().updateButtons(); 300 } 301 } 302 303 306 public void setPreviousPage(IWizardPage page) { 307 previousPage = page; 308 } 309 310 315 public void setTitle(String title) { 316 super.setTitle(title); 317 if (isCurrentPage()) { 318 getContainer().updateTitleBar(); 319 } 320 } 321 322 325 public void setWizard(IWizard newWizard) { 326 wizard = newWizard; 327 } 328 329 333 public String toString() { 334 return name; 335 } 336 } 337 | Popular Tags |