1 6 package com.nightlabs.rcp.wizard; 7 8 import org.eclipse.jface.dialogs.IDialogConstants; 9 import org.eclipse.jface.window.Window; 10 import org.eclipse.jface.wizard.IWizardPage; 11 import org.eclipse.jface.wizard.WizardDialog; 12 import org.eclipse.swt.widgets.Button; 13 import org.eclipse.swt.widgets.Composite; 14 import org.eclipse.swt.widgets.Control; 15 import org.eclipse.swt.widgets.Shell; 16 import org.eclipse.ui.internal.Workbench; 17 18 19 23 public class DynamicPathWizardDialog extends WizardDialog { 24 25 private DynamicPathWizard dynamicWizard; 26 27 public DynamicPathWizardDialog(DynamicPathWizard wizard) { 28 this(Workbench.getInstance().getActiveWorkbenchWindow().getShell(),wizard); 29 } 30 31 public DynamicPathWizardDialog(Shell shell, DynamicPathWizard wizard) { 32 super(shell, wizard); 33 dynamicWizard = wizard; 34 dynamicWizard.setDynamicWizardDialog(this); 35 } 36 37 43 public void update() { 44 super.update(); 45 } 46 47 52 public Button getButton(int id) { 53 return super.getButton(id); 55 } 56 57 protected void backPressed() { 58 buttonBar.setFocus(); super.backPressed(); 60 if (dynamicWizard.getPopulator() != null && 61 getCurrentPage() == dynamicWizard.getWizardEntryPage()) { 62 dynamicWizard.removeAllDynamicWizardPages(); 63 } 64 } 65 66 protected void nextPressed() { 67 buttonBar.setFocus(); if (getCurrentPage() == dynamicWizard.getWizardEntryPage()) { 69 if (dynamicWizard.getPopulator() != null) 70 dynamicWizard.getPopulator().addDynamicWizardPages(dynamicWizard); 71 } 72 super.nextPressed(); 73 } 74 75 78 protected void finishPressed() 79 { 80 buttonBar.setFocus(); super.finishPressed(); 82 } 83 84 87 protected void cancelPressed() 88 { 89 buttonBar.setFocus(); super.cancelPressed(); 91 } 92 93 94 95 protected Control createContents(Composite parent) { 96 Control result = super.createContents(parent); 97 if (dynamicWizard.getWizardEntryPage() instanceof IDynamicPathWizardPage) 98 dynamicWizard.getWizardEntryPage().onShow(); 99 return result; 100 } 101 102 protected void buttonPressed(int buttonId) { 103 if (buttonId == IDialogConstants.FINISH_ID) { 104 IWizardPage currPage = getCurrentPage(); 105 if (currPage instanceof IDynamicPathWizardPage) 106 ((IDynamicPathWizardPage)currPage).onHide(); 107 } 108 super.buttonPressed(buttonId); 109 if (getReturnCode() != Window.OK) { 110 IWizardPage currPage = getCurrentPage(); 111 if (currPage instanceof IDynamicPathWizardPage) 112 ((IDynamicPathWizardPage)currPage).onShow(); 113 } 114 } 115 116 119 public void showPage(IWizardPage page) 120 { 121 IWizardPage currPage = getCurrentPage(); 122 123 if (currPage == page) 124 return; 125 126 if (currPage instanceof IDynamicPathWizardPage) 127 ((IDynamicPathWizardPage)currPage).onHide(); 128 129 super.showPage(page); 130 131 if (page instanceof IDynamicPathWizardPage) 132 ((IDynamicPathWizardPage)page).onShow(); 133 } 134 } 135 | Popular Tags |