1 19 20 package org.netbeans.modules.j2ee.jboss4.nodes.actions; 21 22 import java.net.MalformedURLException ; 23 import java.net.URL ; 24 import org.openide.ErrorManager; 25 import org.openide.awt.HtmlBrowser.URLDisplayer; 26 import org.openide.nodes.Node; 27 import org.openide.util.HelpCtx; 28 import org.openide.util.NbBundle; 29 import org.openide.util.actions.NodeAction; 30 31 36 public class OpenURLAction extends NodeAction { 37 38 protected void performAction(Node[] nodes) { 39 for (int i = 0; i < nodes.length; i++) { 40 OpenURLActionCookie oCookie = (OpenURLActionCookie)nodes[i].getCookie(OpenURLActionCookie.class); 41 42 if(oCookie != null) { 43 try { 44 URLDisplayer.getDefault().showURL(new URL (oCookie.getWebURL())); 45 } catch (MalformedURLException e) { 46 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); 47 } 48 } 49 } 50 } 51 52 protected boolean enable(Node[] nodes) { 53 for (int i = 0; i < nodes.length; i++) { 54 OpenURLActionCookie oCookie = (OpenURLActionCookie)nodes[i].getCookie(OpenURLActionCookie.class); 55 UndeployModuleCookie uCookie = (UndeployModuleCookie)nodes[i].getCookie(UndeployModuleCookie.class); 56 UndeployModuleCookie upCookie = (UndeployModuleCookie)nodes[i].getParentNode().getCookie(UndeployModuleCookie.class); 57 58 if(uCookie != null) 59 if(uCookie.isRunning()) 60 return false; 61 62 if(upCookie != null) 63 if(upCookie.isRunning()) 64 return false; 65 66 if (oCookie != null) 67 return true; 68 } 69 70 return false; 71 } 72 73 public String getName() { 74 return NbBundle.getMessage(OpenURLAction.class, "LBL_OpenInBrowserAction"); } 76 77 protected boolean asynchronous() { 78 return false; 79 } 80 81 public HelpCtx getHelpCtx() { 82 return HelpCtx.DEFAULT_HELP; 83 } 84 } | Popular Tags |