1 19 package org.netbeans.modules.j2ee.sun.ide.runtime.nodes; 20 21 import java.util.List ; 22 import java.util.Arrays ; 23 import javax.management.ObjectName ; 24 import javax.swing.Action ; 25 26 27 import org.netbeans.modules.j2ee.sun.util.NodeTypes; 28 import com.sun.appserv.management.base.Util; 29 import org.netbeans.modules.j2ee.sun.ide.controllers.ControllerUtil; 30 import org.netbeans.modules.j2ee.sun.ide.controllers.WebModuleController; 31 import org.netbeans.modules.j2ee.sun.ide.runtime.actions.EnableDisableAction; 32 import org.netbeans.modules.j2ee.sun.ide.runtime.actions.UndeployAction; 33 import org.openide.actions.PropertiesAction; 34 import org.openide.nodes.Children; 35 import org.openide.nodes.Node; 36 import org.openide.util.actions.SystemAction; 37 38 39 40 41 43 public class WebModuleNode extends AppserverMgmtApplicationsNode { 44 45 private static String NODE_TYPE = NodeTypes.WEB_MODULE; 46 47 51 public WebModuleNode(WebModuleController controller) { 52 super(getChildNodes(controller), controller, NODE_TYPE, false); 53 setDisplayName(controller.getDisplayName()); 54 } 55 56 57 61 public WebModuleNode(final WebModuleController controller, 62 final boolean isEmbedded) { 63 super(getChildNodes(controller), controller, NODE_TYPE, isEmbedded); 64 setDisplayName(controller.getDisplayName()); 65 } 66 67 public WebModuleNode(final String name) { 68 super(Children.LEAF, null, NODE_TYPE, true); 69 setDisplayName(name); 70 } 71 72 75 static Children getChildNodes(WebModuleController controller) { 76 return createWebModuleNodeChildren(controller); 77 } 78 85 public Action [] getActions(boolean flag) { 86 if(!isEmbedded) { 87 return new SystemAction[] { 88 SystemAction.get(UndeployAction.class), 89 SystemAction.get(EnableDisableAction.class), 90 SystemAction.get(PropertiesAction.class) 91 }; 92 } else { 93 return new SystemAction[] { 94 SystemAction.get(PropertiesAction.class) 95 }; 96 } 97 } 98 99 102 static Children createWebModuleNodeChildren(WebModuleController controller) { 103 104 Children children = new Children.Array(); 105 java.util.Vector nodes = new java.util.Vector (); 106 107 if(controller.getJ2EEObject() != null){ 109 String [] servlets = controller.getServlets(); 110 if(servlets != null && servlets.length > 0) { 111 for(int i = 0; i < servlets.length; i++) { 112 nodes.add(new ServletNode(controller, servlets[i])); 113 } 114 } 115 }else{ 116 ObjectName [] subComponents = ControllerUtil.getSubComponentsFromConfig(controller.getName(), controller.getMBeanServerConnection()); 117 for(int i=0; i<subComponents.length; i++){ 118 ObjectName oname = subComponents[i]; 119 String name = Util.getName(oname); 120 nodes.add(new ServletNode(name)); 121 }; 122 } 123 124 Node[] arrayToAdd = new Node[nodes.size()]; 125 children.add((Node[])nodes.toArray(arrayToAdd)); 126 return children; 127 } 128 129 protected List getPropertiesToIgnore() { 130 return Arrays.asList(NodeTypes.WEB_MODULE_NODE); 132 } 133 } 134 | Popular Tags |