improvements
This commit is contained in:
@@ -6,6 +6,8 @@ import ch.psi.utils.swing.SwingUtils;
|
||||
import ch.psi.utils.swing.SwingUtils.OptionResult;
|
||||
import ch.psi.utils.swing.SwingUtils.OptionType;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
@@ -61,7 +63,7 @@ public class NewTest extends javax.swing.JPanel {
|
||||
|
||||
jPopupMenuTable = new javax.swing.JPopupMenu();
|
||||
jMenuItemAddRow = new javax.swing.JMenuItem();
|
||||
jMenuItemReleteRow = new javax.swing.JMenuItem();
|
||||
jMenuItemDeleteRow = new javax.swing.JMenuItem();
|
||||
lblName = new javax.swing.JLabel();
|
||||
lblSuite = new javax.swing.JLabel();
|
||||
lblParams = new javax.swing.JLabel();
|
||||
@@ -72,6 +74,7 @@ public class NewTest extends javax.swing.JPanel {
|
||||
txtTestDescription = new javax.swing.JTextArea();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
jTableParams = new javax.swing.JTable();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
jButtonGenerate = new javax.swing.JButton();
|
||||
|
||||
jMenuItemAddRow.setText("Add Row");
|
||||
@@ -82,13 +85,13 @@ public class NewTest extends javax.swing.JPanel {
|
||||
});
|
||||
jPopupMenuTable.add(jMenuItemAddRow);
|
||||
|
||||
jMenuItemReleteRow.setText("Delete Row");
|
||||
jMenuItemReleteRow.addActionListener(new java.awt.event.ActionListener() {
|
||||
jMenuItemDeleteRow.setText("Delete Row");
|
||||
jMenuItemDeleteRow.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jMenuItemReleteRowActionPerformed(evt);
|
||||
jMenuItemDeleteRowActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPopupMenuTable.add(jMenuItemReleteRow);
|
||||
jPopupMenuTable.add(jMenuItemDeleteRow);
|
||||
|
||||
lblName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
|
||||
lblName.setText("Name *");
|
||||
@@ -104,6 +107,7 @@ public class NewTest extends javax.swing.JPanel {
|
||||
|
||||
txtTestName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
|
||||
|
||||
jComboBoxTestSuites.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
|
||||
jComboBoxTestSuites.setMinimumSize(new java.awt.Dimension(31, 26));
|
||||
jComboBoxTestSuites.setPreferredSize(new java.awt.Dimension(31, 26));
|
||||
|
||||
@@ -124,14 +128,17 @@ public class NewTest extends javax.swing.JPanel {
|
||||
"Parameter", "Value", "Description"
|
||||
}
|
||||
));
|
||||
jTableParams.setColumnSelectionAllowed(true);
|
||||
jTableParams.setDragEnabled(true);
|
||||
jTableParams.setRowHeight(20);
|
||||
jTableParams.getTableHeader().setReorderingAllowed(false);
|
||||
jTableParams.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
jTableParamsMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
jScrollPane1.setViewportView(jTableParams);
|
||||
jTableParams.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
||||
if (jTableParams.getColumnModel().getColumnCount() > 0) {
|
||||
jTableParams.getColumnModel().getColumn(0).setMinWidth(150);
|
||||
jTableParams.getColumnModel().getColumn(0).setPreferredWidth(150);
|
||||
@@ -147,6 +154,23 @@ public class NewTest extends javax.swing.JPanel {
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||
jPanel1.setLayout(jPanel1Layout);
|
||||
jPanel1Layout.setHorizontalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap(442, Short.MAX_VALUE)
|
||||
.addComponent(jButtonGenerate, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
jPanel1Layout.setVerticalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(jButtonGenerate, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
@@ -154,6 +178,9 @@ public class NewTest extends javax.swing.JPanel {
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGap(1, 1, 1))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(lblParams)
|
||||
@@ -161,18 +188,17 @@ public class NewTest extends javax.swing.JPanel {
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(19, 19, 19)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE)
|
||||
.addComponent(txtTestName, javax.swing.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE)
|
||||
.addComponent(jComboBoxTestSuites, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(jButtonGenerate, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 513, javax.swing.GroupLayout.PREFERRED_SIZE)))))
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE)
|
||||
.addGap(1, 1, 1)))
|
||||
.addGap(12, 12, 12))
|
||||
.addComponent(lblName)
|
||||
.addComponent(lblSuite))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addComponent(lblSuite)))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@@ -192,10 +218,10 @@ public class NewTest extends javax.swing.JPanel {
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(lblParams)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(jButtonGenerate, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
@@ -220,14 +246,14 @@ public class NewTest extends javax.swing.JPanel {
|
||||
jTableParams.setModel(model);
|
||||
}//GEN-LAST:event_jMenuItemAddRowActionPerformed
|
||||
|
||||
private void jMenuItemReleteRowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemReleteRowActionPerformed
|
||||
private void jMenuItemDeleteRowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDeleteRowActionPerformed
|
||||
// TODO add your handling code here:
|
||||
int row = jTableParams.getSelectedRow();
|
||||
if(row>=0 && row<jTableParams.getRowCount()){
|
||||
DefaultTableModel model = (DefaultTableModel) jTableParams.getModel();
|
||||
model.removeRow(row);
|
||||
}
|
||||
}//GEN-LAST:event_jMenuItemReleteRowActionPerformed
|
||||
}//GEN-LAST:event_jMenuItemDeleteRowActionPerformed
|
||||
|
||||
/**
|
||||
* constants declarations
|
||||
@@ -248,9 +274,20 @@ public class NewTest extends javax.swing.JPanel {
|
||||
* @param newType the new can be Device or Test.
|
||||
*/
|
||||
private void fillComponents(String newType) {
|
||||
|
||||
// listener for mouse-click also on table header
|
||||
jTableParams.getTableHeader().addMouseListener(new MouseAdapter() {
|
||||
public void mouseClicked(MouseEvent evt) {
|
||||
if(evt.getButton() == java.awt.event.MouseEvent.BUTTON3){
|
||||
jPopupMenuTable.show(jTableParams, evt.getX(), evt.getY());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//adapt labels according to type (Device or Test)
|
||||
if(newType == "Device"){
|
||||
this.lblDescr.setText(newType + " "+ this.lblDescr.getText());
|
||||
this.lblName.setText(newType + " "+ this.lblName.getText());
|
||||
this.lblName.setText( newType + " "+ this.lblName.getText());
|
||||
lblParams.setVisible(false);
|
||||
jTableParams.setVisible(false);
|
||||
jScrollPane1.setVisible(false);
|
||||
@@ -268,6 +305,7 @@ public class NewTest extends javax.swing.JPanel {
|
||||
}
|
||||
this.jComboBoxTestSuites.setEditable(true);
|
||||
this.jComboBoxTestSuites.setSelectedItem(null);
|
||||
|
||||
//fill parameters table
|
||||
InputStream ist = null;
|
||||
try {
|
||||
@@ -486,6 +524,7 @@ public class NewTest extends javax.swing.JPanel {
|
||||
SwingUtils.showMessage(this, "generateTestFiles()", "Cannot find tests default directory " + TESTS_TESTS_DEFAULT_DIR.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* create folders and files for the new device to generate
|
||||
@@ -739,7 +778,8 @@ public class NewTest extends javax.swing.JPanel {
|
||||
private javax.swing.JButton jButtonGenerate;
|
||||
private javax.swing.JComboBox jComboBoxTestSuites;
|
||||
private javax.swing.JMenuItem jMenuItemAddRow;
|
||||
private javax.swing.JMenuItem jMenuItemReleteRow;
|
||||
private javax.swing.JMenuItem jMenuItemDeleteRow;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JPopupMenu jPopupMenuTable;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JScrollPane jScrollPane3;
|
||||
|
||||
Reference in New Issue
Block a user