@Override
public void actionPerformed(ActionEvent e) {
// get the current testbed
TestBedConfiguration testbed = TestBedConfiguration.getInstance();
// get the list of failed tests
CampaignWriter campaign = new CampaignWriter();
for (int i=0; i < tcTable.getRowCount(); i++) {
TestResult tr = (TestResult) tcModel.getValueAt(i, TC);
if (tr.getStatus()== TestResult.Status.FAIL) {
campaign.addCampaign(testbed.getFile().getName().replace("." + StaticConfiguration.CAMPAIGN_FILE_EXTENSION, ""),
tr.getTestCaseDirectory(),
tr.getTestData().getRowId());
}
}
// ask for name of test campaign
String newCampaign = JOptionPane.showInputDialog(null,
"Campaign name",
"Campaign name:", JOptionPane.QUESTION_MESSAGE);
if (newCampaign != null) {
// add the new campaign in the list
if (tcPane.getMainPanel().getTestCampaignPanel().addTestCampaign(newCampaign) >= 0) {
String fileName = StaticConfiguration.CAMPAIGN_DIRECTORY + File.separator + newCampaign + "." + StaticConfiguration.CAMPAIGN_FILE_EXTENSION;
campaign.save(fileName, newCampaign);
JOptionPane.showMessageDialog(null, "Campaign file has been saved in " + fileName + ".", "Information", JOptionPane.INFORMATION_MESSAGE);
}
}
}