Added: animate custom panel:
- immediately, the test list concerns only one device - while test running, if more devices are concerned in the test list. Stil missing: caget from custom panel.
This commit is contained in:
@@ -448,7 +448,7 @@ public class TestingList extends Panel {
|
||||
*
|
||||
* @return custom panel as component
|
||||
*/
|
||||
private Component getCustomPanel(){
|
||||
public Component getCustomPanel(){
|
||||
Component customPanel = null;
|
||||
if(this.jPanelCustomFrame.getComponentCount() >0){
|
||||
Component components[] = this.jPanelCustomFrame.getComponents();
|
||||
@@ -457,6 +457,23 @@ public class TestingList extends Panel {
|
||||
}
|
||||
return customPanel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* add custom panel if specified.
|
||||
* Custom panels are java classes. To add a new custom panel MyNewPanel:
|
||||
* - create a panel and save it as MyNewPanel.java
|
||||
* - add MyNewPanel.java file in the pshell plugins folder
|
||||
* - on pshell, open Plugins and enable MyNewPanel.java
|
||||
* - restart pshell
|
||||
* To show the new panel, open the menu Advanced/Load Custom Panel
|
||||
*
|
||||
* @param panel the panel to add as component
|
||||
*/
|
||||
public void loadCustomPanel(Component panel){
|
||||
if(panel != null)
|
||||
loadCustomPanel(panel.getClass().getName() );
|
||||
}
|
||||
|
||||
/**
|
||||
* add custom panel if specified.
|
||||
@@ -467,6 +484,7 @@ public class TestingList extends Panel {
|
||||
* - restart pshell
|
||||
* To show the new panel, open the menu Advanced/Load Custom Panel
|
||||
*
|
||||
* @param sPanelClassName the panel to add as class name
|
||||
*/
|
||||
private void loadCustomPanel(String sPanelClassName){
|
||||
closeCustomPanel();
|
||||
@@ -482,10 +500,10 @@ public class TestingList extends Panel {
|
||||
if(jTable1.getValueAt(row, COL.STARTSEQUENCE.ordinal())==null) continue;
|
||||
String sStartSequence = String.valueOf(jTable1.getValueAt(row, COL.STARTSEQUENCE.ordinal()));
|
||||
if(sStartSequence.equals(StartSequence.TOGETHER.toString())){
|
||||
SwingUtils.OptionResult ret = SwingUtils.showOption(this, "checkDataFields()",
|
||||
"A custom panel " +
|
||||
" is active. Tests can only run in sequence (one after the other). \nDo you want to set tests in sequence?",
|
||||
OptionType.YesNoCancel);
|
||||
SwingUtils.OptionResult ret = SwingUtils.showOption(this, "Modify Start mode",
|
||||
"A custom panel is active. Tests can only run in sequence (Start mode: 'After previous'). "+
|
||||
"\nDo you want to set all tests Start mode to 'After previous'?",
|
||||
OptionType.YesNo);
|
||||
if(ret == SwingUtils.OptionResult.Yes){
|
||||
changeSequenceToAfter = true ;
|
||||
} else {
|
||||
@@ -615,6 +633,8 @@ public class TestingList extends Panel {
|
||||
jSeparator4 = new javax.swing.JPopupMenu.Separator();
|
||||
jCheckBoxMenuShowSelectedTests1 = new javax.swing.JCheckBoxMenuItem();
|
||||
jMenuItemReload1 = new javax.swing.JMenuItem();
|
||||
jPopupMenuCustom = new javax.swing.JPopupMenu();
|
||||
jMenuItemCustomClose = new javax.swing.JMenuItem();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
jPanelTopCommands = new javax.swing.JPanel();
|
||||
jPanelButtons = new javax.swing.JPanel();
|
||||
@@ -629,9 +649,10 @@ public class TestingList extends Panel {
|
||||
jScrollPane2 = new javax.swing.JScrollPane();
|
||||
jTable1 = new javax.swing.JTable();
|
||||
jPanelCustom = new javax.swing.JPanel();
|
||||
jPanelCustomFrame = new javax.swing.JPanel();
|
||||
jPanelCustomHeader = new javax.swing.JPanel();
|
||||
jButtonX = new javax.swing.JButton();
|
||||
jLabelCustomPanelName = new javax.swing.JLabel();
|
||||
jPanelCustomFrame = new javax.swing.JPanel();
|
||||
|
||||
jCheckBoxMenuShowSelectedTests.setSelected(true);
|
||||
jCheckBoxMenuShowSelectedTests.setText("Show enabled tests only");
|
||||
@@ -773,6 +794,14 @@ public class TestingList extends Panel {
|
||||
});
|
||||
jPopupMenuTable.add(jMenuItemReload1);
|
||||
|
||||
jMenuItemCustomClose.setText("Close this custom panel");
|
||||
jMenuItemCustomClose.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jMenuItemCustomCloseActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPopupMenuCustom.add(jMenuItemCustomClose);
|
||||
|
||||
setLayout(new java.awt.BorderLayout());
|
||||
|
||||
jPanel1.setMinimumSize(new java.awt.Dimension(100, 200));
|
||||
@@ -919,42 +948,50 @@ public class TestingList extends Panel {
|
||||
|
||||
add(jScrollPane2, java.awt.BorderLayout.CENTER);
|
||||
|
||||
jPanelCustom.setPreferredSize(new java.awt.Dimension(400, 100));
|
||||
jPanelCustom.setPreferredSize(new java.awt.Dimension(300, 100));
|
||||
|
||||
jPanelCustomHeader.setPreferredSize(new java.awt.Dimension(88, 20));
|
||||
jPanelCustomHeader.setLayout(new java.awt.BorderLayout());
|
||||
|
||||
jButtonX.setFont(new java.awt.Font("Tahoma", 0, 8)); // NOI18N
|
||||
jButtonX.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/x-8px.png"))); // NOI18N
|
||||
jButtonX.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/x-darker-8px.png"))); // NOI18N
|
||||
jButtonX.setToolTipText("Close this custom panel");
|
||||
jButtonX.setPreferredSize(new java.awt.Dimension(8, 8));
|
||||
jButtonX.setPreferredSize(new java.awt.Dimension(10, 10));
|
||||
jButtonX.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/x-darker-8px.png"))); // NOI18N
|
||||
jButtonX.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButtonXActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanelCustomHeader.add(jButtonX, java.awt.BorderLayout.EAST);
|
||||
|
||||
jLabelCustomPanelName.setMaximumSize(new java.awt.Dimension(1000, 20));
|
||||
jLabelCustomPanelName.setMinimumSize(new java.awt.Dimension(100, 20));
|
||||
jLabelCustomPanelName.setPreferredSize(new java.awt.Dimension(200, 20));
|
||||
jLabelCustomPanelName.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
jLabelCustomPanelNameMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
jPanelCustomHeader.add(jLabelCustomPanelName, java.awt.BorderLayout.CENTER);
|
||||
|
||||
javax.swing.GroupLayout jPanelCustomLayout = new javax.swing.GroupLayout(jPanelCustom);
|
||||
jPanelCustom.setLayout(jPanelCustomLayout);
|
||||
jPanelCustomLayout.setHorizontalGroup(
|
||||
jPanelCustomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanelCustomLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jPanelCustomFrame, javax.swing.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE))
|
||||
.addGroup(jPanelCustomLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabelCustomPanelName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(jButtonX, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelCustomLayout.createSequentialGroup()
|
||||
.addGroup(jPanelCustomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanelCustomHeader, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jPanelCustomFrame, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
jPanelCustomLayout.setVerticalGroup(
|
||||
jPanelCustomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanelCustomLayout.createSequentialGroup()
|
||||
.addGroup(jPanelCustomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jButtonX, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelCustomLayout.createSequentialGroup()
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(jLabelCustomPanelName)
|
||||
.addGap(0, 0, 0)))
|
||||
.addComponent(jPanelCustomHeader, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jPanelCustomFrame, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(253, 253, 253))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
add(jPanelCustom, java.awt.BorderLayout.SOUTH);
|
||||
@@ -1244,10 +1281,22 @@ public class TestingList extends Panel {
|
||||
}//GEN-LAST:event_jMenuLoadCustomPanelMenuSelected
|
||||
|
||||
private void jButtonXActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonXActionPerformed
|
||||
// TODO add your handling code here:
|
||||
|
||||
closeCustomPanel();
|
||||
}//GEN-LAST:event_jButtonXActionPerformed
|
||||
|
||||
private void jLabelCustomPanelNameMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelCustomPanelNameMouseClicked
|
||||
|
||||
if(evt.getButton() == java.awt.event.MouseEvent.BUTTON3){
|
||||
//right mouse click
|
||||
jPopupMenuCustom.show(jLabelCustomPanelName, evt.getX(), evt.getY());
|
||||
}
|
||||
}//GEN-LAST:event_jLabelCustomPanelNameMouseClicked
|
||||
|
||||
private void jMenuItemCustomCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCustomCloseActionPerformed
|
||||
this.closeCustomPanel();
|
||||
}//GEN-LAST:event_jMenuItemCustomCloseActionPerformed
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Witget Variables declaration">
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton jButtonMoveDown;
|
||||
@@ -1262,6 +1311,7 @@ public class TestingList extends Panel {
|
||||
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuShowSelectedTests1;
|
||||
private javax.swing.JLabel jLabelCustomPanelName;
|
||||
private javax.swing.JMenu jMenuAdvanced;
|
||||
private javax.swing.JMenuItem jMenuItemCustomClose;
|
||||
private javax.swing.JMenuItem jMenuItemDeselectSelection;
|
||||
private javax.swing.JMenuItem jMenuItemEditScript;
|
||||
private javax.swing.JMenuItem jMenuItemNewDevice;
|
||||
@@ -1280,9 +1330,11 @@ public class TestingList extends Panel {
|
||||
private javax.swing.JPanel jPanelButtons;
|
||||
private javax.swing.JPanel jPanelCustom;
|
||||
private javax.swing.JPanel jPanelCustomFrame;
|
||||
private javax.swing.JPanel jPanelCustomHeader;
|
||||
private javax.swing.JPanel jPanelSelection;
|
||||
private javax.swing.JPanel jPanelTopCommands;
|
||||
private javax.swing.JPopupMenu jPopupMenuConfigs;
|
||||
private javax.swing.JPopupMenu jPopupMenuCustom;
|
||||
private javax.swing.JPopupMenu jPopupMenuOptions;
|
||||
private javax.swing.JPopupMenu jPopupMenuTable;
|
||||
private javax.swing.JScrollPane jScrollPane2;
|
||||
@@ -1291,7 +1343,7 @@ public class TestingList extends Panel {
|
||||
private javax.swing.JPopupMenu.Separator jSeparator3;
|
||||
private javax.swing.JPopupMenu.Separator jSeparator4;
|
||||
private javax.swing.JPopupMenu.Separator jSeparator5;
|
||||
private javax.swing.JSeparator jSeparator6;
|
||||
private javax.swing.JPopupMenu.Separator jSeparator6;
|
||||
private javax.swing.JTable jTable1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
//</editor-fold>
|
||||
@@ -1533,6 +1585,35 @@ public class TestingList extends Panel {
|
||||
System.out.println("animateCustomPanel(): "+String.valueOf(ex));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Starts animating the custom panel, if present, and only if the whole list of selected tests contains one only device name
|
||||
*
|
||||
* Note: the custom panel must have the public method "animate(String deviceName)"
|
||||
*/
|
||||
public void animateCustomPanel(){
|
||||
//scan the table to see if only one device name is present
|
||||
String sDeviceName = "";
|
||||
String sRowDeviceName = "";
|
||||
boolean bRowTestEnabled = false;
|
||||
for (int row = 0; row < jTable1.getRowCount(); row++) {
|
||||
sRowDeviceName = String.valueOf(jTable1.getValueAt(row, COL.DEVICENAME.ordinal()));
|
||||
bRowTestEnabled = (boolean) jTable1.getValueAt(row, COL.CHECK.ordinal());
|
||||
if(bRowTestEnabled){
|
||||
if(sDeviceName == ""){
|
||||
sDeviceName = sRowDeviceName;
|
||||
} else if(sDeviceName != sRowDeviceName){
|
||||
//there are at least two devices. Cannot animate the custom panel
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
//if only one device name is present in the table, then animate the custom panel with the device
|
||||
if(sDeviceName != ""){
|
||||
animateCustomPanel(sDeviceName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* put the test result in table
|
||||
@@ -1784,6 +1865,7 @@ public class TestingList extends Panel {
|
||||
|
||||
public void run() {
|
||||
// code in the other thread, can reference "var" variable
|
||||
loadCustomPanel(getCustomPanel());
|
||||
executeTest(0);
|
||||
}
|
||||
|
||||
@@ -2478,6 +2560,8 @@ public class TestingList extends Panel {
|
||||
loadTests();
|
||||
//store current file in the properties
|
||||
saveProperties("listFilter", file.getName());
|
||||
//try to animate the custom panel, if the tests list concerns only one device
|
||||
animateCustomPanel();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
SwingUtils.showMessage(this, "loadListFilter()", ex.toString());
|
||||
|
||||
Reference in New Issue
Block a user