KickJava   Java API By Example, From Geeks To Geeks.

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


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  * RequestDisplay.java
22  *
23  *
24  * Created: Wed Jan 31 18:04:22 2001
25  *
26  * @author Ana von Klopp
27  * @version
28  */

29
30 package org.netbeans.modules.web.monitor.client;
31
32 import javax.swing.table.*; // widgets
33
import javax.swing.JLabel JavaDoc;
34 import javax.swing.JTextArea JavaDoc;
35 import org.netbeans.modules.web.monitor.data.*;
36 import org.openide.util.NbBundle;
37 import java.util.ResourceBundle JavaDoc;
38 import java.awt.Component JavaDoc;
39
40 // Can this go into displayTable?
41
import javax.swing.event.TableModelEvent JavaDoc;
42 import javax.swing.event.TableModelListener JavaDoc;
43
44 public class RequestDisplay extends DataDisplay {
45     
46     private final static boolean debug = false;
47     
48     private DisplayTable dt = null;
49     DisplayTable paramTable = null;
50         
51     public RequestDisplay() {
52
53     super();
54     }
55
56     // We're treating these as if they are all strings at the
57
// moment. In reality they can be of different types, though maybe
58
// that does not matter...
59
public void setData(DataRecord md) {
60
61     if(debug) System.out.println("in RequestDisplay.setData()"); //NOI18N
62
this.removeAll();
63     if (md == null)
64         return;
65     
66     String JavaDoc[] requestCategories = {
67         NbBundle.getBundle(RequestDisplay.class).getString("MON_Request_URI"),
68         NbBundle.getBundle(RequestDisplay.class).getString("MON_Method"),
69         NbBundle.getBundle(RequestDisplay.class).getString("MON_Querystring"),
70         NbBundle.getBundle(RequestDisplay.class).getString("MON_Protocol"),
71         NbBundle.getBundle(RequestDisplay.class).getString("MON_Remote_Address"),
72         NbBundle.getBundle(RequestDisplay.class).getString("MON_Scheme"),
73         NbBundle.getBundle(RequestDisplay.class).getString("MON_Status"),
74     };
75
76     RequestData rd = md.getRequestData();
77     dt = new DisplayTable(requestCategories);
78     dt.setValueAt(rd.getAttributeValue("uri"), 0,1); //NOI18N
79
dt.setValueAt(rd.getAttributeValue("method"),1,1); //NOI18N
80
dt.setValueAt(rd.getAttributeValue("queryString"), 2,1); //NOI18N
81
dt.setValueAt(rd.getAttributeValue("protocol"), 3,1); //NOI18N
82
dt.setValueAt(rd.getAttributeValue("ipaddress"), 4,1); //NOI18N
83
dt.setValueAt(rd.getAttributeValue("scheme"), 5,1); //NOI18N
84
dt.setValueAt(rd.getAttributeValue("status"), 6,1); //NOI18N
85
dt.getAccessibleContext().setAccessibleName(NbBundle.getBundle(RequestDisplay.class).getString("ACS_MON_RequestTable_19A11yName"));
86         dt.setToolTipText(NbBundle.getBundle(RequestDisplay.class).getString("ACS_MON_RequestTable_19A11yDesc"));
87
88     int gridy = -1;
89     addGridBagComponent(this, createTopSpacer(), 0, ++gridy,
90                 fullGridWidth, 1, 0, 0,
91                 java.awt.GridBagConstraints.WEST,
92                 java.awt.GridBagConstraints.NONE,
93                 topSpacerInsets,
94                 0, 0);
95
96         JLabel JavaDoc requestHeaderLabel = createHeaderLabel(NbBundle.getBundle(RequestDisplay.class).getString("MON_Request_19"));
97         requestHeaderLabel.setDisplayedMnemonic(NbBundle.getBundle(RequestDisplay.class).getString("MON_Request_19_Mnemonic").charAt(0));
98         requestHeaderLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(RequestDisplay.class).getString("ACS_MON_Request_19A11yDesc"));
99         requestHeaderLabel.setLabelFor(dt);
100     addGridBagComponent(this, requestHeaderLabel, 0, ++gridy,
101                 fullGridWidth, 1, 0, 0,
102                 java.awt.GridBagConstraints.WEST,
103                 java.awt.GridBagConstraints.NONE,
104                 labelInsets,
105                 0, 0);
106
107     addGridBagComponent(this, dt, 0, ++gridy,
108                 fullGridWidth, 1, tableWeightX, tableWeightY,
109                 java.awt.GridBagConstraints.WEST,
110                 java.awt.GridBagConstraints.BOTH,
111                 tableInsets,
112                 0, 0);
113
114
115     String JavaDoc msg;
116     
117     // add the parameters
118

119     Param[] params2 = rd.getParam();
120     String JavaDoc msg2 = ""; //NOI18N
121
Component JavaDoc queryDataLabel = null;
122     boolean bad = false;
123     
124     if(params2 == null || params2.length == 0) {
125         if("POST".equals(rd.getAttributeValue("method"))) { //NOI18N
126

127         String JavaDoc type = rd.getAttributeValue("urlencoded"); //NOI18N
128

129         if(type != null) {
130
131             if (type.equals("false")) { //NOI18N
132
msg2 = NbBundle.getBundle(RequestDisplay.class).getString("MON_Unparameterized");
133             }
134             else if (type.equals("bad")) { //NOI18N
135
msg2 = NbBundle.getBundle(RequestDisplay.class).getString("MON_Warning_param");
136             queryDataLabel =
137                 createHeaderLabel(msg2);
138             bad = true;
139             }
140             else msg2 = NbBundle.getBundle(RequestDisplay.class).getString("MON_No_posted_data");
141         }
142         else msg2 = NbBundle.getBundle(RequestDisplay.class).getString("MON_No_posted_data");
143         } else {
144         msg2 = NbBundle.getBundle(RequestDisplay.class).getString("MON_No_querystring");
145         }
146         if(queryDataLabel == null)
147         queryDataLabel = createDataLabel(msg2);
148         
149     } else {
150         msg2 = NbBundle.getBundle(RequestDisplay.class).getString("MON_Parameters");
151         paramTable = new DisplayTable(params2, true);
152         paramTable.addTableModelListener(new TableModelListener JavaDoc() {
153         public void tableChanged(TableModelEvent JavaDoc evt) {
154             paintTable();
155         }});
156         
157
158             paramTable.getAccessibleContext().setAccessibleName(NbBundle.getBundle(RequestDisplay.class).getString("ACS_MON_ParametersTableA11yName"));
159             paramTable.setToolTipText(NbBundle.getBundle(RequestDisplay.class).getString("ACS_MON_ParametersTableA11yDesc"));
160         queryDataLabel = createSortButtonLabel(msg2, paramTable, NbBundle.getBundle(RequestDisplay.class).getString("MON_Parameters_Mnemonic").charAt(0), NbBundle.getBundle(RequestDisplay.class).getString("ACS_MON_ParametersA11yDesc"));
161     }
162     
163     addGridBagComponent(this, queryDataLabel, 0, ++gridy,
164                 1, 1, 0, 0,
165                 java.awt.GridBagConstraints.WEST,
166                 java.awt.GridBagConstraints.NONE,
167                 labelInsets,
168                 0, 0);
169
170     if (params2 != null && params2.length > 0) {
171         addGridBagComponent(this, paramTable, 0, ++gridy,
172                 fullGridWidth, 1, tableWeightX, tableWeightY,
173                 java.awt.GridBagConstraints.WEST,
174                 java.awt.GridBagConstraints.BOTH,
175                 tableInsets,
176                 0, 0);
177     }
178     else if(bad) {
179         JTextArea JavaDoc ta = new JTextArea JavaDoc(NbBundle.getBundle(RequestDisplay.class).getString("MON_Unparameterized_bad"));
180         ta.setEditable(false);
181         ta.setLineWrap(true);
182         ta.setBackground(this.getBackground());
183         addGridBagComponent(this, ta, 0, ++gridy,
184                 fullGridWidth, 1, tableWeightX, tableWeightY,
185                 java.awt.GridBagConstraints.WEST,
186                 java.awt.GridBagConstraints.BOTH,
187                 tableInsets,
188                 0, 0);
189             
190     }
191     
192     this.add(createRigidArea());
193
194     Param[] param = null;
195     try {
196         param = rd.getRequestAttributesIn().getParam();
197     }
198     catch(Exception JavaDoc ex) {
199     }
200
201     if(param != null && param.length > 0) {
202
203         JLabel JavaDoc requestAttrBeforeLabel =
204         createHeaderLabel(NbBundle.getBundle(RequestDisplay.class).getString("MON_Request_att_before"));
205         requestAttrBeforeLabel.setDisplayedMnemonic(NbBundle.getBundle(RequestDisplay.class).getString("MON_Request_att_before_Mnemonic").charAt(0));
206         requestAttrBeforeLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(RequestDisplay.class).getString("ACS_MON_Request_att_beforeA11yDesc"));
207         addGridBagComponent(this, requestAttrBeforeLabel, 0, ++gridy,
208                 fullGridWidth, 1, 0, 0,
209                 java.awt.GridBagConstraints.WEST,
210                 java.awt.GridBagConstraints.NONE,
211                 labelInsets,
212                 0, 0);
213         dt = new DisplayTable(param);
214         requestAttrBeforeLabel.setLabelFor(dt);
215         dt.getAccessibleContext().setAccessibleName(NbBundle.getBundle(RequestDisplay.class).getString("ACS_MON_Request_att_beforeTableA11yName"));
216         dt.setToolTipText(NbBundle.getBundle(RequestDisplay.class).getString("ACS_MON_Request_att_beforeTableA11yDesc"));
217         addGridBagComponent(this, dt, 0, ++gridy,
218                 fullGridWidth, 1, tableWeightX, tableWeightY,
219                 java.awt.GridBagConstraints.WEST,
220                 java.awt.GridBagConstraints.BOTH,
221                 tableInsets,
222                 0, 0);
223         this.add(createRigidArea());
224     }
225     
226     param = null;
227     try {
228         param = rd.getRequestAttributesOut().getParam();
229     }
230     catch(Exception JavaDoc ex) {
231     }
232
233     if(param != null && param.length > 0) {
234
235         JLabel JavaDoc requestAttrAfterLabel =
236         createHeaderLabel(NbBundle.getBundle(RequestDisplay.class).getString("MON_Request_att_after"));
237         requestAttrAfterLabel.setDisplayedMnemonic(NbBundle.getBundle(RequestDisplay.class).getString("MON_Request_att_after_Mnemonic").charAt(0));
238         requestAttrAfterLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(RequestDisplay.class).getString("ACS_MON_Request_att_afterA11yDesc"));
239         addGridBagComponent(this, requestAttrAfterLabel, 0, ++gridy,
240                 fullGridWidth, 1, 0, 0,
241                 java.awt.GridBagConstraints.WEST,
242                 java.awt.GridBagConstraints.NONE,
243                 labelInsets,
244                 0, 0);
245         dt = new DisplayTable(param);
246         requestAttrAfterLabel.setLabelFor(dt);
247         dt.getAccessibleContext().setAccessibleName(NbBundle.getBundle(RequestDisplay.class).getString("ACS_MON_Request_att_afterTableA11yName"));
248         dt.setToolTipText(NbBundle.getBundle(RequestDisplay.class).getString("ACS_MON_Request_att_afterTableA11yDesc"));
249         addGridBagComponent(this, dt, 0, ++gridy,
250                 fullGridWidth, 1, tableWeightX, tableWeightY,
251                 java.awt.GridBagConstraints.WEST,
252                 java.awt.GridBagConstraints.BOTH,
253                 tableInsets,
254                 0, 0);
255     }
256     
257     addGridBagComponent(this, createGlue(), 0, ++gridy,
258                 1, 1, 1.0, 1.0,
259                 java.awt.GridBagConstraints.WEST,
260                 java.awt.GridBagConstraints.BOTH,
261                 zeroInsets,
262                 0, 0);
263
264
265
266     this.setMaximumSize(this.getPreferredSize());
267     this.repaint();
268     }
269
270     void paintTable()
271     {
272     paramTable.repaint();
273     }
274     
275
276 } // RequestDisplay
277
Popular Tags