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: * RequestDisplay.java
044: *
045: *
046: * Created: Wed Jan 31 18:04:22 2001
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 javax.swing.JLabel;
054: import javax.swing.JTextArea;
055: import org.netbeans.modules.web.monitor.data.*;
056: import org.openide.util.NbBundle;
057: import java.util.ResourceBundle;
058: import java.awt.Component;
059:
060: // Can this go into displayTable?
061: import javax.swing.event.TableModelEvent;
062: import javax.swing.event.TableModelListener;
063:
064: public class RequestDisplay extends DataDisplay {
065:
066: private final static boolean debug = false;
067:
068: private DisplayTable dt = null;
069: DisplayTable paramTable = null;
070:
071: public RequestDisplay() {
072:
073: super ();
074: }
075:
076: // We're treating these as if they are all strings at the
077: // moment. In reality they can be of different types, though maybe
078: // that does not matter...
079: public void setData(DataRecord md) {
080:
081: if (debug)
082: System.out.println("in RequestDisplay.setData()"); //NOI18N
083: this .removeAll();
084: if (md == null)
085: return;
086:
087: String[] requestCategories = {
088: NbBundle.getBundle(RequestDisplay.class).getString(
089: "MON_Request_URI"),
090: NbBundle.getBundle(RequestDisplay.class).getString(
091: "MON_Method"),
092: NbBundle.getBundle(RequestDisplay.class).getString(
093: "MON_Querystring"),
094: NbBundle.getBundle(RequestDisplay.class).getString(
095: "MON_Protocol"),
096: NbBundle.getBundle(RequestDisplay.class).getString(
097: "MON_Remote_Address"),
098: NbBundle.getBundle(RequestDisplay.class).getString(
099: "MON_Scheme"),
100: NbBundle.getBundle(RequestDisplay.class).getString(
101: "MON_Status"), };
102:
103: RequestData rd = md.getRequestData();
104: dt = new DisplayTable(requestCategories);
105: dt.setValueAt(rd.getAttributeValue("uri"), 0, 1); //NOI18N
106: dt.setValueAt(rd.getAttributeValue("method"), 1, 1); //NOI18N
107: dt.setValueAt(rd.getAttributeValue("queryString"), 2, 1); //NOI18N
108: dt.setValueAt(rd.getAttributeValue("protocol"), 3, 1); //NOI18N
109: dt.setValueAt(rd.getAttributeValue("ipaddress"), 4, 1); //NOI18N
110: dt.setValueAt(rd.getAttributeValue("scheme"), 5, 1); //NOI18N
111: dt.setValueAt(rd.getAttributeValue("status"), 6, 1); //NOI18N
112: dt.getAccessibleContext().setAccessibleName(
113: NbBundle.getBundle(RequestDisplay.class).getString(
114: "ACS_MON_RequestTable_19A11yName"));
115: dt.setToolTipText(NbBundle.getBundle(RequestDisplay.class)
116: .getString("ACS_MON_RequestTable_19A11yDesc"));
117:
118: int gridy = -1;
119: addGridBagComponent(this , createTopSpacer(), 0, ++gridy,
120: fullGridWidth, 1, 0, 0,
121: java.awt.GridBagConstraints.WEST,
122: java.awt.GridBagConstraints.NONE, topSpacerInsets, 0, 0);
123:
124: JLabel requestHeaderLabel = createHeaderLabel(NbBundle
125: .getBundle(RequestDisplay.class).getString(
126: "MON_Request_19"));
127: requestHeaderLabel.setDisplayedMnemonic(NbBundle.getBundle(
128: RequestDisplay.class).getString(
129: "MON_Request_19_Mnemonic").charAt(0));
130: requestHeaderLabel
131: .getAccessibleContext()
132: .setAccessibleDescription(
133: NbBundle
134: .getBundle(RequestDisplay.class)
135: .getString("ACS_MON_Request_19A11yDesc"));
136: requestHeaderLabel.setLabelFor(dt);
137: addGridBagComponent(this , requestHeaderLabel, 0, ++gridy,
138: fullGridWidth, 1, 0, 0,
139: java.awt.GridBagConstraints.WEST,
140: java.awt.GridBagConstraints.NONE, labelInsets, 0, 0);
141:
142: addGridBagComponent(this , dt, 0, ++gridy, fullGridWidth, 1,
143: tableWeightX, tableWeightY,
144: java.awt.GridBagConstraints.WEST,
145: java.awt.GridBagConstraints.BOTH, tableInsets, 0, 0);
146:
147: String msg;
148:
149: // add the parameters
150:
151: Param[] params2 = rd.getParam();
152: String msg2 = ""; //NOI18N
153: Component queryDataLabel = null;
154: boolean bad = false;
155:
156: if (params2 == null || params2.length == 0) {
157: if ("POST".equals(rd.getAttributeValue("method"))) { //NOI18N
158:
159: String type = rd.getAttributeValue("urlencoded"); //NOI18N
160:
161: if (type != null) {
162:
163: if (type.equals("false")) { //NOI18N
164: msg2 = NbBundle.getBundle(RequestDisplay.class)
165: .getString("MON_Unparameterized");
166: } else if (type.equals("bad")) { //NOI18N
167: msg2 = NbBundle.getBundle(RequestDisplay.class)
168: .getString("MON_Warning_param");
169: queryDataLabel = createHeaderLabel(msg2);
170: bad = true;
171: } else
172: msg2 = NbBundle.getBundle(RequestDisplay.class)
173: .getString("MON_No_posted_data");
174: } else
175: msg2 = NbBundle.getBundle(RequestDisplay.class)
176: .getString("MON_No_posted_data");
177: } else {
178: msg2 = NbBundle.getBundle(RequestDisplay.class)
179: .getString("MON_No_querystring");
180: }
181: if (queryDataLabel == null)
182: queryDataLabel = createDataLabel(msg2);
183:
184: } else {
185: msg2 = NbBundle.getBundle(RequestDisplay.class).getString(
186: "MON_Parameters");
187: paramTable = new DisplayTable(params2, true);
188: paramTable.addTableModelListener(new TableModelListener() {
189: public void tableChanged(TableModelEvent evt) {
190: paintTable();
191: }
192: });
193:
194: paramTable.getAccessibleContext().setAccessibleName(
195: NbBundle.getBundle(RequestDisplay.class).getString(
196: "ACS_MON_ParametersTableA11yName"));
197: paramTable.setToolTipText(NbBundle.getBundle(
198: RequestDisplay.class).getString(
199: "ACS_MON_ParametersTableA11yDesc"));
200: queryDataLabel = createSortButtonLabel(msg2, paramTable,
201: NbBundle.getBundle(RequestDisplay.class).getString(
202: "MON_Parameters_Mnemonic").charAt(0),
203: NbBundle.getBundle(RequestDisplay.class).getString(
204: "ACS_MON_ParametersA11yDesc"));
205: }
206:
207: addGridBagComponent(this , queryDataLabel, 0, ++gridy, 1, 1, 0,
208: 0, java.awt.GridBagConstraints.WEST,
209: java.awt.GridBagConstraints.NONE, labelInsets, 0, 0);
210:
211: if (params2 != null && params2.length > 0) {
212: addGridBagComponent(this , paramTable, 0, ++gridy,
213: fullGridWidth, 1, tableWeightX, tableWeightY,
214: java.awt.GridBagConstraints.WEST,
215: java.awt.GridBagConstraints.BOTH, tableInsets, 0, 0);
216: } else if (bad) {
217: JTextArea ta = new JTextArea(NbBundle.getBundle(
218: RequestDisplay.class).getString(
219: "MON_Unparameterized_bad"));
220: ta.setEditable(false);
221: ta.setLineWrap(true);
222: ta.setBackground(this .getBackground());
223: addGridBagComponent(this , ta, 0, ++gridy, fullGridWidth, 1,
224: tableWeightX, tableWeightY,
225: java.awt.GridBagConstraints.WEST,
226: java.awt.GridBagConstraints.BOTH, tableInsets, 0, 0);
227:
228: }
229:
230: this .add(createRigidArea());
231:
232: Param[] param = null;
233: try {
234: param = rd.getRequestAttributesIn().getParam();
235: } catch (Exception ex) {
236: }
237:
238: if (param != null && param.length > 0) {
239:
240: JLabel requestAttrBeforeLabel = createHeaderLabel(NbBundle
241: .getBundle(RequestDisplay.class).getString(
242: "MON_Request_att_before"));
243: requestAttrBeforeLabel.setDisplayedMnemonic(NbBundle
244: .getBundle(RequestDisplay.class).getString(
245: "MON_Request_att_before_Mnemonic")
246: .charAt(0));
247: requestAttrBeforeLabel
248: .getAccessibleContext()
249: .setAccessibleDescription(
250: NbBundle
251: .getBundle(RequestDisplay.class)
252: .getString(
253: "ACS_MON_Request_att_beforeA11yDesc"));
254: addGridBagComponent(this , requestAttrBeforeLabel, 0,
255: ++gridy, fullGridWidth, 1, 0, 0,
256: java.awt.GridBagConstraints.WEST,
257: java.awt.GridBagConstraints.NONE, labelInsets, 0, 0);
258: dt = new DisplayTable(param);
259: requestAttrBeforeLabel.setLabelFor(dt);
260: dt.getAccessibleContext().setAccessibleName(
261: NbBundle.getBundle(RequestDisplay.class).getString(
262: "ACS_MON_Request_att_beforeTableA11yName"));
263: dt.setToolTipText(NbBundle.getBundle(RequestDisplay.class)
264: .getString(
265: "ACS_MON_Request_att_beforeTableA11yDesc"));
266: addGridBagComponent(this , dt, 0, ++gridy, fullGridWidth, 1,
267: tableWeightX, tableWeightY,
268: java.awt.GridBagConstraints.WEST,
269: java.awt.GridBagConstraints.BOTH, tableInsets, 0, 0);
270: this .add(createRigidArea());
271: }
272:
273: param = null;
274: try {
275: param = rd.getRequestAttributesOut().getParam();
276: } catch (Exception ex) {
277: }
278:
279: if (param != null && param.length > 0) {
280:
281: JLabel requestAttrAfterLabel = createHeaderLabel(NbBundle
282: .getBundle(RequestDisplay.class).getString(
283: "MON_Request_att_after"));
284: requestAttrAfterLabel
285: .setDisplayedMnemonic(NbBundle.getBundle(
286: RequestDisplay.class).getString(
287: "MON_Request_att_after_Mnemonic").charAt(0));
288: requestAttrAfterLabel
289: .getAccessibleContext()
290: .setAccessibleDescription(
291: NbBundle
292: .getBundle(RequestDisplay.class)
293: .getString(
294: "ACS_MON_Request_att_afterA11yDesc"));
295: addGridBagComponent(this , requestAttrAfterLabel, 0,
296: ++gridy, fullGridWidth, 1, 0, 0,
297: java.awt.GridBagConstraints.WEST,
298: java.awt.GridBagConstraints.NONE, labelInsets, 0, 0);
299: dt = new DisplayTable(param);
300: requestAttrAfterLabel.setLabelFor(dt);
301: dt.getAccessibleContext().setAccessibleName(
302: NbBundle.getBundle(RequestDisplay.class).getString(
303: "ACS_MON_Request_att_afterTableA11yName"));
304: dt
305: .setToolTipText(NbBundle.getBundle(
306: RequestDisplay.class).getString(
307: "ACS_MON_Request_att_afterTableA11yDesc"));
308: addGridBagComponent(this , dt, 0, ++gridy, fullGridWidth, 1,
309: tableWeightX, tableWeightY,
310: java.awt.GridBagConstraints.WEST,
311: java.awt.GridBagConstraints.BOTH, tableInsets, 0, 0);
312: }
313:
314: addGridBagComponent(this , createGlue(), 0, ++gridy, 1, 1, 1.0,
315: 1.0, java.awt.GridBagConstraints.WEST,
316: java.awt.GridBagConstraints.BOTH, zeroInsets, 0, 0);
317:
318: this .setMaximumSize(this .getPreferredSize());
319: this .repaint();
320: }
321:
322: void paintTable() {
323: paramTable.repaint();
324: }
325:
326: } // RequestDisplay
|