Closedown

This commit is contained in:
boccioli_m
2015-06-23 10:12:00 +02:00
parent 8e721a0625
commit 67aef3a39c
7 changed files with 624 additions and 776 deletions

View File

@@ -2,14 +2,10 @@
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
*/
import ch.psi.pshell.core.Controller;
import ch.psi.utils.swing.MonitoredPanel;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.swing.SwingUtils;
import ch.psi.wsaf.ApplicationStateException;
import ch.psi.wsaf.Task;
import ch.psi.wsaf.TaskRunningException;
import java.awt.Desktop;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@@ -27,10 +23,9 @@ import java.io.InputStream;
import java.util.Properties;
import java.util.logging.FileHandler;
import java.util.logging.SimpleFormatter;
import javafx.scene.control.SelectionMode;
import javax.script.ScriptException;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.SwingUtilities;
import javax.swing.JFrame;
import org.apache.commons.io.FilenameUtils;
public class TestingList extends Panel {
@@ -49,6 +44,12 @@ public class TestingList extends Panel {
protected JPanel create() {
try {
testingList = new NetbeansPluginPanel();
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.getContentPane().add(new TestingListDetails());
frame.pack();
frame.setVisible(true);
} catch (IOException ex) {
Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex);
}
@@ -289,9 +290,6 @@ public class TestingList extends Panel {
public void keyReleased(java.awt.event.KeyEvent evt) {
jTable1KeyReleased(evt);
}
public void keyTyped(java.awt.event.KeyEvent evt) {
jTable1KeyTyped(evt);
}
});
jScrollPane2.setViewportView(jTable1);
@@ -366,6 +364,8 @@ public class TestingList extends Panel {
add(jPanel1, java.awt.BorderLayout.NORTH);
}// </editor-fold>//GEN-END:initComponents
private void jButtonRunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRunActionPerformed
if(this.jButtonRun.getToolTipText().equals("Run selected tests")){
setButtonToStart();
@@ -383,7 +383,7 @@ public class TestingList extends Panel {
this.jTable1.setEnabled(true);
}
private void setButtonToStart(){
private void setButtonToStart(){
this.jButtonRun.setToolTipText("Stop tests");
jButtonRun.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/button_stop-64px.png")));
this.jTable1.clearSelection();
@@ -412,22 +412,22 @@ public class TestingList extends Panel {
}//GEN-LAST:event_jCheckBox1ActionPerformed
private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
switch (evt.getClickCount()){
case 1:
int colIndex = jTable1.getSelectedColumn();
if (colIndex == COL.CHECK.ordinal()) updateStatus();
break;
case 2:
SwingUtils.showMessage(this, "jBu","bo");
TestingListDetails detailsPanel = new TestingListDetails();
//detailsPanel.setVisible(true);
//add(detailsPanel);
break;
}
}//GEN-LAST:event_jTable1MouseClicked
try{
switch (evt.getClickCount()){
case 1:
int colIndex = jTable1.getSelectedColumn();
if (colIndex == COL.CHECK.ordinal()) updateStatus();
break;
case 2:
openDetails();
SwingUtils.showMessage(this, "jBu","bo");
break;
}
} catch (Exception ex){
SwingUtils.showException(this, ex);
}
private void jTable1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTable1KeyTyped
}//GEN-LAST:event_jTable1KeyTyped
}//GEN-LAST:event_jTable1MouseClicked
//oopen the log file using one of th default OS text reades
private void jButtonOpenLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOpenLogActionPerformed
@@ -458,6 +458,7 @@ public class TestingList extends Panel {
moveUp();
}//GEN-LAST:event_jButtonMoveUpActionPerformed
//<editor-fold defaultstate="collapsed" desc="Witget Variables declaration">
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButtonMoveDown;
private javax.swing.JButton jButtonMoveUp;
@@ -469,26 +470,71 @@ public class TestingList extends Panel {
private javax.swing.JScrollPane jScrollPane2;
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
public boolean isTestRunAllowed(){
return this.jButtonRun.getToolTipText().equals("Stop tests");
}
//move selection up in table
private void moveUp(){
DefaultTableModel model = (DefaultTableModel)jTable1.getModel();
int[] rows = jTable1.getSelectedRows();
model.moveRow(rows[0],rows[rows.length-1],rows[0]-1);
jTable1.setRowSelectionInterval(rows[0]-1, rows[rows.length-1]-1);
}
//move selection down in table
private void moveDown(){
DefaultTableModel model = (DefaultTableModel)jTable1.getModel();
int[] rows = jTable1.getSelectedRows();
model.moveRow(rows[0],rows[rows.length-1],rows[0]+1);
jTable1.setRowSelectionInterval(rows[0]+1, rows[rows.length-1]+1);
}
}
//open details of the selected test in a new panel
private void openDetails() throws ClassNotFoundException, InstantiationException, IllegalAccessException{
String sDeviceName;
String sTestName;
String sTestCaseName;
String sDeviceDescription;
String sLastResult;
String 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();
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())));
//create map to pass to details panel
HashMap details = new HashMap();
details.put("deviceName", sDeviceName);
details.put("deviceDescription", sDeviceDescription);
details.put("testSuite", sTestCaseName);
details.put("testName", sTestName);
details.put("testResult", sLastResult);
details.put("time", sResultTime);
details.put("parameters", mParameters);
//open details panel
JDialog dlg = new JDialog(getView(), true);
//dlg.setLayout(new BorderLayout());
//TestingListDetails detailsPanel = new TestingListDetails();
Class TestingListDetailsClass = getController().getClassByName("TestingListDetails");
TestingListDetails detailsPanel = (TestingListDetails) TestingListDetailsClass.newInstance();
dlg.getContentPane().add(detailsPanel);
//dlg.add(new TestingListDetails());
dlg.pack();
dlg.setVisible(true);
}
//show test result in table
public int showResult(String deviceName, String testName, String res, String status) {
int rowD = -1;
@@ -628,7 +674,6 @@ public class TestingList extends Panel {
}
showResult(sDeviceName, sTestPath, "Test running", TestStatus.RUNNING.toString());
//launch the test
args.put("DEVICE", sDeviceName);
args.put("ret", "");
args.put("status", false);
@@ -742,7 +787,7 @@ public class TestingList extends Panel {
logger.log(Level.INFO, iCounter + " tests loaded.");
}
private HashMap buildParametersMap(String parametersString){
//<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:
@@ -760,6 +805,8 @@ public class TestingList extends Panel {
...
the name 'name' is the mapping key. 'value' and 'description' are constant mapping keys of a nested map.
*/
//</editor-fold>
private HashMap buildParametersMap(String parametersString){
HashMap mParameters = new HashMap(); // contains name and attributes
HashMap mParameterAttributes = new HashMap(); //contians value and description
String[] dsParameterAttributes = null;