diff --git a/plugins/EditTestingList.java b/plugins/EditTestingList.java index c08ad41..e3bf37a 100644 --- a/plugins/EditTestingList.java +++ b/plugins/EditTestingList.java @@ -225,74 +225,80 @@ public class EditTestingList extends javax.swing.JPanel { * @throws IOException */ public void loadTests() { - Properties propDevice = new Properties(); - Properties propTest = new Properties(); - //String fileName = TESTS_DEVICES_DEFAULT_DIR; - //File folder = new File(fileName); - File testsFolder = null; - String sTestName; - int iCounter = 0; + 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){ + //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 { - propDevice.load(is); - } catch (IOException ex) { + is = new FileInputStream(configFile); + } catch (FileNotFoundException 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); + 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++; } - 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"); + else{ + SwingUtils.showMessage(this, "loadTests()", "Could not find any test"); + } } } } + } catch (Exception ex) { + Logger.getLogger(EditTestingList.class.getName()).log(Level.SEVERE, null, ex); } } diff --git a/plugins/TestingList.java b/plugins/TestingList.java index abc7992..395726f 100644 --- a/plugins/TestingList.java +++ b/plugins/TestingList.java @@ -658,33 +658,9 @@ public class TestingList extends Panel { * @throws exception */ private void openListEditor() throws Exception { - //pick details from the clicked row -/* int row = jTable1.getSelectedRow(); - String sDeviceName = jTable1.getValueAt(row, COL.DEVICENAME.ordinal()).toString(); - String sTestName = jTable1.getValueAt(row, COL.TESTNAME.ordinal()).toString(); - String sTestPath = String.valueOf(jTable1.getValueAt(row, COL.TESTPATH.ordinal())); - String sTestCaseName = jTable1.getValueAt(row, COL.TESTSUITE.ordinal()).toString(); - String sTestDescription = jTable1.getValueAt(row, COL.TESTDESCR.ordinal()).toString(); - String sDeviceDescription = jTable1.getValueAt(row, COL.DEVICEDESCR.ordinal()).toString(); - String sLastResult = jTable1.getValueAt(row, COL.RESULT.ordinal()).toString(); - String sResultTime = jTable1.getValueAt(row, COL.TIME.ordinal()).toString(); - String sTestHelp = String.valueOf(jTable1.getValueAt(row, COL.TESTHELP.ordinal())); - HashMap mParameters = getTestParameters(sTestPath); - //create map for passing details to Details Panel - HashMap details = new HashMap(); - details.put("deviceName", sDeviceName); - details.put("deviceDescription", sDeviceDescription); - details.put("testDescription", sTestDescription); - details.put("testSuite", sTestCaseName); - details.put("testName", sTestName); - details.put("testResult", sLastResult); - details.put("time", sResultTime); - details.put("parameters", mParameters); - details.put("testHelp", sTestHelp); - details.put("testPath", sTestPath); -*/ //open details panel + JDialog dlg = new JDialog(getView(), "Add/remove tests", true); - //create a class to visualise the details panel + //create a class to visualise the edit panel Class editTestingListClass = getController().getClassByName("EditTestingList"); JPanel detailsPanel = (JPanel) editTestingListClass.getConstructor(new Class[]{TableModel.class}).newInstance(jTable1.getModel());