diff --git a/plugins/TestMain.java b/plugins/TestMain.java
index 5afcae1..28e3813 100644
--- a/plugins/TestMain.java
+++ b/plugins/TestMain.java
@@ -1,5 +1,8 @@
+import java.io.IOException;
import java.util.HashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.swing.JFrame;
/*
@@ -18,7 +21,8 @@ public class TestMain {
* @param args the command line arguments
*/
public static void main(String[] args) {
- // TODO code application logic here
+ try {
+ // TODO code application logic here
HashMap details = new HashMap();
details.put("deviceName", "Device name");
details.put("deviceDescription", "Device des");
@@ -29,13 +33,21 @@ public class TestMain {
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", "this is a help directly from config file");
+// 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);
+ }
}
diff --git a/plugins/TestingList.form b/plugins/TestingList.form
index 66dc9e3..c19e604 100644
--- a/plugins/TestingList.form
+++ b/plugins/TestingList.form
@@ -196,6 +196,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/TestingList.java b/plugins/TestingList.java
index 87cbbd0..f942050 100644
--- a/plugins/TestingList.java
+++ b/plugins/TestingList.java
@@ -18,9 +18,14 @@ import javax.swing.JPanel;
import javax.swing.table.DefaultTableModel;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Iterator;
import java.util.Properties;
+import java.util.Vector;
import java.util.logging.FileHandler;
import java.util.logging.SimpleFormatter;
import javax.swing.JDialog;
@@ -278,6 +283,8 @@ public class TestingList extends Panel {
jCheckBox1 = new javax.swing.JCheckBox();
jButtonMoveDown = new javax.swing.JButton();
jButtonMoveUp = new javax.swing.JButton();
+ jButton1 = new javax.swing.JButton();
+ jButton2 = new javax.swing.JButton();
setLayout(new java.awt.BorderLayout());
@@ -387,6 +394,22 @@ public class TestingList extends Panel {
});
jPanel2.add(jButtonMoveUp, java.awt.BorderLayout.PAGE_START);
+ jButton1.setText("jButton1");
+ jButton1.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jButton1ActionPerformed(evt);
+ }
+ });
+ jPanel2.add(jButton1, java.awt.BorderLayout.CENTER);
+
+ jButton2.setText("jButton2");
+ jButton2.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jButton2ActionPerformed(evt);
+ }
+ });
+ jPanel2.add(jButton2, java.awt.BorderLayout.LINE_END);
+
jPanel1.add(jPanel2, java.awt.BorderLayout.LINE_START);
add(jPanel1, java.awt.BorderLayout.NORTH);
@@ -483,8 +506,20 @@ public class TestingList extends Panel {
moveUp();
}//GEN-LAST:event_jButtonMoveUpActionPerformed
+ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
+ // TODO add your handling code here:
+ this.saveSettings();
+ }//GEN-LAST:event_jButton1ActionPerformed
+
+ private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
+ // TODO add your handling code here:
+ this.loadSettings();
+ }//GEN-LAST:event_jButton2ActionPerformed
+
//
// Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton jButton1;
+ private javax.swing.JButton jButton2;
private javax.swing.JButton jButtonMoveDown;
private javax.swing.JButton jButtonMoveUp;
private javax.swing.JButton jButtonOpenLog;
@@ -523,11 +558,11 @@ public class TestingList extends Panel {
//open details of the selected test in a new panel
private void openDetails() throws Exception{
-
//pick details from the clicked row
int row = jTable1.getSelectedRow();
String sDeviceName = jTable1.getValueAt(row, COL.DEVICENAME.ordinal()).toString();
String sTestName = jTable1.getValueAt(row, COL.TESTNAME.ordinal()).toString();
+ String sTestPath = String.valueOf(jTable1.getValueAt(row, COL.TESTPATH.ordinal()));
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();
@@ -546,6 +581,7 @@ public class TestingList extends Panel {
details.put("time", sResultTime);
details.put("parameters", mParameters);
details.put("testHelp", sTestHelp);
+ details.put("testPath", sTestPath);
//open details panel
JDialog dlg = new JDialog(getView(), "Test Details - " + sTestName , true);
//create a class to visualise the details panel
@@ -736,7 +772,7 @@ public class TestingList extends Panel {
/**
*table management
*/
- public void buildTable() {
+ private void buildTable() {
String sDate = getNow();
DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
jTable1.setModel(model);
@@ -744,17 +780,19 @@ public class TestingList extends Panel {
jTable1.getColumnModel().getColumn(COL.CHECK.ordinal()).setMaxWidth(27);
jTable1.getColumnModel().getColumn(COL.DEVICENAME.ordinal()).setPreferredWidth(30);
jTable1.getColumnModel().getColumn(COL.STATUS.ordinal()).setPreferredWidth(30);
- jTable1.getColumnModel().getColumn(COL.DEVICEDESCR.ordinal()).setMinWidth(0);
- jTable1.getColumnModel().getColumn(COL.DEVICEDESCR.ordinal()).setMaxWidth(0);
- jTable1.getColumnModel().getColumn(COL.TESTPATH.ordinal()).setMinWidth(0);
- jTable1.getColumnModel().getColumn(COL.TESTPATH.ordinal()).setMaxWidth(0);
- jTable1.getColumnModel().getColumn(COL.TESTDESCR.ordinal()).setMinWidth(0);
- jTable1.getColumnModel().getColumn(COL.TESTDESCR.ordinal()).setMaxWidth(0);
- jTable1.getColumnModel().getColumn(COL.TESTPARAMS.ordinal()).setMinWidth(0);
- jTable1.getColumnModel().getColumn(COL.TESTPARAMS.ordinal()).setMaxWidth(0);
+ hideColumn(COL.DEVICEDESCR);
+ hideColumn(COL.TESTPATH);
+ hideColumn(COL.TESTDESCR);
+ hideColumn(COL.TESTPARAMS);
+ hideColumn(COL.TESTHELP);
jTable1.setAutoCreateRowSorter(true);
updateStatus();
}
+
+ private void hideColumn(COL column){
+ jTable1.getColumnModel().getColumn(column.ordinal()).setMinWidth(0);
+ jTable1.getColumnModel().getColumn(column.ordinal()).setMaxWidth(0);
+ }
//append test info to table
private void addToTable(String deviceName,
@@ -898,7 +936,59 @@ public class TestingList extends Panel {
System.out.println("Open command cancelled by user.");
}
}
+
+ private void saveSettings() {
+ final JFileChooser fc = new JFileChooser();
+ int returnVal = fc.showOpenDialog(NetbeansPluginPanel.this);
+
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+ File file = fc.getSelectedFile();
+ saveSettings(file);
+ }
+ }
+
+ private void saveSettings(File file) {
+ DefaultTableModel tableModel = (DefaultTableModel) jTable1.getModel();
+ try {
+ ObjectOutputStream out = new ObjectOutputStream(
+ new FileOutputStream(file));
+ out.writeObject(tableModel.getDataVector());
+ out.close();
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ private void loadSettings() {
+ final JFileChooser fc = new JFileChooser();
+ int returnVal = fc.showOpenDialog(NetbeansPluginPanel.this);
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+ File file = fc.getSelectedFile();
+ loadSettings(file);
+ }
+ }
+
+ private void loadSettings(File file) {
+ DefaultTableModel tableModel = (DefaultTableModel) jTable1.getModel();
+ try {
+ ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
+ Vector rowData = (Vector)in.readObject();
+ Iterator itr = rowData.iterator();
+ for (int row = 0 ; row < jTable1.getRowCount() ; row++){
+ tableModel.removeRow(row);
+ }
+ while(itr.hasNext()) {
+ tableModel.addRow((Vector) itr.next());
+ }
+ in.close();
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ SwingUtils.showMessage(this, "getTestInProgress()", ex.toString());
+ }
+ }
}
}
diff --git a/plugins/TestingListDetails.form b/plugins/TestingListDetails.form
index 468f93a..64a879e 100644
--- a/plugins/TestingListDetails.form
+++ b/plugins/TestingListDetails.form
@@ -49,13 +49,7 @@
-
-
-
-
-
-
-
+
@@ -63,15 +57,14 @@
-
-
-
-
-
-
+
+
+
+
+
@@ -337,14 +330,6 @@
-
-
-
-
-
-
-
-
@@ -358,6 +343,9 @@
+
+
+
diff --git a/plugins/TestingListDetails.java b/plugins/TestingListDetails.java
index af0cb5d..270bdf2 100644
--- a/plugins/TestingListDetails.java
+++ b/plugins/TestingListDetails.java
@@ -2,9 +2,15 @@
* Copyright (c) 2015 Paul Scherrer Institute. All rights reserved.
*/
+import java.awt.Desktop;
import java.io.File;
+import java.io.IOException;
import java.util.HashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.swing.ImageIcon;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
import javax.swing.table.DefaultTableModel;
import org.apache.commons.io.FilenameUtils;
@@ -61,7 +67,6 @@ public class TestingListDetails extends javax.swing.JPanel {
jLabel8 = new javax.swing.JLabel();
jScrollPane3 = new javax.swing.JScrollPane();
txtTestDescription = new javax.swing.JTextArea();
- jLabel3 = new javax.swing.JLabel();
jScrollPane4 = new javax.swing.JScrollPane();
jEditorPaneHelp = new javax.swing.JEditorPane();
@@ -171,11 +176,9 @@ public class TestingListDetails extends javax.swing.JPanel {
txtTestDescription.setRows(5);
jScrollPane3.setViewportView(txtTestDescription);
- jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- jLabel3.setText("Help");
-
jEditorPaneHelp.setContentType("text/html"); // NOI18N
jEditorPaneHelp.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
+ jEditorPaneHelp.setDropMode(javax.swing.DropMode.INSERT);
jScrollPane4.setViewportView(jEditorPaneHelp);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
@@ -210,24 +213,19 @@ public class TestingListDetails extends javax.swing.JPanel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cmCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGap(18, 18, 18)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jLabel3)
- .addGap(0, 0, Short.MAX_VALUE))
- .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE))
+ .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel1)
- .addComponent(txtDeviceName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel3))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel1)
+ .addComponent(txtDeviceName, 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.BASELINE)
.addComponent(jLabel2)
.addComponent(txtDeviceDescription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
@@ -263,14 +261,15 @@ public class TestingListDetails extends javax.swing.JPanel {
}// //GEN-END:initComponents
private void fillComponents(HashMap hDetails) {
+ //add values to each text box
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("testResult").toString());
- this.jEditorPaneHelp.setText(String.valueOf(hDetails.get("testHelp")));
-
+ //help text
+ showHelp(String.valueOf(hDetails.get("testPath")), String.valueOf(hDetails.get("testHelp")));
//parameters table
HashMap hParams = (HashMap) hDetails.get("parameters");
String name="", value="", description="";
@@ -288,6 +287,47 @@ public class TestingListDetails extends javax.swing.JPanel {
jTableParams.setModel(model);
}
}
+
+ //load and show help
+ private void showHelp(String sTestPath, String sHelpText){
+ this.jEditorPaneHelp.addHyperlinkListener(new HyperlinkListener() {
+ @Override
+ public void hyperlinkUpdate(HyperlinkEvent hle) {
+ if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) {
+ System.out.println(hle.getURL());
+ Desktop desktop = Desktop.getDesktop();
+ try {
+ desktop.browse(hle.getURL().toURI());
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+ });
+ this.jEditorPaneHelp.setEditable(false);
+ //if there is no input, exit
+ if(sTestPath == "" && sHelpText == ""){
+ return;
+ }
+ File fTest = new File(sTestPath);
+ String sParentPath = fTest.getParent().toString();
+ File fHelp = new File(FilenameUtils.separatorsToSystem(sParentPath + "/help.html"));
+
+ if(fHelp.isFile()){//if local help file existis:
+ try {
+ this.jEditorPaneHelp.setPage(fHelp.toURI().toURL());
+ } catch (IOException ex) {
+ this.jEditorPaneHelp.setText(String.valueOf(ex));
+ }
+ } else { //help.html file is present. see if a plain text has been given from .config file
+ if(sHelpText.isEmpty() || sHelpText == "null"){
+ this.jEditorPaneHelp.setText("[No help available]");
+ //this.jEditorPaneHelp.setVisible(false);
+ }else {
+ this.jEditorPaneHelp.setText(sHelpText);
+ }
+ }
+ }
private void cmCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmCancelActionPerformed
@@ -305,7 +345,6 @@ public class TestingListDetails extends javax.swing.JPanel {
private javax.swing.JEditorPane jEditorPaneHelp;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
diff --git a/script/tests/tests/Collimator Tests/Calibrate/.config b/script/tests/tests/Collimator Tests/Calibrate/.config
index 2d54ba8..5e59d3d 100644
--- a/script/tests/tests/Collimator Tests/Calibrate/.config
+++ b/script/tests/tests/Collimator Tests/Calibrate/.config
@@ -4,11 +4,9 @@ filename=Calibrate.xml
help = \
This test sends a command to the low level firmware which controls the collimators \n\
requesting that it calibrates itself. \n\n\
-Calibration involves moving to the R1 and R2 reference positions and measuring the \n\
+Calibration involves moving to the R1 and R2 reference positions and measuring the \n\
number of steps required to do so. At the end of the sequence the default collimator \n\
will be selected. \n\n\
During the course of the expected calibration period (45-70 seconds) the test \n\
procedure will plot the values of all critical system variables. \n\n\
-For further information please consult Valery Ovinnikov.
-
-
\ No newline at end of file
+For further information please consult Valery Ovinnikov.
\