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.spi.RefactoringElementsBag; 24 import org.netbeans.modules.j2ee.dd.api.ejb.Entity; 25 import org.netbeans.modules.j2ee.dd.api.ejb.Query; 26 import org.netbeans.modules.javacore.internalapi.ExternalChange; 27 import org.netbeans.modules.javacore.internalapi.JavaMetamodel; 28 import org.openide.util.NbBundle; 29 import org.openide.ErrorManager; 30 31 34 public class EjbQueryMethodSafeDeleteRefactoring extends BaseRefactoring { 35 36 private static final ErrorManager err = ErrorManager.getDefault().getInstance("org.netbeans.modules.j2ee.refactoring.safedelete"); private Entity entity; 38 private Query query; 39 40 public EjbQueryMethodSafeDeleteRefactoring(EjbHelper helper, Entity entity, Query query) { 41 super(helper); 42 this.entity = entity; 43 this.query = query; 44 } 45 46 protected Problem preCheckThis() { 47 return new Problem(false, NbBundle.getMessage(EjbQueryMethodSafeDeleteRefactoring.class, 48 "TXT_QueryMethodWarningSafeDelete", query.getQueryMethod().getMethodName())); 49 } 50 51 public Problem prepareThis(RefactoringElementsBag refactoringElementsBag) { 52 helper.addRefactoringElement(refactoringElementsBag, new EjbJarRefactoringElement()); 53 return null; 54 } 55 56 public final class EjbJarRefactoringElement extends AbstractSafeDeleteRefactoringElement implements ExternalChange { 57 58 public EjbJarRefactoringElement() { 59 super(helper.getFileObject()); 60 } 61 62 65 public String getDisplayText() { 66 return NbBundle.getMessage(EjbQueryMethodSafeDeleteRefactoring.class, 67 "TXT_EjbJarQueryMethodSafeDelete", query.getQueryMethod().getMethodName()); } 69 70 72 public void performChange() { 73 JavaMetamodel.getManager().registerExtChange(this); 74 } 75 76 public void performExternalChange() { 77 entity.removeQuery(query); 78 helper.writeDD(); 79 } 80 81 public void undoExternalChange() { 82 entity.addQuery(query); 83 helper.writeDD(); 84 } 85 } 86 } 87 | Popular Tags |