import java.util.HashMap; 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) { // 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); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.getContentPane().add(new TestingListDetails(details)); frame.pack(); frame.setVisible(true); } 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; } }