This commit is contained in:
boccioli_m
2018-03-20 13:48:39 +01:00
parent f952dba362
commit 23f6671e41
12 changed files with 507 additions and 3410 deletions

View File

@@ -54,7 +54,7 @@
<Group type="102" alignment="0" attributes="0">
<Component id="lblParams" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="549" max="32767" attributes="0"/>
<Component id="jScrollPane1" pref="514" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
@@ -73,19 +73,12 @@
</Group>
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="txtTestName" max="32767" attributes="0"/>
<Component id="jComboBoxTestSuites" alignment="1" max="32767" attributes="0"/>
<Component id="jScrollPane3" alignment="1" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="txtContactName" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Component id="txtTestName" max="32767" attributes="0"/>
<Component id="jComboBoxTestSuites" alignment="1" max="32767" attributes="0"/>
<Component id="jScrollPane3" alignment="1" max="32767" attributes="0"/>
<Component id="txtContactName" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
@@ -94,33 +87,31 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="lblName" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="txtTestName" min="-2" pref="30" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtTestName" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblSuite" min="-2" max="-2" attributes="0"/>
<Component id="jComboBoxTestSuites" min="-2" pref="30" max="-2" attributes="0"/>
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblSuite" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jComboBoxTestSuites" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane3" pref="126" max="32767" attributes="0"/>
<Component id="jScrollPane3" pref="81" max="32767" attributes="0"/>
<Component id="lblDescr" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="txtContactName" min="-2" max="-2" attributes="0"/>
<Component id="lblContact" min="-2" max="-2" attributes="0"/>
<Component id="txtContactName" min="-2" pref="30" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="16" max="-2" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="lblParams" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="171" max="32767" attributes="0"/>
<EmptySpace min="0" pref="132" max="32767" attributes="0"/>
</Group>
<Component id="jScrollPane1" pref="0" max="32767" attributes="0"/>
</Group>
@@ -181,15 +172,12 @@
</Property>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[30, 26]"/>
<Dimension value="[30, 23]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[60, 26]"/>
<Dimension value="[60, 23]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="txtTestNameActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JComboBox" name="jComboBoxTestSuites">
<Properties>
@@ -229,7 +217,6 @@
<Property name="lineWrap" type="boolean" value="true"/>
<Property name="rows" type="int" value="5"/>
<Property name="toolTipText" type="java.lang.String" value="Add here a detailed description"/>
<Property name="wrapStyleWord" type="boolean" value="true"/>
</Properties>
</Component>
</SubComponents>
@@ -240,12 +227,6 @@
<Font name="Tahoma" size="14" style="0"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Write here the user name of the person who can be contacted for any question concerning this test"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[6, 26]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[6, 26]"/>
</Property>
</Properties>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
@@ -274,7 +255,7 @@
<Editor/>
<Renderer/>
</Column>
<Column maxWidth="200" minWidth="-1" prefWidth="100" resizable="true">
<Column maxWidth="100" minWidth="-1" prefWidth="80" resizable="true">
<Title/>
<Editor/>
<Renderer/>

View File

