1 12 package org.eclipse.jdt.internal.ui.refactoring.reorg; 13 14 15 import org.eclipse.ltk.core.refactoring.Refactoring; 16 import org.eclipse.ltk.core.refactoring.RefactoringStatus; 17 import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; 18 19 import org.eclipse.jdt.core.ICompilationUnit; 20 import org.eclipse.jdt.core.JavaCore; 21 22 import org.eclipse.jdt.internal.corext.refactoring.rename.RenameCompilationUnitProcessor; 23 import org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating; 24 import org.eclipse.jdt.internal.corext.util.JavaModelUtil; 25 26 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; 27 import org.eclipse.jdt.internal.ui.JavaPluginImages; 28 import org.eclipse.jdt.internal.ui.refactoring.RefactoringMessages; 29 30 public class RenameCuWizard extends RenameTypeWizard { 31 32 public RenameCuWizard(Refactoring refactoring) { 33 super(refactoring, 34 RefactoringMessages.RenameCuWizard_defaultPageTitle, 35 RefactoringMessages.RenameCuWizard_inputPage_description, 36 JavaPluginImages.DESC_WIZBAN_REFACTOR_CU, 37 IJavaHelpContextIds.RENAME_CU_WIZARD_PAGE); 38 } 39 40 protected RefactoringStatus validateNewName(String newName) { 41 String fullName= JavaModelUtil.getRenamedCUName(getCompilationUnit(), newName); 42 return super.validateNewName(fullName); 43 } 44 45 private ICompilationUnit getCompilationUnit() { 46 return (ICompilationUnit) getCompilationUnitProcessor().getElements()[0]; 47 } 48 49 protected RenameInputWizardPage createInputPage(String message, String initialSetting) { 50 return new RenameTypeWizardInputPage(message, IJavaHelpContextIds.RENAME_CU_WIZARD_PAGE, true, initialSetting) { 51 protected RefactoringStatus validateTextField(String text) { 52 return validateNewName(text); 53 } 54 protected String getNewName(INameUpdating nameUpdating) { 55 String result= nameUpdating.getNewElementName(); 56 return JavaCore.removeJavaLikeExtension(result); 58 } 59 }; 60 } 61 62 protected boolean isRenameType() { 63 return getCompilationUnitProcessor().isWillRenameType(); 66 } 67 68 private RenameCompilationUnitProcessor getCompilationUnitProcessor() { 69 return ((RenameCompilationUnitProcessor) ((RenameRefactoring) getRefactoring()).getProcessor()); 70 } 71 } 72 | Popular Tags |