KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > monitor > client > MonitorAction


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
20 /**
21  * MonitorAction.java
22  *
23  *
24  * Created: Wed Feb 2 15:37:25 2000
25  *
26  * @author Ana von Klopp
27  * @version
28  */

29
30 package org.netbeans.modules.web.monitor.client;
31
32 import org.openide.util.actions.CallableSystemAction;
33 import org.openide.util.HelpCtx;
34 import org.openide.util.NbBundle;
35 import org.openide.windows.Mode;
36 import org.openide.windows.WindowManager;
37
38
39 public class MonitorAction extends CallableSystemAction {
40
41     static transient Controller controller = null;
42     private static final boolean debug = false;
43      
44     public MonitorAction() {
45     }
46
47     protected static Controller getController() {
48     return Controller.getInstance();
49     }
50     
51     public String JavaDoc getName () {
52     return NbBundle.getBundle(MonitorAction.class).getString("MON_HTTP_Transaction_13");
53     }
54   
55     public HelpCtx getHelpCtx () {
56     return new HelpCtx (MonitorAction.class);
57     }
58
59     protected String JavaDoc iconResource () {
60     return "org/netbeans/modules/web/monitor/client/icons/menuitem.gif"; //NOI18N
61

62     }
63
64     protected boolean asynchronous() {
65         return false;
66     }
67     
68     /**
69      * Starts a monitor window. This method is used by the menu item,
70      * so it should verify that the execution server is running, and
71      * if it isn't, restart it.
72      */

73   
74     public void performAction() {
75     openTransactionView();
76     }
77    
78     static void addTransaction(String JavaDoc id) {
79     if(!TransactionView.getInstance().isOpened()) {
80             boolean initialized = TransactionView.getInstance().isInitialized();
81             // If not initialized yet, this will cause the record to be loaded
82
// from disk, so we don't need to add it in this case
83
openTransactionView();
84             if (!initialized) {
85                 return;
86             }
87     }
88     // Otherwise we add it to the current records
89
Controller.getInstance().addTransaction(id);
90     }
91
92     private static void openTransactionView() {
93
94     TransactionView tv = TransactionView.getInstance();
95         WindowManager wm = WindowManager.getDefault();
96     Mode mode = wm.findMode(tv);
97         
98         if(mode == null) {
99             mode = wm.findMode("output"); // NOI18N
100
if(mode != null) {
101                 mode.dockInto(tv);
102             }
103         }
104     tv.open();
105         tv.requestVisible();
106         tv.requestActive();
107     }
108
109     public static void log(String JavaDoc s) {
110     log("MonitorAction::" + s); //NOI18N
111
}
112 }
113
114
Popular Tags