KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mc4j > console > connection > StatsIntrospectorAction


1 /*
2  * Copyright 2002-2004 Greg Hinkle
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.mc4j.console.connection;
18
19 import org.mc4j.ems.connection.bean.EmsBean;
20 import org.openide.nodes.Node;
21 import org.openide.util.HelpCtx;
22 import org.openide.util.actions.NodeAction;
23 import org.openide.windows.IOProvider;
24 import org.openide.windows.OutputWriter;
25
26 import java.util.SortedSet JavaDoc;
27
28 /**
29  *
30  * @author Greg Hinkle (ghinkle@users.sourceforge.net), August 2002
31  * @version $Revision: 570 $($Author: ghinkl $ / $Date: 2006-04-12 15:14:16 -0400 (Wed, 12 Apr 2006) $)
32  */

33 public class StatsIntrospectorAction extends NodeAction {
34
35     protected void performAction(Node[] nodes) {
36         ConnectionNode node = (ConnectionNode)nodes[0];
37
38         OutputWriter w = IOProvider.getDefault().getIO("Stats Output", true).getOut();
39
40         SortedSet JavaDoc<EmsBean> beans = node.getEmsConnection().getBeans();
41
42         for (EmsBean bean : beans) {
43             if (bean.getAttribute("Stats") != null) {
44                 w.println("\t" + bean.getBeanName().getCanonicalName());
45             }
46         }
47      }
48
49
50     protected boolean enable(Node[] nodes) {
51         return ((nodes.length == 1) &&
52             (nodes[0] instanceof ConnectionNode) &&
53             (((ConnectionNode)nodes[0]).isConnected()));
54     }
55
56     public String JavaDoc getName() {
57         return "Print Stats Nodes";
58     }
59
60     protected String JavaDoc iconResource() {
61         return null;
62     }
63
64     public HelpCtx getHelpCtx() {
65         return HelpCtx.DEFAULT_HELP;
66         // If you will provide context help then use:
67
// return new HelpCtx(DisconnectAction.class);
68
}
69
70 }
71
Popular Tags