diff --git a/plugins/EditTestingList.java b/plugins/EditTestingList.java index 9688989..fea4093 100644 --- a/plugins/EditTestingList.java +++ b/plugins/EditTestingList.java @@ -5,21 +5,12 @@ import ch.psi.utils.swing.SwingUtils; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; import java.io.ObjectInputStream; -import java.nio.file.Paths; import java.util.Iterator; -import java.util.Properties; import java.util.Vector; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; -import org.apache.commons.io.FilenameUtils; /* * To change this license header, choose License Headers in Project Properties. @@ -43,7 +34,6 @@ public class EditTestingList extends javax.swing.JPanel { public EditTestingList(TableModel hDetails) { initComponents(); fillComponents(hDetails); - // loadTests(); } /** @@ -213,121 +203,9 @@ public class EditTestingList extends javax.swing.JPanel { ex.printStackTrace(); SwingUtils.showMessage(this, "loadSettings()", ex.toString()); } - } + } } - - /** - * scan tests directory, scan devices directory, search for their test cases - * and scan for tests. - * - * @throws FileNotFoundException - * @throws IOException - */ - public void loadTests() { - try { - Properties propDevice = new Properties(); - Properties propTest = new Properties(); - //String fileName = TESTS_DEVICES_DEFAULT_DIR; - //File folder = new File(fileName); - TestingList testingList = new TestingList(); - - File testsFolder = null; - String sTestName; - int iCounter = 0; - //search devices and their tests - //Scan the list of devices - File[] listOfFiles = (TestingList.TESTS_DEVICES_DEFAULT_DIR.toFile()).listFiles(); - for (File listOfFile : listOfFiles) { - propDevice.clear(); - if (listOfFile.isFile()) { - } else if (listOfFile.isDirectory()) { - File configFile = new File(listOfFile.getPath() + FilenameUtils.separatorsToSystem("/.config")); - if (configFile.exists() && !configFile.isDirectory()) { - InputStream is = null; - try { - is = new FileInputStream(configFile); - } catch (FileNotFoundException ex) { - Logger.getLogger(EditTestingList.class.getName()).log(Level.SEVERE, null, ex); - } - if(is != null){ - try { - propDevice.load(is); - } catch (IOException ex) { - Logger.getLogger(EditTestingList.class.getName()).log(Level.SEVERE, null, ex); - } - //config of device was loaded. now load the config of each test belonging to the device - //sTestName = TESTS_TESTS_DEFAULT_DIR + propDevice.getProperty("tests"); - //testsFolder = new File(sTestName); - testsFolder = Paths.get(TestingList.TESTS_TESTS_DEFAULT_DIR.toString(), propDevice.getProperty("tests")).toFile(); - if (testsFolder.exists() && testsFolder.isDirectory()) { - File[] listOfTests = testsFolder.listFiles(); - for (File listOfTest : listOfTests) { - propTest.clear(); - if (listOfTest.isDirectory()) { - configFile = new File(listOfTest.getPath() + FilenameUtils.separatorsToSystem("/.config")); - if (configFile.exists() && !configFile.isDirectory()) { - InputStream ist = null; - try { - ist = new FileInputStream(configFile); - } catch (FileNotFoundException ex) { - Logger.getLogger(EditTestingList.class.getName()).log(Level.SEVERE, null, ex); - } - try { - propTest.load(ist); - } catch (IOException ex) { - Logger.getLogger(EditTestingList.class.getName()).log(Level.SEVERE, null, ex); - } - addToTable("", - propDevice.getProperty("name"), - propDevice.getProperty("description"), - propDevice.getProperty("tests"), - "path", - propTest.getProperty("name"), - propTest.getProperty("parameters")); - iCounter++; - } - } - } - } - } - else{ - SwingUtils.showMessage(this, "loadTests()", "Could not find any test"); - } - } - } - } - } catch (Exception ex) { - Logger.getLogger(EditTestingList.class.getName()).log(Level.SEVERE, null, ex); - } - } - - //append test info to table - private void addToTable(String deviceName, - String deviceDescription, - String testSuite, - String testName, - String testParams, - String testDescription, - String testHelp) { - try { - String sDate = ""; - if (testName.equals("") || deviceName.equals("")) { - return; - } - ImageIcon icon = null;// new ImageIcon(getClass().getResource("/icons/button_pause-16px.png")); - DefaultTableModel model = (DefaultTableModel) jTable1.getModel(); - //String testPath = FilenameUtils.separatorsToSystem(TESTS_TESTS_DEFAULT_DIR + testSuite + "/" + testName + "/" + testName + ".py"); - String testPath = Paths.get(TestingList.TESTS_TESTS_DEFAULT_DIR.toString(), testSuite, testName, testName + ".py").toString(); - model.addRow(new Object[]{false, "", sDate, deviceName, deviceDescription, testSuite, testName, testPath, testParams, testDescription, testHelp, "", "Pending", icon}); - jTable1.setModel(model); - } catch (Exception ex) { - Logger.getLogger(EditTestingList.class.getName()).log(Level.SEVERE, null, ex); - } - - } - - private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked if (this.jTable1.isEnabled()) { try {