1 19 20 package org.netbeans.modules.j2ee.refactoring.rename; 21 22 import java.text.MessageFormat ; 23 import javax.jmi.reflect.RefObject; 24 import org.netbeans.jmi.javamodel.JavaClass; 25 import org.netbeans.modules.j2ee.refactoring.Utility; 26 import org.netbeans.modules.j2ee.refactoring.jaxwssupport.JaxWsXmlRefactoringSupport; 27 import org.netbeans.modules.j2ee.refactoring.jaxwssupport.SunJaxWsXmlElementSupport; 28 import org.netbeans.modules.refactoring.api.AbstractRefactoring; 29 import org.netbeans.modules.refactoring.api.Problem; 30 import org.netbeans.modules.refactoring.spi.RefactoringElementImplementation; 31 import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; 32 import org.netbeans.modules.websvc.api.jaxws.project.config.Endpoint; 33 import org.netbeans.modules.websvc.api.jaxws.project.config.Endpoints; 34 import org.openide.filesystems.FileObject; 35 import org.openide.util.NbBundle; 36 37 44 public class SunJaxWsXmlRenameRefactoring extends JaxWsXmlRefactoringSupport { 45 46 49 public SunJaxWsXmlRenameRefactoring() { 50 } 51 52 55 public Problem prepare(AbstractRefactoring refactor, RefObject refObject, 56 String newName, RefactoringElementsBag refactoringElements) { 57 58 if (!(refObject instanceof JavaClass) || !isWebSvcFromWsdl((JavaClass) refObject)){ 59 return null; 60 } 61 62 JavaClass javaClass = (JavaClass) refObject; 63 Endpoints model = getEndpointsModel(javaClass); 64 if (model == null){ 65 return null; 66 } 67 68 FileObject sunjaxwsfile = getSunJaxWsXmlFile(javaClass); 69 for (Endpoint each : getEndpoints(javaClass)) { 70 RefactoringElementImplementation refactoringElem = 71 new SunJaxWsXmlRenameRefactoringElement(javaClass.getName(), Utility.renameClass(javaClass.getName(), newName), model, each, sunjaxwsfile); 72 refactoringElements.add(refactor, refactoringElem); 73 74 } 75 76 return null; 77 } 78 79 82 private static class SunJaxWsXmlRenameRefactoringElement extends SunJaxWsXmlElementSupport { 83 84 public SunJaxWsXmlRenameRefactoringElement(String oldName, String newName, 85 Endpoints model, Endpoint endpoint, FileObject parentFile) { 86 super(oldName, newName, model, endpoint, parentFile); 87 } 88 89 public String getDisplayText() { 90 Object [] args = new Object [] {parentFile.getNameExt(), oldName, newName}; 91 return MessageFormat.format(NbBundle.getMessage(SunJaxWsXmlRenameRefactoring.class, "TXT_SunJaxWsXmlRename"), args); 92 } 93 94 } 95 96 } 97 | Popular Tags |