diff --git a/config/plugins.properties b/config/plugins.properties index d98f103..cf9bfa7 100644 --- a/config/plugins.properties +++ b/config/plugins.properties @@ -1,4 +1,11 @@ -.\\home\\plugins\\EditTestingList.java=enabled +.\\home\\plugins\\EditTestingList - Copy.java=disabled +.\\home\\plugins\\NewTest - Copy.java=disabled +.\\home\\plugins\\EditTestingList - Copy.java=disabled +.\\home\\plugins\\EditTestingList - Copy.java=disabled +.\\home\\plugins\\EditTestingListNew.java=disabled +.\\home\\plugins\\FilterTable.java=disabled +.\\home\\plugins\\NewTest.java=enabled +.\\home\\plugins\\EditTestingList.java=disabled .\\home\\plugins\\new_main.py=disabled .\\home\\plugins\\TestMain.java=disabled .\\home\\plugins\\TestingListDetails.java=enabled diff --git a/plugins/TestingList.form b/plugins/TestingList.form index 58eb1f8..ab19f83 100644 --- a/plugins/TestingList.form +++ b/plugins/TestingList.form @@ -16,16 +16,47 @@ - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -106,13 +137,13 @@ - + - + @@ -125,6 +156,14 @@ + + + + + + + + @@ -133,14 +172,23 @@ - + + + + + + + + + + - + @@ -154,6 +202,15 @@ + + + + + + + + + @@ -170,6 +227,9 @@ + + + diff --git a/plugins/TestingList.java b/plugins/TestingList.java index 88c9102..3d3a793 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; @@ -40,6 +41,7 @@ import javax.swing.DefaultCellEditor; import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JFileChooser; +import javax.swing.JMenuItem; import javax.swing.RowFilter; import javax.swing.filechooser.FileSystemView; import javax.swing.table.DefaultTableCellRenderer; @@ -63,13 +65,13 @@ public class TestingList extends Panel { } }; - public TestingList() throws Exception{ + public TestingList() throws Exception { initComponents(); initLogger(); buildTable(); - try{ + try { loadTests(); - } catch (Exception ex){ + } catch (Exception ex) { getLogger().severe(ex.getMessage()); } } @@ -241,24 +243,68 @@ public class TestingList extends Panel { } }; + /** + * List of Keys defining the arguments to be passed to a test script + */ + public enum testPropertyNames { + + DEVICE_NAME, + DEVICE_DESCRIPTION, + TEST_NAME, + TEST_DESCRIPTION, + TEST_PARAMETERS, + TEST_HELP; + + @Override + public final String toString() { + String val = ""; + switch (this) { + case DEVICE_NAME: + case TEST_NAME: + val = "name"; + break; + case TEST_PARAMETERS: + val = "parameters"; + break; + case DEVICE_DESCRIPTION: + case TEST_DESCRIPTION: + val = "description"; + break; + case TEST_HELP: + val = "help"; + break; + } + return val; + } + }; + Logger logger = Logger.getLogger("TestsLog"); //these paths are converted to unix or win path according to host OS - public static Path TESTS_DEVICES_DEFAULT_DIR = Paths.get(".","home", "script", "tests", "devices"); - public static Path TESTS_TESTS_DEFAULT_DIR = Paths.get(".","home", "script", "tests", "tests"); - public static Path TESTS_CONFIG_DEFAULT_DIR = Paths.get(".","home", "script", "tests", "comfig"); - public final Path TESTS_LOG_DEFAULT_DIR = Paths.get(".","home", "script", "tests", "log", "TestsLog"+ getnow() + ".txt"); + public static Path TESTS_DEVICES_DEFAULT_DIR = Paths.get(".", "home", "script", "tests", "devices"); + public static Path TESTS_TESTS_DEFAULT_DIR = Paths.get(".", "home", "script", "tests", "tests"); + public static Path TESTS_CONFIG_DEFAULT_DIR = Paths.get(".", "home", "script", "tests", "config"); + public final Path TESTS_LOG_DEFAULT_DIR = Paths.get(".", "home", "script", "tests", "log", "TestsLog" + getnow() + ".txt"); + public static String TESTS_CONFIG_FILENAME = ".config"; + public static String TESTS_HELP_FILENAME = "help.html"; - - private void log(Object text){ - try { + /** + * write info into a log file + * @param text the info to be logged + */ + private void log(Object text) { + try { getController().getDataManager().appendLog(String.valueOf(text)); } catch (IOException ex) { Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); } } + + /** + * initialise the logger + */ private void initLogger() { try { - + FileHandler fh; // This block configure the logger with handler and formatter fh = new FileHandler(TESTS_LOG_DEFAULT_DIR.toString()); @@ -284,13 +330,18 @@ public class TestingList extends Panel { jPopupMenuOptions = new javax.swing.JPopupMenu(); jCheckBoxMenuShowSelectedTests = new javax.swing.JCheckBoxMenuItem(); + jMenuItemReload = new javax.swing.JMenuItem(); + jSeparator1 = new javax.swing.JPopupMenu.Separator(); + jMenuAdvanced = new javax.swing.JMenu(); + jMenuItemNewTest = new javax.swing.JMenuItem(); jMenuItemOpenLog = new javax.swing.JMenuItem(); + jPopupMenuConfigs = new javax.swing.JPopupMenu(); jScrollPane2 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jPanel1 = new javax.swing.JPanel(); jButtonRun = new javax.swing.JButton(); jPanel3 = new javax.swing.JPanel(); - jButtonShowCheckedOnly = new javax.swing.JButton(); + jButtonOptions = new javax.swing.JButton(); jButtonSave = new javax.swing.JButton(); jButtonOpen = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); @@ -306,13 +357,34 @@ public class TestingList extends Panel { }); jPopupMenuOptions.add(jCheckBoxMenuShowSelectedTests); + jMenuItemReload.setText("Reload tests"); + jMenuItemReload.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItemReloadActionPerformed(evt); + } + }); + jPopupMenuOptions.add(jMenuItemReload); + jPopupMenuOptions.add(jSeparator1); + + jMenuAdvanced.setText("Advanced"); + + jMenuItemNewTest.setText("New Test..."); + jMenuItemNewTest.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItemNewTestActionPerformed(evt); + } + }); + jMenuAdvanced.add(jMenuItemNewTest); + jMenuItemOpenLog.setText("Open Log"); jMenuItemOpenLog.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemOpenLogActionPerformed(evt); } }); - jPopupMenuOptions.add(jMenuItemOpenLog); + jMenuAdvanced.add(jMenuItemOpenLog); + + jPopupMenuOptions.add(jMenuAdvanced); setLayout(new java.awt.BorderLayout()); @@ -365,9 +437,9 @@ public class TestingList extends Panel { jButtonRun.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/play-circled-64-000000.png"))); // NOI18N jButtonRun.setToolTipText("Run selected tests"); - jButtonRun.setMaximumSize(new java.awt.Dimension(33, 39)); + jButtonRun.setMaximumSize(new java.awt.Dimension(330000, 39)); jButtonRun.setMinimumSize(new java.awt.Dimension(90, 90)); - jButtonRun.setPreferredSize(new java.awt.Dimension(33, 39)); + jButtonRun.setPreferredSize(new java.awt.Dimension(90, 39)); jButtonRun.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonRunActionPerformed(evt); @@ -375,18 +447,26 @@ public class TestingList extends Panel { }); jPanel1.add(jButtonRun, java.awt.BorderLayout.CENTER); + jPanel3.setMinimumSize(new java.awt.Dimension(0, 80)); + jPanel3.setPreferredSize(new java.awt.Dimension(100, 80)); jPanel3.setLayout(new java.awt.BorderLayout()); - jButtonShowCheckedOnly.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/settings-32px.png"))); // NOI18N - jButtonShowCheckedOnly.addActionListener(new java.awt.event.ActionListener() { + jButtonOptions.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/settings-32px.png"))); // NOI18N + jButtonOptions.setMaximumSize(new java.awt.Dimension(60, 40)); + jButtonOptions.setMinimumSize(new java.awt.Dimension(0, 40)); + jButtonOptions.setPreferredSize(new java.awt.Dimension(50, 40)); + jButtonOptions.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - jButtonShowCheckedOnlyActionPerformed(evt); + jButtonOptionsActionPerformed(evt); } }); - jPanel3.add(jButtonShowCheckedOnly, java.awt.BorderLayout.LINE_START); + jPanel3.add(jButtonOptions, java.awt.BorderLayout.LINE_START); jButtonSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/android-save-24-000000.png"))); // NOI18N jButtonSave.setToolTipText("Save current configuration"); + jButtonSave.setMaximumSize(new java.awt.Dimension(60, 40)); + jButtonSave.setMinimumSize(new java.awt.Dimension(0, 40)); + jButtonSave.setPreferredSize(new java.awt.Dimension(50, 40)); jButtonSave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonSaveActionPerformed(evt); @@ -396,6 +476,7 @@ public class TestingList extends Panel { jButtonOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/folder-open-24-000000.png"))); // NOI18N jButtonOpen.setToolTipText("Open configuration"); + jButtonOpen.setMinimumSize(new java.awt.Dimension(0, 9)); jButtonOpen.setPreferredSize(new java.awt.Dimension(33, 50)); jButtonOpen.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -462,6 +543,9 @@ public class TestingList extends Panel { this.jButtonRun.setToolTipText("Run selected tests"); jButtonRun.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/play-circled-64-000000.png"))); this.jTable1.setEnabled(true); + this.jButtonOpen.setEnabled(true); + this.jButtonOptions.setEnabled(true); + this.jButtonSave.setEnabled(true); } private void setButtonToStart() { @@ -469,6 +553,9 @@ public class TestingList extends Panel { jButtonRun.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/stop-circled-64-000000.png"))); this.jTable1.clearSelection(); this.jTable1.setEnabled(false); + this.jButtonOpen.setEnabled(false); + this.jButtonOptions.setEnabled(false); + this.jButtonSave.setEnabled(false); } private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed @@ -522,34 +609,35 @@ public class TestingList extends Panel { private void jButtonOpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOpenActionPerformed this.loadSettings(); - new Thread(() -> { - try { - //Object ret = eval("parallelize((run,('testLocalVar1',globals(),{'a':'21', 'b':34})), (run,('testLocalVar2',globals(),{'a':231, 'b':234})))"); - Object ret; - ret = eval("parallelize((run,('dummy',)))"); - ret = eval("parallelize((run,('testLocalVar1', None,{'a':21, 'b':34})), (run,('testLocalVar2', None, {'a':231, 'b':234})))"); - Object ret1 = ((ArrayList) ret).get(0); - Object ret2 = ((ArrayList) ret).get(1); - System.out.println(String.valueOf(ret1)); - System.out.println(String.valueOf(ret2)); - } catch (Exception ex) { - SwingUtils.showException(this, ex); - } - }).start(); - + //this below is a test that can be useful to check that multithreading does work fine with passing variables + /* new Thread(() -> { + try { + //Object ret = eval("parallelize((run,('testLocalVar1',globals(),{'a':'21', 'b':34})), (run,('testLocalVar2',globals(),{'a':231, 'b':234})))"); + Object ret; + ret = eval("parallelize((run,('dummy',)))"); + ret = eval("parallelize((run,('testLocalVar1', None,{'a':21, 'b':34})), (run,('testLocalVar2', None, {'a':231, 'b':234})))"); + Object ret1 = ((ArrayList) ret).get(0); + Object ret2 = ((ArrayList) ret).get(1); + System.out.println(String.valueOf(ret1)); + System.out.println(String.valueOf(ret2)); + } catch (Exception ex) { + SwingUtils.showException(this, ex); + } + }).start(); + */ }//GEN-LAST:event_jButtonOpenActionPerformed private void jButtonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSaveActionPerformed saveSettings(); }//GEN-LAST:event_jButtonSaveActionPerformed - private void jButtonShowCheckedOnlyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonShowCheckedOnlyActionPerformed - jPopupMenuOptions.show(jButtonShowCheckedOnly,0,jButtonShowCheckedOnly.getHeight()); - }//GEN-LAST:event_jButtonShowCheckedOnlyActionPerformed + private void jButtonOptionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOptionsActionPerformed + jPopupMenuOptions.show(jButtonOptions, 0, jButtonOptions.getHeight()); + }//GEN-LAST:event_jButtonOptionsActionPerformed private void jCheckBoxMenuShowSelectedTestsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuShowSelectedTestsActionPerformed // TODO add your handling code here: - showSelectedTestsOnly(jCheckBoxMenuShowSelectedTests.getState()); + showSelectedTestsOnly(jCheckBoxMenuShowSelectedTests.getState()); }//GEN-LAST:event_jCheckBoxMenuShowSelectedTestsActionPerformed private void jMenuItemOpenLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemOpenLogActionPerformed @@ -566,77 +654,140 @@ public class TestingList extends Panel { SwingUtils.showMessage(this, "jButtonOpenLogActionPerformed()", "jButtonOpenLogActionPerformed() " + ex.toString() + " \nPlease open the file manually. \nFile dir: " + TESTS_LOG_DEFAULT_DIR); Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); - } + } }//GEN-LAST:event_jMenuItemOpenLogActionPerformed + private void jMenuItemReloadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemReloadActionPerformed + // TODO add your handling code here: + reloadTests(); + try { + cleanTests(); + } catch (IOException ex) { + Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); + } + }//GEN-LAST:event_jMenuItemReloadActionPerformed + + private void jMenuItemNewTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemNewTestActionPerformed + // TODO add your handling code here: + openNewTestEditor(); + }//GEN-LAST:event_jMenuItemNewTestActionPerformed + // // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButtonMoveDown; private javax.swing.JButton jButtonMoveUp; private javax.swing.JButton jButtonOpen; + private javax.swing.JButton jButtonOptions; private javax.swing.JButton jButtonRun; private javax.swing.JButton jButtonSave; - private javax.swing.JButton jButtonShowCheckedOnly; private javax.swing.JCheckBox jCheckBox1; private javax.swing.JCheckBoxMenuItem jCheckBoxMenuShowSelectedTests; + private javax.swing.JMenu jMenuAdvanced; + private javax.swing.JMenuItem jMenuItemNewTest; private javax.swing.JMenuItem jMenuItemOpenLog; + private javax.swing.JMenuItem jMenuItemReload; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; + private javax.swing.JPopupMenu jPopupMenuConfigs; private javax.swing.JPopupMenu jPopupMenuOptions; private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JPopupMenu.Separator jSeparator1; private javax.swing.JTable jTable1; // End of variables declaration//GEN-END:variables // - + /** + * reload tests from files + */ + public void reloadTests() { + try { + loadTests(); + } catch (IOException ex) { + Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); + } + } + /** * filter table: show only rows selected (checkbox checked) for running. - * @param show if false, show all tests. If true, show only selected tests. - */ - private void showSelectedTestsOnly(boolean show){ - if(show){ + * + * @param show if false, show all tests. If true, show only selected tests. + */ + public void showSelectedTestsOnly(boolean show) { + if (show) { filterTests("true"); - } - else{ + } else { filterTests(""); + reloadTests(); } } + public void openNewTestEditor(){ + try { + // NewTest nt = new NewTest(); + // nt.setVisible(true); + JDialog dlg = new JDialog(getView(), "New Test", true); + //create a class to visualise the details panel + String sDetails = ""; + Class testingListDetailsClass = getController().getClassByName("NewTest"); + JPanel detailsPanel = (JPanel) testingListDetailsClass.getConstructor(new Class[]{String.class}).newInstance(new Object[]{sDetails}); + + dlg.getContentPane().add(detailsPanel); + //dlg.add(new TestingListDetails()); + dlg.pack(); + dlg.setVisible(true); + } catch (ClassNotFoundException ex) { + Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); + } 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); + } 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); + } + + } + /** * filter table: show only rows containing the specified text. - * @param filterText text for filtering; can be a regex pattern. - */ - private void filterTests(String filterText){ - TableModel model = new DefaultTableModel() { - public Class getColumnClass(int column) { - Class returnValue; - if ((column >= 0) && (column < getColumnCount())) { - returnValue = getValueAt(0, column).getClass(); - } else { - returnValue = Object.class; - } - return returnValue; - } - }; - model = jTable1.getModel(); - - final TableRowSorter sorter = new TableRowSorter(model); - jTable1.setRowSorter(sorter); + * + * @param filterText text for filtering; can be a regex pattern. + */ + private void filterTests(String filterText) { + TableModel model = new DefaultTableModel() { + public Class getColumnClass(int column) { + Class returnValue; + if ((column >= 0) && (column < getColumnCount())) { + returnValue = getValueAt(0, column).getClass(); + } else { + returnValue = Object.class; + } + return returnValue; + } + }; + model = jTable1.getModel(); + + final TableRowSorter sorter = new TableRowSorter(model); + jTable1.setRowSorter(sorter); if (filterText.length() == 0) { - sorter.setRowFilter(null); - } else { - try { - sorter.setRowFilter(RowFilter.regexFilter(filterText)); - } catch (PatternSyntaxException pse) { - System.err.println("Bad regex pattern"); - } + sorter.setRowFilter(null); + } else { + try { + sorter.setRowFilter(RowFilter.regexFilter(filterText)); + } catch (PatternSyntaxException pse) { + System.err.println("Bad regex pattern"); + } } } - - + /** - * returns whether or not the tests can run (Run launched by the user) + * return whether or not the tests can run (Run launched by the user) * * @return status of run button. True = tests launching sequence is running */ @@ -745,7 +896,7 @@ public class TestingList extends Panel { int rowD = -1; String sTestName = testPath; //getController().getDataManager().appendLog(str(log)); - + getLogger().log(Level.FINE, "Looking for: deviceName: " + deviceName + "; testPath: " + testPath + " in table."); String sStatus; if (status == "true") { @@ -796,7 +947,7 @@ public class TestingList extends Panel { } /** - * returns the amount of tests currently in Pending state + * return the amount of tests currently in Pending state * * @return int counter of pending tests */ @@ -805,7 +956,7 @@ public class TestingList extends Panel { } /** - * returns the amount of tests currently in Running state + * return the amount of tests currently in Running state * * @return int counter of running tests */ @@ -814,7 +965,7 @@ public class TestingList extends Panel { } /** - * returns the amount of tests currently in Pending state + * return the amount of tests currently in Success state * * @return int counter of successful tests */ @@ -876,7 +1027,7 @@ public class TestingList extends Panel { } /** - * returns the status of the specified test name for specified device name + * return the status of the specified test name for specified device name * * @param deviceName name of the device * @param testPath path of the test file @@ -944,7 +1095,7 @@ public class TestingList extends Panel { } /** - * + * tests run multithreaded */ public class RunTest implements Runnable { @@ -1007,6 +1158,12 @@ public class TestingList extends Panel { } } + /** + * build a HashMap containing the items picked from a specific table row. + * + * @param row the row whose items will fill the HashMap + * @return the HashMap containing the items picked from the specified table row. + */ private HashMap buildMapFromTableRow(int row) { String sDeviceName = jTable1.getValueAt(row, COL.DEVICENAME.ordinal()).toString(); String sTestName = jTable1.getValueAt(row, COL.TESTNAME.ordinal()).toString(); @@ -1025,47 +1182,56 @@ public class TestingList extends Panel { return testArgs; } - + /** - * convert HashMap string separators to python dictionary string separators - * - * @param sParameters string coming from HashMap conaining the list of parameters to be passed to the test script. - * Example: - * {repeatTimes={description=Repeat N times, value=1}, midPoint={description=Middle point A, value=41.0}, spanFromMidPoint={description=B steps around middle point A, value=2.0}} - * @return string of dictionary in python syntax. This can be passed to the python test script. - * Example of output: - * {'repeatTimes':{'description':'Repeat N times','value':'1'},'midPoint':{'description':'Middle point A','value':'41.0'},'spanFromMidPoint':{'description':'B steps around middle point A','value':'2.0'} - */ - private String convertParametersMapToPythonMap(String sParameters){ + * convert HashMap string separators to python dictionary string + * separators + * + * @param sParameters string coming from HashMap conaining the list of + * parameters to be passed to the test script. Example: + * {repeatTimes={description=Repeat N times, value=1}, + * midPoint={description=Middle point A, value=41.0}, + * spanFromMidPoint={description=B steps around middle point A, + * value=2.0}} + * @return string of dictionary in python syntax. This can be passed to + * the python test script. Example of output: + * {'repeatTimes':{'description':'Repeat N + * times','value':'1'},'midPoint':{'description':'Middle point + * A','value':'41.0'},'spanFromMidPoint':{'description':'B steps around + * middle point A','value':'2.0'} + */ + private String convertParametersMapToPythonMap(String sParameters) { String sPythonParams = sParameters; - sPythonParams = sPythonParams.replace(", " , ","); - sPythonParams = sPythonParams.replace(" ," , ","); - sPythonParams = sPythonParams.replace("{{" , "#@"); - sPythonParams = sPythonParams.replace("}}" , "@#"); - sPythonParams = sPythonParams.replace("}," , "@%#"); - sPythonParams = sPythonParams.replace(",{" , "#%@"); - sPythonParams = sPythonParams.replace("={" , "^%&"); - sPythonParams = sPythonParams.replace("=}" , "&%^"); - sPythonParams = sPythonParams.replace("," , "','"); - sPythonParams = sPythonParams.replace("{" , "{'"); - sPythonParams = sPythonParams.replace("}" , "'}"); - sPythonParams = sPythonParams.replace("=" , "':'"); + sPythonParams = sPythonParams.replace(", ", ","); + sPythonParams = sPythonParams.replace(" ,", ","); + sPythonParams = sPythonParams.replace("{{", "#@"); + sPythonParams = sPythonParams.replace("}}", "@#"); + sPythonParams = sPythonParams.replace("},", "@%#"); + sPythonParams = sPythonParams.replace(",{", "#%@"); + sPythonParams = sPythonParams.replace("={", "^%&"); + sPythonParams = sPythonParams.replace("=}", "&%^"); + sPythonParams = sPythonParams.replace(",", "','"); + sPythonParams = sPythonParams.replace("{", "{'"); + sPythonParams = sPythonParams.replace("}", "'}"); + sPythonParams = sPythonParams.replace("=", "':'"); sPythonParams = sPythonParams.replace("^%&", "':{'"); sPythonParams = sPythonParams.replace("&%^", "'}:'"); - sPythonParams = sPythonParams.replace("#@" , "{{'"); - sPythonParams = sPythonParams.replace("@#" , "'}}"); + sPythonParams = sPythonParams.replace("#@", "{{'"); + sPythonParams = sPythonParams.replace("@#", "'}}"); sPythonParams = sPythonParams.replace("@%#", "'},'"); sPythonParams = sPythonParams.replace("#%@", "',{'"); return sPythonParams; } - /** start all the tests in the array rowsToExecute. - * all tests in the listed row indexes will be started at the same time. - * - * @param rowsToExecute array of indexes relative to the test rows in the table. - * The indexes in the array will execute the test in corresponding row + /** + * start all the tests in the array rowsToExecute. all tests in the + * listed row indexes will be started at the same time. + * + * @param rowsToExecute array of indexes relative to the test rows in + * the table. The indexes in the array will execute the test in + * corresponding row * @return return value: 0 means ok, <0 means problem - */ + */ private int executeParallelTestsGroup(int[] rowsToExecute) { int iRet = -1; HashMap args2 = new HashMap(); //this is the global map that will contain one map per test. @@ -1117,35 +1283,13 @@ public class TestingList extends Panel { int iTotalEntries = hTests.entrySet().size(); HashMap args = new HashMap(); for (Map.Entry hTest : hTests.entrySet()) { - //REMOVE this when local parameters will work - /* - args.put("parameters", hTest.getValue().get("parameters")); - args.put("device", hTest.getValue().get(testArgNames.DEVICE.toString())); - args.put("test", hTest.getValue().get(testArgNames.TEST.toString())); - args.put("ret", ""); - args.put("status", hTest.getValue().get(testArgNames.STATUS.toString())); - setGlobalsVars(hTest.getValue()); //set global variables that can be read by all test scripts - setGlobalsVars(args); //set global variables that can be read by all test scripts - //end REMOVE -*/ sTestPath = hTest.getKey().toString(); sTestPath = sTestPath.replace("\\", "\\\\"); - //System.out.println(hTest.getValue().get("test")); sParallelizeCommand = sParallelizeCommand + "(run,(str('" + sTestPath; - //System.out.println("A"+i); sParallelizeArguments = "None, {'parameters':" + convertParametersMapToPythonMap(hTest.getValue().get("parameters").toString()) + ",'test':'" + hTest.getValue().get(testArgNames.TEST.toString()) + "','device':'" + hTest.getValue().get(testArgNames.DEVICE.toString()) + "','status':'" + hTest.getValue().get(testArgNames.STATUS.toString()) + "'}"; - //without parameters: - /* - sParallelizeArguments = "None" - + ",{'test':'" + hTest.getValue().get(testArgNames.TEST.toString()) - + "','device':'" + hTest.getValue().get(testArgNames.DEVICE.toString()) - + "','status':'" + hTest.getValue().get(testArgNames.STATUS.toString()) + "'}"; - */ - //this to remove arguments. COMMENT OUT when arguments work well - //sParallelizeArguments = ""; sParallelizeCommand = sParallelizeCommand + "')," + sParallelizeArguments; i++; if (i < iTotalEntries) { @@ -1157,11 +1301,7 @@ public class TestingList extends Panel { System.out.println(sParallelizeCommand); Object ret; ret = eval(sParallelizeCommand); -// Object ret = eval("parallelize((run,(str('"+sTestPath+"'),)), (run,('Motor Test 3 200ms',)))"); - //System.out.println("Ret = " + String.valueOf(ret)); String sTestResult, sTestStatus; - //read the return mapping and put the result in the right table row - //System.out.println("ret type "+ret.getClass().toString() ); //scan through all return mappings of all run tests for (Object oTestRet : (ArrayList) ret) { //check if the mapping of the selected test has all expected return values @@ -1214,7 +1354,7 @@ public class TestingList extends Panel { } /** - * table management + * table management (hide internal columns, size, etc) */ private void buildTable() { String sDate = getNow(); @@ -1250,7 +1390,19 @@ public class TestingList extends Panel { jTable1.getColumnModel().getColumn(column.ordinal()).setMaxWidth(0); } - //append test info to table + /** + * append test info (see parameters) to table + * + * @param deviceName + * @param deviceDescription + * @param testSuite + * @param testName + * @param testParams string of parameters. See buildParametersMap() for + * details + * @param testDescription + * @param testHelp + * + */ private void addToTable(String deviceName, String deviceDescription, String testSuite, @@ -1262,16 +1414,28 @@ public class TestingList extends Panel { if (testName.equals("") || deviceName.equals("")) { return; } - try{ + try { 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(TESTS_TESTS_DEFAULT_DIR.toString(), testSuite, testName, testName + ".py").toString(); Object rowData[] = new Object[]{false, "", sDate, deviceName, deviceDescription, testSuite, testName, testPath, testParams, testDescription, testHelp, "", "Pending", icon}; - - model.addRow(rowData); - } - catch (Exception ex) { + //vedify that this test is not already in the table + int totalRows = model.getRowCount(); + boolean bTestAlreadyInTable = false; + for (int row = 0; row < totalRows; row++) { + bTestAlreadyInTable = (model.getValueAt(row, COL.DEVICENAME.ordinal()).toString().equals(deviceName) + && model.getValueAt(row, COL.TESTSUITE.ordinal()).toString().equals(testSuite) + && model.getValueAt(row, COL.TESTNAME.ordinal()).toString().equals(testName) + && model.getValueAt(row, COL.TESTPATH.ordinal()).toString().equals(testPath)); + if (bTestAlreadyInTable) { + break; + } + } + if (!bTestAlreadyInTable) { + model.addRow(rowData); + } + } catch (Exception ex) { ex.printStackTrace(); SwingUtils.showMessage(this, "loadSettings()", ex.toString()); } @@ -1315,27 +1479,25 @@ public class TestingList extends Panel { File testsFolder = null; String sTestName; int iCounter = 0; - //search devices and their tests + //search devices and their tests //Scan the list of devices File[] listOfFiles = 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")); + File configFile = new File(listOfFile.getPath() + FilenameUtils.separatorsToSystem("/" + TESTS_CONFIG_FILENAME)); 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"); - //testsFolder = new File(sTestName); testsFolder = Paths.get(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")); + configFile = new File(listOfTest.getPath() + FilenameUtils.separatorsToSystem("/" + TESTS_CONFIG_FILENAME)); if (configFile.exists() && !configFile.isDirectory()) { InputStream ist = new FileInputStream(configFile); propTest.load(ist); @@ -1351,12 +1513,103 @@ public class TestingList extends Panel { } } } + is.close(); } } } logger.log(Level.INFO, iCounter + " tests loaded."); } + /** + * scan tests table and see if tests in the table still exist in directory. + * Remove from table the tests whose files do not exist in directories. + * + * @throws FileNotFoundException + * @throws IOException + */ + public void cleanTests() throws FileNotFoundException, IOException { + 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; + //search devices and their tests + //Scan the list of devices + File[] listOfFiles = TESTS_DEVICES_DEFAULT_DIR.toFile().listFiles(); + //first, collect all tests from files + List testsInDir = new ArrayList(); + List testDetails = new ArrayList(); + for (File listOfFile : listOfFiles) { + propDevice.clear(); + if (listOfFile.isFile()) { + } else if (listOfFile.isDirectory()) { + File configFile = new File(listOfFile.getPath() + FilenameUtils.separatorsToSystem("/"+TESTS_CONFIG_FILENAME)); + 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 + testsFolder = Paths.get(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("/"+TESTS_CONFIG_FILENAME)); + if (configFile.exists() && !configFile.isDirectory()) { + InputStream ist = new FileInputStream(configFile); + propTest.load(ist); + ist.close(); + testDetails = new ArrayList(); + testDetails.add(propDevice.getProperty("name")); + testDetails.add(propDevice.getProperty("tests")); + testDetails.add(propTest.getProperty("name")); + iCounter++; + testsInDir.add(testDetails); + } + } + } + } + is.close(); + } + } + } + //now check each test in table, if it is present in directory + DefaultTableModel model = (DefaultTableModel) jTable1.getModel(); + int row; + boolean bTestAlreadyInTable = false; + String testSuiteTable, testSuiteDir; + String testNameTable, testNameDir; + String deviceNameTable, deviceNameDir; + String testPathTable, testPathDir; + int totalRows = model.getRowCount(); + //loop among the tests in the table + for (row = 0; row < totalRows; row++) { + bTestAlreadyInTable = false; + //deviceNameTable = model.getValueAt(row, COL.DEVICENAME.ordinal()).toString(); + //testSuiteTable = model.getValueAt(row, COL.TESTSUITE.ordinal()).toString(); + //testNameTable = model.getValueAt(row, COL.TESTNAME.ordinal()).toString(); + testPathTable = model.getValueAt(row, COL.TESTPATH.ordinal()).toString(); + //loop to compare current test in table with all tests in directory + for (int i = 0; i < testsInDir.size(); i++) { + deviceNameDir = testsInDir.get(i).get(0).toString(); + testSuiteDir = testsInDir.get(i).get(1).toString(); + testNameDir = testsInDir.get(i).get(2).toString(); + testPathDir = Paths.get(TESTS_TESTS_DEFAULT_DIR.toString(), testSuiteDir, testNameDir, testNameDir + ".py").toString(); + bTestAlreadyInTable = (testPathDir.equals(testPathTable)); + if (bTestAlreadyInTable) { + break; + } + } + if (!bTestAlreadyInTable) { + //this test in table does not exist any more in the tests directory: remove + model.removeRow(row); + totalRows = model.getRowCount(); + } + } + } + /** * Build a map with optional parameters to be passed to the testing script. * The map is like this: parameters \_ name | \_ value | \_ description \_ @@ -1384,42 +1637,75 @@ public class TestingList extends Panel { return mParameters; } - private HashMap getTestParameters(String sTestPath){ - String testParams = getConfigItem("parameters", sTestPath); + /** + * get the parameters from the test config file + * + * @param sTestPath directory where the test files are (directory with the + * test name) + * @return HashMap of the test parameters. See buildParametersMap() for + * details. + */ + private HashMap getTestParameters(String sTestPath) { + String testParams = getConfigItem("parameters", sTestPath); return buildParametersMap(testParams); } - - private String getTestDescription(String sTestPath){ + + /** + * Get the description of the test. + * + * @param sTestPath directory where the test files are (directory with the + * test name) + * @return test description + */ + private String getTestDescription(String sTestPath) { return getConfigItem("description", sTestPath); } - - private String getConfigItem(String sParameterName, String sTestPath){ - Properties propTest = new Properties(); - File fileTest = new File(sTestPath); - File dirTest = fileTest.getParentFile(); - String testParams = ""; - if (dirTest.isDirectory()) { - File configFile = new File(dirTest.getPath() + FilenameUtils.separatorsToSystem("/.config")); - if (configFile.exists() && !configFile.isDirectory()) { - try { - InputStream ist = new FileInputStream(configFile); - propTest.load(ist); - testParams = propTest.getProperty(sParameterName); - } catch (IOException ex) { - Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - return testParams; + + /** + * generic function that get a configuration item of a test. + * + * @param sParameterName configuration item name to retrieve from the test + * @param sTestPath directory where the test files are (directory with the + * test name) + * @return value of the configuration item + */ + private String getConfigItem(String sParameterName, String sTestPath) { + Properties propTest = new Properties(); + File fileTest = new File(sTestPath); + File dirTest = fileTest.getParentFile(); + String testParams = ""; + if (dirTest.isDirectory()) { + File configFile = new File(dirTest.getPath() + FilenameUtils.separatorsToSystem("/"+TESTS_CONFIG_FILENAME)); + if (configFile.exists() && !configFile.isDirectory()) { + try { + InputStream ist = new FileInputStream(configFile); + propTest.load(ist); + testParams = propTest.getProperty(sParameterName); + if (testParams == null) { + testParams = ""; + } + ist.close(); + } catch (IOException ex) { + Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); + } + } } - + return testParams; + } + /** * Save current setup in a file. The current position of table rows is also * saved. */ public void saveSettings() { - final FileSystemView fsv = new DirectoryRestrictedFileSystemView(TESTS_CONFIG_DEFAULT_DIR.toFile()); - JFileChooser fc = new JFileChooser(fsv.getHomeDirectory(),fsv); + if (!TESTS_CONFIG_DEFAULT_DIR.toFile().isDirectory()) { + boolean success = TESTS_CONFIG_DEFAULT_DIR.toFile().mkdirs(); + if (!success) { + // Directory creation failed + SwingUtils.showMessage(this, "saveSettings()", "Cannot create directory " + TESTS_CONFIG_DEFAULT_DIR.toString()); + } + } + JFileChooser fc = new JFileChooser(TESTS_CONFIG_DEFAULT_DIR.toFile()); int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); @@ -1451,6 +1737,7 @@ public class TestingList extends Panel { */ public void loadSettings() { final JFileChooser fc = new JFileChooser(); + fc.setCurrentDirectory(TESTS_CONFIG_DEFAULT_DIR.toFile()); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); @@ -1461,8 +1748,8 @@ public class TestingList extends Panel { } /** - * Load current setup from a file. The current position of table rows is also - * saved. + * Load current setup from a file. The current position of table rows is + * also saved. * * @param file file containing the settings */ @@ -1486,53 +1773,4 @@ public class TestingList extends Panel { } } - /** - * override FileSystemView in order to create a file system view restricted directory - * so that user can only load/save settings on a specific directory - * - */ - public class DirectoryRestrictedFileSystemView extends FileSystemView - { - private final File[] rootDirectories; - - public DirectoryRestrictedFileSystemView(File rootDirectory) - { - this.rootDirectories = new File[] {rootDirectory}; - } - - public DirectoryRestrictedFileSystemView(File[] rootDirectories) - { - this.rootDirectories = rootDirectories; - } - - @Override - public File createNewFolder(File containingDir) throws IOException - { - throw new UnsupportedOperationException("Unable to create directory"); - } - - @Override - public File[] getRoots() - { - return rootDirectories; - } - - @Override - public boolean isRoot(File file) - { - for (File root : rootDirectories) { - if (root.equals(file)) { - return true; - } - } - return false; - } - - @Override - public File getHomeDirectory() - { - return rootDirectories[0]; - } - } - //end of class } diff --git a/plugins/TestingListDetails.form b/plugins/TestingListDetails.form index cd15dc4..f2eb0f6 100644 --- a/plugins/TestingListDetails.form +++ b/plugins/TestingListDetails.form @@ -38,15 +38,9 @@ - - - - - - - + @@ -93,16 +87,12 @@ - + - - - - - - + + @@ -245,36 +235,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -353,5 +313,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/TestingListDetails.java b/plugins/TestingListDetails.java index 49ce44f..9f6193f 100644 --- a/plugins/TestingListDetails.java +++ b/plugins/TestingListDetails.java @@ -2,10 +2,21 @@ * Copyright (c) 2015 Paul Scherrer Institute. All rights reserved. */ +import ch.psi.utils.swing.SwingUtils; import java.awt.Desktop; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.HashMap; +import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.ImageIcon; @@ -39,6 +50,9 @@ public class TestingListDetails extends javax.swing.JPanel { initComponents(); fillComponents(hDetails); } + + public static String TESTS_CONFIG_FILENAME = ".config"; + public static Path TESTS_TESTS_DEFAULT_DIR = Paths.get(".", "home", "script", "tests", "tests"); /** * This method is called from within the constructor to initialize the form. @@ -61,9 +75,6 @@ public class TestingListDetails extends javax.swing.JPanel { jScrollPane1 = new javax.swing.JScrollPane(); jTableParams = new javax.swing.JTable(); jLabel7 = new javax.swing.JLabel(); - cmCancel = new javax.swing.JButton(); - cmOk = new javax.swing.JButton(); - cmDefault = new javax.swing.JButton(); jScrollPane2 = new javax.swing.JScrollPane(); txtTestResult = new javax.swing.JTextArea(); jLabel8 = new javax.swing.JLabel(); @@ -71,6 +82,9 @@ public class TestingListDetails extends javax.swing.JPanel { txtTestDescription = new javax.swing.JTextArea(); jScrollPane4 = new javax.swing.JScrollPane(); jEditorPaneHelp = new javax.swing.JEditorPane(); + jPanel1 = new javax.swing.JPanel(); + jButtonCancel = new javax.swing.JButton(); + jButtonOk = new javax.swing.JButton(); jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel1.setText("Device name"); @@ -134,29 +148,6 @@ public class TestingListDetails extends javax.swing.JPanel { jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel7.setText("Test Parameters"); - cmCancel.setText("Cancel"); - this.cmCancel.setVisible(false); - this.cmOk.setVisible(false); - cmCancel.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - cmCancelActionPerformed(evt); - } - }); - - cmOk.setText("Ok"); - this.cmCancel.setVisible(false); - this.cmOk.setVisible(false); - - cmDefault.setText("Save as Default"); - this.cmCancel.setVisible(false); - this.cmOk.setVisible(false); - this.cmDefault.setVisible(false); - cmDefault.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - cmDefaultActionPerformed(evt); - } - }); - jScrollPane2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N txtTestResult.setEditable(false); @@ -183,6 +174,35 @@ public class TestingListDetails extends javax.swing.JPanel { jEditorPaneHelp.setDropMode(javax.swing.DropMode.INSERT); jScrollPane4.setViewportView(jEditorPaneHelp); + jButtonCancel.setText("Cancel"); + + jButtonOk.setText("Ok"); + jButtonOk.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButtonOkActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jButtonOk, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jButtonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButtonCancel) + .addComponent(jButtonOk)) + .addContainerGap()) + ); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -207,13 +227,8 @@ public class TestingListDetails extends javax.swing.JPanel { .addComponent(txtTestName) .addComponent(jScrollPane3) .addComponent(jScrollPane2) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(cmDefault, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(cmOk, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(cmCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE))) + .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE) .addContainerGap()) @@ -251,13 +266,10 @@ public class TestingListDetails extends javax.swing.JPanel { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel7) - .addGap(0, 229, Short.MAX_VALUE)) + .addGap(0, 192, Short.MAX_VALUE)) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(cmCancel) - .addComponent(cmOk) - .addComponent(cmDefault))) + .addGap(18, 18, 18) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jScrollPane4) .addContainerGap()))) @@ -332,20 +344,103 @@ public class TestingListDetails extends javax.swing.JPanel { } } } + + /** + * Build a map with optional parameters to be passed to the testing script. + * The map is like this: parameters \_ name | \_ value | \_ description \_ + * name | \_ value | \_ description ... the name 'name' is the mapping key. + * 'value' and 'description' are constant mapping keys of a nested map. + * + * @param parametersString string containing the parameters. Syntax: + * name:value:description[;name:value:description;...] + */ + private HashMap buildParametersMap(String parametersString) { + HashMap mParameters = new HashMap(); // contains name and attributes + HashMap mParameterAttributes = new HashMap(); //contians value and description + String[] dsParameterAttributes = null; + String[] dsParameters = parametersString.split(";"); + for (String sParameter : dsParameters) { + dsParameterAttributes = sParameter.split(":"); + if (dsParameterAttributes.length > 2) { + mParameterAttributes = new HashMap(); + mParameterAttributes.put("value", (Object) dsParameterAttributes[1]); + mParameterAttributes.put("description", dsParameterAttributes[2]); + //add parameter name and attributes (value + description) + mParameters.put(dsParameterAttributes[0], mParameterAttributes); + } + } + return mParameters; + } + + private HashMap getParametersFromTable(){ + HashMap mParameters = new HashMap(); // contains name and attributes + HashMap mParameterAttributes = new HashMap(); //contians value and description + for(int row=0 ; row - - - - - - - - - - 3000 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -