1 19 20 package org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action; 21 22 import org.netbeans.modules.j2ee.dd.api.ejb.EntityAndSession; 23 import org.netbeans.modules.j2ee.ejbcore._RetoucheUtil; 24 import java.io.IOException ; 25 import java.util.Collections ; 26 import javax.lang.model.element.Modifier; 27 import org.netbeans.modules.j2ee.common.method.MethodCustomizerFactory; 28 import org.netbeans.modules.j2ee.common.method.MethodCustomizer; 29 import org.netbeans.modules.j2ee.common.method.MethodModel; 30 import org.netbeans.modules.j2ee.dd.api.ejb.Entity; 31 import org.netbeans.modules.j2ee.ejbcore.action.HomeMethodGenerator; 32 import org.netbeans.modules.j2ee.ejbcore.api.methodcontroller.EjbMethodController; 33 import org.netbeans.modules.j2ee.ejbcore.api.methodcontroller.MethodType; 34 import org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.shared.MethodsNode; 35 import org.openide.ErrorManager; 36 import org.openide.filesystems.FileObject; 37 import org.openide.util.NbBundle; 38 39 43 public class AddHomeMethodStrategy extends AbstractAddMethodStrategy { 44 45 public AddHomeMethodStrategy(String name) { 46 super (name); 47 } 48 public AddHomeMethodStrategy () { 49 super(NbBundle.getMessage(AddHomeMethodStrategy.class, "LBL_AddHomeMethodAction")); 50 } 51 52 protected MethodModel getPrototypeMethod() { 53 return MethodModel.create( 54 "homeMethod", 55 "void", 56 "", 57 Collections.<MethodModel.Variable>emptyList(), 58 Collections.<String >emptyList(), 59 Collections.<Modifier>emptySet() 60 ); 61 } 62 63 protected MethodCustomizer createDialog(FileObject fileObject, final MethodModel methodModel) throws IOException { 64 String className = _RetoucheUtil.getMainClassName(fileObject); 65 EjbMethodController ejbMethodController = EjbMethodController.createFromClass(fileObject, className); 66 MethodsNode methodsNode = getMethodsNode(); 67 return MethodCustomizerFactory.homeMethod( 68 getTitle(), 69 methodModel, 70 ejbMethodController.hasRemote(), 71 ejbMethodController.hasLocal(), 72 methodsNode == null ? ejbMethodController.hasLocal() : methodsNode.isLocal(), 73 methodsNode == null ? ejbMethodController.hasRemote() : !methodsNode.isLocal(), 74 Collections.<MethodModel>emptySet() ); 76 } 77 78 public MethodType.Kind getPrototypeMethodKind() { 79 return MethodType.Kind.HOME; 80 } 81 82 protected void generateMethod(EntityAndSession entityAndSession, 83 MethodModel method, boolean isOneReturn, 84 boolean publishToLocal, 85 boolean publishToRemote, String ejbql, 86 FileObject ejbClassFO, String className) throws IOException { 87 HomeMethodGenerator generator = HomeMethodGenerator.create(entityAndSession, ejbClassFO); 88 generator.generate(method, publishToLocal, publishToRemote); 89 } 90 91 public boolean supportsEjb(FileObject fileObject, String className) { 92 try { 93 EntityAndSession ejb = getEntityAndSession(fileObject, className); 94 if (ejb instanceof Entity) { 95 return true; 96 } 97 } catch (IOException ioe) { 98 ErrorManager.getDefault().notify(ioe); 99 } 100 return false; 101 } 102 } 103 | Popular Tags |