1 19 20 package org.netbeans.modules.j2ee.refactoring.moveclass; 21 22 import java.text.MessageFormat ; 23 import java.util.Collection ; 24 import java.util.Iterator ; 25 import org.netbeans.jmi.javamodel.JavaClass; 26 import org.netbeans.jmi.javamodel.Resource; 27 import org.netbeans.modules.j2ee.refactoring.Utility; 28 import org.netbeans.modules.j2ee.refactoring.jaxwssupport.JaxWsXmlRefactoringSupport; 29 import org.netbeans.modules.j2ee.refactoring.jaxwssupport.SunJaxWsXmlElementSupport; 30 import org.netbeans.modules.refactoring.api.MoveClassRefactoring; 31 import org.netbeans.modules.refactoring.api.Problem; 32 import org.netbeans.modules.refactoring.spi.RefactoringElementImplementation; 33 import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; 34 import org.netbeans.modules.websvc.api.jaxws.project.config.Endpoint; 35 import org.netbeans.modules.websvc.api.jaxws.project.config.Endpoints; 36 import org.openide.filesystems.FileObject; 37 import org.openide.util.NbBundle; 38 39 46 public class SunJaxWsXmlMoveClassRefactoring extends JaxWsXmlRefactoringSupport { 47 48 51 public SunJaxWsXmlMoveClassRefactoring() { 52 } 53 54 57 public Problem prepare(MoveClassRefactoring moveClassRefactor, 58 Collection resources, RefactoringElementsBag refactoringElements) { 59 60 for (Iterator it = resources.iterator(); it.hasNext();) { 61 Resource elem = (Resource) it.next(); 62 63 for (Iterator it2 = elem.getClassifiers().iterator(); it2.hasNext();) { 64 JavaClass javaClass = (JavaClass) it2.next(); 65 66 if (!isWebSvcFromWsdl(javaClass)){ 67 continue; 68 } 69 70 Endpoints model = getEndpointsModel(javaClass); 71 if (model == null){ 72 return null; 73 } 74 75 FileObject sunjaxwsfile = getSunJaxWsXmlFile(javaClass); 76 String newName = moveClassRefactor.getTargetPackageName(elem) + "." + javaClass.getSimpleName(); 77 78 for (Endpoint each : getEndpoints(javaClass)) { 79 RefactoringElementImplementation refactoringElem = 80 new SunJaxWsXmlMoveClassRefactoringElement(javaClass.getName(), newName, model, each, sunjaxwsfile); 81 82 refactoringElements.add(moveClassRefactor, refactoringElem); 83 84 } 85 } 86 } 87 return null; 88 } 89 90 93 private static class SunJaxWsXmlMoveClassRefactoringElement extends SunJaxWsXmlElementSupport { 94 95 public SunJaxWsXmlMoveClassRefactoringElement(String oldName, String newName, 96 Endpoints model, Endpoint endpoint, FileObject parentFile) { 97 super(oldName, newName, model, endpoint, parentFile); 98 } 99 100 public String getDisplayText() { 101 Object [] args = new Object [] {parentFile.getNameExt(), oldName, newName}; 102 return MessageFormat.format(NbBundle.getMessage(SunJaxWsXmlMoveClassRefactoring.class, "TXT_SunJaxWsXmlMoveClass"), args); 103 } 104 105 } 106 107 } 108 | Popular Tags |