89 lines
3.5 KiB
Java
89 lines
3.5 KiB
Java
|
|
import java.io.IOException;
|
|
import java.util.HashMap;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
import javax.swing.JFrame;
|
|
|
|
/*
|
|
* To change this license header, choose License Headers in Project Properties.
|
|
* To change this template file, choose Tools | Templates
|
|
* and open the template in the editor.
|
|
*/
|
|
|
|
/**
|
|
*
|
|
* @author boccioli_m
|
|
*/
|
|
public class TestMain {
|
|
|
|
/**
|
|
* @param args the command line arguments
|
|
*/
|
|
public static void main(String[] args) {
|
|
try {
|
|
// TODO code application logic here
|
|
HashMap details = new HashMap();
|
|
details.put("deviceName", "Device name");
|
|
details.put("deviceDescription", "Device des");
|
|
details.put("testSuite", "test suite");
|
|
details.put("testName", "test name");
|
|
details.put("testResult", "Device res");
|
|
details.put("time", "time");
|
|
HashMap params = new HashMap();
|
|
params = aBuildParametersMap("repeatTimes:3:Repeat times;midPoint:41.0:Middle point;spanFromMidPoint:11.0:Span around middle point");
|
|
details.put("parameters", params);
|
|
details.put("testDescription", "TestDescription");
|
|
details.put("testPath", "C:\\Users\\boccioli_m\\Documents\\pshell\\home\\script\\tests\\tests\\Collimator Tests\\Calibrate\\Calibrate.py");
|
|
details.put("testHelp", "<html>this is a <b>help</b><code> directly from config file</code></html>");
|
|
// details.put("testHelpUrl", "file:\\\\C:\\Users\\boccioli_m\\Documents\\pshell\\home\\script\\tests\\tests\\Collimator Tests\\Calibrate\\help.html");
|
|
// details.put("testHelpUrl", "http://www.google.com");
|
|
System.out.print(new java.io.File(".").getCanonicalPath());
|
|
|
|
JFrame frame = new JFrame();
|
|
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
|
frame.getContentPane().add(new TestingListDetails(details));
|
|
frame.pack();
|
|
frame.setVisible(true);
|
|
} catch (IOException ex) {
|
|
Logger.getLogger(TestMain.class.getName()).log(Level.SEVERE, null, ex);
|
|
}
|
|
}
|
|
|
|
|
|
public static HashMap aBuildParametersMap(String parametersString){
|
|
/*
|
|
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.
|
|
*/
|
|
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;
|
|
}
|
|
}
|