use of org.apache.jmeter.gui.SavePropertyDialog in project jmeter-plugins by undera.
the class MergeResultsGui method actionPerformed.
public void actionPerformed(ActionEvent action) {
String command = action.getActionCommand();
if (grid.isEditing()) {
TableCellEditor cellEditor = grid.getCellEditor(grid.getEditingRow(), grid.getEditingColumn());
cellEditor.stopCellEditing();
}
switch(command) {
case ACTION_ADD:
{
tableModel.addRow(defaultValues);
tableModel.fireTableDataChanged();
if (tableModel.getRowCount() >= MAX_FILE_HANDLES) {
addRowButton.setEnabled(false);
copyRowButton.setEnabled(false);
}
// Enable DELETE and MERGE
deleteRowButton.setEnabled(true);
mergeButton.setEnabled(true);
// Highlight (select) the appropriate row.
int rowToSelect = tableModel.getRowCount() - 1;
if (rowToSelect < grid.getRowCount()) {
grid.setRowSelectionInterval(rowToSelect, rowToSelect);
}
updateUI();
break;
}
case ACTION_COPY:
{
final int selectedRow = grid.getSelectedRow();
if (tableModel.getRowCount() == 0 || selectedRow < 0) {
return;
}
tableModel.addRow(tableModel.getRowData(selectedRow));
tableModel.fireTableDataChanged();
if (tableModel.getRowCount() >= MAX_FILE_HANDLES) {
addRowButton.setEnabled(false);
copyRowButton.setEnabled(false);
}
// Enable DELETE and MERGE
deleteRowButton.setEnabled(true);
mergeButton.setEnabled(true);
// Highlight (select) the appropriate row.
int rowToSelect = selectedRow + 1;
grid.setRowSelectionInterval(rowToSelect, rowToSelect);
updateUI();
break;
}
case ACTION_DELETE:
final int rowSelected = grid.getSelectedRow();
if (rowSelected >= 0) {
tableModel.removeRow(rowSelected);
tableModel.fireTableDataChanged();
if (tableModel.getRowCount() < MAX_FILE_HANDLES) {
addRowButton.setEnabled(true);
copyRowButton.setEnabled(true);
}
// table to delete.
if (tableModel.getRowCount() == 0) {
deleteRowButton.setEnabled(false);
mergeButton.setEnabled(false);
} else // Table still contains one or more rows, so highlight
// (select) the appropriate one.
{
int rowToSelect = rowSelected;
if (rowSelected >= tableModel.getRowCount()) {
rowToSelect = rowSelected - 1;
}
grid.setRowSelectionInterval(rowToSelect, rowToSelect);
}
updateUI();
}
break;
case ACTION_MERGE:
String output = getFile();
if (output.isEmpty()) {
GuiPackage.showErrorMessage("Error merging results files - empty output filename", "Output file error");
return;
}
boolean isSuccess = loadFilesFromTable((CorrectedResultCollector) collector);
if (isSuccess) {
mergeService = new MergeResultsService();
collector.setFilename(output);
mergeService.mergeSamples((CorrectedResultCollector) collector, samples);
}
samples.clear();
break;
case ACTION_SAVE_CONFIG:
SavePropertyDialog d = new SavePropertyDialog(GuiPackage.getInstance().getMainFrame(), JMeterUtils.getResString("sample_result_save_configuration"), true, collector.getSaveConfig());
d.pack();
ComponentUtil.centerComponentInComponent(GuiPackage.getInstance().getMainFrame(), d);
d.setVisible(true);
break;
}
}
Aggregations