1 19 20 30 31 34 35 package org.netbeans.modules.web.monitor.client; 36 37 import java.awt.event.*; 38 import javax.swing.event.TableModelEvent ; 39 import javax.swing.event.TableModelListener ; 40 import java.util.ResourceBundle ; 41 import java.util.Hashtable ; 42 import org.openide.util.NbBundle; 43 import org.netbeans.modules.web.monitor.data.*; 44 45 class EditPanelRequest extends DataDisplay { 46 47 private final static boolean debug = false; 48 49 private static final String [] methodChoices = { 50 EditPanel.GET, 51 EditPanel.POST, 52 EditPanel.PUT 53 }; 54 55 private DisplayTable requestTable = null; 56 private MonitorData monitorData = null; 57 58 EditPanelRequest() { 59 super(); 60 } 61 62 void redisplayData() { 65 setData(monitorData); 66 } 67 68 void setData(MonitorData md) { 69 70 this.monitorData = md; 71 if(debug) log("setData()"); setRequestTable(); 73 74 this.removeAll(); 75 76 int gridy = -1; 77 int fullGridWidth = java.awt.GridBagConstraints.REMAINDER; 78 79 addGridBagComponent(this, createTopSpacer(), 0, ++gridy, 80 fullGridWidth, 1, 0, 0, 81 java.awt.GridBagConstraints.WEST, 82 java.awt.GridBagConstraints.NONE, 83 topSpacerInsets, 84 0, 0); 85 86 addGridBagComponent(this, 87 createHeaderLabel 88 (NbBundle.getBundle(EditPanelRequest.class).getString("MON_Request_19"), 89 NbBundle.getBundle(EditPanelRequest.class).getString("MON_Request_19_Mnemonic").charAt(0), 90 NbBundle.getBundle(EditPanelRequest.class).getString("ACS_MON_Request_19A11yDesc"), 91 requestTable), 92 0, ++gridy, 93 fullGridWidth, 1, 0, 0, 94 java.awt.GridBagConstraints.WEST, 95 java.awt.GridBagConstraints.NONE, 96 labelInsets, 97 0, 0); 98 99 addGridBagComponent(this, requestTable, 0, ++gridy, 100 fullGridWidth, 1, 1.0, 0, 101 java.awt.GridBagConstraints.NORTHWEST, 102 java.awt.GridBagConstraints.HORIZONTAL, 103 tableInsets, 104 0, 0); 105 106 addGridBagComponent(this, createGlue(), 0, ++gridy, 107 1, 1, 1.0, 1.0, 108 java.awt.GridBagConstraints.WEST, 109 java.awt.GridBagConstraints.BOTH, 110 zeroInsets, 111 0, 0); 112 113 114 int gridx = -1; 115 addGridBagComponent(this, createGlue(), ++gridx, ++gridy, 116 1, 1, 1.0, 0, 117 java.awt.GridBagConstraints.WEST, 118 java.awt.GridBagConstraints.NONE, 119 buttonInsets, 120 0, 0); 121 122 this.setMaximumSize(this.getPreferredSize()); 124 this.repaint(); 125 } 126 127 void setRequestTable() { 128 129 String [] requestCategories = { 130 NbBundle.getBundle(EditPanelRequest.class).getString("MON_Request_URI"), 131 NbBundle.getBundle(EditPanelRequest.class).getString("MON_Method"), 132 NbBundle.getBundle(EditPanelRequest.class).getString("MON_Protocol") 133 }; 134 135 requestTable = 136 new DisplayTable(requestCategories, DisplayTable.REQUEST); 137 138 RequestData rd = monitorData.getRequestData(); 139 requestTable.setValueAt(rd.getAttributeValue("uri"), 0,1); requestTable.setValueAt(rd.getAttributeValue(EditPanel.METHOD),1,1); 141 requestTable.setValueAt(rd.getAttributeValue("protocol"), 2,1); 143 javax.swing.JComboBox box = requestTable.setChoices(1, 1, methodChoices, false); 144 box.getAccessibleContext().setAccessibleName(requestCategories[1]); 145 box.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(EditPanelRequest.class,"ACS_MON_RequestMethod")); 146 requestTable.getAccessibleContext().setAccessibleName(NbBundle.getBundle(EditPanelRequest.class).getString("ACS_MON_RequestTable_19A11yName")); 147 requestTable.setToolTipText(NbBundle.getBundle(EditPanelRequest.class).getString("ACS_MON_RequestTable_19A11yDesc")); 148 149 requestTable.addTableModelListener(new TableModelListener () { 150 public void tableChanged(TableModelEvent evt) { 151 152 if(debug) log("tableChanged"); 154 RequestData rd = monitorData.getRequestData(); 155 156 String method = rd.getAttributeValue(EditPanel.METHOD); 159 String newMethod = (String )requestTable.getValueAt(1, 1); 160 if (method != null && !method.equals(newMethod)) { 161 rd.setAttributeValue(EditPanel.METHOD, newMethod); 162 163 if(method.equals(EditPanel.GET) && newMethod.equals(EditPanel.POST)) { 164 165 try { 168 String queryString = 169 rd.getAttributeValue("queryString"); Hashtable ht = 171 javax.servlet.http.HttpUtils.parseQueryString(queryString); 172 rd.setAttributeValue("queryString", ""); } 174 catch(Exception ex) { } 175 176 177 } 178 else if(method.equals(EditPanel.POST) && 179 newMethod.equals(EditPanel.GET)) { 180 Util.addParametersToQuery(rd); 181 } 182 } 183 184 String uri = (String )requestTable.getValueAt(0,1); 188 uri = uri.trim(); 189 190 String protocol = (String )requestTable.getValueAt(2,1); 191 protocol = protocol.trim(); 192 rd.setAttributeValue("uri", uri); rd.setAttributeValue("protocol", protocol); }}); 195 } 196 197 public void repaint() { 198 super.repaint(); 199 } 202 203 void log(String s) { 204 System.out.println("EditPanelRequest::" + s); } 206 207 } | Popular Tags |