1 19 20 package org.netbeans.modules.j2ee.refactoring; 21 22 import java.util.Collection ; 23 import javax.jmi.reflect.RefObject; 24 import org.netbeans.modules.refactoring.api.AbstractRefactoring; 25 import org.netbeans.modules.refactoring.api.ChangeParametersRefactoring.ParameterInfo; 26 import org.netbeans.modules.refactoring.api.Problem; 27 import org.netbeans.modules.refactoring.api.ChangeParametersRefactoring; 28 import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; 29 import org.netbeans.modules.refactoring.spi.RefactoringPlugin; 30 import org.openide.ErrorManager; 31 32 import org.netbeans.modules.j2ee.refactoring.changeparam.*; 33 import org.openide.util.NbBundle; 34 35 39 public class J2EEChangeParamRefactoringPlugin implements RefactoringPlugin { 40 41 42 private static ThreadLocal semafor = new ThreadLocal (); 43 44 private EjbJarChangeParamRefactoring ejbJarChangeParamRefactor; 45 private WebservicesXmlChangeParamRefactoring webservicesXmlChangeParamRefactor; 48 49 private AbstractRefactoring refactoring; 50 51 private static ErrorManager err = ErrorManager.getDefault().getInstance("org.netbeans.modules.j2ee.refactoring.changeparam"); 53 54 public J2EEChangeParamRefactoringPlugin(AbstractRefactoring refactoring) { 55 this.refactoring = refactoring; 56 } 57 58 61 public Problem preCheck() { 62 Problem problem = null; 63 if (semafor.get() == null) { 64 semafor.set(new Object ()); 65 ChangeParametersRefactoring changeParamRefactor = ((ChangeParametersRefactoring)refactoring); 66 67 RefObject refO = (RefObject) changeParamRefactor.getRefactoredObject(); 68 err.log("refO: " + refO); 69 if (!Utility.isEjb30(refO)){ 70 Problem ejbJarProblem = getEjbJarChangeParamRefactor().preCheck(refO); 71 problem = Utility.addProblemsToEnd(problem, ejbJarProblem); 72 } else if (Utility.hasEjbJar(refO)){ 73 Problem ejbJarProblem = new Problem(false, NbBundle.getMessage(J2EEChangeParamRefactoringPlugin.class, "TXT_EjbJarChangeParamsWarning")); problem = Utility.addProblemsToEnd(problem, ejbJarProblem); 75 } 76 77 Problem websvcProblem = getWebservicesXmlChangeParamRefactor().preCheck(refO); 78 problem = Utility.addProblemsToEnd(problem, websvcProblem); 79 80 semafor.set(null); 81 } 82 83 return problem; 84 } 85 86 public Problem fastCheckParameters() { 87 Problem problem = null; 88 if (semafor.get() == null) { 89 semafor.set(new Object ()); 90 ChangeParametersRefactoring changeParamRefactor = ((ChangeParametersRefactoring)refactoring); 91 92 RefObject refO = (RefObject) changeParamRefactor.getRefactoredObject(); 93 err.log("refO: " + refO); 94 95 if (!Utility.isEjb30(refO)){ 96 Problem ejbJarProblem = getEjbJarChangeParamRefactor().fastCheckParameters(refO); 97 problem = Utility.addProblemsToEnd(problem, ejbJarProblem); 98 } 99 100 Problem websvcProblem = getWebservicesXmlChangeParamRefactor().fastCheckParameters(refO); 101 problem = Utility.addProblemsToEnd(problem, websvcProblem); 102 103 semafor.set(null); 104 } 105 return problem; 106 } 107 108 111 public Problem checkParameters() { 112 return fastCheckParameters(); 113 } 114 115 121 public Problem prepare(RefactoringElementsBag refactoringElements) { 122 Problem problem = null; 123 if (semafor.get() == null) { 124 semafor.set(new Object ()); 125 ChangeParametersRefactoring changeParamRefactor = ((ChangeParametersRefactoring)refactoring); 126 127 RefObject refO = (RefObject) changeParamRefactor.getRefactoredObject(); 128 ParameterInfo[] paramInfo = changeParamRefactor.getParameterInfo(); 129 int modifiers = changeParamRefactor.getModifiers(); 130 131 err.log("refO: " + refO); 132 133 139 if (!Utility.isEjb30(refO)){ 140 Problem ejbJarProblem = getEjbJarChangeParamRefactor().prepare(refactoring, refO, paramInfo, modifiers, refactoringElements); 141 problem = Utility.addProblemsToEnd(problem, ejbJarProblem); 142 } 143 144 Problem webservicesProblem = getWebservicesXmlChangeParamRefactor().prepare(refactoring, refO, paramInfo, modifiers, refactoringElements); 145 problem = Utility.addProblemsToEnd(problem, webservicesProblem); 146 147 semafor.set(null); 148 } 149 err.log("Gonna return problem: " + problem); 150 return problem; 151 } 152 153 public void cancelRequest() { } 154 155 private EjbJarChangeParamRefactoring getEjbJarChangeParamRefactor() { 156 if (ejbJarChangeParamRefactor == null) { 157 ejbJarChangeParamRefactor = new EjbJarChangeParamRefactoring(); 158 } 159 return ejbJarChangeParamRefactor; 160 } 161 162 private WebservicesXmlChangeParamRefactoring getWebservicesXmlChangeParamRefactor() { 177 if (webservicesXmlChangeParamRefactor == null) { 178 webservicesXmlChangeParamRefactor = new WebservicesXmlChangeParamRefactoring(); 179 } 180 return webservicesXmlChangeParamRefactor; 181 } 182 183 } 184 | Popular Tags |