1 19 20 package org.netbeans.modules.j2ee.oc4j.nodes.actions; 21 22 import java.net.MalformedURLException ; 23 import java.net.URL ; 24 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; 25 import org.netbeans.modules.j2ee.oc4j.nodes.OC4JInstanceNode; 26 import org.netbeans.modules.j2ee.oc4j.util.OC4JPluginProperties; 27 import org.openide.ErrorManager; 28 import org.openide.nodes.Node; 29 import org.openide.util.HelpCtx; 30 import org.openide.util.NbBundle; 31 import org.openide.util.actions.CookieAction; 32 import org.openide.awt.HtmlBrowser.URLDisplayer; 33 34 38 public class ShowAdminToolAction extends CookieAction { 39 40 protected Class [] cookieClasses() { 41 return new Class [] {}; 42 } 43 44 protected int mode() { 45 return MODE_EXACTLY_ONE; 46 } 48 49 protected void performAction(Node[] nodes) { 50 if( (nodes == null) || (nodes.length < 1) ) 51 return; 52 53 for (int i = 0; i < nodes.length; i++) { 54 Object node = nodes[i].getLookup().lookup(OC4JInstanceNode.class); 55 if (node instanceof OC4JInstanceNode) { 56 try { 57 URL url = new URL (((OC4JInstanceNode) node).getAdminURL()); 58 URLDisplayer.getDefault().showURL(url); 59 } catch (MalformedURLException ex) { 60 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); 61 } 62 } 63 } 64 } 65 66 public String getName() { 67 return NbBundle.getMessage(ShowAdminToolAction.class, "LBL_ShowAdminGUIAction"); 68 } 69 70 public HelpCtx getHelpCtx() { 71 return null; } 75 76 protected boolean enable(Node[] nodes) { 77 for (Node node : nodes) { 78 OC4JInstanceNode iNode = node.getLookup().lookup(OC4JInstanceNode.class); 79 if(iNode != null) { 80 InstanceProperties prop = iNode.getDeploymentManager().getInstanceProperties(); 81 String port = prop.getProperty(InstanceProperties.HTTP_PORT_NUMBER); 82 String host = prop.getProperty(OC4JPluginProperties.PROPERTY_HOST); 83 return OC4JPluginProperties.isRunning(host, port); 84 } 85 } 86 return false; 87 } 88 89 protected boolean asynchronous() { 90 return false; 91 } 92 } | Popular Tags |