diff --git a/plugins/TestingList.java b/plugins/TestingList.java index abc7992..b75238a 100644 --- a/plugins/TestingList.java +++ b/plugins/TestingList.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.lang.reflect.InvocationTargetException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; @@ -657,41 +658,68 @@ 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 - Class editTestingListClass = getController().getClassByName("EditTestingList"); - JPanel detailsPanel = (JPanel) editTestingListClass.getConstructor(new Class[]{TableModel.class}).newInstance(jTable1.getModel()); - - dlg.getContentPane().add(detailsPanel); - //dlg.add(new TestingListDetails()); - dlg.pack(); - dlg.setVisible(true); + private void openListEditor() { + try { + //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 + Class editTestingListClass = null; + try { + editTestingListClass = getController().getClassByName("EditTestingList"); + } catch (ClassNotFoundException ex) { + Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); + } + if(editTestingListClass== null){ + Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, "Cannot initialise list of tests"); + } + JPanel detailsPanel = null; + try { + detailsPanel = (JPanel) editTestingListClass.getConstructor(new Class[]{TableModel.class}).newInstance(jTable1.getModel()); + } catch (InstantiationException ex) { + Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); + } catch (IllegalArgumentException ex) { + Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); + } catch (InvocationTargetException ex) { + Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); + } + if(detailsPanel ==null){ + Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, "Cannot initialise panel"); + } + dlg.getContentPane().add(detailsPanel); + //dlg.add(new TestingListDetails()); + dlg.pack(); + dlg.setVisible(true); + } catch (NoSuchMethodException ex) { + Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); + } catch (SecurityException ex) { + Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); + } } /**