KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > websphere6 > ui > nodes > actions > ShowServerLogAction


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.j2ee.websphere6.ui.nodes.actions;
20
21 import java.io.File JavaDoc;
22 import org.netbeans.modules.j2ee.websphere6.WSDeploymentManager;
23 import org.netbeans.modules.j2ee.websphere6.ui.nodes.WSManagerNode;
24 import org.netbeans.modules.j2ee.websphere6.util.WSDebug;
25 import org.netbeans.modules.j2ee.websphere6.util.WSTailer;
26 import org.openide.nodes.Node;
27 import org.openide.util.HelpCtx;
28 import org.openide.util.NbBundle;
29 import org.openide.util.actions.CookieAction;
30
31 /**
32  *
33  * @author Kirill Sorokin
34  */

35 public class ShowServerLogAction extends CookieAction {
36     protected void performAction(Node[] nodes) {
37         if( (nodes == null) || (nodes.length < 1)) {
38             return;
39         }
40         
41         for (int i = 0; i < nodes.length; i++) {
42             Object JavaDoc node = nodes[i].getLookup().lookup(WSManagerNode.class);
43             if (node instanceof WSManagerNode) {
44                 try{
45                     File JavaDoc file =
46                             new File JavaDoc(((WSManagerNode) node).getLogFilePath());
47                     
48                     WSDebug.notify(file.getAbsolutePath());
49                     
50                     
51                     WSDeploymentManager dm = ((WSManagerNode) node).
52                             getDeploymentManager();
53                     
54                     new WSTailer(file,
55                             NbBundle.getMessage(
56                             ShowServerLogAction.class,
57                             "LBL_LogWindowTitle",
58                             dm.getServerTitleMessage())).start(); // NOI18N
59
} catch (Exception JavaDoc e){
60                     return;//nothing much to do
61
}
62             }
63         }
64     }
65     
66     public String JavaDoc getName() {
67         return NbBundle.getMessage(ShowAdminConsoleAction.class, "LBL_ShowServerLog");
68     }
69     
70     protected int mode() {
71         return MODE_EXACTLY_ONE;
72     }
73     
74     public HelpCtx getHelpCtx() {
75         return null;
76     }
77     
78     protected Class JavaDoc[] cookieClasses() {
79         return new Class JavaDoc[]{};
80     }
81     
82     protected boolean enable(Node[] nodes) {
83         if (nodes == null || nodes.length < 1) {
84             return false;
85         }
86         
87         boolean local = true;
88         
89         for (int i = 0; i < nodes.length; i++) {
90             Object JavaDoc node = nodes[i].getLookup().lookup(WSManagerNode.class);
91             if (!(node instanceof WSManagerNode)) {
92                 local = false;
93                 break;
94             }
95             
96             WSDeploymentManager dm =
97                     ((WSManagerNode) node).getDeploymentManager();
98             
99             local = dm.getIsLocal().equals("true"); // NOI18N
100
}
101         
102         return local;
103     }
104     
105     protected boolean asynchronous() {
106         return false;
107     }
108 }
Popular Tags