/*
 * Copyright (c) 2015 Paul Scherrer Institute. All rights reserved.
 */

import ch.psi.utils.swing.SwingUtils;
import java.awt.Desktop;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.table.DefaultTableModel;
import org.apache.commons.io.FilenameUtils;

/*
 * 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 TestingListDetails extends javax.swing.JPanel {

    /**
     * Creates new form TestingListDetails
     */
    public TestingListDetails() {
        initComponents();
    }
    
    public TestingListDetails(HashMap hDetails) {
        initComponents();
        fillComponents(hDetails);
    }
    
    public static String TESTS_CONFIG_FILENAME = ".config";
    public static Path TESTS_TESTS_DEFAULT_DIR = Paths.get(".", "home", "script", "tests", "tests");

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        txtDeviceName = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        txtDeviceDescription = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        txtTestSuite = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        txtTestName = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jScrollPaneParam = new javax.swing.JScrollPane();
        jTableParams = new javax.swing.JTable();
        jLabel7 = new javax.swing.JLabel();
        jScrollPaneRes = new javax.swing.JScrollPane();
        txtTestResult = new javax.swing.JTextArea();
        jLabel8 = new javax.swing.JLabel();
        jScrollPaneTestDesc = new javax.swing.JScrollPane();
        txtTestDescription = new javax.swing.JTextArea();
        jScrollPaneHtml = new javax.swing.JScrollPane();
        jEditorPaneHelp = new javax.swing.JEditorPane();
        jButtonOk = new javax.swing.JButton();
        txtTestResultSummary = new javax.swing.JTextField();
        jButtonMoreResult = new javax.swing.JButton();
        jButtonMoreTest = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel1.setText("Device name");
        jLabel1.setVisible(false);

        txtDeviceName.setEditable(false);
        txtDeviceName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtDeviceName.setText("jTextField1");
        txtDeviceName.setVisible(false);

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel2.setText("Device Description");
        jLabel2.setVisible(false);

        txtDeviceDescription.setEditable(false);
        txtDeviceDescription.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtDeviceDescription.setText("jTextField2");
        txtDeviceDescription.setVisible(false);

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel4.setText("Test Case/Suite");
        jLabel4.setVisible(false);

        txtTestSuite.setEditable(false);
        txtTestSuite.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtTestSuite.setText("jTextField2");
        txtTestSuite.setVisible(false);

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel5.setText("Test Name");

        txtTestName.setEditable(false);
        txtTestName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtTestName.setText("jTextField2");

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel6.setText("Last Test Result");

        jScrollPaneParam.setMinimumSize(new java.awt.Dimension(150, 100));

        jTableParams.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTableParams.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Parameter", "Value", "Description"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, true, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableParams.setDragEnabled(true);
        jTableParams.setMinimumSize(new java.awt.Dimension(180, 100));
        jTableParams.setRowHeight(20);
        jScrollPaneParam.setViewportView(jTableParams);
        if (jTableParams.getColumnModel().getColumnCount() > 0) {
            jTableParams.getColumnModel().getColumn(0).setMinWidth(150);
            jTableParams.getColumnModel().getColumn(0).setPreferredWidth(150);
            jTableParams.getColumnModel().getColumn(0).setMaxWidth(150);
            jTableParams.getColumnModel().getColumn(1).setPreferredWidth(80);
            jTableParams.getColumnModel().getColumn(1).setMaxWidth(100);
        }

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel7.setText("Test Parameters");

        jScrollPaneRes.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jScrollPaneRes.setMinimumSize(new java.awt.Dimension(150, 100));
        jScrollPaneRes.setPreferredSize(new java.awt.Dimension(146, 91));
        jScrollPaneRes.setVisible(false);

        txtTestResult.setEditable(false);
        txtTestResult.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.background"));
        txtTestResult.setColumns(20);
        txtTestResult.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtTestResult.setLineWrap(true);
        txtTestResult.setRows(5);
        jScrollPaneRes.setViewportView(txtTestResult);

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel8.setText("Test Description");
        jLabel8.setVisible(false);

        jScrollPaneTestDesc.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jScrollPaneTestDesc.setVisible(false);

        txtTestDescription.setEditable(false);
        txtTestDescription.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.background"));
        txtTestDescription.setColumns(20);
        txtTestDescription.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtTestDescription.setLineWrap(true);
        txtTestDescription.setRows(5);
        jScrollPaneTestDesc.setViewportView(txtTestDescription);

        jEditorPaneHelp.setContentType("text/html"); // NOI18N
        jEditorPaneHelp.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jEditorPaneHelp.setDropMode(javax.swing.DropMode.INSERT);
        jEditorPaneHelp.setMinimumSize(new java.awt.Dimension(6, 400));
        jEditorPaneHelp.setPreferredSize(new java.awt.Dimension(6, 400));
        jScrollPaneHtml.setViewportView(jEditorPaneHelp);

        jButtonOk.setText("Save");
        jButtonOk.setToolTipText("Save parameters values");
        jButtonOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonOkActionPerformed(evt);
            }
        });

        txtTestResultSummary.setEditable(false);
        txtTestResultSummary.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtTestResultSummary.setText("jTextField1");

        jButtonMoreResult.setText("More");
        jButtonMoreResult.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonMoreResultActionPerformed(evt);
            }
        });

        jButtonMoreTest.setText("More");
        jButtonMoreTest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonMoreTestActionPerformed(evt);
            }
        });

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel9.setText("Last Result Details");
        jLabel9.setVisible(false);

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel10.setText("(Value valid for all devices)");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jLabel5)
                                        .addComponent(jLabel8)
                                        .addComponent(jLabel6)
                                        .addComponent(jLabel9)
                                        .addComponent(jLabel1)
                                        .addComponent(jLabel10))
                                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING))
                                .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING))
                            .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtDeviceName)
                            .addComponent(txtDeviceDescription)
                            .addComponent(jScrollPaneTestDesc)
                            .addComponent(jScrollPaneRes, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jScrollPaneParam, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(txtTestResultSummary, javax.swing.GroupLayout.PREFERRED_SIZE, 440, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButtonMoreResult))
                            .addComponent(txtTestSuite)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(txtTestName, javax.swing.GroupLayout.PREFERRED_SIZE, 441, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButtonMoreTest))))
                    .addComponent(jButtonOk, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jScrollPaneHtml, javax.swing.GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtTestName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButtonMoreTest)
                            .addComponent(jLabel5))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtTestSuite, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel8)
                            .addComponent(jScrollPaneTestDesc, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jButtonMoreResult)
                                .addComponent(jLabel6))
                            .addComponent(txtTestResultSummary, javax.swing.GroupLayout.Alignment.TRAILING, 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.LEADING)
                            .addComponent(jLabel9)
                            .addComponent(jScrollPaneRes, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(txtDeviceName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtDeviceDescription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPaneParam, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel10)
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonOk))
                    .addComponent(jScrollPaneHtml, javax.swing.GroupLayout.DEFAULT_SIZE, 559, Short.MAX_VALUE))
                .addContainerGap())
        );
    }// </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("deviceName").toString() + " - " + 
                                    hDetails.get("testName").toString() + "\n" + 
                                    hDetails.get("testResult").toString());
        this.txtTestResultSummary.setText( hDetails.get("testResult").toString());
        this.txtTestResultSummary.setCaretPosition(0);
        //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="";
        DefaultTableModel model = (DefaultTableModel) jTableParams.getModel();

       for(Object entry : hParams.keySet()){
            Object param = entry;
            if(param instanceof String){
                name = (String) param;
                HashMap attributes = (HashMap) hParams.get(param);
                value = (String) attributes.get("value");
                description = (String) attributes.get("description");
                model.addRow(new Object[]{name, value, description});
            }
            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);
            }
        }      
    }
    
    /**
     * 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.
     *
     * @param parametersString string containing the parameters. Syntax:
     * name:value:description[;name:value:description;...]
     */
    private HashMap buildParametersMap(String parametersString) {
        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;
    }
    
    private HashMap getParametersFromTable(){
        HashMap mParameters = new HashMap(); // contains name and attributes
        HashMap mParameterAttributes = new HashMap(); //contians value and description
        for(int row=0 ; row<jTableParams.getRowCount() ; row++){
            String sParam = jTableParams.getValueAt(row, 0).toString();
            String sVal = jTableParams.getValueAt(row, 1).toString();
            String sDescr = jTableParams.getValueAt(row, 2).toString();
            mParameterAttributes = new HashMap();
            mParameterAttributes.put("value", (Object) sVal);
            mParameterAttributes.put("description", sDescr);
            //add parameter name and attributes (value + description)
            mParameters.put(sParam, mParameterAttributes);          
        }
        return mParameters;
    }
    
    public boolean updateTestConfig(Path testDir,
                                    String sTestName,
                                    String sTestSuite,
                                    HashMap hmTestParams){
        //generate test config file from template        
        boolean success = false;        
        try {        
            Path path = Paths.get(testDir + FilenameUtils.separatorsToSystem("/"+TESTS_CONFIG_FILENAME));
            File configFile = path.toFile();
            //Loop among the test parameters and generate variable assignement syntax for python
            String sTestParameters = "";
            String name="", value="", description="";
            for(Object entry : hmTestParams.keySet()){
                Object param = entry;
                if(param instanceof String){
                    name = (String) param;
                    HashMap attributes = (HashMap) hmTestParams.get(param);
                    value = (String) attributes.get("value");
                    description = (String) attributes.get("description");
                    //build the python code for getting the test parameter
                    sTestParameters = sTestParameters + name + ":" + value + ":" + description + ";" ; 
                }               
            }  
            FileInputStream in = new FileInputStream(path.toFile());
            Properties props = new Properties();
            props.load(in);
            in.close();
            FileOutputStream out = new FileOutputStream(path.toFile());
            props.setProperty("parameters", sTestParameters);
            props.store(out, null);
            out.close();

            success = true;            
        } catch (FileNotFoundException ex) {
            SwingUtils.showMessage(this, "generateTestConfig()", "Cannot find file: " + ex.toString());
            success = false;
        } catch (IOException ex) {
            SwingUtils.showMessage(this, "generateTestConfig()", "Problem with file aaccess: " + ex.toString());
            success = false;
        }
        return success;
    }

    private void jButtonOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOkActionPerformed
        // TODO add your handling code here:
        Path testPath = Paths.get(TESTS_TESTS_DEFAULT_DIR.toString(), this.txtTestSuite.getText(), this.txtTestName.getText());
        updateTestConfig(testPath, this.txtTestName.getText(), this.txtTestSuite.getText(),getParametersFromTable());
    }//GEN-LAST:event_jButtonOkActionPerformed

    private void jButtonMoreResultActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMoreResultActionPerformed
        if(this.jButtonMoreResult.getText()=="More"){
            this.jButtonMoreResult.setText("Less");
            this.jScrollPaneRes.setVisible(true);
            this.jLabel9.setVisible(true);
            this.txtDeviceName.setVisible(true);
            this.jLabel1.setVisible(true);
            this.jLabel2.setVisible(true);
            this.txtDeviceDescription.setVisible(true);
        }else{
            this.jScrollPaneRes.setVisible(false);
            this.jLabel9.setVisible(false);
            this.txtDeviceName.setVisible(false);
            this.jLabel1.setVisible(false);
            this.jLabel2.setVisible(false);
            this.txtDeviceDescription.setVisible(false);
            this.jButtonMoreResult.setText("More");            
        }
    }//GEN-LAST:event_jButtonMoreResultActionPerformed

    private void jButtonMoreTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMoreTestActionPerformed
        if(this.jButtonMoreTest.getText()=="More"){
            this.jButtonMoreTest.setText("Less");
            this.jScrollPaneTestDesc.setVisible(true);
            this.jLabel4.setVisible(true);
            this.txtTestSuite.setVisible(true);
            this.jLabel8.setVisible(true);
        }else{
            this.jScrollPaneTestDesc.setVisible(false);
            this.jLabel4.setVisible(false);
            this.txtTestSuite.setVisible(false);
            this.jLabel8.setVisible(false);
            this.jButtonMoreTest.setText("More");            
        }        
    }//GEN-LAST:event_jButtonMoreTestActionPerformed

    // <editor-fold defaultstate="collapsed" desc="Variables declaration">                              
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonMoreResult;
    private javax.swing.JButton jButtonMoreTest;
    private javax.swing.JButton jButtonOk;
    private javax.swing.JEditorPane jEditorPaneHelp;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPaneHtml;
    private javax.swing.JScrollPane jScrollPaneParam;
    private javax.swing.JScrollPane jScrollPaneRes;
    private javax.swing.JScrollPane jScrollPaneTestDesc;
    private javax.swing.JTable jTableParams;
    private javax.swing.JTextField txtDeviceDescription;
    private javax.swing.JTextField txtDeviceName;
    private javax.swing.JTextArea txtTestDescription;
    private javax.swing.JTextField txtTestName;
    private javax.swing.JTextArea txtTestResult;
    private javax.swing.JTextField txtTestResultSummary;
    private javax.swing.JTextField txtTestSuite;
    // End of variables declaration//GEN-END:variables
// </editor-fold>  

}
