(JTable table, JFrame parentFrame,DefaultTableModel tableModel)
| 204 | |
| 205 | // 编辑行 |
| 206 | private static void editRow(JTable table, JFrame parentFrame,DefaultTableModel tableModel) { |
| 207 | int selectedRow = table.getSelectedRow(); |
| 208 | |
| 209 | if (selectedRow != -1) { |
| 210 | System.out.println(tableModel.getValueAt(selectedRow, 0)); |
| 211 | // 从1下标开始,因为0的下标是checkBox类型,在编辑页面不需要读取 |
| 212 | String hostText = (String)tableModel.getValueAt(selectedRow, 1); |
| 213 | String itemText = (String) tableModel.getValueAt(selectedRow, 2); |
| 214 | String matchText = (String) tableModel.getValueAt(selectedRow, 3); |
| 215 | String replaceText = (String) tableModel.getValueAt(selectedRow, 4); |
| 216 | String typeText = (String) tableModel.getValueAt(selectedRow, 5); |
| 217 | String commentText = (String) tableModel.getValueAt(selectedRow, 6); |
| 218 | |
| 219 | JComboBox JComboBoxitem = new JComboBox(); // 请求、响应部分选择 |
| 220 | DefaultComboBoxModel defaultComboBoxModelitem = new DefaultComboBoxModel(); |
| 221 | defaultComboBoxModelitem.addElement("Request header"); |
| 222 | defaultComboBoxModelitem.addElement("Request body"); |
| 223 | defaultComboBoxModelitem.addElement("Response header"); |
| 224 | defaultComboBoxModelitem.addElement("Response body"); |
| 225 | JComboBoxitem.setModel(defaultComboBoxModelitem); |
| 226 | |
| 227 | JComboBox JComboBoxtype = new JComboBox(); // 请求、响应部分选择 |
| 228 | DefaultComboBoxModel defaultComboBoxModeltype = new DefaultComboBoxModel(); |
| 229 | defaultComboBoxModeltype.addElement("Regex"); |
| 230 | defaultComboBoxModeltype.addElement("Literal"); |
| 231 | defaultComboBoxModeltype.addElement("Extract"); |
| 232 | JComboBoxtype.setModel(defaultComboBoxModeltype); |
| 233 | |
| 234 | JTextField hostField = new JTextField(30); |
| 235 | JTextField matchField = new JTextField(30); |
| 236 | JTextField replaceField = new JTextField(30); |
| 237 | // JTextField typeField = new JTextField(); |
| 238 | JTextField commentField = new JTextField(30); |
| 239 | |
| 240 | JPanel panel = new JPanel(new GridLayout(6, 2)); |
| 241 | panel.add(new JLabel("Host:")); |
| 242 | panel.add(hostField); |
| 243 | panel.add(new JLabel("Item:")); |
| 244 | panel.add(JComboBoxitem); |
| 245 | panel.add(new JLabel("Match:")); |
| 246 | panel.add(matchField); |
| 247 | panel.add(new JLabel("Replace:")); |
| 248 | panel.add(replaceField); |
| 249 | panel.add(new JLabel("Type:")); |
| 250 | panel.add(JComboBoxtype); |
| 251 | panel.add(new JLabel("Comment:")); |
| 252 | panel.add(commentField); |
| 253 | |
| 254 | hostField.setText(hostText); |
| 255 | JComboBoxitem.setSelectedItem(itemText); |
| 256 | matchField.setText(matchText); |
| 257 | replaceField.setText(replaceText); |
| 258 | JComboBoxtype.setSelectedItem(typeText); |
| 259 | commentField.setText(commentText); |
| 260 | |
| 261 | int result = JOptionPane.showConfirmDialog(parentFrame, panel, "Edit Row", |
| 262 | JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); |
| 263 |
no test coverage detected