1 19 20 package org.netbeans.modules.tomcat5.nodes.actions; 21 22 import java.net.MalformedURLException ; 23 import java.net.URL ; 24 import org.netbeans.modules.tomcat5.TomcatManager; 25 import org.netbeans.modules.tomcat5.nodes.TomcatInstanceNode; 26 import org.openide.ErrorManager; 27 import org.openide.awt.HtmlBrowser.URLDisplayer; 28 import org.openide.nodes.Node; 29 import org.openide.util.HelpCtx; 30 import org.openide.util.NbBundle; 31 import org.openide.util.RequestProcessor; 32 import org.openide.util.actions.NodeAction; 33 34 39 public class AdminConsoleAction extends NodeAction { 40 41 protected void performAction (Node[] nodes) { 42 for (int i = 0; i < nodes.length; i++) { 43 final TomcatInstanceNode cookie = (TomcatInstanceNode)nodes[i].getCookie(TomcatInstanceNode.class); 44 if (cookie != null) { 45 RequestProcessor.getDefault().post(new Runnable () { 46 public void run() { 47 TomcatManager tm = cookie.getTomcatManager(); 48 String adminUrl = tm.getServerUri() + "/admin"; try { 50 URLDisplayer.getDefault().showURL(new URL (adminUrl)); 51 } catch (MalformedURLException e) { 52 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); 53 } 54 } 55 }); 56 } 57 } 58 } 59 60 protected boolean enable (Node[] nodes) { 61 for (int i = 0; i < nodes.length; i++) { 62 TomcatInstanceNode cookie = (TomcatInstanceNode)nodes[i].getCookie(TomcatInstanceNode.class); 63 if (cookie == null) { 64 return false; 65 } 66 } 67 return true; 68 } 69 70 public String getName () { 71 return NbBundle.getMessage(AdminConsoleAction.class, "LBL_AdminConsoleAction"); 72 } 73 74 protected boolean asynchronous() { 75 return false; 76 } 77 78 public HelpCtx getHelpCtx () { 79 return HelpCtx.DEFAULT_HELP; 80 } 81 } 82 | Popular Tags |