1 19 20 29 30 package org.netbeans.modules.web.monitor.client; 31 32 import javax.swing.table.*; import javax.swing.JLabel ; 34 import javax.swing.JTextArea ; 35 import org.netbeans.modules.web.monitor.data.*; 36 import org.openide.util.NbBundle; 37 import java.util.ResourceBundle ; 38 import java.awt.Component ; 39 40 import javax.swing.event.TableModelEvent ; 42 import javax.swing.event.TableModelListener ; 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 public void setData(DataRecord md) { 60 61 if(debug) System.out.println("in RequestDisplay.setData()"); this.removeAll(); 63 if (md == null) 64 return; 65 66 String [] 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); dt.setValueAt(rd.getAttributeValue("method"),1,1); dt.setValueAt(rd.getAttributeValue("queryString"), 2,1); dt.setValueAt(rd.getAttributeValue("protocol"), 3,1); dt.setValueAt(rd.getAttributeValue("ipaddress"), 4,1); dt.setValueAt(rd.getAttributeValue("scheme"), 5,1); dt.setValueAt(rd.getAttributeValue("status"), 6,1); 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 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 msg; 116 117 119 Param[] params2 = rd.getParam(); 120 String msg2 = ""; Component queryDataLabel = null; 122 boolean bad = false; 123 124 if(params2 == null || params2.length == 0) { 125 if("POST".equals(rd.getAttributeValue("method"))) { 127 String type = rd.getAttributeValue("urlencoded"); 129 if(type != null) { 130 131 if (type.equals("false")) { msg2 = NbBundle.getBundle(RequestDisplay.class).getString("MON_Unparameterized"); 133 } 134 else if (type.equals("bad")) { 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 () { 153 public void tableChanged(TableModelEvent 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 ta = new JTextArea (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 ex) { 199 } 200 201 if(param != null && param.length > 0) { 202 203 JLabel 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 ex) { 231 } 232 233 if(param != null && param.length > 0) { 234 235 JLabel 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 } | Popular Tags |