@@ -14,7 +14,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -40,8 +39,7 @@ import javax.naming.directory.SearchResult;
import javax.naming.ldap.InitialLdapContext;
import javax.naming.ldap.LdapContext;
import javax.swing.table.DefaultTableModel;
//import org.json.simple.JSONArray;
//import org.json.simple.JSONObject;
/**
*
* @author boccioli_m
@@ -60,11 +58,9 @@ public class NewTest extends javax.swing.JPanel {
public static Path TEMPLATES_DEVICECONFIG_FILEPATH = Paths.get(TESTS_ROOT_DIR, "templates","deviceTemplate.config");
public static String TESTS_CONFIG_FILENAME = ".config";
public static String TESTS_HELP_FILENAME = "help.html";
public static String ALLOWED_CHARSET1 = "[a-z A-Z 0-9 . _ \\- \\[\\] () : < > = \\$]*"; //les restricted set of chars
public static String ALLOWED_CHARSET2 = "[a-z A-Z 0-9 . _ \\- \\[\\] () : \\$]*"; //more restricted set of chars
public static String ALLOWED_CHARSET3 = "[a-zA-Z0-9._ \\- \\$ , :]*"; //even more restricted set of chars
public static String VALUE_SEPARATOR = "&";
public static String PARAM_SEPARATOR = ";";
public static String ALLOWED_CHARSET1 = "[a-z A-Z 0-9 . _ \\- \\[\\] () : , < > =]*"; //les restricted set of chars
public static String ALLOWED_CHARSET2 = "[a-z A-Z 0-9 . _ \\- \\[\\] ()]*"; //more restricted set of chars
public static String ALLOWED_CHARSET3 = "[a-zA-Z0-9._\\-]*"; //even more restricted set of chars
/**
* enumeration of table column indexes
@@ -155,13 +151,8 @@ public class NewTest extends javax.swing.JPanel {
txtTestName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
txtTestName.setToolTipText("");
txtTestName.setMinimumSize(new java.awt.Dimension(30, 26));
txtTestName.setPreferredSize(new java.awt.Dimension(60, 26));
txtTestName.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtTestNameActionPerformed(evt);
}
});
txtTestName.setMinimumSize(new java.awt.Dimension(30, 23));
txtTestName.setPreferredSize(new java.awt.Dimension(60, 23));
jComboBoxTestSuites.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jComboBoxTestSuites.setToolTipText("Select a Test Suite or add a new one");
@@ -175,13 +166,10 @@ public class NewTest extends javax.swing.JPanel {
txtTestDescription.setLineWrap(true);
txtTestDescription.setRows(5);
txtTestDescription.setToolTipText("Add here a detailed description");
txtTestDescription.setWrapStyleWord(true);
jScrollPane3.setViewportView(txtTestDescription);
txtContactName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
txtContactName.setToolTipText("Write here the user name of the person who can be contacted for any question concerning this test");
txtContactName.setMinimumSize(new java.awt.Dimension(6, 26));
txtContactName.setPreferredSize(new java.awt.Dimension(6, 26));
jTableParams.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jTableParams.setModel(new javax.swing.table.DefaultTableModel(
@@ -207,8 +195,8 @@ public class NewTest extends javax.swing.JPanel {
jTableParams.getColumnModel().getColumn(0).setMinWidth(150);
jTableParams.getColumnModel().getColumn(0).setPreferredWidth(150);
jTableParams.getColumnModel().getColumn(0).setMaxWidth(150);
jTableParams.getColumnModel().getColumn(1).setPreferredWidth(100);
jTableParams.getColumnModel().getColumn(1).setMaxWidth(200);
jTableParams.getColumnModel().getColumn(1).setPreferredWidth(80);
jTableParams.getColumnModel().getColumn(1).setMaxWidth(100);
}
jButtonGenerate.setText("Generate");
@@ -250,7 +238,7 @@ public class NewTest extends javax.swing.JPanel {
.addGroup(layout.createSequentialGroup()
.addComponent(lblParams)
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 549, Short.MAX_VALUE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 514, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblName)
@@ -263,44 +251,36 @@ public class NewTest extends javax.swing.JPanel {
.addComponent(lblContact))
.addGap(10, 10, 10)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtTestName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jComboBoxTestSuites, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING))
.addGap(12, 12, 12))
.addGroup(layout.createSequentialGroup()
.addComponent(txtContactName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())))))
.addComponent(txtTestName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jComboBoxTestSuites, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(txtContactName))
.addGap(12, 12, 12))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblName)
.addComponent(txtTestName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblSuite)
.addComponent(jComboBoxTestSuites, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(lblName))
.addComponent(txtTestName, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE)
.addComponent(lblDescr))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblSuite)
.addComponent(jComboBoxTestSuites, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)
.addComponent(lblDescr))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(lblContact)
.addGap(29, 29, 29))
.addGroup(layout.createSequentialGroup()
.addComponent(txtContactName, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
.addComponent(txtContactName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblContact))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblParams)
.addGap(0, 171, Short.MAX_VALUE))
.addGap(0, 132, Short.MAX_VALUE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
@@ -341,17 +321,11 @@ public class NewTest extends javax.swing.JPanel {
}
}//GEN-LAST:event_jMenuItemDeleteRowActionPerformed
private void txtTestNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTestNameActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtTestNameActionPerformed
/**
* fill table with example parameters
* @param newType of type TypeOfNewFile, can be device or test.
*/
private void fillComponents(TypeOfNewFile newType) {
txtContactName.setText(System.getProperty("user.name"));
// listener for mouse-click also on table header
jTableParams.getTableHeader().addMouseListener(new MouseAdapter() {
@@ -369,9 +343,9 @@ public class NewTest extends javax.swing.JPanel {
this.lblName.setText( newType + " "+ this.lblName.getText());
this.lblName.setToolTipText(newType + " name. Can be a PV name.");
this.txtTestName.setToolTipText(newType + " name. Can be a PV name.");
//lblParams.setVisible(false);
//jTableParams.setVisible(false);
//jScrollPane1.setVisible(false);
lblParams.setVisible(false);
jTableParams.setVisible(false);
jScrollPane1.setVisible(false);
lblContact.setVisible(false);
txtContactName.setVisible(false);
}
@@ -449,7 +423,7 @@ public class NewTest extends javax.swing.JPanel {
String[] dsParameterAttributes = null;
String[] dsParameters = parametersString.split(";");
for (String sParameter : dsParameters) {
dsParameterAttributes = sParameter.split("&");
dsParameterAttributes = sParameter.split(":");
if (dsParameterAttributes.length > 2) {
mParameterAttributes = new HashMap();
mParameterAttributes.put("value", (Object) dsParameterAttributes[1]);
@@ -784,7 +758,7 @@ public class NewTest extends javax.swing.JPanel {
* @param hmTestParams test parameters. For the details of the structure, see buildParametersMap
* @return true if success, false if else
*/
public boolean generateTestConfigOld(Path templateDir,
public boolean generateTestConfig(Path templateDir,
Path testDir,
String sTestName,
String sTestDescription,
@@ -810,7 +784,7 @@ public class NewTest extends javax.swing.JPanel {
value = (String) attributes.get("value");
description = (String) attributes.get("description");
//build the python code for getting the test parameter
sTestParameters = sTestParameters + name + VALUE_SEPARATOR + value + VALUE_SEPARATOR + description + PARAM_SEPARATOR ;
sTestParameters = sTestParameters + name + ":" + value + ":" + description + ";" ;
}
}
FileInputStream in = new FileInputStream(configFile);
@@ -844,101 +818,6 @@ public class NewTest extends javax.swing.JPanel {
}
/**
* generate the python script that runs the test
*
* @param templateDir the path of the template to be used for the generation of theconfig.
* it can be: TEMPLATES_TESTCONFIG_FILEPATH, TEMPLATES_DEVICECONFIG_FILEPATH
* @param testDir path where the test is located (including the test name dir)
* @param sTestName name of the test
* @param sTestDescription description of the test
* @param sTestSuite test cases/test suite name
* @param hmTestParams test parameters. For the details of the structure, see buildParametersMap
* @return true if success, false if else
*/
public boolean generateTestConfig(Path templateDir,
Path testDir,
String sTestName,
String sTestDescription,
String sTestSuite,
HashMap hmTestParams){
//generate test config file from template
boolean success = false;
try {
Path path = Paths.get(testDir.toString(),TESTS_CONFIG_FILENAME);
if(Files.exists(path)){
Files.delete(path);
}
Files.copy(templateDir, path);
File configFile = path.toFile();
//Loop among the test parameters and generate variable assignement syntax for python
String sTestParameters = "";
String name="", value="", description="";
for(Object entry : hmTestParams.keySet()){
Object param = entry;
if(param instanceof String){
name = (String) param;
HashMap attributes = (HashMap) hmTestParams.get(param);
value = (String) attributes.get("value");
description = (String) attributes.get("description");
//build the python code for getting the test parameter
sTestParameters = sTestParameters + name + VALUE_SEPARATOR + "\"" + value + "\"" + VALUE_SEPARATOR + "\"" + description + "\"" + PARAM_SEPARATOR ;
}
}
FileInputStream in = new FileInputStream(configFile);
Properties props = new Properties();
props.load(in);
in.close();
FileOutputStream out = new FileOutputStream(configFile);
if(sType == TypeOfNewFile.Device){
//creation of device config
props.setProperty("name", sTestName);
props.setProperty("description", sTestDescription);
props.setProperty("tests", sTestSuite);
props.setProperty("parameters", sTestParameters);
}else{
//creation of test config
props.setProperty("name", sTestName);
props.setProperty("description", sTestDescription);
props.setProperty("parameters", sTestParameters);
}
props.store(out, null);
out.close();
/*
JSONObject obj = new JSONObject();
obj.put("Name", "crunchify.com");
obj.put("Author", "App Shah");
JSONArray company = new JSONArray();
company.add("Compnay: eBay");
company.add("Compnay: Paypal");
company.add("Compnay: Google");
obj.put("Company List", company);
String jsonConfig = obj.toJSONString();
FileWriter jout = new FileWriter(configFile);
jout.write(jsonConfig);
jout.flush();
jout.close();
*/
success = true;
} catch (FileNotFoundException ex) {
SwingUtils.showMessage(this, "generateTestConfig()", "Cannot find file: " + ex.toString());
Logger.getLogger(NewTest.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
SwingUtils.showMessage(this, "generateTestConfig()", "Problem with file aaccess: " + ex.toString());
Logger.getLogger(NewTest.class.getName()).log(Level.SEVERE, null, ex);
}
return success;
}
/**
* generate the html help file of the test
*

File diff suppressed because it is too large Load Diff

View File

@@ -104,6 +104,9 @@
</Component>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItemRunSingleTest">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons/play-circled-16-000000.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Run this test now"/>
</Properties>
<Events>
@@ -259,14 +262,14 @@
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
<Property name="columns" type="int" value="2"/>
<Property name="rows" type="int" value="2"/>
</Layout>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Component class="javax.swing.JButton" name="jButtonOptions">
<Properties>
<Property name="toolTipText" type="java.lang.String" value="More actions"/>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons/listing-option-32px.png"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Optional actions"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[60, 40]"/>
</Property>
@@ -280,10 +283,18 @@
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonOptionsActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Before"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="jButtonSave">
<Properties>
<Property name="toolTipText" type="java.lang.String" value="Save current list of tests"/>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons/android-save-24-000000.png"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Save current configuration"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[60, 40]"/>
</Property>
@@ -297,15 +308,18 @@
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonSaveActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jButtonLog">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonLogActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="After"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="jButtonOpen">
<Properties>
<Property name="toolTipText" type="java.lang.String" value="Open a list of tests"/>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons/folder-open-24-000000.png"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Open configuration"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 9]"/>
</Property>
@@ -316,11 +330,19 @@
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonOpenActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Last"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="jButtonRun">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons/play-circled-64-000000.png"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Run enabled tests"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[330000, 39]"/>
@@ -367,6 +389,9 @@
</Component>
<Component class="javax.swing.JButton" name="jButtonMoveDown">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons/chevron-down-16-000000.png"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Move the selected tests down"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[25, 25]"/>
@@ -389,6 +414,9 @@
</Component>
<Component class="javax.swing.JButton" name="jButtonMoveUp">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons/chevron-up-16-000000.png"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Move the selected tests up"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[25, 25]"/>
@@ -505,6 +533,9 @@
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="8" style="0"/>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons/x-darker-8px.png"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Close this custom panel"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[12, 12]"/>
@@ -515,6 +546,9 @@
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[12, 12]"/>
</Property>
<Property name="rolloverIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/icons/x-darker-8px.png"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonXActionPerformed"/>

View File

@@ -40,8 +40,6 @@ import java.lang.reflect.Method;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -58,7 +56,6 @@ import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JMenuItem;
import javax.swing.RowFilter;
import javax.swing.UIManager;
import javax.swing.filechooser.FileSystemView;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableModel;
@@ -66,7 +63,7 @@ import javax.swing.table.TableRowSorter;
import org.apache.commons.io.FilenameUtils;
import org.python.core.PyList;
import static org.python.bouncycastle.util.Arrays.append;
import java.util.Collections;
//</editor-fold>
/**
@@ -295,17 +292,12 @@ public class TestingList extends Panel {
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";
public static String VALUE_SEPARATOR = "&";
public static String PARAM_SEPARATOR = ";";
/**
* initialise panel
*/
private void initialise(){
/*
// testing RPS packets
System.out.println("msg:");
int PORT1 = 0x8899; // this port
String mode = "2,IQCOM,$BMA1,1,DIA";
@@ -326,8 +318,6 @@ public class TestingList extends Panel {
System.out.print(String.format("%02X ", msg[i]));
}
System.out.println("");
// end of testing RPS packets
*/
@@ -336,8 +326,9 @@ public class TestingList extends Panel {
initComponents();
addIcons();
initComponents();
initLogger();
buildTable();
@@ -349,8 +340,7 @@ public class TestingList extends Panel {
} catch (Exception ex) {
getLogger().severe(ex.getMessage());
}
loadProperties();
loadProperties();
}
@@ -680,7 +670,7 @@ public class TestingList extends Panel {
logger.addHandler(fh);
SimpleFormatter formatter = new SimpleFormatter();
fh.setFormatter(formatter);
log("INF - " + "New testing session");
log("INFO - " + "New testing session");
} catch (SecurityException e) {
SwingUtils.showMessage(this, "initLogger()", e.toString());
} catch (IOException e) {
@@ -732,7 +722,6 @@ public class TestingList extends Panel {
jPanelButtons = new javax.swing.JPanel();
jButtonOptions = new javax.swing.JButton();
jButtonSave = new javax.swing.JButton();
jButtonLog = new javax.swing.JButton();
jButtonOpen = new javax.swing.JButton();
jButtonRun = new javax.swing.JButton();
jPanelSelection = new javax.swing.JPanel();
@@ -824,6 +813,7 @@ public class TestingList extends Panel {
jPopupMenuTable.add(jMenuItemShowDetails);
jPopupMenuTable.add(jSeparator5);
jMenuItemRunSingleTest.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/play-circled-16-000000.png"))); // NOI18N
jMenuItemRunSingleTest.setText("Run this test now");
jMenuItemRunSingleTest.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -914,9 +904,10 @@ public class TestingList extends Panel {
jPanelButtons.setMinimumSize(new java.awt.Dimension(0, 80));
jPanelButtons.setPreferredSize(new java.awt.Dimension(100, 80));
jPanelButtons.setLayout(new java.awt.GridLayout(2, 2));
jPanelButtons.setLayout(new java.awt.BorderLayout());
jButtonOptions.setToolTipText("More actions");
jButtonOptions.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/listing-option-32px.png"))); // NOI18N
jButtonOptions.setToolTipText("Optional actions");
jButtonOptions.setMaximumSize(new java.awt.Dimension(60, 40));
jButtonOptions.setMinimumSize(new java.awt.Dimension(0, 40));
jButtonOptions.setPreferredSize(new java.awt.Dimension(50, 40));
@@ -925,9 +916,10 @@ public class TestingList extends Panel {
jButtonOptionsActionPerformed(evt);
}
});
jPanelButtons.add(jButtonOptions);
jPanelButtons.add(jButtonOptions, java.awt.BorderLayout.LINE_START);
jButtonSave.setToolTipText("Save current list of tests");
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));
@@ -936,16 +928,10 @@ public class TestingList extends Panel {
jButtonSaveActionPerformed(evt);
}
});
jPanelButtons.add(jButtonSave);
jPanelButtons.add(jButtonSave, java.awt.BorderLayout.LINE_END);
jButtonLog.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonLogActionPerformed(evt);
}
});
jPanelButtons.add(jButtonLog);
jButtonOpen.setToolTipText("Open a list of tests");
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() {
@@ -953,10 +939,11 @@ public class TestingList extends Panel {
jButtonOpenActionPerformed(evt);
}
});
jPanelButtons.add(jButtonOpen);
jPanelButtons.add(jButtonOpen, java.awt.BorderLayout.PAGE_END);
jPanelTopCommands.add(jPanelButtons, java.awt.BorderLayout.EAST);
jButtonRun.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/play-circled-64-000000.png"))); // NOI18N
jButtonRun.setToolTipText("Run enabled tests");
jButtonRun.setMaximumSize(new java.awt.Dimension(330000, 39));
jButtonRun.setMinimumSize(new java.awt.Dimension(90, 90));
@@ -980,6 +967,7 @@ public class TestingList extends Panel {
});
jPanelSelection.add(jCheckBoxEnableDisable, java.awt.BorderLayout.WEST);
jButtonMoveDown.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/chevron-down-16-000000.png"))); // NOI18N
jButtonMoveDown.setToolTipText("Move the selected tests down");
jButtonMoveDown.setMaximumSize(new java.awt.Dimension(25, 25));
jButtonMoveDown.setMinimumSize(new java.awt.Dimension(25, 25));
@@ -991,6 +979,7 @@ public class TestingList extends Panel {
});
jPanelSelection.add(jButtonMoveDown, java.awt.BorderLayout.SOUTH);
jButtonMoveUp.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/chevron-up-16-000000.png"))); // NOI18N
jButtonMoveUp.setToolTipText("Move the selected tests up");
jButtonMoveUp.setMaximumSize(new java.awt.Dimension(25, 25));
jButtonMoveUp.setMinimumSize(new java.awt.Dimension(25, 25));
@@ -1056,10 +1045,12 @@ public class TestingList extends Panel {
jPanelCustomHeader.setLayout(new java.awt.BorderLayout());
jButtonX.setFont(new java.awt.Font("Tahoma", 0, 8)); // NOI18N
jButtonX.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/x-darker-8px.png"))); // NOI18N
jButtonX.setToolTipText("Close this custom panel");
jButtonX.setMaximumSize(new java.awt.Dimension(12, 12));
jButtonX.setMinimumSize(new java.awt.Dimension(12, 12));
jButtonX.setPreferredSize(new java.awt.Dimension(12, 12));
jButtonX.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/x-darker-8px.png"))); // NOI18N
jButtonX.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonXActionPerformed(evt);
@@ -1101,16 +1092,6 @@ public class TestingList extends Panel {
add(jPanelCustom, java.awt.BorderLayout.SOUTH);
}// </editor-fold>//GEN-END:initComponents
private void addIcons() {
jButtonRun.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/play-circled-64-000000.png")));
jButtonLog.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/logbook-32px.png")));
jButtonOptions.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/listing-option-32px.png")));
jButtonSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/android-save-24-000000.png")));
jButtonOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/folder-open-36-000000.png")));
jButtonMoveUp.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/chevron-up-24-000000.png")));
jButtonMoveDown.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/chevron-down-24-000000.png")));
}
private void jButtonRunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRunActionPerformed
if (this.jButtonRun.getToolTipText().equals("Run enabled tests")) {
Object pshellStatus;
@@ -1236,7 +1217,7 @@ public class TestingList extends Panel {
openDetails();
break;
}
//updateStatus();
updateStatus();
} catch (Exception ex) {
SwingUtils.showException(this, ex);
}
@@ -1289,14 +1270,14 @@ public class TestingList extends Panel {
}//GEN-LAST:event_jButtonOptionsActionPerformed
private void jCheckBoxMenuShowSelectedTestsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuShowSelectedTestsActionPerformed
// TODO add your handling code here:
boolean bShow = jCheckBoxMenuShowSelectedTests.getState();
showEnabledTestsOnly(bShow);
jCheckBoxMenuShowSelectedTests1.setState(bShow);
}//GEN-LAST:event_jCheckBoxMenuShowSelectedTestsActionPerformed
private void jMenuItemOpenLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemOpenLogActionPerformed
// TODO add your handling code here:
String cmd;
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
cmd = "notepad.exe " + TESTS_LOG_DEFAULT_DIR;
@@ -1313,7 +1294,7 @@ public class TestingList extends Panel {
}//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();
@@ -1324,24 +1305,24 @@ public class TestingList extends Panel {
}//GEN-LAST:event_jMenuItemReloadActionPerformed
private void jMenuItemNewTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemNewTestActionPerformed
// TODO add your handling code here:
openNewTestEditor("Test");
}//GEN-LAST:event_jMenuItemNewTestActionPerformed
private void jMenuItemNewDeviceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemNewDeviceActionPerformed
// TODO add your handling code here:
openNewTestEditor("Device");
}//GEN-LAST:event_jMenuItemNewDeviceActionPerformed
private void jCheckBoxMenuShowSelectedTests1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuShowSelectedTests1ActionPerformed
// TODO add your handling code here:
boolean bShow = jCheckBoxMenuShowSelectedTests1.getState();
showEnabledTestsOnly(bShow);
jCheckBoxMenuShowSelectedTests.setState(bShow);
}//GEN-LAST:event_jCheckBoxMenuShowSelectedTests1ActionPerformed
private void jMenuItemReload1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemReload1ActionPerformed
// TODO add your handling code here:
reloadTests();
try {
cleanTests();
@@ -1353,7 +1334,7 @@ public class TestingList extends Panel {
private void jMenuItemShowDetailsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemShowDetailsActionPerformed
try {
// TODO add your handling code here:
openDetails();
} catch (Exception ex) {
Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex);
@@ -1361,32 +1342,32 @@ public class TestingList extends Panel {
}//GEN-LAST:event_jMenuItemShowDetailsActionPerformed
private void jMenuItemSelectAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSelectAllActionPerformed
// TODO add your handling code here:
enableAll(true);
}//GEN-LAST:event_jMenuItemSelectAllActionPerformed
private void jMenuItemSelectNoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSelectNoneActionPerformed
// TODO add your handling code here:
enableAll(false);
}//GEN-LAST:event_jMenuItemSelectNoneActionPerformed
private void jMenuItemSelectSelectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSelectSelectionActionPerformed
// TODO add your handling code here:
enableSelection(true);
}//GEN-LAST:event_jMenuItemSelectSelectionActionPerformed
private void jMenuItemDeselectSelectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDeselectSelectionActionPerformed
// TODO add your handling code here:
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<rows.length ; row++){
try {
String sTestPath = String.valueOf(jTable1.getValueAt(rows[row], COL.TESTPATH.ordinal())).replace("\\", File.separator);
System.out.println("Test Path: " + sTestPath);
System.out.println(sTestPath);
((View)App.getInstance().getMainFrame()).openScript(sTestPath);
} catch (IOException ex) {
Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex);
@@ -1395,14 +1376,14 @@ public class TestingList extends Panel {
}//GEN-LAST:event_jMenuItemEditScriptActionPerformed
private void jMenuItemRunSingleTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemRunSingleTestActionPerformed
// TODO add your handling code here:
enableAll(false);
enableSelection(true);
jButtonRunActionPerformed( evt);
}//GEN-LAST:event_jMenuItemRunSingleTestActionPerformed
private void jMenuLoadCustomPanelMenuSelected(javax.swing.event.MenuEvent evt) {//GEN-FIRST:event_jMenuLoadCustomPanelMenuSelected
// TODO add your handling code here:
List<String> menuList = getCustomPanels();
jMenuLoadCustomPanel.removeAll();
for(int u = 0; u < menuList.size(); u++){
@@ -1435,22 +1416,12 @@ public class TestingList extends Panel {
}//GEN-LAST:event_jMenuItemCustomCloseActionPerformed
private void jMenuItemDeselectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDeselectActionPerformed
// TODO add your handling code here:
this.jTable1.clearSelection();
}//GEN-LAST:event_jMenuItemDeselectActionPerformed
private void jButtonLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLogActionPerformed
try {
String logViewerScript = Paths.get(".", "home", "script", "startlogviewer-rpstests.sh").toString();
Process p = Runtime.getRuntime().exec(logViewerScript);
} catch (IOException ex) {
Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex);
}
}//GEN-LAST:event_jButtonLogActionPerformed
//<editor-fold defaultstate="collapsed" desc="Witget Variables declaration">
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButtonLog;
private javax.swing.JButton jButtonMoveDown;
private javax.swing.JButton jButtonMoveUp;
private javax.swing.JButton jButtonOpen;
@@ -1593,7 +1564,7 @@ public class TestingList extends Panel {
* @return status of run button. True = tests launching sequence is running
*/
public boolean isTestRunAllowed() {
return (this.jButtonRun.getToolTipText().equals("Stop tests") && countPendingTests() > 0);
return (this.jButtonRun.getToolTipText().equals("Stop tests") && pendingTestsCount() > 0);
}
/**
@@ -1645,12 +1616,10 @@ public class TestingList extends Panel {
int row = jTable1.getSelectedRow();
String sDeviceName = jTable1.getValueAt(row, COL.DEVICENAME.ordinal()).toString();
String sTestName = jTable1.getValueAt(row, COL.TESTNAME.ordinal()).toString();
String sTestPath = jTable1.getValueAt(row, COL.TESTPATH.ordinal()).toString();
String sTestPath = String.valueOf(jTable1.getValueAt(row, COL.TESTPATH.ordinal())).replace("\\", File.separator);
String sTestCaseName = jTable1.getValueAt(row, COL.TESTSUITE.ordinal()).toString();
String sTestDescription = getTestDescription(sTestPath);
String sDevicePath = jTable1.getValueAt(row, COL.DEVICEPATH.ordinal()).toString();
System.out.println("sDevicePath: "+sDevicePath);
System.out.println("sTestPath: "+sTestPath);
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();
@@ -1660,7 +1629,6 @@ public class TestingList extends Panel {
HashMap details = new HashMap();
details.put("deviceName", sDeviceName);
details.put("deviceDescription", sDeviceDescription);
details.put("devicePath", sDevicePath);
details.put("testDescription", sTestDescription);
details.put("testSuite", sTestCaseName);
details.put("testName", sTestName);
@@ -1739,7 +1707,7 @@ public class TestingList extends Panel {
case "Success":
icon = TestStatus.SUCCESS.Icon();
logger.log(Level.INFO, sStatus + " - Device: " + deviceName + "; Test: " + sTestName + "; Result: " + res);
log("INF - " + sStatus + " - Device: " + deviceName + "; Test: " + sTestName + "; Result: " + res);
log("INFO - " + sStatus + " - Device: " + deviceName + "; Test: " + sTestName + "; Result: " + res);
break;
case "Failure":
icon = TestStatus.FAILURE.Icon();
@@ -1759,36 +1727,18 @@ public class TestingList extends Panel {
logger.log(Level.SEVERE, "Cant find Test: " + testPath + " in table.");
}
//check if there are still pending tests. If not, set the status of the tool to Stopped.
if (countPendingTests() == 0 && countRunningTests() == 0) {
if (pendingTestsCount() == 0 && runningTestsCount() == 0) {
setToStopped();
}
updateResultSummary();
return rowD;
}
/**
* show a summary icon indicating if all tests succeeded
* or if at least one failed
*/
public void updateResultSummary() {
ImageIcon summaryIcon = null;
if(countRunningTests()>0){
summaryIcon = TestStatus.RUNNING.Icon();
} else if(countFailureTests()>0){
summaryIcon = TestStatus.FAILURE.Icon();
} else if(countSuccessTests()>0){
summaryIcon = TestStatus.SUCCESS.Icon();
}
//System.out.println("successful: "+countSuccessTests() + " Failed: "+countSuccessTests() );
setIcon(jTable1, COL.ICON.ordinal(), summaryIcon, "");
}
/**
* return the amount of tests currently in Pending state
*
* @return int counter of pending tests
*/
public int countPendingTests() {
public int pendingTestsCount() {
return testsStatusCount(TestStatus.PENDING);
}
@@ -1797,7 +1747,7 @@ public class TestingList extends Panel {
*
* @return int counter of running tests
*/
public int countRunningTests() {
public int runningTestsCount() {
return testsStatusCount(TestStatus.RUNNING);
}
@@ -1806,19 +1756,10 @@ public class TestingList extends Panel {
*
* @return int counter of successful tests
*/
public int countSuccessTests() {
public int successTestsCount() {
return testsStatusCount(TestStatus.SUCCESS);
}
/**
* return the amount of tests currently in Failure state
*
* @return int counter of failed tests
*/
public int countFailureTests() {
return testsStatusCount(TestStatus.FAILURE);
}
/**
* returns the amount of tests currently in "status" state
*
@@ -1828,16 +1769,15 @@ public class TestingList extends Panel {
private int testsStatusCount(TestStatus status) {
String sStatus;
boolean bSelected;
int iTestsCount = 0;
int iPendingTestsCount = 0;
for (int row = 0; row < jTable1.getRowCount(); row++) {
bSelected = (boolean) jTable1.getValueAt(row, COL.CHECK.ordinal());
sStatus = jTable1.getValueAt(row, COL.STATUS.ordinal()).toString();
//System.out.println("sStatus: " +sStatus);
if (bSelected && sStatus.equals(status.toString())) {
iTestsCount++;
if (bSelected && sStatus == status.toString()) {
iPendingTestsCount++;
}
}
return iTestsCount;
return iPendingTestsCount;
}
/**
@@ -1949,7 +1889,6 @@ public class TestingList extends Panel {
jTable1.setValueAt(sStatus, row, COL.STATUS.ordinal());
jTable1.setValueAt(sStart, row, COL.STARTSEQUENCE.ordinal());
}
updateResultSummary();
}
/**
@@ -2042,12 +1981,13 @@ public class TestingList extends Panel {
String sDeviceName = jTable1.getValueAt(row, COL.DEVICENAME.ordinal()).toString();
String sDevicePath = jTable1.getValueAt(row, COL.DEVICEPATH.ordinal()).toString().replace("\\", File.separator);
String sTestName = jTable1.getValueAt(row, COL.TESTNAME.ordinal()).toString();
String sTestCaseName = jTable1.getValueAt(row, COL.TESTSUITE.ordinal()).toString();
String sTestPath = jTable1.getValueAt(row, COL.TESTPATH.ordinal()).toString().replace("\\", File.separator);
// HashMap mParameters = buildParametersMap(String.valueOf(jTable1.getValueAt(row, COL.TESTPARAMS.ordinal())));
//get the parameters directly frm he config file
// System.out.println("sTestPath: " + sTestPath);
HashMap mParameters = getParameters(sTestPath, sDevicePath);
HashMap testArgs = new HashMap();
System.out.println("mParameters: " + mParameters.toString());
//args.put("ret", "");
testArgs.put(testArgNames.PARAMETERS.toString(), mParameters);
testArgs.put(testArgNames.TEST.toString(), sTestName);
@@ -2064,10 +2004,10 @@ public class TestingList extends Panel {
*
* @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"}}
* {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
@@ -2080,15 +2020,15 @@ public class TestingList extends Panel {
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("#@", "{{'");
@@ -2113,6 +2053,7 @@ public class TestingList extends Panel {
int iRet = -1;
HashMap args2 = new HashMap(); //this is the global map that will contain one map per test.
HashMap testArgs; //this is the map for a test.
RunTest runTest;
String sTestName = "", sDeviceName = "", sTestPath = "", sTestID = ""; //sTestID is the compination of device name + test path
for (int row : rowsToExecute) {
//System.out.println(String.valueOf(row) + "\t" + sDeviceName + "\t" + sTestName + "\t" + sTestCaseName + "\t" + String.valueOf(rowsToExecute.length));
@@ -2144,9 +2085,7 @@ public class TestingList extends Panel {
logger.log(Level.INFO, msg);
System.out.println(msg);
}
//System.out.println("sTestID: " + sTestID);
Object retargs = args2.put(sTestID, testArgs);
//System.out.println("retargs: " + retargs);
args2.put(sTestID, testArgs);
hTests = args2;
iRet = 0;
} catch (Exception ex) {
@@ -2188,7 +2127,7 @@ public class TestingList extends Panel {
}
//animate the custom panel (if present)
animateCustomPanel(sDeviceName);
//System.out.println("sParallelizeCommand: " +sParallelizeCommand);
//System.out.println(sParallelizeCommand);
//run test(s)
Object ret = eval(sParallelizeCommand);
//System.out.println(ret);
@@ -2275,20 +2214,11 @@ public class TestingList extends Panel {
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
renderer.setToolTipText("Click for options");
jTable1.getColumnModel().getColumn(COL.STARTSEQUENCE.ordinal()).setCellRenderer(renderer);
jTable1.getColumnModel().getColumn(COL.STARTSEQUENCE.ordinal()).setPreferredWidth(130);
jTable1.getColumnModel().getColumn(COL.STARTSEQUENCE.ordinal()).setMaxWidth(130);
jTable1.getColumnModel().getColumn(COL.STARTSEQUENCE.ordinal()).setPreferredWidth(30);
jTable1.getColumnModel().getColumn(COL.ICON.ordinal()).setMaxWidth(27);
jTable1.getColumnModel().getColumn(COL.CHECK.ordinal()).setMaxWidth(27);
jTable1.getColumnModel().getColumn(COL.DEVICENAME.ordinal()).setPreferredWidth(200);
jTable1.getColumnModel().getColumn(COL.DEVICENAME.ordinal()).setMaxWidth(200);
jTable1.getColumnModel().getColumn(COL.TESTNAME.ordinal()).setPreferredWidth(200);
jTable1.getColumnModel().getColumn(COL.TESTNAME.ordinal()).setMaxWidth(200);
jTable1.getColumnModel().getColumn(COL.TESTSUITE.ordinal()).setPreferredWidth(200);
jTable1.getColumnModel().getColumn(COL.TESTSUITE.ordinal()).setMaxWidth(200);
jTable1.getColumnModel().getColumn(COL.STATUS.ordinal()).setPreferredWidth(90);
jTable1.getColumnModel().getColumn(COL.STATUS.ordinal()).setMaxWidth(90);
jTable1.getColumnModel().getColumn(COL.TIME.ordinal()).setPreferredWidth(200);
jTable1.getColumnModel().getColumn(COL.TIME.ordinal()).setMaxWidth(200);
jTable1.getColumnModel().getColumn(COL.DEVICENAME.ordinal()).setPreferredWidth(30);
jTable1.getColumnModel().getColumn(COL.STATUS.ordinal()).setPreferredWidth(20);
hideColumn(COL.DEVICEDESCR);
hideColumn(COL.DEVICEPATH);
hideColumn(COL.TESTPATH);
@@ -2323,12 +2253,10 @@ public class TestingList extends Panel {
*/
private void addToTable(String deviceName,
String deviceDescription,
String devicePath,
String testSuite,
String testName,
String testParams,
String testDescription,
String testPath,
String testHelp) {
String sDate = "";
if (testName.equals("") || deviceName.equals("")) {
@@ -2338,14 +2266,9 @@ public class TestingList extends Panel {
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 otestPath = Paths.get(TESTS_TESTS_DEFAULT_DIR.toString(), testSuite, testName, testName + ".py").toString();
String odevicePath = Paths.get(TESTS_DEVICES_DEFAULT_DIR.toString(), deviceName, deviceName + ".config").toString();
System.out.println("Old Test Path = " + otestPath);
System.out.println("Old Dev Path = " + odevicePath);
System.out.println("Test Path = " + testPath);
System.out.println("Dev Path = " + devicePath);
String testPath = Paths.get(TESTS_TESTS_DEFAULT_DIR.toString(), testSuite, testName, testName + ".py").toString();
String devicePath = Paths.get(TESTS_DEVICES_DEFAULT_DIR.toString(), deviceName, deviceName + ".config").toString();
System.out.println("Path = " + testPath);
Object rowData[] = new Object[]{false, "", sDate, deviceName, devicePath, deviceDescription, testSuite, testName, testPath, testParams, testDescription, testHelp, "", "Pending", icon};
//vedify that this test is not already in the table
int totalRows = model.getRowCount();
@@ -2356,15 +2279,11 @@ public class TestingList extends Panel {
&& model.getValueAt(row, COL.TESTNAME.ordinal()).toString().equals(testName)
&& model.getValueAt(row, COL.TESTPATH.ordinal()).toString().replace("\\", File.separator).equals(testPath));
if (bTestAlreadyInTable) {
System.out.println(" test already in table");
break;
}
}
if (!bTestAlreadyInTable) {
System.out.println(" test not in table: adding it...");
System.out.println(" rowData: " + rowData);
model.addRow(rowData);
jTable1.updateUI();
}
} catch (Exception ex) {
ex.printStackTrace();
@@ -2412,45 +2331,34 @@ public class TestingList extends Panel {
int iCounter = 0;
//search devices and their tests
//Scan the list of devices
//File[] listOfDevices = TESTS_DEVICES_DEFAULT_DIR.toFile().listFiles();
List<File> listOfDevices = new ArrayList<File>();
Collections.addAll(listOfDevices, listFilesAsArray(TESTS_DEVICES_DEFAULT_DIR.toFile(), true));
File[] listOfDevices = TESTS_DEVICES_DEFAULT_DIR.toFile().listFiles();
for (File deviceInList : listOfDevices) {
propDevice.clear();
if (deviceInList.isFile()) {
} else if (deviceInList.isDirectory()) {
System.out.println("deviceInList:" + deviceInList.getPath()+ FilenameUtils.separatorsToSystem("/" + TESTS_CONFIG_FILENAME));
File configFile = new File(deviceInList.getPath() + FilenameUtils.separatorsToSystem("/" + TESTS_CONFIG_FILENAME));
if (configFile.exists() && !configFile.isDirectory()) {
System.out.println("deviceInList found");
InputStream is = new FileInputStream(configFile);
propDevice.load(is);
is.close();
//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();
System.out.println(" testsFolder:" + testsFolder);
if (testsFolder.exists() && testsFolder.isDirectory()) {
System.out.println(" testsFolder found");
File[] listOfTests = testsFolder.listFiles();
for (File testinList : listOfTests) {
propTest.clear();
if (testinList.isDirectory()) {
configFile = new File(testinList.getPath() + FilenameUtils.separatorsToSystem("/" + TESTS_CONFIG_FILENAME));
System.out.println(" configFile:" + testinList.getPath() + FilenameUtils.separatorsToSystem("/" + TESTS_CONFIG_FILENAME));
if (configFile.exists() && !configFile.isDirectory()) {
System.out.println(" configFile exists");
InputStream ist = new FileInputStream(configFile);
propTest.load(ist);
ist.close();
addToTable(propDevice.getProperty("name"),
propDevice.getProperty("description"),
deviceInList.getPath(),
propDevice.getProperty("tests"),
propTest.getProperty("name"),
"", //test parameters
"", //test description
testinList.getPath(),
propTest.getProperty("help"));
iCounter++;
}
@@ -2463,33 +2371,6 @@ public class TestingList extends Panel {
//showEnabledTestsOnly(jCheckBoxMenuShowSelectedTests1.getState());
logger.log(Level.INFO, iCounter + " tests loaded.");
}
public static File[] listFilesAsArray(File directory, boolean recurse)
{
Collection files = listFiles(directory, recurse);
File[] arr = new File[files.size()];
return (File[]) files.toArray(arr);
}
public static Collection listFiles(File directory, boolean recurse){
// List of files / directories
Vector files = new Vector ();
// Get files / directories in the directory
File[] entries = directory.listFiles();
// Go over entries
for (File entry : entries){
files.add(entry);
// If the file is a directory and the recurse flag
// is set, recurse into the directory
if (recurse && entry.isDirectory()){
files.addAll(listFiles(entry, recurse));
}
}
// Return collection of files
return files;
}
/**
* scan tests table and see if tests/devices in the table still exist in directory.
@@ -2596,16 +2477,15 @@ public static Collection listFiles(File directory, boolean recurse){
HashMap mParameters = new HashMap(); // contains name and attributes
HashMap mParameterAttributes = new HashMap(); //contians value and description
String[] dsParameterAttributes = null;
String[] dsParameters = parametersString.split(PARAM_SEPARATOR);
String[] dsParameters = parametersString.split(";");
for (String sParameter : dsParameters) {
dsParameterAttributes = sParameter.split(VALUE_SEPARATOR);
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);
System.out.println(dsParameterAttributes[0] + dsParameterAttributes[1] + dsParameterAttributes[2]);
}
}
return mParameters;
@@ -2794,51 +2674,4 @@ public static Collection listFiles(File directory, boolean recurse){
SwingUtils.showMessage(this, "loadListFilter()", ex.toString());
}
}
/**
* for putting an icon and text to a table header
*/
public class iconRenderer extends DefaultTableCellRenderer{
public Component getTableCellRendererComponent(javax.swing.JTable table,
Object obj,boolean isSelected, boolean hasFocus, int row,
int column) {
txtIcon i = (txtIcon)obj;
if (obj == i) {
setIcon(i.imageIcon);
setText(i.txt);
}
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
setHorizontalAlignment(javax.swing.JLabel.CENTER);
return this;
}
}
/**
* for putting an icon and text to a table header
*/
public class txtIcon {
String txt;
ImageIcon imageIcon;
txtIcon(String text, ImageIcon icon) {
txt = text;
imageIcon = icon;
}
}
/**
* put an icon and text to a table header
*
* @param table the table where the header is
* @param col_index column index of the table header where to put the icon
* @param icon the icon to put to the header
* @param name the text to put to the header
*/
public void setIcon(javax.swing.JTable table, int col_index, ImageIcon icon,String name){
table.getTableHeader().getColumnModel().getColumn(col_index).setHeaderRenderer(new iconRenderer());
table.getColumnModel().getColumn(col_index).setHeaderValue(new txtIcon(name, icon));
table.updateUI();
}
}

View File

@@ -20,28 +20,24 @@
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel5" alignment="0" max="-2" attributes="0"/>
<Component id="jLabel8" alignment="0" max="-2" attributes="0"/>
<Component id="jLabel6" alignment="0" max="-2" attributes="0"/>
<Component id="jLabel9" alignment="0" max="-2" attributes="0"/>
<Component id="jLabelDeviceName" alignment="0" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel5" alignment="0" max="-2" attributes="0"/>
<Component id="jLabel8" alignment="0" max="-2" attributes="0"/>
<Component id="jLabel6" alignment="0" max="-2" attributes="0"/>
<Component id="jLabel9" alignment="0" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="0" max="-2" attributes="0"/>
<Component id="jLabel10" alignment="0" max="-2" attributes="0"/>
</Group>
<Component id="jLabel4" alignment="0" max="-2" attributes="0"/>
</Group>
<Component id="jLabel2" alignment="0" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel7" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Component id="jLabel7" alignment="0" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="txtDeviceName" alignment="0" max="32767" attributes="0"/>
<Component id="txtDeviceDescription" alignment="0" max="32767" attributes="0"/>
@@ -49,14 +45,14 @@
<Component id="jScrollPaneRes" alignment="0" max="32767" attributes="0"/>
<Component id="jScrollPaneParam" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Component id="txtTestResultSummary" pref="440" max="32767" attributes="0"/>
<Component id="txtTestResultSummary" min="-2" pref="440" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jButtonMoreResult" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="txtTestSuite" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Component id="txtTestName" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="txtTestName" min="-2" pref="441" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jButtonMoreTest" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
@@ -80,13 +76,13 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtTestName" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="txtTestName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButtonMoreTest" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtTestSuite" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="txtTestSuite" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
@@ -100,7 +96,7 @@
<Component id="jButtonMoreResult" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="txtTestResultSummary" alignment="1" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="txtTestResultSummary" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
@@ -109,12 +105,12 @@
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabelDeviceName" min="-2" max="-2" attributes="0"/>
<Component id="txtDeviceName" alignment="0" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Component id="txtDeviceName" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtDeviceDescription" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="txtDeviceDescription" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
@@ -122,6 +118,8 @@
<Component id="jScrollPaneParam" pref="0" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel10" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
@@ -139,7 +137,7 @@
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabelDeviceName">
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="14" style="0"/>
@@ -147,7 +145,7 @@
<Property name="text" type="java.lang.String" value="Device name"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="jLabelDeviceName.setVisible(true);"/>
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="jLabel1.setVisible(false);"/>
</AuxValues>
</Component>
<Component class="javax.swing.JTextField" name="txtDeviceName">
@@ -157,15 +155,9 @@
<Font name="Tahoma" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="jTextField1"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[6, 26]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[72, 26]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="txtDeviceName.setVisible(true);"/>
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="txtDeviceName.setVisible(false);"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
@@ -229,12 +221,6 @@
<Font name="Tahoma" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="jTextField2"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[6, 26]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[72, 26]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
@@ -271,12 +257,12 @@
</Property>
<Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
<TableColumnModel selectionModel="0">
<Column maxWidth="150" minWidth="150" prefWidth="120" resizable="true">
<Column maxWidth="150" minWidth="150" prefWidth="150" resizable="true">
<Title/>
<Editor/>
<Renderer/>
</Column>
<Column maxWidth="200" minWidth="-1" prefWidth="120" resizable="true">
<Column maxWidth="100" minWidth="-1" prefWidth="80" resizable="true">
<Title/>
<Editor/>
<Renderer/>
@@ -379,7 +365,6 @@
</Property>
<Property name="lineWrap" type="boolean" value="true"/>
<Property name="rows" type="int" value="5"/>
<Property name="wrapStyleWord" type="boolean" value="true"/>
</Properties>
</Component>
</SubComponents>
@@ -426,12 +411,6 @@
<Font name="Tahoma" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="jTextField1"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[6, 26]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[72, 26]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jButtonMoreResult">
@@ -461,6 +440,14 @@
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="jLabel9.setVisible(false);"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="jLabel10">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="(Value valid for all devices)"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jButtonOk1">
<Properties>
<Property name="text" type="java.lang.String" value="Save for this device"/>

View File

@@ -4,15 +4,25 @@
import ch.psi.utils.swing.SwingUtils;
import java.awt.Desktop;
import java.awt.event.KeyEvent;
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;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.table.DefaultTableModel;
@@ -45,15 +55,7 @@ public class TestingListDetails extends javax.swing.JPanel {
public static String TESTS_CONFIG_FILENAME = ".config";
public static Path TESTS_TESTS_DEFAULT_DIR = Paths.get(".", "home", "script", "tests", "tests");
public static Path TESTS_DEVICES_DEFAULT_DIR = Paths.get(".", "home", "script", "tests", "devices");
public static String VALUE_SEPARATOR = "&";
public static String PARAM_SEPARATOR = ";";
private String testName;
private String testDescription;
private String testPath;
private String deviceName;
private String deviceDescription;
private String devicePath;
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
@@ -63,7 +65,7 @@ public class TestingListDetails extends javax.swing.JPanel {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabelDeviceName = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
txtDeviceName = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
txtDeviceDescription = new javax.swing.JTextField();
@@ -87,18 +89,17 @@ public class TestingListDetails extends javax.swing.JPanel {
jButtonMoreResult = new javax.swing.JButton();
jButtonMoreTest = new javax.swing.JButton();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jButtonOk1 = new javax.swing.JButton();
jLabelDeviceName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabelDeviceName.setText("Device name");
jLabelDeviceName.setVisible(true);
jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel1.setText("Device name");
jLabel1.setVisible(false);
txtDeviceName.setEditable(false);
txtDeviceName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
txtDeviceName.setText("jTextField1");
txtDeviceName.setMinimumSize(new java.awt.Dimension(6, 26));
txtDeviceName.setPreferredSize(new java.awt.Dimension(72, 26));
txtDeviceName.setVisible(true);
txtDeviceName.setVisible(false);
jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel2.setText("Device Description");
@@ -124,8 +125,6 @@ public class TestingListDetails extends javax.swing.JPanel {
txtTestName.setEditable(false);
txtTestName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
txtTestName.setText("jTextField2");
txtTestName.setMinimumSize(new java.awt.Dimension(6, 26));
txtTestName.setPreferredSize(new java.awt.Dimension(72, 26));
jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel6.setText("Last Test Result");
@@ -155,10 +154,10 @@ public class TestingListDetails extends javax.swing.JPanel {
jScrollPaneParam.setViewportView(jTableParams);
if (jTableParams.getColumnModel().getColumnCount() > 0) {
jTableParams.getColumnModel().getColumn(0).setMinWidth(150);
jTableParams.getColumnModel().getColumn(0).setPreferredWidth(120);
jTableParams.getColumnModel().getColumn(0).setPreferredWidth(150);
jTableParams.getColumnModel().getColumn(0).setMaxWidth(150);
jTableParams.getColumnModel().getColumn(1).setPreferredWidth(120);
jTableParams.getColumnModel().getColumn(1).setMaxWidth(200);
jTableParams.getColumnModel().getColumn(1).setPreferredWidth(80);
jTableParams.getColumnModel().getColumn(1).setMaxWidth(100);
}
jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
@@ -190,7 +189,6 @@ public class TestingListDetails extends javax.swing.JPanel {
txtTestDescription.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
txtTestDescription.setLineWrap(true);
txtTestDescription.setRows(5);
txtTestDescription.setWrapStyleWord(true);
jScrollPaneTestDesc.setViewportView(txtTestDescription);
jEditorPaneHelp.setContentType("text/html"); // NOI18N
@@ -211,8 +209,6 @@ public class TestingListDetails extends javax.swing.JPanel {
txtTestResultSummary.setEditable(false);
txtTestResultSummary.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
txtTestResultSummary.setText("jTextField1");
txtTestResultSummary.setMinimumSize(new java.awt.Dimension(6, 26));
txtTestResultSummary.setPreferredSize(new java.awt.Dimension(72, 26));
jButtonMoreResult.setText("More");
jButtonMoreResult.addActionListener(new java.awt.event.ActionListener() {
@@ -232,6 +228,9 @@ public class TestingListDetails extends javax.swing.JPanel {
jLabel9.setText("Last Result Details");
jLabel9.setVisible(false);
jLabel10.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel10.setText("(Value valid for all devices)");
jButtonOk1.setText("Save for this device");
jButtonOk1.setToolTipText("Save parameters values for this specific device");
jButtonOk1.addActionListener(new java.awt.event.ActionListener() {
@@ -248,36 +247,34 @@ public class TestingListDetails extends javax.swing.JPanel {
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(jLabel8)
.addComponent(jLabel6)
.addComponent(jLabel9)
.addComponent(jLabelDeviceName))
.addGap(18, 18, 18))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(jLabel8)
.addComponent(jLabel6)
.addComponent(jLabel9)
.addComponent(jLabel1)
.addComponent(jLabel10))
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING))
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtDeviceName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtDeviceName)
.addComponent(txtDeviceDescription)
.addComponent(jScrollPaneTestDesc)
.addComponent(jScrollPaneRes, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPaneParam, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(txtTestResultSummary, javax.swing.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)
.addComponent(txtTestResultSummary, javax.swing.GroupLayout.PREFERRED_SIZE, 440, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButtonMoreResult))
.addComponent(txtTestSuite)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(txtTestName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createSequentialGroup()
.addComponent(txtTestName, javax.swing.GroupLayout.PREFERRED_SIZE, 441, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButtonMoreTest))))
.addGroup(layout.createSequentialGroup()
.addComponent(jButtonOk1)
@@ -294,12 +291,12 @@ public class TestingListDetails extends javax.swing.JPanel {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtTestName, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtTestName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButtonMoreTest)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtTestSuite, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtTestSuite, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -310,24 +307,26 @@ public class TestingListDetails extends javax.swing.JPanel {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonMoreResult)
.addComponent(jLabel6))
.addComponent(txtTestResultSummary, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(txtTestResultSummary, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel9)
.addComponent(jScrollPaneRes, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabelDeviceName)
.addComponent(txtDeviceName, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel1)
.addComponent(txtDeviceName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtDeviceDescription, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtDeviceDescription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPaneParam, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel10)
.addGap(0, 0, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
@@ -338,41 +337,21 @@ public class TestingListDetails extends javax.swing.JPanel {
);
}// </editor-fold>//GEN-END:initComponents
private class Details{
private HashMap hDetails;
public Details(HashMap details) {
hDetails = details;
}
public String get(String detailName){
return hDetails.get(detailName).toString().replace("\"", "");
}
}
private void fillComponents(HashMap hDetails) {
Details details = new Details(hDetails);
testName = details.get("testName");
testDescription = details.get("testDescription");
testPath = details.get("testPath");
deviceName = details.get("deviceName");
deviceDescription = details.get("deviceDescription");
devicePath = details.get("devicePath");
//add values to each text box
this.txtDeviceName.setText(deviceName);
this.txtDeviceDescription.setText(deviceDescription);
this.txtTestDescription.setText(testDescription);
this.txtTestName.setText(testName);
this.txtTestSuite.setText(details.get("testSuite"));
this.txtTestResult.setText(details.get("time") + "\n" +
details.get("deviceName") + " - " +
details.get("testName") + "\n" +
details.get("testResult"));
this.txtTestResultSummary.setText( details.get("testResult"));
this.txtDeviceName.setText(hDetails.get("deviceName").toString());
this.txtDeviceDescription.setText(hDetails.get("deviceDescription").toString());
this.txtTestDescription.setText(hDetails.get("testDescription").toString());
this.txtTestSuite.setText(hDetails.get("testSuite").toString());
this.txtTestName.setText(hDetails.get("testName").toString());
this.txtTestResult.setText(hDetails.get("time").toString() + "\n" +
hDetails.get("deviceName").toString() + " - " +
hDetails.get("testName").toString() + "\n" +
hDetails.get("testResult").toString());
this.txtTestResultSummary.setText( hDetails.get("testResult").toString());
this.txtTestResultSummary.setCaretPosition(0);
System.out.println("detail testPath: "+testPath);
System.out.println("detail devicePath: "+devicePath);
//help text
showHelp(details.get("testPath"), details.get("testHelp"));
showHelp(String.valueOf(hDetails.get("testPath")), String.valueOf(hDetails.get("testHelp")));
//parameters table
HashMap hParams = (HashMap) hDetails.get("parameters");
String name="", value="", description="";
@@ -382,9 +361,9 @@ public class TestingListDetails extends javax.swing.JPanel {
Object param = entry;
if(param instanceof String){
name = (String) param;
Details attributes = new Details((HashMap) hParams.get(param));
value = attributes.get("value");
description = attributes.get("description");
HashMap attributes = (HashMap) hParams.get(param);
value = (String) attributes.get("value");
description = (String) attributes.get("description");
model.addRow(new Object[]{name, value, description});
}
jTableParams.setModel(model);
@@ -432,13 +411,40 @@ 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<jTableParams.getRowCount() ; row++){
String sParam = jTableParams.getValueAt(row, 0).toString();
String sVal = "\"" + jTableParams.getValueAt(row, 1).toString().replace("\"", "").replace("&","").replace(";","") + "\"";
String sDescr = "\"" +jTableParams.getValueAt(row, 2).toString() + "\"";
String sVal = jTableParams.getValueAt(row, 1).toString();
String sDescr = jTableParams.getValueAt(row, 2).toString();
mParameterAttributes = new HashMap();
mParameterAttributes.put("value", (Object) sVal);
mParameterAttributes.put("description", sDescr);
@@ -456,7 +462,7 @@ public class TestingListDetails extends javax.swing.JPanel {
boolean success = false;
try {
Path path = Paths.get(testDir + FilenameUtils.separatorsToSystem("/"+TESTS_CONFIG_FILENAME));
System.out.println("Test path: "+path);
File configFile = path.toFile();
//Loop among the test parameters and generate variable assignement syntax for python
String sTestParameters = "";
String name="", value="", description="";
@@ -464,12 +470,11 @@ public class TestingListDetails extends javax.swing.JPanel {
Object param = entry;
if(param instanceof String){
name = (String) param;
Details attributes = new Details((HashMap) hmTestParams.get(param));
value = "\""+attributes.get("value")+"\"";
description = "\""+attributes.get("description")+"\"";
HashMap attributes = (HashMap) hmTestParams.get(param);
value = (String) attributes.get("value");
description = (String) attributes.get("description");
//build the python code for getting the test parameter
sTestParameters = sTestParameters + name + VALUE_SEPARATOR + value + VALUE_SEPARATOR + description + PARAM_SEPARATOR ;
//System.out.println("sTestParameters: "+sTestParameters);
sTestParameters = sTestParameters + name + ":" + value + ":" + description + ";" ;
}
}
FileInputStream in = new FileInputStream(path.toFile());
@@ -511,8 +516,8 @@ public class TestingListDetails extends javax.swing.JPanel {
private void jButtonMoreTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMoreTestActionPerformed
if(this.jButtonMoreTest.getText()=="More"){
//this.txtDeviceName.setVisible(true);
//this.jLabelDeviceName.setVisible(true);
this.txtDeviceName.setVisible(true);
this.jLabel1.setVisible(true);
this.jLabel2.setVisible(true);
this.txtDeviceDescription.setVisible(true);
this.jButtonMoreTest.setText("Less");
@@ -521,8 +526,8 @@ public class TestingListDetails extends javax.swing.JPanel {
this.txtTestSuite.setVisible(true);
this.jLabel8.setVisible(true);
}else{
//this.txtDeviceName.setVisible(false);
//this.jLabelDeviceName.setVisible(false);
this.txtDeviceName.setVisible(false);
this.jLabel1.setVisible(false);
this.jLabel2.setVisible(false);
this.txtDeviceDescription.setVisible(false);
this.jScrollPaneTestDesc.setVisible(false);
@@ -545,6 +550,8 @@ public class TestingListDetails extends javax.swing.JPanel {
private javax.swing.JButton jButtonOk;
private javax.swing.JButton jButtonOk1;
private javax.swing.JEditorPane jEditorPaneHelp;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
@@ -552,7 +559,6 @@ public class TestingListDetails extends javax.swing.JPanel {
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JLabel jLabelDeviceName;
private javax.swing.JScrollPane jScrollPaneHtml;
private javax.swing.JScrollPane jScrollPaneParam;
private javax.swing.JScrollPane jScrollPaneRes;

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,4 @@
#Tue Mar 20 13:40:52 CET 2018
name=new bx84 2
parameters=
description=bla

View File

@@ -0,0 +1,15 @@
<html>
<!-- Copyright (c) 2015 Paul Scherrer Institute. All rights reserved. -->
<body>
<h2>Description</h2>
bla
<h2>Parameters</h2>
<table>
</table>
<h2>Contact</h2>
<a href="https://intranet.psi.ch/search/#?t=phonebook&q=boccioli_m">Marco Boccioli</a> <br/>
Tel. 3078
</html>
</body>

View File

@@ -0,0 +1,174 @@
# Test name: new bx84 2
# bla
# Copyright (c) 2015 Paul Scherrer Institute. All rights reserved.
###### Init - DO NOT MODIFY THE CODE BELOW ######
global sys, inspect, os, traceback
import sys, inspect, os, traceback
def startTest(testName, DEVICE, params):
"""
Main method running the test
"""
# by default, assume the test failed:
ret = 'Test failed'
status = False
# put the whole custom code under try/catch.
try:
# get the path of this script:
testPath = inspect.getfile(inspect.currentframe())
# init the testing tool class:
test = TestingTool(testName, testPath, DEVICE, params)
################ END OF Init #####################
######### WRITE YOUR CODE HERE BELOW #############
"""
All the code in this section # WRITE YOUR CODE HERE BELOW # is just an example and can be modified/deleted.
It must be indented to the same level as this comment.
-----------------------------------
GETTING INPUTS:
-----------------------------------
If needed, the following methods are available:
test.getPath() string, path of this test file
test.getName() string, name of this test
test.getDeviceName() string, device for which the test must run (typically it is the beginning of a process variable name)
test.getPlotName() string, name to be given to the plot when using setPlotTitle(). Example: scan.setPlotTitle(test.getPlotName())
-----------------------------------
GETTING TEST PARAMETERS:
-----------------------------------
if you need to get parameters for the test, use:
myParamValue = test.getParam('myParamName')
the calls to getParam are added to the code automatically, one per parameter, when creating the new test.
NOTE: Casting may be necessary.
See the test config for the list of parameters specific to the test.
-----------------------------------
SETTING OUTPUTS:
-----------------------------------
When the test has ended (error or success), this method must be called in order to return to pshell:
test.sendFeedback(ret,success)
ret string, a text summarizing the result of the test.
success bool, True = test successful. False = test failed.
-----------------------------------
LOG INFO:
-----------------------------------
when some information must be shown on the log on pshell, use the following line:
test.log('text to log')
"""
########## Example (can be removed) ######
# print the list of parameters passed. If any error, stop and send feedback.
test.log("Example - Test name: " + test.getName())
test.log("Example - Device name: " + test.getDeviceName() )
try:
test.log("Running test with the following parameters:")
test.printParams()
# If present, use the parameters here below for your test script.
# These parameters were automatically generated: you might need to change the casting.
except:
import traceback
# test failed, write the report into the variables ret and success and send feedback:
ret = 'Could not retrieve testing parameters - ' + traceback.format_exc()
success = False
test.sendFeedback(ret, success)
return
# loop to read channels for a while and plot the channels values.
# initialise plot tab with 2 plots: pass here the axis names:
scan = ManualScan(['sample'], ['Status (MSTA)', 'Position (VAL)'])
# set plot name(tab title):
scan.setPlotTitle(test.getPlotName())
# start plots. See further below how to add points to the plots (scan):
scan.start()
# inject a sinus into the plot, as example
from math import sin
motor_msta = 0
# take 100 samples of a sinus and a jigsaw plot them:
for sample in range(0, 100):
readback1 = sample #the x axis.
sleep(0.1) # settling time.
# get value (it is translated to a caget):
motor_msta = motor_msta + +1
if motor_msta > 50:
motor_msta = 0
# get value:
motor_val = sin(float(sample)/10.0)*10.0-10.0
# add values to plot:
scan.append([readback1], [readback1], [motor_msta, motor_val])
# now try with data from real device: this part will most probably fail: correct the PV names with existing ones.
try:
# set up connection to channels. "type" of data can be "d" (= double), "l" (= long).
pv_motor_msta = Channel(test.getDeviceName() + ':IST:2' , type='d')
pv_motor_val = Channel(test.getDeviceName() + ':IST:1' , type='d')
pv_motor_com = Channel(test.getDeviceName() + ':COM:2' , type='d')
except:
import traceback
# prepare return information: return text:
ret = 'Unable to create channel - ' + traceback.format_exc()
# prepare return information: return success:
success = False
# send return information:
test.sendFeedback(ret, success)
return
# send a command to a channel (it is translated to a caput): uncomment this line below to try it
#pv_motor_com.put(1.0, timeout=None) # optionally, a timeout can be given.
# take 100 samples of the channels and plot them:
for sample in range(0, 100):
readback1 = sample #the x axis.
sleep(0.1) # settling time.
# get value (it is translated to a caget):
motor_msta = pv_motor_msta.get()
# get value:
motor_val = pv_motor_val.get()
# add values to plot:
scan.append([readback1], [readback1], [motor_msta, motor_val])
# Closing channels: all channels that were opened with Channel() must be closed before exit:
pv_motor_msta.close()
pv_motor_val.close()
pv_motor_com.close()
# IMPORTANT: if the test was successful, write the report into the variables ret and success.
# for example, write the following:
ret = "Example - Test successful, here some detail: ..."
success = True
test.sendFeedback(ret, success)
# once the test is finished, no need to do anything. The code below yours will do the rest.
################ End of Example ##########
################ END OF YOUR CODE ################
###### Final - DO NOT MODIFY THE CODE BELOW ######
# just in case the feedback was forgotten.
test.sendFeedback(ret, success)
except (KeyboardInterrupt):
# user stop error handler.
import traceback
ret = 'Test stopped by user.'
success = False
test.sendFeedback(ret, success)
except:
# generic error handler.
import traceback
ret = traceback.format_exc()
success = False
test.sendFeedback(ret, success)
# launch the test.
startTest(test, device, parameters)
################ END OF Final ####################
#### IF NEEDED, ADD YOUR FUNCTIONS HERE BELOW ####
# Indent to end left
# def yourCustomFunction: