1 19 package org.netbeans.modules.j2ee.websphere6.ui.nodes.actions; 20 21 import java.io.IOException ; 22 import java.net.Socket ; 23 import java.net.URL ; 24 import java.net.UnknownHostException ; 25 import org.netbeans.modules.j2ee.websphere6.WSDeploymentManager; 26 import org.netbeans.modules.j2ee.websphere6.ui.nodes.WSManagerNode; 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 ShowAdminConsoleAction extends CookieAction { 39 protected void performAction(Node[] nodes) { 40 if( (nodes == null) || (nodes.length < 1)) { 41 return; 42 } 43 44 for (int i = 0; i < nodes.length; i++) { 45 Object node = nodes[i].getLookup().lookup(WSManagerNode.class); 46 if (node instanceof WSManagerNode) { 47 try{ 48 URL url = new URL ( 49 ((WSManagerNode) node).getAdminConsoleURL()); 50 51 URLDisplayer.getDefault().showURL(url); 52 } catch (Exception e){ 53 return; } 55 } 56 } 57 } 58 59 public String getName() { 60 return NbBundle.getMessage(ShowAdminConsoleAction.class, "LBL_ShowAdminConsole"); 61 } 62 63 protected int mode() { 64 return MODE_EXACTLY_ONE; 65 } 66 67 public HelpCtx getHelpCtx() { 68 return null; 69 } 70 71 protected Class [] cookieClasses() { 72 return new Class []{}; 73 } 74 75 protected boolean enable(Node[] nodes) { 76 if (nodes == null || nodes.length < 1) { 77 return false; 78 } 79 80 boolean running = true; 81 82 for (int i = 0; i < nodes.length; i++) { 83 Object node = nodes[i].getLookup().lookup(WSManagerNode.class); 84 if (!(node instanceof WSManagerNode)) { 85 running = false; 86 break; 87 } 88 89 WSDeploymentManager dm = 90 ((WSManagerNode) node).getDeploymentManager(); 91 92 try { 94 new Socket (dm.getHost(), new Integer (dm.getPort()).intValue()); 95 96 running = true; 97 } catch (UnknownHostException e) { 98 ErrorManager.getDefault().notify(ErrorManager.ERROR, e); 99 } catch (IOException e) { 100 running = false; 101 } 102 } 103 104 return running; 105 } 106 107 protected boolean asynchronous() { 108 return false; 109 } 110 } | Popular Tags |