1 19 20 package org.netbeans.modules.j2ee.jboss4.nodes.actions; 21 22 import java.io.File ; 23 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; 24 import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport; 25 import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager; 26 import org.netbeans.modules.j2ee.jboss4.ide.JBLogWriter; 27 import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties; 28 import org.netbeans.modules.j2ee.jboss4.nodes.JBManagerNode; 29 import org.openide.nodes.Node; 30 import org.openide.util.HelpCtx; 31 import org.openide.util.NbBundle; 32 import org.openide.util.actions.NodeAction; 33 import org.openide.windows.InputOutput; 34 35 39 public class OpenServerLogAction extends NodeAction { 40 41 public OpenServerLogAction() { 42 } 43 44 protected boolean enable(Node[] activatedNodes) { 45 return true; 46 } 47 48 protected void performAction(Node[] activatedNodes) { 49 for (Node activatedNode : activatedNodes) { 50 Object node = activatedNode.getLookup().lookup(JBManagerNode.class); 51 52 if (!(node instanceof JBManagerNode)) { 53 continue; 54 } 55 56 JBDeploymentManager dm = ((JBManagerNode)node).getDeploymentManager(); 57 InputOutput io = UISupport.getServerIO(dm.getUrl()); 58 if (io != null) { 59 io.select(); 60 } 61 62 String instanceName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR); 63 JBLogWriter logWriter = JBLogWriter.getInstance(instanceName); 64 if (logWriter == null) { 65 if (JBLogWriter.VERBOSE) { 66 System.out.println("CREATING LOG WRITER reading from the server.log file"); 67 } 68 logWriter = JBLogWriter.createInstance(io, instanceName); 69 String serverDir = dm.getInstanceProperties().getProperty(JBPluginProperties.PROPERTY_SERVER_DIR); 70 String logFileName = serverDir + File.separator + "log" + File.separator + "server.log" ; File logFile = new File (logFileName); 72 if (logFile.exists()) { 73 logWriter.start(logFile); 74 } 75 } 76 else { 77 logWriter.refresh(); 78 } 79 } 80 } 81 82 public HelpCtx getHelpCtx() { 83 return HelpCtx.DEFAULT_HELP; 84 } 85 86 public String getName() { 87 return NbBundle.getMessage(OpenServerLogAction.class, "LBL_OpenServerLogAction"); 88 } 89 90 public boolean asynchronous() { 91 return false; 92 } 93 94 } 95 | Popular Tags |