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.jaxwssupport.JaxWsXmlRefactoringElementSupport; 28 import org.netbeans.modules.j2ee.refactoring.jaxwssupport.JaxWsXmlRefactoringSupport; 29 import org.netbeans.modules.refactoring.api.MoveClassRefactoring; 30 import org.netbeans.modules.refactoring.api.Problem; 31 import org.netbeans.modules.refactoring.spi.RefactoringElementImplementation; 32 import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; 33 import org.netbeans.modules.websvc.api.jaxws.project.config.JaxWsModel; 34 import org.netbeans.modules.websvc.api.jaxws.project.config.Service; 35 import org.openide.filesystems.FileObject; 36 import org.openide.util.NbBundle; 37 38 45 public class JaxWsXmlMoveClassRefactoring extends JaxWsXmlRefactoringSupport { 46 47 50 public JaxWsXmlMoveClassRefactoring() { 51 } 52 53 56 public Problem prepare(MoveClassRefactoring moveClassRefactor, 57 Collection resources, RefactoringElementsBag refactoringElements) { 58 59 for (Iterator it = resources.iterator(); it.hasNext();) { 60 Resource elem = (Resource) it.next(); 61 62 for (Iterator it2 = elem.getClassifiers().iterator(); it2.hasNext();) { 63 JavaClass javaClass = (JavaClass) it2.next(); 64 65 JaxWsModel model = getModel(javaClass); 66 if (model == null){ 67 return null; 69 } 70 if (!isWebSvcFromWsdl(javaClass)){ 71 continue; 72 } 73 74 String newName = moveClassRefactor.getTargetPackageName(elem) + "." + javaClass.getSimpleName(); 75 Service service = model.findServiceByImplementationClass(javaClass.getName()); 76 if (service != null){ 77 RefactoringElementImplementation refactoringElem = 78 new JaxWsXmlMoveClassRefactoringElement(javaClass.getName(), newName, model, service, model.getJaxWsFile()); 79 80 refactoringElements.add(moveClassRefactor, refactoringElem); 81 82 } 83 } 84 } 85 86 return null; 87 } 88 89 92 private static class JaxWsXmlMoveClassRefactoringElement extends JaxWsXmlRefactoringElementSupport { 93 94 101 public JaxWsXmlMoveClassRefactoringElement(String oldName, String newName, 102 JaxWsModel model, Service service, FileObject parentFile) { 103 super(oldName, newName, model, service, parentFile); 104 } 105 106 110 public String getDisplayText() { 111 Object [] args = new Object [] {parentFile.getNameExt(), oldName, newName}; 112 return MessageFormat.format(NbBundle.getMessage(JaxWsXmlMoveClassRefactoring.class, "TXT_JaxWsXmlMoveClass"), args); 113 } 114 115 } 116 117 } 118 | Popular Tags |