Closedown

This commit is contained in:
boccioli_m
2015-06-10 10:30:20 +02:00
parent 71e8b8136a
commit 466e4428e4

View File

@@ -65,7 +65,6 @@ public class TestingList extends Panel {
//start next test
if(iCurrentTestPos>0)
{
Thread.sleep(9000);
testingList.executeTest(iCurrentTestPos+1);
}
}
@@ -95,8 +94,6 @@ public class TestingList extends Panel {
private final int COL_STATUS = 7;
private final int COL_ICON = 8;
private void initLogger() {
try {
FileHandler fh;
@@ -122,72 +119,6 @@ public class TestingList extends Panel {
@SuppressWarnings("unchecked")
//show test result in table
public int showResult(String deviceName, String testName, String res, String status) {
int rowD = -1, colT = -1;
//search for device name in table
for (int row = 0; row <= jTable1.getRowCount() - 1; row++) {
if (deviceName.equals(jTable1.getValueAt(row, COL_DEVICENAME))) {
rowD = row;
break;
}
}
if (rowD >= 0) {
//search for test name in table
if (testName.equals(jTable1.getValueAt(rowD, COL_TESTNAME))) {
colT = COL_TESTNAME;
}
}
String iconSource = "/icons/button_help-16px.png";
switch (status) {
case "Success":
iconSource = "/icons/button_ok-16px.png";
logger.log(Level.INFO, "Device: " + testName + "Test: " + testName + " Result: " + res + " (" + status + ")");
break;
case "Failed":
iconSource = "/icons/button_close-16px.png";
logger.log(Level.SEVERE, "Device: " + testName + "Test: " + testName + " Result: " + res + " (" + status + ")");
break;
case "Running":
iconSource = "/icons/button_play-16px.png";
logger.log(Level.INFO, "Running Test: " + testName + " ... ");
break;
}
ImageIcon icon = new ImageIcon(getClass().getResource(iconSource));
jTable1.setValueAt(icon, rowD, COL_ICON);
if (colT >= 0 && rowD >= 0) {
jTable1.setValueAt(getNow(), rowD, COL_TIME);
jTable1.setValueAt(res, rowD, COL_RESULT);
jTable1.setValueAt(status, rowD, COL_STATUS);
}
return rowD;
}
//returns the status of the specified test name for specified device name
public String getResult(String deviceName, String testName){
String sStatus = "";
int rowD = -1, colT = -1;
//search for device name in table
for (int row = 0; row <= jTable1.getRowCount() - 1; row++) {
if (deviceName.equals(jTable1.getValueAt(row, COL_DEVICENAME))) {
rowD = row;
break;
}
}
if (rowD >= 0) {
//search for test name in table
if (testName.equals(jTable1.getValueAt(rowD, COL_TESTNAME))) {
colT = COL_TESTNAME;
}
}
if (colT >= 0 && rowD >= 0) {
sStatus = jTable1.getValueAt(rowD, COL_STATUS).toString();
}
return sStatus;
}
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
@@ -289,11 +220,8 @@ public class TestingList extends Panel {
}// </editor-fold>//GEN-END:initComponents
private void jButtonRunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRunActionPerformed
try {
this.executeTest(0);
} catch (InterruptedException ex) {
Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex);
}
this.executeTest(0);
}//GEN-LAST:event_jButtonRunActionPerformed
private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
@@ -304,25 +232,6 @@ public class TestingList extends Panel {
updateStatus();
}//GEN-LAST:event_jCheckBox1ActionPerformed
public void updateStatus() {
String sStatus, iconSource;
boolean bSelected;
for (int row = 0; row <= jTable1.getRowCount() - 1; row++) {
bSelected = (boolean) jTable1.getValueAt(row, COL_CHECK);
if (bSelected) {
sStatus = "Pending";
iconSource = "/icons/button_pause-16px.png";
} else {
sStatus = "Disabled";
iconSource = "/icons/button_stop-16px.png";
}
ImageIcon icon = new ImageIcon(getClass().getResource(iconSource));
jTable1.setValueAt(bSelected, row, COL_CHECK);
jTable1.setValueAt(icon, row, COL_ICON);
jTable1.setValueAt(sStatus, row, COL_STATUS);
}
}
private void jTable1InputMethodTextChanged(java.awt.event.InputMethodEvent evt) {//GEN-FIRST:event_jTable1InputMethodTextChanged
}//GEN-LAST:event_jTable1InputMethodTextChanged
@@ -369,15 +278,100 @@ public class TestingList extends Panel {
private javax.swing.JTextArea jTextField1;
// End of variables declaration//GEN-END:variables
//show test result in table
public int showResult(String deviceName, String testName, String res, String status) {
int rowD = -1, colT = -1;
//search for device name in table
for (int row = 0; row <= jTable1.getRowCount() - 1; row++) {
if (deviceName.equals(jTable1.getValueAt(row, COL_DEVICENAME))) {
rowD = row;
break;
}
}
if (rowD >= 0) {
//search for test name in table
if (testName.equals(jTable1.getValueAt(rowD, COL_TESTNAME))) {
colT = COL_TESTNAME;
}
}
String iconSource = "/icons/button_help-16px.png";
switch (status) {
case "Success":
iconSource = "/icons/button_ok-16px.png";
logger.log(Level.INFO, "Device: " + testName + "Test: " + testName + " Result: " + res + " (" + status + ")");
break;
case "Failed":
iconSource = "/icons/button_close-16px.png";
logger.log(Level.SEVERE, "Device: " + testName + "Test: " + testName + " Result: " + res + " (" + status + ")");
break;
case "Running":
iconSource = "/icons/button_play-16px.png";
logger.log(Level.INFO, "Running Test: " + testName + " ... ");
break;
}
ImageIcon icon = new ImageIcon(getClass().getResource(iconSource));
jTable1.setValueAt(icon, rowD, COL_ICON);
if (colT >= 0 && rowD >= 0) {
jTable1.setValueAt(getNow(), rowD, COL_TIME);
jTable1.setValueAt(res, rowD, COL_RESULT);
jTable1.setValueAt(status, rowD, COL_STATUS);
}
return rowD;
}
//returns the status of the specified test name for specified device name
public String getResult(String deviceName, String testName){
String sStatus = "";
int rowD = -1, colT = -1;
//search for device name in table
for (int row = 0; row <= jTable1.getRowCount() - 1; row++) {
if (deviceName.equals(jTable1.getValueAt(row, COL_DEVICENAME))) {
rowD = row;
break;
}
}
if (rowD >= 0) {
//search for test name in table
if (testName.equals(jTable1.getValueAt(rowD, COL_TESTNAME))) {
colT = COL_TESTNAME;
}
}
if (colT >= 0 && rowD >= 0) {
sStatus = jTable1.getValueAt(rowD, COL_STATUS).toString();
}
return sStatus;
}
public void updateStatus() {
String sStatus, iconSource;
boolean bSelected;
for (int row = 0; row <= jTable1.getRowCount() - 1; row++) {
bSelected = (boolean) jTable1.getValueAt(row, COL_CHECK);
if (bSelected) {
sStatus = "Pending";
iconSource = "/icons/button_pause-16px.png";
} else {
sStatus = "Disabled";
iconSource = "/icons/button_stop-16px.png";
}
ImageIcon icon = new ImageIcon(getClass().getResource(iconSource));
jTable1.setValueAt(bSelected, row, COL_CHECK);
jTable1.setValueAt(icon, row, COL_ICON);
jTable1.setValueAt(sStatus, row, COL_STATUS);
}
}
//execute the selected tests in the list, starting from the position
public void executeTest(int position) throws InterruptedException{
public void executeTest(int position){
boolean bSelected = false;
String sDeviceName;
String sTestName;
HashMap args = new HashMap();
//scan through the table starting from 'position' and execute the first selected test found
int row = position;
Thread.sleep(1000);
int row = position;
if (row <= jTable1.getRowCount() ) {
for(row = position ; row <= jTable1.getRowCount() ; row++){
bSelected = (boolean) jTable1.getValueAt(row, COL_CHECK);