Startup
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
|
||||
* Copyright (c) 2015 Paul Scherrer Institute. All rights reserved.
|
||||
*/
|
||||
|
||||
import ch.psi.utils.swing.MonitoredPanel;
|
||||
@@ -28,6 +28,10 @@ import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author boccioli_m
|
||||
*/
|
||||
public class TestingList extends Panel {
|
||||
|
||||
NetbeansPluginPanel testingList;
|
||||
@@ -39,6 +43,10 @@ public class TestingList extends Panel {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected JPanel create() {
|
||||
try {
|
||||
@@ -50,8 +58,13 @@ public class TestingList extends Panel {
|
||||
return testingList;
|
||||
}
|
||||
|
||||
//listen to script end of execution and get return value
|
||||
@Override
|
||||
/**
|
||||
* listen to script end of execution and get return value
|
||||
* @param fileName
|
||||
* @param result
|
||||
* @param exception
|
||||
*/
|
||||
@Override
|
||||
protected void onExecutedFile(String fileName, Object result, Throwable exception) {
|
||||
int iCurrentTestPos = 0;
|
||||
try {
|
||||
@@ -106,9 +119,10 @@ public class TestingList extends Panel {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//table column indexes
|
||||
public enum COL {
|
||||
/**
|
||||
*enumeration of table column indexes
|
||||
*/
|
||||
public enum COL {
|
||||
CHECK (0),
|
||||
TIME (1),
|
||||
DEVICENAME (2),
|
||||
@@ -118,30 +132,39 @@ public class TestingList extends Panel {
|
||||
TESTPATH (6),
|
||||
TESTPARAMS (7),
|
||||
TESTDESCR (8),
|
||||
RESULT (9),
|
||||
STATUS (10),
|
||||
ICON (11);
|
||||
TESTHELP (9),
|
||||
RESULT (10),
|
||||
STATUS (11),
|
||||
ICON (12);
|
||||
private int value;
|
||||
|
||||
private COL(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int index(){
|
||||
return (int) value;
|
||||
}
|
||||
};
|
||||
|
||||
//enumeration of possible test statuses: text and related icon
|
||||
public enum TestStatus {
|
||||
/**
|
||||
*enumeration of possible test statuses: text and related icon
|
||||
*/
|
||||
public enum TestStatus {
|
||||
SUCCESS,
|
||||
FAILURE,
|
||||
PENDING,
|
||||
DISABLED,
|
||||
RUNNING;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String IconFilename(){
|
||||
String iconFileName = "";
|
||||
switch (this){
|
||||
@@ -187,6 +210,10 @@ public class TestingList extends Panel {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ImageIcon Icon(){
|
||||
String iconFileName = this.IconFilename();
|
||||
ImageIcon icon = null;
|
||||
@@ -196,7 +223,10 @@ public class TestingList extends Panel {
|
||||
}
|
||||
};
|
||||
|
||||
public class NetbeansPluginPanel extends MonitoredPanel {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class NetbeansPluginPanel extends MonitoredPanel {
|
||||
Logger logger = Logger.getLogger("TestsLog");
|
||||
//these paths are converted to unix or win path according to host OS
|
||||
private final String TESTS_DEVICES_DEFAULT_DIR = new java.io.File(".").getCanonicalPath()
|
||||
@@ -223,6 +253,10 @@ public class TestingList extends Panel {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public NetbeansPluginPanel() throws IOException {
|
||||
initComponents();
|
||||
initLogger();
|
||||
@@ -253,14 +287,14 @@ public class TestingList extends Panel {
|
||||
|
||||
},
|
||||
new String [] {
|
||||
"Select", "Time", "Device Name", "Device Description", "Test Suite", "Test Name", "Test Peth", "Test Parameters", "Test Description", "Last Test Result", "Status", ""
|
||||
"Select", "Time", "Device Name", "Device Description", "Test Suite", "Test Name", "Test Peth", "Test Parameters", "Test Description", "Test Help", "Last Test Result", "Status", ""
|
||||
}
|
||||
) {
|
||||
Class[] types = new Class [] {
|
||||
java.lang.Boolean.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, javax.swing.Icon.class
|
||||
java.lang.Boolean.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, javax.swing.Icon.class
|
||||
};
|
||||
boolean[] canEdit = new boolean [] {
|
||||
true, false, false, false, false, false, false, false, false, false, false, false
|
||||
true, false, false, false, false, false, false, false, false, false, false, false, false
|
||||
};
|
||||
|
||||
public Class getColumnClass(int columnIndex) {
|
||||
@@ -462,8 +496,11 @@ public class TestingList extends Panel {
|
||||
private javax.swing.JTable jTable1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
//</editor-fold>
|
||||
|
||||
//return status of run button. True = tests launching sequence is running
|
||||
|
||||
/**
|
||||
*
|
||||
* @return status of run button. True = tests launching sequence is running
|
||||
*/
|
||||
public boolean isTestRunAllowed(){
|
||||
return this.jButtonRun.getToolTipText().equals("Stop tests");
|
||||
}
|
||||
@@ -486,18 +523,18 @@ public class TestingList extends Panel {
|
||||
|
||||
//open details of the selected test in a new panel
|
||||
private void openDetails() throws Exception{
|
||||
String sDeviceName, sTestName, sTestCaseName, sDeviceDescription, sTestDescription, sLastResult, sResultTime;
|
||||
HashMap mParameters = new HashMap();
|
||||
|
||||
//pick details from the clicked row
|
||||
int row = jTable1.getSelectedRow();
|
||||
sDeviceName = jTable1.getValueAt(row, COL.DEVICENAME.ordinal()).toString();
|
||||
sTestName = jTable1.getValueAt(row, COL.TESTNAME.ordinal()).toString();
|
||||
sTestCaseName = jTable1.getValueAt(row, COL.TESTSUITE.ordinal()).toString();
|
||||
sTestDescription = jTable1.getValueAt(row, COL.TESTDESCR.ordinal()).toString();
|
||||
sDeviceDescription = jTable1.getValueAt(row, COL.DEVICEDESCR.ordinal()).toString();
|
||||
sLastResult = jTable1.getValueAt(row, COL.RESULT.ordinal()).toString();
|
||||
sResultTime = jTable1.getValueAt(row, COL.TIME.ordinal()).toString();
|
||||
mParameters = buildParametersMap(String.valueOf(jTable1.getValueAt(row, COL.TESTPARAMS.ordinal())));
|
||||
String sDeviceName = jTable1.getValueAt(row, COL.DEVICENAME.ordinal()).toString();
|
||||
String sTestName = jTable1.getValueAt(row, COL.TESTNAME.ordinal()).toString();
|
||||
String sTestCaseName = jTable1.getValueAt(row, COL.TESTSUITE.ordinal()).toString();
|
||||
String sTestDescription = jTable1.getValueAt(row, COL.TESTDESCR.ordinal()).toString();
|
||||
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();
|
||||
String sTestHelp = String.valueOf(jTable1.getValueAt(row, COL.TESTHELP.ordinal()));
|
||||
HashMap mParameters = buildParametersMap(String.valueOf(jTable1.getValueAt(row, COL.TESTPARAMS.ordinal())));
|
||||
//create map for passing details to Details Panel
|
||||
HashMap details = new HashMap();
|
||||
details.put("deviceName", sDeviceName);
|
||||
@@ -508,6 +545,7 @@ public class TestingList extends Panel {
|
||||
details.put("testResult", sLastResult);
|
||||
details.put("time", sResultTime);
|
||||
details.put("parameters", mParameters);
|
||||
details.put("testHelp", sTestHelp);
|
||||
//open details panel
|
||||
JDialog dlg = new JDialog(getView(), "Test Details - " + sTestName , true);
|
||||
//create a class to visualise the details panel
|
||||
@@ -519,8 +557,15 @@ public class TestingList extends Panel {
|
||||
dlg.pack();
|
||||
dlg.setVisible(true);
|
||||
}
|
||||
|
||||
//show test result in table
|
||||
|
||||
/**
|
||||
*show test result in table
|
||||
* @param deviceName
|
||||
* @param testName
|
||||
* @param res
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
public int showResult(String deviceName, String testName, String res, String status) {
|
||||
int rowD = -1;
|
||||
String sTestName = testName;
|
||||
@@ -560,8 +605,11 @@ public class TestingList extends Panel {
|
||||
}
|
||||
return rowD;
|
||||
}
|
||||
|
||||
//find the test currently in progress
|
||||
|
||||
/**
|
||||
*find the test currently in progress
|
||||
* @return properties of the test in progress
|
||||
*/
|
||||
public String[] getTestInProgress() {
|
||||
String[] dsTestProperties = {"",""};
|
||||
//search for device name in table
|
||||
@@ -606,7 +654,9 @@ public class TestingList extends Panel {
|
||||
return sStatus;
|
||||
}
|
||||
|
||||
//visualise test status (columns status and icon)
|
||||
/**
|
||||
*visualise test status (columns status and icon)
|
||||
*/
|
||||
public void updateStatus() {
|
||||
String sStatus;
|
||||
boolean bSelected;
|
||||
@@ -683,7 +733,9 @@ public class TestingList extends Panel {
|
||||
}
|
||||
}
|
||||
|
||||
//table management
|
||||
/**
|
||||
*table management
|
||||
*/
|
||||
public void buildTable() {
|
||||
String sDate = getNow();
|
||||
DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
|
||||
@@ -710,7 +762,8 @@ public class TestingList extends Panel {
|
||||
String testSuite,
|
||||
String testName,
|
||||
String testParams,
|
||||
String testDescription) {
|
||||
String testDescription,
|
||||
String testHelp) {
|
||||
String sDate = "";
|
||||
if (testName.equals("") || deviceName.equals("")) {
|
||||
return;
|
||||
@@ -718,19 +771,26 @@ 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");
|
||||
model.addRow(new Object[]{false, sDate, deviceName, deviceDescription, testSuite, testName, testPath, testParams, testDescription, "", "Pending", icon});
|
||||
model.addRow(new Object[]{false, sDate, deviceName, deviceDescription, testSuite, testName, testPath, testParams, testDescription, testHelp, "", "Pending", icon});
|
||||
jTable1.setModel(model);
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
//formatted time
|
||||
/**
|
||||
*
|
||||
* @return formatted time
|
||||
*/
|
||||
public String getNow() {
|
||||
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||||
Date date = new Date();
|
||||
return dateFormat.format(date);
|
||||
}
|
||||
|
||||
//time without format
|
||||
|
||||
/**
|
||||
*
|
||||
* @return time with sortable format
|
||||
*/
|
||||
public String getnow() {
|
||||
DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
Date date = new Date();
|
||||
@@ -769,12 +829,13 @@ public class TestingList extends Panel {
|
||||
if (configFile.exists() && !configFile.isDirectory()) {
|
||||
InputStream ist = new FileInputStream(configFile);
|
||||
propTest.load(ist);
|
||||
addToTable(propDevice.getProperty("name"),
|
||||
propDevice.getProperty("description"),
|
||||
propDevice.getProperty("tests"),
|
||||
propTest.getProperty("name"),
|
||||
propTest.getProperty("parameters"),
|
||||
propTest.getProperty("description"));
|
||||
addToTable( propDevice.getProperty("name"),
|
||||
propDevice.getProperty("description"),
|
||||
propDevice.getProperty("tests"),
|
||||
propTest.getProperty("name"),
|
||||
propTest.getProperty("parameters"),
|
||||
propTest.getProperty("description"),
|
||||
propTest.getProperty("help"));
|
||||
iCounter++;
|
||||
}
|
||||
}
|
||||
@@ -786,25 +847,23 @@ public class TestingList extends Panel {
|
||||
logger.log(Level.INFO, iCounter + " tests loaded.");
|
||||
}
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Function Description">
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
//</editor-fold>
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
private HashMap buildParametersMap(String parametersString){
|
||||
HashMap mParameters = new HashMap(); // contains name and attributes
|
||||
HashMap mParameterAttributes = new HashMap(); //contians value and description
|
||||
@@ -823,6 +882,9 @@ public class TestingList extends Panel {
|
||||
return mParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void selectFile() {
|
||||
final JFileChooser fc = new JFileChooser();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user