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.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 (Node node:nodes) { 40 OpenURLActionCookie oCookie = node.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(Node node:nodes) { 54 OpenURLActionCookie oCookie = node.getCookie(OpenURLActionCookie.class); 55 UndeployModuleCookie uCookie = node.getCookie(UndeployModuleCookie.class); 56 57 if(uCookie != null) 58 if(uCookie.isRunning()) 59 return false; 60 61 if (oCookie != null && oCookie.getWebURL() != null) 62 return true; 63 } 64 65 return false; 66 } 67 68 public String getName() { 69 return NbBundle.getMessage(OpenURLAction.class, "LBL_OpenInBrowserAction"); } 71 72 protected boolean asynchronous() { 73 return false; 74 } 75 76 public HelpCtx getHelpCtx() { 77 return HelpCtx.DEFAULT_HELP; 78 } 79 } | Popular Tags |