1 19 20 package org.netbeans.modules.j2ee.refactoring.safedelete; 21 22 import org.netbeans.modules.refactoring.api.Problem; 23 import org.netbeans.modules.refactoring.api.SafeDeleteRefactoring; 24 import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; 25 import org.netbeans.modules.j2ee.refactoring.Utility; 26 import org.netbeans.modules.j2ee.dd.api.ejb.Ejb; 27 import org.netbeans.modules.j2ee.dd.api.ejb.EntityAndSession; 28 import org.netbeans.modules.javacore.internalapi.ExternalChange; 29 import org.netbeans.modules.javacore.internalapi.JavaMetamodel; 30 import org.netbeans.jmi.javamodel.JavaClass; 31 import org.netbeans.jmi.javamodel.UnresolvedClass; 32 import org.netbeans.jmi.javamodel.Element; 33 import org.netbeans.modules.web.taglib.model.FunctionType; 34 import org.netbeans.modules.web.taglib.model.TagType; 35 import org.netbeans.modules.web.taglib.model.Taglib; 36 import org.netbeans.modules.web.taglib.model.Taglib; 37 import org.netbeans.modules.web.taglib.model.ValidatorType; 38 import org.openide.util.NbBundle; 39 40 import java.util.List ; 41 import java.util.LinkedList ; 42 43 46 public class TldClassSafeDeleteRefactoring extends BaseRefactoring { 47 private final Taglib taglib; 48 private JavaClass javaClass; 49 50 public TldClassSafeDeleteRefactoring(TldHelper helper, Taglib taglib, JavaClass javaClass) { 51 super(helper); 52 this.taglib = taglib; 53 this.javaClass = javaClass; 54 } 55 56 protected Problem preCheckThis() { 57 return null; 58 } 59 60 protected Problem prepareThis(RefactoringElementsBag refactoringElementsBag) { 61 String name = javaClass.getName(); 62 TagType[] tagTypes = taglib.getTag(); 64 if ((tagTypes != null) && (tagTypes.length > 0)) { 65 for (int tt = 0; tt < tagTypes.length; tt++) { 66 TagType tagT = tagTypes[tt]; 67 String tagClass = tagT.getTagClass(); 68 if ((tagClass != null) && (tagClass.equals(name))) { 69 helper.addRefactoringElement(refactoringElementsBag, new TaglibTagClassSafeDeleteRefactoringElement(taglib, tagT)); 70 } 71 String teiClass = tagT.getTeiClass(); 72 if ((teiClass != null) && (teiClass.equals(name))) { 73 } 75 } 76 } 77 78 FunctionType[] functionTypes = taglib.getFunction(); 79 if ((functionTypes != null) && (functionTypes.length > 0)) { 80 for (int tt = 0; tt < functionTypes.length; tt++) { 81 FunctionType functionT = functionTypes[tt]; 82 String functionClass = functionT.getFunctionClass(); 83 if ((functionClass != null) && (functionClass.equals(name))) { 84 } 86 } 87 } 88 89 ValidatorType validatorType = taglib.getValidator(); 91 if (validatorType != null) { 92 String validatorClass = validatorType.getValidatorClass(); 93 if ((validatorClass != null) && (validatorClass.equals(name))) { 94 } 96 } 97 98 org.netbeans.modules.web.taglib.model.ListenerType[] listenerTypes = taglib.getListener(); 100 if ((listenerTypes != null) && (listenerTypes.length > 0)) { 101 for (int tt = 0; tt < listenerTypes.length; tt++) { 102 org.netbeans.modules.web.taglib.model.ListenerType listenerT = listenerTypes[tt]; 103 String listenerClass = listenerT.getListenerClass(); 104 if ((listenerClass != null) && (listenerClass.equals(name))) { 105 } 107 } 108 } 109 return null; 110 } 111 112 public final class TaglibTagClassSafeDeleteRefactoringElement extends AbstractSafeDeleteRefactoringElement implements ExternalChange { 113 114 private TagType tagType = null; 115 116 public TaglibTagClassSafeDeleteRefactoringElement(Taglib taglib, TagType tagType) { 117 super(helper.getFileObject()); 118 this.tagType = tagType; 119 } 120 121 126 public String getDisplayText() { 127 return NbBundle.getMessage(TaglibTagClassSafeDeleteRefactoringElement.class, "TXT_TaglibTagClassSafeDelete", tagType.getName()); 128 } 129 130 133 public void performChange() { 134 JavaMetamodel.getManager().registerExtChange(this); 135 } 136 137 public void performExternalChange() { 138 taglib.removeTag(tagType); 139 helper.writeDD(); 140 } 141 142 public void undoExternalChange() { 143 taglib.addTag(tagType); 144 helper.writeDD(); 145 } 146 } 147 } 148 | Popular Tags |