diff --git a/plugins/TestingList.form b/plugins/TestingList.form index 145c17f..3f3a5a1 100644 --- a/plugins/TestingList.form +++ b/plugins/TestingList.form @@ -24,6 +24,7 @@ + @@ -74,6 +75,7 @@ + @@ -109,6 +111,7 @@ + diff --git a/plugins/TestingList.java b/plugins/TestingList.java index 3e5a661..db8722a 100644 --- a/plugins/TestingList.java +++ b/plugins/TestingList.java @@ -77,14 +77,18 @@ public class TestingList extends Panel { Logger logger = Logger.getLogger("TestsLog"); //these paths are converted to unix or win path according to host OS - private final String TESTS_DEVICES_DEFAULT_DIR = new java.io.File( "." ).getCanonicalPath()+ FilenameUtils.separatorsToSystem("/home/script/tests/production/"); - private final String TESTS_TESTS_DEFAULT_DIR = new java.io.File( "." ).getCanonicalPath()+ FilenameUtils.separatorsToSystem("/home/script/tests/tests/"); - private final String TESTS_LOG_DEFAULT_DIR = new java.io.File( "." ).getCanonicalPath()+ FilenameUtils.separatorsToSystem("/home/script/tests/log/TestsLog"+getnow()+".txt"); + private final String TESTS_DEVICES_DEFAULT_DIR = new java.io.File( "." ).getCanonicalPath()+ + FilenameUtils.separatorsToSystem("/home/script/tests/production/"); + private final String TESTS_TESTS_DEFAULT_DIR = new java.io.File( "." ).getCanonicalPath()+ + FilenameUtils.separatorsToSystem("/home/script/tests/tests/"); + private final String TESTS_LOG_DEFAULT_DIR = new java.io.File( "." ).getCanonicalPath()+ + FilenameUtils.separatorsToSystem("/home/script/tests/log/TestsLog"+getnow()+".txt"); //table1 columns indexes private final int COL_CHECK = 0; private final int COL_TIME = 1; + private final int COL_DEVICENAME = 2; private final int COL_RESULT = 6; - private final int COL_SUCCESS = 7; + private final int COL_STATUS = 7; private final int COL_ICON = 8; private void initLogger(){ @@ -102,25 +106,22 @@ public class TestingList extends Panel { e.printStackTrace(); } } - - public NetbeansPluginPanel() throws IOException { - initComponents(); - initLogger(); - buildTable(); - loadTests(); - } - @SuppressWarnings("unchecked") - - public void showResult(String deviceName, String testName, String res, String status){ + public NetbeansPluginPanel() throws IOException { + initComponents(); + initLogger(); + buildTable(); + loadTests(); + } + @SuppressWarnings("unchecked") - + + //show test result in table + public void 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++) { - for (int col = 0; col <= jTable1.getColumnCount() - 1; col++) { - if (deviceName.equals(jTable1.getValueAt(row, col))) { rowD = row; break; @@ -130,7 +131,6 @@ public class TestingList extends Panel { if (rowD>0){ //search for test name in table for (int col = 0; col <= jTable1.getColumnCount() - 1; col++) { - if (testName.equals(jTable1.getValueAt(rowD, col))) { colT = col; break; @@ -158,13 +158,9 @@ public class TestingList extends Panel { if(colT>0 && rowD>0){ jTable1.setValueAt(getNow(), rowD, COL_TIME); jTable1.setValueAt(res, rowD, COL_RESULT); - jTable1.setValueAt(status, rowD, COL_SUCCESS); - jTable1.getCellEditor(rowD, COL_SUCCESS); - } - /*else{ //no test found in table. appen new one - DefaultTableModel model = (DefaultTableModel) jTable1.getModel(); - model.addRow(new Object[]{true, getNow(), deviceName, testName, res, status, icon }); - }*/ + jTable1.setValueAt(status, rowD, COL_STATUS); + jTable1.getCellEditor(rowD, COL_STATUS); + } } @@ -183,6 +179,7 @@ public class TestingList extends Panel { setLayout(new java.awt.BorderLayout(10, 10)); jButtonRun.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/button_play-64px.png"))); // NOI18N + jButtonRun.setToolTipText("Run selected tests"); jButtonRun.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonRunActionPerformed(evt); @@ -239,6 +236,7 @@ public class TestingList extends Panel { add(jScrollPane2, java.awt.BorderLayout.PAGE_END); jCheckBox1.setText("All"); + jCheckBox1.setToolTipText("Select/Deselect All Tests"); jCheckBox1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox1ActionPerformed(evt); @@ -253,6 +251,7 @@ public class TestingList extends Panel { add(jScrollPane1, java.awt.BorderLayout.PAGE_START); jButtonOpenLog.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/log-icon-64px.png"))); // NOI18N + jButtonOpenLog.setToolTipText("Open current sessions Log"); jButtonOpenLog.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonOpenLogActionPerformed(evt); @@ -307,7 +306,7 @@ public class TestingList extends Panel { ImageIcon icon = new ImageIcon(getClass().getResource(iconSource)); jTable1.setValueAt(bSelected, row, COL_CHECK); jTable1.setValueAt(icon, row, COL_ICON); - jTable1.setValueAt(sStatus, row, COL_SUCCESS); + jTable1.setValueAt(sStatus, row, COL_STATUS); } } @@ -365,35 +364,33 @@ public class TestingList extends Panel { String sDate = getNow(); ImageIcon icon = new ImageIcon(getClass().getResource("/icons/button_pause-16px.png")); DefaultTableModel model = (DefaultTableModel) jTable1.getModel(); - /*model.addRow(new Object[] {false, sDate, "LS", "Check Status", "No comm", "Pending", icon}); - model.addRow(new Object[] {true, sDate, "RS", "Calibrate", "Calibration done", "Pending", icon}); - model.addRow(new Object[] {false, sDate, "MWD", "Display Test", "Sequence terminated", "Pending", icon}); - model.addRow(new Object[] {false, sDate, "FIXL", "Lamp Test", "Failure", "Pending", icon});*/ jTable1.setModel(model); jTable1.getColumnModel().getColumn(COL_ICON).setMaxWidth(27); jTable1.getColumnModel().getColumn(COL_CHECK).setMaxWidth(27); - + jTable1.getColumnModel().getColumn(COL_DEVICENAME).setPreferredWidth(100); + jTable1.getColumnModel().getColumn(COL_STATUS).setPreferredWidth(100); updateStatus(); } + //append test info to table public void addToTable(String deviceName, String deviceDescription, String testSuite, String testName){ String sDate = ""; - if(testName.equals("") || deviceName.equals("")) return; - + if(testName.equals("") || deviceName.equals("")) return; ImageIcon icon = new ImageIcon(getClass().getResource("/icons/button_pause-16px.png")); DefaultTableModel model = (DefaultTableModel) jTable1.getModel(); - model.addRow(new Object[] {false, sDate, deviceName, deviceDescription, testSuite, testName, "", "Pending", icon}); + model.addRow(new Object[] {false, sDate, deviceName, deviceDescription, testSuite, testName, "", "Pending", icon}); jTable1.setModel(model); - updateStatus(); } + //formatted time public String getNow(){ DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Date date = new Date(); return dateFormat.format(date); } + //time without format public String getnow(){ DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); Date date = new Date(); @@ -410,6 +407,7 @@ public class TestingList extends Panel { File testsFolder = null; String sTestName; //search of devices and their tests + //Scan the list of devices File[] listOfFiles = folder.listFiles(); for (File listOfFile : listOfFiles) { if (listOfFile.isFile()) { @@ -419,7 +417,6 @@ public class TestingList extends Panel { File configFile = new File(listOfFile.getPath() + FilenameUtils.separatorsToSystem("/.config")); if(configFile.exists() && !configFile.isDirectory()){ InputStream is = new FileInputStream(configFile); - propDevice.load(is); //config of device was loaded. now load the config of each test belonging to the device sTestName = TESTS_TESTS_DEFAULT_DIR + propDevice.getProperty("tests"); @@ -433,7 +430,6 @@ public class TestingList extends Panel { configFile = new File(listOfTest.getPath() + FilenameUtils.separatorsToSystem("/.config")); if(configFile.exists() && !configFile.isDirectory()){ InputStream ist = new FileInputStream(configFile); - propTest.load(ist); addToTable(propDevice.getProperty("name"), propDevice.getProperty("description"), @@ -450,7 +446,6 @@ public class TestingList extends Panel { } } } - } }