1 19 package org.netbeans.modules.j2ee.sun.ide.j2ee.runtime.actions; 20 21 import java.io.File ; 22 import org.openide.nodes.Node; 23 import org.openide.util.HelpCtx; 24 import org.openide.util.NbBundle; 25 import org.openide.util.actions.CookieAction; 26 27 import javax.enterprise.deploy.spi.DeploymentManager ; 28 29 import org.netbeans.modules.j2ee.sun.ide.j2ee.LogViewerSupport; 30 31 import org.netbeans.modules.j2ee.sun.ide.j2ee.DeploymentManagerProperties; 32 import org.netbeans.modules.j2ee.sun.api.SunDeploymentManagerInterface; 33 import org.netbeans.modules.j2ee.sun.ide.j2ee.runtime.nodes.ManagerNode; 34 import org.netbeans.modules.j2ee.sun.ide.j2ee.ui.Util; 35 import org.openide.windows.InputOutput; 36 40 public class ViewLogAction extends CookieAction { 41 42 protected Class [] cookieClasses() { 43 return new Class [] {}; 44 } 45 46 protected int mode() { 47 return MODE_EXACTLY_ONE; 48 } 50 51 protected void performAction(Node[] nodes) { 52 if(nodes[0].getLookup().lookup(ManagerNode.class) != null){ 53 ManagerNode node = (ManagerNode)nodes[0].getCookie(ManagerNode.class); 54 SunDeploymentManagerInterface sdm = node.getDeploymentManager(); 55 viewLog(sdm,true,true); } 57 58 59 60 } 61 public static void viewLog(SunDeploymentManagerInterface sdm){ 62 viewLog(sdm,false,false); 64 } 65 66 public static InputOutput viewLog(SunDeploymentManagerInterface sdm, boolean entireFile, boolean forced){ 67 try{ 68 if(sdm.isLocal()==false){ 69 return null; 70 } 71 72 DeploymentManagerProperties dmProps = new DeploymentManagerProperties((DeploymentManager ) sdm); 73 String domainRoot = dmProps.getLocation(); 74 if (domainRoot == null) { 75 return null; 76 } 77 String domain = dmProps.getDomainName(); 78 File f = new File (domainRoot+File.separator+domain+"/logs/server.log"); 81 LogViewerSupport p = LogViewerSupport.getLogViewerSupport(f , dmProps.getUrl(),2000,entireFile); 82 return p.showLogViewer(forced); 83 } catch (Exception e){ 84 Util.showInformation(e.getLocalizedMessage()); 85 } 86 return null; 87 } 88 public String getName() { 89 return NbBundle.getMessage(ViewLogAction.class, "LBL_ViewlogAction"); 90 } 91 92 protected String iconResource() { 93 return "org/netbeans/modules/j2ee/sun/ide/resources/AddInstanceActionIcon.gif"; 94 } 95 96 public HelpCtx getHelpCtx() { 97 return null; } 101 102 protected boolean enable(Node[] nodes) { 103 if( (nodes == null) || (nodes.length < 1) ) { 104 return false; 105 } 106 if (nodes.length > 1) { 107 return false; 108 } 109 if(nodes[0].getLookup().lookup(ManagerNode.class) != null){ 110 try{ 111 ManagerNode node = (ManagerNode)nodes[0].getLookup().lookup(ManagerNode.class); 112 113 114 SunDeploymentManagerInterface sdm = node.getDeploymentManager(); 115 return sdm.isLocal(); 116 } catch (Exception e){ 117 } 119 } 120 return false; 121 } 122 123 129 130 137 138 protected boolean asynchronous() { 139 return false; 140 } 141 142 } 143 | Popular Tags |