From 20605f08c33e4b252513f778ce6a1c969e8efc3b Mon Sep 17 00:00:00 2001 From: boccioli_m Date: Thu, 3 Sep 2015 15:12:36 +0200 Subject: [PATCH] Closedown --- config/users | Bin 355 -> 381 bytes plugins/TestingList.form | 8 +++ plugins/TestingList.java | 36 ++++++++++++ script/tests/templates/testTemplate.py | 74 +++++++++++++------------ 4 files changed, 82 insertions(+), 36 deletions(-) diff --git a/config/users b/config/users index 00095b87b8329c91cae597dc7412703356aebd63..0f5bc180b050404178f7be3e06eaa2d9510a3b16 100644 GIT binary patch delta 106 zcmaFN^p|OZ5j%4^3j+fK^F+&8Yz&NbMGQ(4ZN(>kaPsC#%1=(t%+JY;&n+%wsAFJa yU;t4ZB@FE8`AJFn@rf|uI*>S92?K9pN^WLeW^qYTVo81xP@PL^T4HHVNd*8j3LfbI delta 51 zcmey%^q6Ua5j#^k3j+fK(?rWzY>W(bMGQ(4ZN(>ka1vlo&reFqk54QvWT<0cVqlyc H!>9-VZGH`? diff --git a/plugins/TestingList.form b/plugins/TestingList.form index f4718b5..8a5e134 100644 --- a/plugins/TestingList.form +++ b/plugins/TestingList.form @@ -50,6 +50,14 @@ + + + + + + + + diff --git a/plugins/TestingList.java b/plugins/TestingList.java index f89211d..755dfa4 100644 --- a/plugins/TestingList.java +++ b/plugins/TestingList.java @@ -3,8 +3,12 @@ */ // +import ch.psi.pshell.core.Controller; +import ch.psi.pshell.security.AccessLevel; +import ch.psi.pshell.ui.App; import ch.psi.pshell.ui.Panel; import ch.psi.pshell.ui.Plugin; +import ch.psi.pshell.ui.View; import ch.psi.utils.swing.SwingUtils; import ch.psi.wsaf.Task; import java.awt.Point; @@ -347,6 +351,7 @@ public class TestingList extends Panel { jMenuItemNewTest = new javax.swing.JMenuItem(); jMenuItemNewDevice = new javax.swing.JMenuItem(); jSeparator2 = new javax.swing.JPopupMenu.Separator(); + jMenuItemEditScript = new javax.swing.JMenuItem(); jMenuItemOpenLog = new javax.swing.JMenuItem(); jPopupMenuConfigs = new javax.swing.JPopupMenu(); jPopupMenuTable = new javax.swing.JPopupMenu(); @@ -410,6 +415,14 @@ public class TestingList extends Panel { jMenuAdvanced.add(jMenuItemNewDevice); jMenuAdvanced.add(jSeparator2); + jMenuItemEditScript.setText("Edit selected test"); + jMenuItemEditScript.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItemEditScriptActionPerformed(evt); + } + }); + jMenuAdvanced.add(jMenuItemEditScript); + jMenuItemOpenLog.setText("Open Log"); jMenuItemOpenLog.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -767,6 +780,10 @@ public class TestingList extends Panel { }//GEN-LAST:event_jButtonSaveActionPerformed private void jButtonOptionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOptionsActionPerformed + //enable some menu items only for administrator access control level + this.jMenuItemEditScript.setEnabled(Controller.getInstance().getLevel()==AccessLevel.administrator); + this.jMenuItemNewTest.setEnabled(Controller.getInstance().getLevel()==AccessLevel.administrator); + this.jMenuItemNewDevice.setEnabled(Controller.getInstance().getLevel()==AccessLevel.administrator); jPopupMenuOptions.show(jButtonOptions, 0, jButtonOptions.getHeight()); }//GEN-LAST:event_jButtonOptionsActionPerformed @@ -860,6 +877,20 @@ public class TestingList extends Panel { enableSelection(false); }//GEN-LAST:event_jMenuItemDeselectSelectionActionPerformed + private void jMenuItemEditScriptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemEditScriptActionPerformed + // TODO add your handling code here: + int rows[] = jTable1.getSelectedRows(); + for(int row=0 ; row // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButtonMoveDown; @@ -873,6 +904,7 @@ public class TestingList extends Panel { private javax.swing.JCheckBoxMenuItem jCheckBoxMenuShowSelectedTests1; private javax.swing.JMenu jMenuAdvanced; private javax.swing.JMenuItem jMenuItemDeselectSelection; + private javax.swing.JMenuItem jMenuItemEditScript; private javax.swing.JMenuItem jMenuItemNewDevice; private javax.swing.JMenuItem jMenuItemNewTest; private javax.swing.JMenuItem jMenuItemOpenLog; @@ -1733,6 +1765,10 @@ public class TestingList extends Panel { } } } + //if not administrator, then show only enabled tests + boolean bShow = Controller.getInstance().getLevel()==AccessLevel.administrator; + showSelectedTestsOnly(bShow); + jCheckBoxMenuShowSelectedTests1.setState(bShow); logger.log(Level.INFO, iCounter + " tests loaded."); } diff --git a/script/tests/templates/testTemplate.py b/script/tests/templates/testTemplate.py index 892a8b6..b0e52b6 100644 --- a/script/tests/templates/testTemplate.py +++ b/script/tests/templates/testTemplate.py @@ -20,48 +20,50 @@ def startTest(testName, DEVICE, params): ######### WRITE YOUR CODE HERE BELOW ############# - #All the code in this section ## ..YOUR CODE.. ## can be modified/deleted. - #It must be indented at the same level as this comment - #----------------------------------- - # GETTING INPUTS: - #If needed, the following variables are available: - #testPath string, path of this test file - #testName string, name of this test - #DEVICE string, device for which the test must run (typically it is the beginning of a process variable name) - #----------------------------------- - # GETTING TEST PARAMETERS: - #if you need to get parameters for the test, use (casting may be necessary): - #myParamValue = test.getParam('myParamName') - #see the test config for the list of parameters specific to the test. - #----------------------------------- - # SETTING OUTPUTS: - #ret string, a text summarizing the result of the test. It must be set before the end of your code. - #success bool, True = test successful. It must be set before the end of your code. - #test.sendFeedback(ret,success) method that ends the testing script and gives the report to the calling application. - #Examples: - # - #whenever the code must quit (i.e. after an error), you must end with: - #ret = 'here is some info on what failed on the test' - #success = false - #test.sendFeedback(ret, success) - # - #whenever the code is finished successfully, you must end with: - #ret = 'here is some info on the success of the test' - #success = true - #test.sendFeedback(ret, success) - #----------------------------------- - # LOG INFO: - #when some information must be shown on the log, use: - #test.log('test to log') + """ + All the code in this section ###..YOUR CODE..### can be modified/deleted. + It must be indented to the same level as this comment + ----------------------------------- + GETTING INPUTS: + If needed, the following variables are available: + testPath string, path of this test file + testName string, name of this test + DEVICE string, device for which the test must run (typically it is the beginning of a process variable name) + ----------------------------------- + GETTING TEST PARAMETERS: + if you need to get parameters for the test, use (casting may be necessary): + myParamValue = test.getParam('myParamName') + see the test config for the list of parameters specific to the test. + ----------------------------------- + SETTING OUTPUTS: + ret string, a text summarizing the result of the test. It must be set before the end of your code. + success bool, True = test successful. It must be set before the end of your code. + test.sendFeedback(ret,success) method that ends the testing script and gives the report to the calling application. + Examples: + + whenever the code must quit (i.e. after an error), you must end with: + ret = 'here is some info on what failed on the test' + success = false + test.sendFeedback(ret, success) + + whenever the code is finished successfully, you must end with: + ret = 'here is some info on the success of the test' + success = true + test.sendFeedback(ret, success) + ----------------------------------- + LOG INFO: + when some information must be shown on the log, use: + test.log('test to log') + """ ########## Example (can be removed) ###### #print the list of parameters passed. If any error, stop and send feedback - test.log("Example - Test name: "+testName): - test.log("Example - Device name: "+DEVICE): + test.log("Example - Test name: "+testName) + test.log("Example - Device name: "+DEVICE) try: test.log("Running test Initialise with the following parameters:") test.log(params ) - #If present, use the parameters here below for your test script + #If present, use the parameters here below for your test script. You might need to change the casting #$testParameters except: ret = 'Could not retrieve testing parameters - ' + traceback.format_exc()