1 11 package org.eclipse.ltk.ui.refactoring; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.jface.dialogs.DialogSettings; 16 import org.eclipse.jface.dialogs.IDialogSettings; 17 import org.eclipse.jface.wizard.IWizard; 18 import org.eclipse.jface.wizard.WizardPage; 19 20 import org.eclipse.ltk.core.refactoring.Refactoring; 21 22 37 public abstract class RefactoringWizardPage extends WizardPage { 38 39 public static final String REFACTORING_SETTINGS= "org.eclipse.ltk.ui.refactoring.settings"; 41 42 private final boolean fConventionalWizard; 43 44 59 protected RefactoringWizardPage(String name, boolean wizard) { 60 super(name); 61 fConventionalWizard= wizard; 62 } 63 64 70 protected RefactoringWizardPage(String name) { 71 super(name); 72 fConventionalWizard= false; 73 } 74 75 81 public void setWizard(IWizard newWizard) { 82 Assert.isTrue(fConventionalWizard || newWizard instanceof RefactoringWizard); 83 super.setWizard(newWizard); 84 } 85 86 94 protected Refactoring getRefactoring() { 95 RefactoringWizard wizard= getRefactoringWizard(); 96 if (wizard == null) 97 return null; 98 return wizard.getRefactoring(); 99 } 100 101 107 protected RefactoringWizard getRefactoringWizard() { 108 IWizard wizard= getWizard(); 109 if (wizard instanceof RefactoringWizard) 110 return (RefactoringWizard) wizard; 111 return null; 112 } 113 114 124 protected boolean performFinish() { 125 return true; 126 } 127 128 134 protected IDialogSettings getRefactoringSettings() { 135 IDialogSettings settings= getDialogSettings(); 136 if (settings == null) 137 return null; 138 IDialogSettings result= settings.getSection(REFACTORING_SETTINGS); 139 if (result == null) { 140 result= new DialogSettings(REFACTORING_SETTINGS); 141 settings.addSection(result); 142 } 143 return result; 144 } 145 } 146 | Popular Tags |