/** * Update model values * @param actionEvent the event that led to this call */ protected void doUpdate(ActionEvent actionEvent) { tableModel.setValueAt(nameTF.getText(), selectedRow, 0); tableModel.setValueAt(valueTA.getText(), selectedRow, 1); // Change Cancel label to Close closeButton.setText(JMeterUtils.getResString("close")); //$NON-NLS-1$ textChanged = false; }
/** * replace the argument value of the selection with a variable * the variable name is derived from the parameter name */ private void transformNameIntoVariable() { int[] rowsSelected = getTable().getSelectedRows(); for (int selectedRow : rowsSelected) { String name = (String) tableModel.getValueAt(selectedRow, 0); if (StringUtils.isNotBlank(name)) { name = name.trim(); name = name.replaceAll("\\$", "_"); name = name.replaceAll("\\{", "_"); name = name.replaceAll("\\}", "_"); tableModel.setValueAt("${" + name + "}", selectedRow, 1); } } }
/** * runs specified command on currently selected table row. * * @param command specifies which process will be done on selected * file. it's coming from action command currently caught by * action listener. * * @param rowSelected index of selected row. */ private void runCommandOnRow(String command, int rowSelected) { if (DELETE.equals(command)) { tableModel.removeRow(rowSelected); } else if (BROWSE.equals(command)) { String path = browseAndGetFilePath(); if(StringUtils.isNotBlank(path)) { tableModel.setValueAt(path, rowSelected, 0); } } }
@Override public void actionPerformed(ActionEvent e) { try { String clipboardContent = GuiUtils.getPastedText(); if(clipboardContent == null) { return; } String[] clipboardLines = clipboardContent.split("\n"); // $NON-NLS-1$ for (String clipboardLine : clipboardLines) { String[] columns = clipboardLine.split("\t"); // $NON-NLS-1$ model.addRow(clazz.newInstance()); for (int i=0; i < columns.length; i++) { model.setValueAt(columns[i], model.getRowCount() - 1, i); } } if(model.getRowCount()>1) { upButton.setEnabled(true); downButton.setEnabled(true); } else { upButton.setEnabled(false); downButton.setEnabled(false); } } catch (Exception err) { log.error("The class type given to TableEditor was not instantiable.", err); } } }