1 19 20 package org.netbeans.modules.j2ee.refactoring.rename; 21 22 import java.io.IOException ; 23 import java.text.MessageFormat ; 24 import javax.jmi.reflect.RefObject; 25 import org.netbeans.api.project.FileOwnerQuery; 26 import org.netbeans.api.project.Project; 27 import org.netbeans.jmi.javamodel.Annotation; 28 import org.netbeans.jmi.javamodel.AttributeValue; 29 import org.netbeans.jmi.javamodel.JavaClass; 30 import org.netbeans.jmi.javamodel.Resource; 31 import org.netbeans.modules.j2ee.refactoring.jaxwssupport.JaxWsXmlRefactoringElementSupport; 32 import org.netbeans.modules.j2ee.refactoring.Utility; 33 import org.netbeans.modules.j2ee.refactoring.jaxwssupport.JaxWsXmlRefactoringSupport; 34 import org.netbeans.modules.javacore.api.JavaModel; 35 import org.netbeans.modules.javacore.internalapi.ExternalChange; 36 import org.netbeans.modules.javacore.internalapi.JavaMetamodel; 37 import org.netbeans.modules.refactoring.api.AbstractRefactoring; 38 import org.netbeans.modules.refactoring.api.Problem; 39 import org.netbeans.modules.refactoring.spi.RefactoringElementImplementation; 40 import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; 41 import org.netbeans.modules.websvc.api.jaxws.project.config.JaxWsModel; 42 import org.netbeans.modules.websvc.api.jaxws.project.config.JaxWsModelProvider; 43 import org.netbeans.modules.websvc.api.jaxws.project.config.Service; 44 import org.openide.ErrorManager; 45 import org.openide.filesystems.FileObject; 46 import org.openide.util.NbBundle; 47 48 55 public class JaxWsXmlRenameRefactoring extends JaxWsXmlRefactoringSupport { 56 57 60 public JaxWsXmlRenameRefactoring() { 61 } 62 63 66 public Problem prepare(AbstractRefactoring refactor, RefObject refObject, 67 String newName, RefactoringElementsBag refactoringElements) { 68 69 if (!(refObject instanceof JavaClass) || !isWebSvcFromWsdl((JavaClass) refObject)){ 70 return null; 71 } 72 73 JavaClass javaClass = (JavaClass) refObject; 74 75 JaxWsModel model = getModel(javaClass); 76 if (model == null){ 77 return null; 78 } 79 newName = Utility.renameClass(javaClass.getName(), newName); 80 81 Service service = model.findServiceByImplementationClass(javaClass.getName()); 82 if (service != null){ 83 RefactoringElementImplementation refactoringElem = 84 new JaxWsXmlRenameRefactoringElement(javaClass.getName(), newName, model, service, model.getJaxWsFile()); 85 86 refactoringElements.add(refactor, refactoringElem); 87 } 88 89 return null; 90 } 91 92 95 private static class JaxWsXmlRenameRefactoringElement extends JaxWsXmlRefactoringElementSupport { 96 97 104 public JaxWsXmlRenameRefactoringElement(String oldName, String newName, 105 JaxWsModel model, Service service, FileObject parentFile) { 106 super(oldName, newName, model, service, parentFile); 107 } 108 109 113 public String getDisplayText() { 114 Object [] args = new Object [] {parentFile.getNameExt(), oldName, newName}; 115 return MessageFormat.format(NbBundle.getMessage(JaxWsXmlRenameRefactoring.class, "TXT_JaxWsXmlRename"), args); 116 } 117 } 118 119 } 120 | Popular Tags |