001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: /**
043: * MonitorAction.java
044: *
045: *
046: * Created: Wed Feb 2 15:37:25 2000
047: *
048: * @author Ana von Klopp
049: * @version
050: */package org.netbeans.modules.web.monitor.client;
051:
052: import org.openide.util.actions.CallableSystemAction;
053: import org.openide.util.HelpCtx;
054: import org.openide.util.NbBundle;
055: import org.openide.windows.Mode;
056: import org.openide.windows.WindowManager;
057:
058: public class MonitorAction extends CallableSystemAction {
059:
060: static transient Controller controller = null;
061: private static final boolean debug = false;
062:
063: public MonitorAction() {
064: }
065:
066: protected static Controller getController() {
067: return Controller.getInstance();
068: }
069:
070: public String getName() {
071: return NbBundle.getBundle(MonitorAction.class).getString(
072: "MON_HTTP_Transaction_13");
073: }
074:
075: public HelpCtx getHelpCtx() {
076: return new HelpCtx(MonitorAction.class);
077: }
078:
079: protected String iconResource() {
080: return "org/netbeans/modules/web/monitor/client/icons/menuitem.gif"; //NOI18N
081:
082: }
083:
084: protected boolean asynchronous() {
085: return false;
086: }
087:
088: /**
089: * Starts a monitor window. This method is used by the menu item,
090: * so it should verify that the execution server is running, and
091: * if it isn't, restart it.
092: */
093:
094: public void performAction() {
095: openTransactionView();
096: }
097:
098: static void addTransaction(String id) {
099: if (!TransactionView.getInstance().isOpened()) {
100: boolean initialized = TransactionView.getInstance()
101: .isInitialized();
102: // If not initialized yet, this will cause the record to be loaded
103: // from disk, so we don't need to add it in this case
104: openTransactionView();
105: if (!initialized) {
106: return;
107: }
108: }
109: // Otherwise we add it to the current records
110: Controller.getInstance().addTransaction(id);
111: }
112:
113: private static void openTransactionView() {
114:
115: TransactionView tv = TransactionView.getInstance();
116: WindowManager wm = WindowManager.getDefault();
117: Mode mode = wm.findMode(tv);
118:
119: if (mode == null) {
120: mode = wm.findMode("output"); // NOI18N
121: if (mode != null) {
122: mode.dockInto(tv);
123: }
124: }
125: tv.open();
126: tv.requestVisible();
127: tv.requestActive();
128: }
129:
130: public static void log(String s) {
131: log("MonitorAction::" + s); //NOI18N
132: }
133: }
|