1 11 12 package org.eclipse.jdt.internal.ui.refactoring.reorg; 13 14 import org.eclipse.core.runtime.CoreException; 15 16 import org.eclipse.jface.resource.ImageDescriptor; 17 18 import org.eclipse.jdt.internal.corext.refactoring.rename.RenamingNameSuggestor; 19 import org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating; 20 import org.eclipse.jdt.internal.ui.JavaPlugin; 21 import org.eclipse.jdt.internal.ui.refactoring.RefactoringMessages; 22 23 import org.eclipse.ltk.core.refactoring.Refactoring; 24 import org.eclipse.ltk.core.refactoring.RefactoringStatus; 25 import org.eclipse.ltk.ui.refactoring.RefactoringWizard; 26 27 public class RenameRefactoringWizard extends RefactoringWizard { 28 29 private final String fInputPageDescription; 30 private final String fPageContextHelpId; 31 private final ImageDescriptor fInputPageImageDescriptor; 32 33 35 38 public static final String UPDATE_TEXTUAL_MATCHES= "updateTextualMatches"; 42 public static final String UPDATE_QUALIFIED_NAMES= "updateQualifiedNames"; 46 public static final String QUALIFIED_NAMES_PATTERNS= "patterns"; 48 51 public static final String TYPE_UPDATE_SIMILAR_ELEMENTS= "updateSimilarElements"; 56 public static final String TYPE_SIMILAR_MATCH_STRATEGY= "updateSimilarElementsMatchStrategy"; 58 61 public static final String PACKAGE_RENAME_SUBPACKAGES= "renameSubpackages"; 63 66 public static final String FIELD_RENAME_GETTER= "renameGetter"; 70 public static final String FIELD_RENAME_SETTER= "renameSetter"; 72 73 public RenameRefactoringWizard(Refactoring refactoring, String defaultPageTitle, String inputPageDescription, 74 ImageDescriptor inputPageImageDescriptor, String pageContextHelpId) { 75 super(refactoring, DIALOG_BASED_USER_INTERFACE); 76 setDefaultPageTitle(defaultPageTitle); 77 fInputPageDescription= inputPageDescription; 78 fInputPageImageDescriptor= inputPageImageDescriptor; 79 fPageContextHelpId= pageContextHelpId; 80 setDialogSettings(JavaPlugin.getDefault().getDialogSettings()); 81 } 82 83 86 protected void addUserInputPages() { 87 String initialSetting= getNameUpdating().getCurrentElementName(); 88 RenameInputWizardPage inputPage= createInputPage(fInputPageDescription, initialSetting); 89 inputPage.setImageDescriptor(fInputPageImageDescriptor); 90 addPage(inputPage); 91 } 92 93 private INameUpdating getNameUpdating() { 94 return (INameUpdating)getRefactoring().getAdapter(INameUpdating.class); 95 } 96 97 protected RenameInputWizardPage createInputPage(String message, String initialSetting) { 98 return new RenameInputWizardPage(message, fPageContextHelpId, true, initialSetting) { 99 protected RefactoringStatus validateTextField(String text) { 100 return validateNewName(text); 101 } 102 }; 103 } 104 105 protected RefactoringStatus validateNewName(String newName) { 106 INameUpdating ref= getNameUpdating(); 107 ref.setNewElementName(newName); 108 try{ 109 return ref.checkNewElementName(newName); 110 } catch (CoreException e){ 111 JavaPlugin.log(e); 112 return RefactoringStatus.createFatalErrorStatus(RefactoringMessages.RenameRefactoringWizard_internal_error); 113 } 114 } 115 } 116 | Popular Tags |