From d80fb06a4efb9bcc48b2edf040c6800aa967a029 Mon Sep 17 00:00:00 2001 From: boccioli_m Date: Tue, 18 Aug 2015 14:46:02 +0200 Subject: [PATCH] Closedown --- plugins/EditTestingList.form | 113 +++++++++++++++++++++ plugins/EditTestingList.java | 192 +++++++++++++++++++++++++++++++++++ plugins/TestingList.form | 13 +++ plugins/TestingList.java | 60 +++++++++++ 4 files changed, 378 insertions(+) create mode 100644 plugins/EditTestingList.form create mode 100644 plugins/EditTestingList.java diff --git a/plugins/EditTestingList.form b/plugins/EditTestingList.form new file mode 100644 index 0000000..8e6b08e --- /dev/null +++ b/plugins/EditTestingList.form @@ -0,0 +1,113 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/EditTestingList.java b/plugins/EditTestingList.java new file mode 100644 index 0000000..6d7bca5 --- /dev/null +++ b/plugins/EditTestingList.java @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2015 Paul Scherrer Institute. All rights reserved. + */ + +import ch.psi.utils.swing.SwingUtils; +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 javax.swing.table.TableModel; +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 EditTestingList extends javax.swing.JPanel { + + /** + * Creates new form TestingListDetails + */ + public EditTestingList() { + initComponents(); + } + + public EditTestingList(TableModel hDetails) { + initComponents(); + fillComponents(hDetails); + } + + /** + * 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + cmCancel = new javax.swing.JButton(); + cmOk = new javax.swing.JButton(); + cmDefault = new javax.swing.JButton(); + jScrollPane5 = new javax.swing.JScrollPane(); + jTable1 = new javax.swing.JTable(); + + cmCancel.setText("Cancel"); + this.cmCancel.setVisible(false); + this.cmOk.setVisible(false); + cmCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cmCancelActionPerformed(evt); + } + }); + + cmOk.setText("Ok"); + this.cmCancel.setVisible(false); + this.cmOk.setVisible(false); + + cmDefault.setText("Save as Default"); + this.cmCancel.setVisible(false); + this.cmOk.setVisible(false); + this.cmDefault.setVisible(false); + cmDefault.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cmDefaultActionPerformed(evt); + } + }); + + jTable1.setFont(new java.awt.Font("Tahoma", 0, 15)); // NOI18N + jTable1.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + + }, + new String [] { + "Select", "Start", "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, java.lang.Object.class, java.lang.Object.class, javax.swing.Icon.class + }; + boolean[] canEdit = new boolean [] { + true, true, false, false, false, false, false, false, false, false, false, false, false, false + }; + + public Class getColumnClass(int columnIndex) { + return types [columnIndex]; + } + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return canEdit [columnIndex]; + } + }); + jTable1.setDragEnabled(true); + jTable1.setDropMode(javax.swing.DropMode.INSERT); + jTable1.setRowHeight(22); + jTable1.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jTable1MouseClicked(evt); + } + }); + jTable1.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + jTable1KeyReleased(evt); + } + }); + jScrollPane5.setViewportView(jTable1); + + 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.LEADING, false) + .addGroup(layout.createSequentialGroup() + .addGap(1, 1, 1) + .addComponent(cmDefault, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(180, 180, 180) + .addComponent(cmOk, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cmCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jScrollPane5)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 547, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(cmCancel) + .addComponent(cmOk) + .addComponent(cmDefault))) + ); + }// //GEN-END:initComponents + + private void fillComponents(TableModel hDetails) { + jTable1.setModel(hDetails); + } + + + + private void cmCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmCancelActionPerformed + + }//GEN-LAST:event_cmCancelActionPerformed + + private void cmDefaultActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmDefaultActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_cmDefaultActionPerformed + + private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked + if (this.jTable1.isEnabled()) { + try { + switch (evt.getClickCount()) { + case 1: + break; + case 2: + + break; + } + + } catch (Exception ex) { + SwingUtils.showException(this, ex); + } + } + }//GEN-LAST:event_jTable1MouseClicked + + private void jTable1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTable1KeyReleased + + }//GEN-LAST:event_jTable1KeyReleased + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton cmCancel; + private javax.swing.JButton cmDefault; + private javax.swing.JButton cmOk; + private javax.swing.JScrollPane jScrollPane5; + private javax.swing.JTable jTable1; + // End of variables declaration//GEN-END:variables +} diff --git a/plugins/TestingList.form b/plugins/TestingList.form index 1f6d6d6..115e62d 100644 --- a/plugins/TestingList.form +++ b/plugins/TestingList.form @@ -163,6 +163,19 @@ + + + + + + + + + + + + + diff --git a/plugins/TestingList.java b/plugins/TestingList.java index 48c7fad..b6da796 100644 --- a/plugins/TestingList.java +++ b/plugins/TestingList.java @@ -335,6 +335,7 @@ public class TestingList extends Panel { jButtonOpenLog = new javax.swing.JButton(); jButtonOpen = new javax.swing.JButton(); jButtonSave = new javax.swing.JButton(); + jButton1 = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); jCheckBox1 = new javax.swing.JCheckBox(); jButtonMoveDown = new javax.swing.JButton(); @@ -432,6 +433,14 @@ public class TestingList extends Panel { }); jPanel3.add(jButtonSave, java.awt.BorderLayout.LINE_END); + jButton1.setText("+"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + jPanel3.add(jButton1, java.awt.BorderLayout.LINE_START); + jPanel1.add(jPanel3, java.awt.BorderLayout.EAST); jPanel2.setLayout(new java.awt.BorderLayout()); @@ -588,8 +597,17 @@ public class TestingList extends Panel { saveSettings(); }//GEN-LAST:event_jButtonSaveActionPerformed + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + try { + openListEditor(); + } catch (Exception ex) { + Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex); + } + }//GEN-LAST:event_jButton1ActionPerformed + // // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; private javax.swing.JButton jButtonMoveDown; private javax.swing.JButton jButtonMoveUp; private javax.swing.JButton jButtonOpen; @@ -684,6 +702,48 @@ public class TestingList extends Panel { dlg.setVisible(true); } + /** + * open details of the selected row in a new panel + * + * @throws exception + */ + private void openListEditor() 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(); + 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 = getTestParameters(sTestPath); + //create map for passing details to Details Panel + HashMap details = new HashMap(); + details.put("deviceName", sDeviceName); + details.put("deviceDescription", sDeviceDescription); + details.put("testDescription", sTestDescription); + details.put("testSuite", sTestCaseName); + details.put("testName", sTestName); + details.put("testResult", sLastResult); + details.put("time", sResultTime); + details.put("parameters", mParameters); + details.put("testHelp", sTestHelp); + details.put("testPath", sTestPath); +*/ //open details panel + JDialog dlg = new JDialog(getView(), "Add/remove tests", true); + //create a class to visualise the details panel + Class editTestingListClass = getController().getClassByName("EditTestingList"); + JPanel detailsPanel = (JPanel) editTestingListClass.getConstructor(new Class[]{HashMap.class}).newInstance(jTable1.getModel()); + + dlg.getContentPane().add(detailsPanel); + //dlg.add(new TestingListDetails()); + dlg.pack(); + dlg.setVisible(true); + } + /** * put the test result in table *