1 19 20 package org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.shared; 21 22 import javax.swing.Action ; 23 import org.netbeans.api.java.classpath.ClassPath; 24 import org.netbeans.modules.j2ee.dd.api.ejb.EjbJar; 25 import org.netbeans.modules.j2ee.dd.api.ejb.EntityAndSession; 26 import org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.AddActionGroup; 27 import org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.GoToSourceAction; 28 import org.openide.cookies.OpenCookie; 29 import org.openide.loaders.DataObject; 30 import org.openide.nodes.AbstractNode; 31 import org.openide.nodes.Children; 32 import org.openide.util.NbBundle; 33 import org.openide.util.actions.SystemAction; 34 import org.openide.util.lookup.AbstractLookup; 35 import org.openide.util.lookup.InstanceContent; 36 37 43 public class MethodsNode extends AbstractNode implements OpenCookie { 44 45 private final EjbViewController controller; 46 private EntityAndSession model; 47 private ClassPath srcPath; 48 private boolean local; 49 50 public MethodsNode(EntityAndSession model, EjbJar module, ClassPath srcPath, Children children, boolean local) { 51 this(new InstanceContent(), model, module, srcPath, children, local); 52 } 53 54 private MethodsNode(InstanceContent content, EntityAndSession model, EjbJar module, ClassPath srcPath, Children children, boolean local) { 55 super(children, new AbstractLookup(content)); 56 controller = new EjbViewController(model, module, srcPath); 57 this.model = model; 58 this.srcPath = srcPath; 59 this.local = local; 60 content.add(this); 61 if (controller.getBeanDo() != null) { 62 content.add(controller.getBeanDo()); 63 } 64 } 65 66 public Action [] getActions(boolean context) { 67 return new Action [] { 68 new GoToSourceAction(srcPath, local ? model.getLocal() : model.getRemote(), 69 NbBundle.getMessage(MethodsNode.class, "LBL_GoToSourceGroup")), 70 SystemAction.get(AddActionGroup.class), 71 }; 72 } 73 74 public Action getPreferredAction() { 75 return new GoToSourceAction(srcPath, local ? model.getLocal() : model.getRemote(), 76 NbBundle.getMessage(MethodsNode.class, "LBL_GoToSourceGroup")); 77 } 78 79 public void open() { 80 DataObject dataObject = controller.getBeanDo(); 81 if (dataObject != null) { 82 OpenCookie cookie = (OpenCookie) dataObject.getCookie(OpenCookie.class); 83 if(cookie != null){ 84 cookie.open(); 85 } 86 } 87 } 88 89 public boolean isLocal() { 90 return local; 91 } 92 } 93 | Popular Tags |