This commit is contained in:
boccioli_m
2017-10-19 16:17:21 +02:00
parent e3a36b6459
commit 2ed5d67e20
14 changed files with 386 additions and 47 deletions

View File

@@ -56,6 +56,7 @@ import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JMenuItem;
import javax.swing.RowFilter;
import javax.swing.UIManager;
import javax.swing.filechooser.FileSystemView;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableModel;
@@ -346,7 +347,8 @@ public class TestingList extends Panel {
} catch (Exception ex) {
getLogger().severe(ex.getMessage());
}
loadProperties();
loadProperties();
}
@@ -1570,7 +1572,7 @@ public class TestingList extends Panel {
* @return status of run button. True = tests launching sequence is running
*/
public boolean isTestRunAllowed() {
return (this.jButtonRun.getToolTipText().equals("Stop tests") && pendingTestsCount() > 0);
return (this.jButtonRun.getToolTipText().equals("Stop tests") && countPendingTests() > 0);
}
/**
@@ -1733,18 +1735,34 @@ public class TestingList extends Panel {
logger.log(Level.SEVERE, "Cant find Test: " + testPath + " in table.");
}
//check if there are still pending tests. If not, set the status of the tool to Stopped.
if (pendingTestsCount() == 0 && runningTestsCount() == 0) {
if (countPendingTests() == 0 && countRunningTests() == 0) {
setToStopped();
}
updateResultSummary();
return rowD;
}
/**
* show a summary icon indicating if all tests succeeded
* or if at least one failed
*/
public void updateResultSummary() {
ImageIcon summaryIcon = null;
if(countFailureTests()>0){
summaryIcon = TestStatus.FAILURE.Icon();
} else if(countSuccessTests()>0){
summaryIcon = TestStatus.SUCCESS.Icon();
}
//System.out.println("successful: "+countSuccessTests() + " Failed: "+countSuccessTests() );
setIcon(jTable1, COL.ICON.ordinal(), summaryIcon, "");
}
/**
* return the amount of tests currently in Pending state
*
* @return int counter of pending tests
*/
public int pendingTestsCount() {
public int countPendingTests() {
return testsStatusCount(TestStatus.PENDING);
}
@@ -1753,7 +1771,7 @@ public class TestingList extends Panel {
*
* @return int counter of running tests
*/
public int runningTestsCount() {
public int countRunningTests() {
return testsStatusCount(TestStatus.RUNNING);
}
@@ -1762,10 +1780,19 @@ public class TestingList extends Panel {
*
* @return int counter of successful tests
*/
public int successTestsCount() {
public int countSuccessTests() {
return testsStatusCount(TestStatus.SUCCESS);
}
/**
* return the amount of tests currently in Failure state
*
* @return int counter of failed tests
*/
public int countFailureTests() {
return testsStatusCount(TestStatus.FAILURE);
}
/**
* returns the amount of tests currently in "status" state
*
@@ -1775,15 +1802,16 @@ public class TestingList extends Panel {
private int testsStatusCount(TestStatus status) {
String sStatus;
boolean bSelected;
int iPendingTestsCount = 0;
int iTestsCount = 0;
for (int row = 0; row < jTable1.getRowCount(); row++) {
bSelected = (boolean) jTable1.getValueAt(row, COL.CHECK.ordinal());
sStatus = jTable1.getValueAt(row, COL.STATUS.ordinal()).toString();
if (bSelected && sStatus == status.toString()) {
iPendingTestsCount++;
//System.out.println("sStatus: " +sStatus);
if (bSelected && sStatus.equals(status.toString())) {
iTestsCount++;
}
}
return iPendingTestsCount;
return iTestsCount;
}
/**
@@ -1895,6 +1923,7 @@ public class TestingList extends Panel {
jTable1.setValueAt(sStatus, row, COL.STATUS.ordinal());
jTable1.setValueAt(sStart, row, COL.STARTSEQUENCE.ordinal());
}
updateResultSummary();
}
/**
@@ -2283,7 +2312,7 @@ public class TestingList extends Panel {
//String testPath = FilenameUtils.separatorsToSystem(TESTS_TESTS_DEFAULT_DIR + testSuite + "/" + testName + "/" + testName + ".py");
String testPath = Paths.get(TESTS_TESTS_DEFAULT_DIR.toString(), testSuite, testName, testName + ".py").toString();
String devicePath = Paths.get(TESTS_DEVICES_DEFAULT_DIR.toString(), deviceName, deviceName + ".config").toString();
System.out.println("Path = " + testPath);
//System.out.println("Path = " + testPath);
Object rowData[] = new Object[]{false, "", sDate, deviceName, devicePath, deviceDescription, testSuite, testName, testPath, testParams, testDescription, testHelp, "", "Pending", icon};
//vedify that this test is not already in the table
int totalRows = model.getRowCount();
@@ -2690,4 +2719,51 @@ public class TestingList extends Panel {
SwingUtils.showMessage(this, "loadListFilter()", ex.toString());
}
}
/**
* for putting an icon and text to a table header
*/
public class iconRenderer extends DefaultTableCellRenderer{
public Component getTableCellRendererComponent(javax.swing.JTable table,
Object obj,boolean isSelected, boolean hasFocus, int row,
int column) {
txtIcon i = (txtIcon)obj;
if (obj == i) {
setIcon(i.imageIcon);
setText(i.txt);
}
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
setHorizontalAlignment(javax.swing.JLabel.CENTER);
return this;
}
}
/**
* for putting an icon and text to a table header
*/
public class txtIcon {
String txt;
ImageIcon imageIcon;
txtIcon(String text, ImageIcon icon) {
txt = text;
imageIcon = icon;
}
}
/**
* put an icon and text to a table header
*
* @param table the table where the header is
* @param col_index column index of the table header where to put the icon
* @param icon the icon to put to the header
* @param name the text to put to the header
*/
public void setIcon(javax.swing.JTable table, int col_index, ImageIcon icon,String name){
table.getTableHeader().getColumnModel().getColumn(col_index).setHeaderRenderer(new iconRenderer());
table.getColumnModel().getColumn(col_index).setHeaderValue(new txtIcon(name, icon));
table.updateUI();
}
}