Closedown
This commit is contained in:
@@ -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 {
|
||||
}// </editor-fold>//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;
|
||||
|
||||
Reference in New Issue
Block a user