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: * ContextDisplay.java
044: *
045: *
046: * Created: Wed Jan 16 14:44:11 PST 2002
047: *
048: * @author Ana von Klopp
049: * @version
050: */package org.netbeans.modules.web.monitor.client;
051:
052: import javax.swing.table.*; // widgets
053: import org.netbeans.modules.web.monitor.data.*;
054: import org.openide.util.NbBundle;
055: import java.util.*;
056:
057: public class ContextDisplay extends DataDisplay {
058:
059: private final static boolean debug = false;
060:
061: DisplayTable contextTable;
062:
063: public ContextDisplay() {
064: super ();
065: }
066:
067: // We're treating these as if they are all strings at the
068: // moment. In reality they can be of different types, though maybe
069: // that does not matter...
070: public void setData(DataRecord md) {
071:
072: //boolean iplanet = false;
073: boolean servlet = true;
074: boolean failed = false;
075:
076: if (debug)
077: System.out.println("in ContextDisplay.setData()"); //NOI18N
078: this .removeAll();
079: if (md == null)
080: return;
081:
082: ContextData cd = md.getContextData();
083: if (cd != null)
084: displayContextData(cd);
085: else {
086: ServletData sd = md.getServletData();
087: displayServletData(sd);
088:
089: }
090: }
091:
092: private void displayContextData(ContextData cd) {
093: if (debug)
094: System.out.println(cd.dumpBeanNode());
095:
096: String[] props = {
097: NbBundle.getBundle(ClientDisplay.class).getString(
098: "MON_Context_name"),
099: NbBundle.getBundle(ClientDisplay.class).getString(
100: "MON_Absolute_path"), };
101:
102: contextTable = new DisplayTable(props);
103:
104: int gridy = -1;
105:
106: addGridBagComponent(this , createTopSpacer(), 0, ++gridy,
107: fullGridWidth, 1, 0, 0,
108: java.awt.GridBagConstraints.WEST,
109: java.awt.GridBagConstraints.NONE, topSpacerInsets, 0, 0);
110:
111: // context data
112: addGridBagComponent(this , createHeaderLabel(NbBundle.getBundle(
113: ClientDisplay.class).getString("MON_Servlet_context"),
114: NbBundle.getBundle(ClientDisplay.class).getString(
115: "MON_Servlet_context_Mnemonic").charAt(0),
116: NbBundle.getBundle(ClientDisplay.class).getString(
117: "ACS_MON_Servlet_contextA11yDesc"),
118: contextTable), 0, ++gridy, fullGridWidth, 1, 0, 0,
119: java.awt.GridBagConstraints.WEST,
120: java.awt.GridBagConstraints.NONE, labelInsets, 0, 0);
121:
122: contextTable.setValueAt(cd.getAttributeValue("contextName"), 0,
123: 1); //NOI18N
124: contextTable.setValueAt(cd.getAttributeValue("absPath"), 1, 1); //NOI18N
125: contextTable.getAccessibleContext().setAccessibleName(
126: NbBundle.getBundle(ClientDisplay.class).getString(
127: "ACS_MON_Servlet_contextTableA11yName"));
128: contextTable.setToolTipText(NbBundle.getBundle(
129: ClientDisplay.class).getString(
130: "ACS_MON_Servlet_contextTableA11yDesc"));
131: addGridBagComponent(this , contextTable, 0, ++gridy,
132: fullGridWidth, 1, tableWeightX, tableWeightY,
133: java.awt.GridBagConstraints.WEST,
134: java.awt.GridBagConstraints.BOTH, tableInsets, 0, 0);
135:
136: Param[] ctxtparam = null;
137: try {
138: ctxtparam = cd.getContextAttributes().getParam();
139: } catch (Exception ex) {
140: }
141:
142: if (ctxtparam != null && ctxtparam.length > 0) {
143:
144: DisplayTable dt = new DisplayTable(ctxtparam);
145: addGridBagComponent(this , createHeaderLabel(NbBundle
146: .getBundle(ClientDisplay.class).getString(
147: "MON_Context_att"), NbBundle.getBundle(
148: ClientDisplay.class).getString(
149: "MON_Context_att_Mnemonic").charAt(0), NbBundle
150: .getBundle(ClientDisplay.class).getString(
151: "ACS_MON_Context_att_A11yDesc"), dt), 0,
152: ++gridy, fullGridWidth, 1, 0, 0,
153: java.awt.GridBagConstraints.WEST,
154: java.awt.GridBagConstraints.NONE, labelInsets, 0, 0);
155: dt.getAccessibleContext().setAccessibleName(
156: NbBundle.getBundle(ClientDisplay.class).getString(
157: "ACS_MON_Context_att_TableA11yName"));
158: dt.setToolTipText(NbBundle.getBundle(ClientDisplay.class)
159: .getString("ACS_MON_Context_att_TableA11yDesc"));
160: addGridBagComponent(this , dt, 0, ++gridy, fullGridWidth, 1,
161: tableWeightX, tableWeightY,
162: java.awt.GridBagConstraints.WEST,
163: java.awt.GridBagConstraints.BOTH, tableInsets, 0, 0);
164: }
165:
166: // Init parameters
167: Param[] param = cd.getParam();
168: if (param == null || param.length == 0)
169: addGridBagComponent(this , createDataLabel(NbBundle
170: .getBundle(ClientDisplay.class).getString(
171: "MON_No_init")), 0, ++gridy, fullGridWidth,
172: 1, 0, 0, java.awt.GridBagConstraints.WEST,
173: java.awt.GridBagConstraints.NONE, labelInsets, 0, 0);
174: else {
175:
176: DisplayTable paramTable = new DisplayTable(param);
177: paramTable.getAccessibleContext().setAccessibleName(
178: NbBundle.getBundle(ClientDisplay.class).getString(
179: "ACS_MON_Init_parametersTableA11yName"));
180: paramTable.setToolTipText(NbBundle.getBundle(
181: ClientDisplay.class).getString(
182: "ACS_MON_Init_parametersTableA11yDesc"));
183: addGridBagComponent(this , createHeaderLabel(NbBundle
184: .getBundle(ClientDisplay.class).getString(
185: "MON_Init_parameters"), NbBundle.getBundle(
186: ClientDisplay.class).getString(
187: "MON_Init_parameters_Mnemonic").charAt(0), NbBundle
188: .getBundle(ClientDisplay.class).getString(
189: "ACS_MON_Init_parametersA11yDesc"),
190: paramTable), 0, ++gridy, fullGridWidth, 1, 0, 0,
191: java.awt.GridBagConstraints.WEST,
192: java.awt.GridBagConstraints.NONE, labelInsets, 0, 0);
193: addGridBagComponent(this , paramTable, 0, ++gridy,
194: fullGridWidth, 1, tableWeightX, tableWeightY,
195: java.awt.GridBagConstraints.WEST,
196: java.awt.GridBagConstraints.BOTH, tableInsets, 0, 0);
197: }
198:
199: addGridBagComponent(this , createGlue(), 0, ++gridy, 1, 1, 1.0,
200: 1.0, java.awt.GridBagConstraints.WEST,
201: java.awt.GridBagConstraints.BOTH, zeroInsets, 0, 0);
202: }
203:
204: // This method is for backwards compatibility only, it will
205: // display context data recorded with FFJ 3.0
206: private void displayServletData(ServletData sd) {
207: if (debug)
208: System.out.println(sd.dumpBeanNode());
209:
210: String[] props = {
211: NbBundle.getBundle(ClientDisplay.class).getString(
212: "MON_Context_name"),
213: NbBundle.getBundle(ClientDisplay.class).getString(
214: "MON_Absolute_path"), };
215:
216: contextTable = new DisplayTable(props);
217:
218: int gridy = -1;
219:
220: addGridBagComponent(this , createTopSpacer(), 0, ++gridy,
221: fullGridWidth, 1, 0, 0,
222: java.awt.GridBagConstraints.WEST,
223: java.awt.GridBagConstraints.NONE, topSpacerInsets, 0, 0);
224:
225: // context data
226: addGridBagComponent(this , createHeaderLabel(NbBundle.getBundle(
227: ClientDisplay.class).getString("MON_Servlet_context"),
228: NbBundle.getBundle(ClientDisplay.class).getString(
229: "MON_Servlet_context_Mnemonic").charAt(0),
230: NbBundle.getBundle(ClientDisplay.class).getString(
231: "ACS_MON_Servlet_contextA11yDesc"),
232: contextTable), 0, ++gridy, fullGridWidth, 1, 0, 0,
233: java.awt.GridBagConstraints.WEST,
234: java.awt.GridBagConstraints.NONE, labelInsets, 0, 0);
235:
236: contextTable.setValueAt(sd.getAttributeValue("contextName"), 0,
237: 1); //NOI18N
238: contextTable.setValueAt(sd.getAttributeValue("absPath"), 1, 1); //NOI18N
239: contextTable.getAccessibleContext().setAccessibleName(
240: NbBundle.getBundle(ClientDisplay.class).getString(
241: "ACS_MON_Servlet_contextTableA11yName"));
242: contextTable.setToolTipText(NbBundle.getBundle(
243: ClientDisplay.class).getString(
244: "ACS_MON_Servlet_contextTableA11yDesc"));
245: addGridBagComponent(this , contextTable, 0, ++gridy,
246: fullGridWidth, 1, tableWeightX, tableWeightY,
247: java.awt.GridBagConstraints.WEST,
248: java.awt.GridBagConstraints.BOTH, tableInsets, 0, 0);
249:
250: addGridBagComponent(this , createGlue(), 0, ++gridy, 1, 1, 1.0,
251: 1.0, java.awt.GridBagConstraints.WEST,
252: java.awt.GridBagConstraints.BOTH, zeroInsets, 0, 0);
253: }
254: } // ContextDisplay
|