1 11 package org.eclipse.jdt.internal.core; 12 13 import org.eclipse.jdt.core.IJavaElement; 14 import org.eclipse.jdt.core.IJavaModelStatus; 15 import org.eclipse.jdt.core.IJavaModelStatusConstants; 16 import org.eclipse.jdt.core.ISourceReference; 17 import org.eclipse.jdt.core.JavaModelException; 18 import org.eclipse.jdt.internal.core.util.Messages; 19 20 30 public class RenameElementsOperation extends MoveElementsOperation { 31 35 public RenameElementsOperation(IJavaElement[] elements, IJavaElement[] destinations, String [] newNames, boolean force) { 36 super(elements, destinations, force); 39 setRenamings(newNames); 40 } 41 44 protected String getMainTaskName() { 45 return Messages.operation_renameElementProgress; 46 } 47 50 protected boolean isRename() { 51 return true; 52 } 53 56 protected IJavaModelStatus verify() { 57 IJavaModelStatus status = super.verify(); 58 if (! status.isOK()) 59 return status; 60 if (this.renamingsList == null || this.renamingsList.length == 0) 61 return new JavaModelStatus(IJavaModelStatusConstants.NULL_NAME); 62 return JavaModelStatus.VERIFIED_OK; 63 } 64 67 protected void verify(IJavaElement element) throws JavaModelException { 68 if (element == null || !element.exists()) 69 error(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, element); 70 71 if (element.isReadOnly()) 72 error(IJavaModelStatusConstants.READ_ONLY, element); 73 74 if (!(element instanceof ISourceReference)) 75 error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element); 76 77 int elementType = element.getElementType(); 78 if (elementType < IJavaElement.TYPE || elementType == IJavaElement.INITIALIZER) 79 error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element); 80 81 verifyRenaming(element); 82 } 83 } 84 | Popular Tags |