Startup
This commit is contained in:
@@ -11,7 +11,9 @@ import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.pshell.ui.Plugin;
|
||||
import ch.psi.pshell.ui.View;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
import ch.psi.utils.swing.SwingUtils.OptionType;
|
||||
import ch.psi.wsaf.Task;
|
||||
import java.awt.Component;
|
||||
import java.awt.Point;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@@ -34,6 +36,7 @@ import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
@@ -299,8 +302,7 @@ public class TestingList extends Panel {
|
||||
* initialise panel
|
||||
*/
|
||||
private void initialise(){
|
||||
initComponents();
|
||||
//closeCustomPanel();
|
||||
initComponents();
|
||||
initLogger();
|
||||
buildTable();
|
||||
|
||||
@@ -441,6 +443,21 @@ public class TestingList extends Panel {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the presently active custom panel
|
||||
*
|
||||
* @return custom panel as component
|
||||
*/
|
||||
private Component getCustomPanel(){
|
||||
Component customPanel = null;
|
||||
if(this.jPanelCustomFrame.getComponentCount() >0){
|
||||
Component components[] = this.jPanelCustomFrame.getComponents();
|
||||
//there is only one component
|
||||
customPanel = components[0];
|
||||
}
|
||||
return customPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* add custom panel if specified.
|
||||
* Custom panels are java classes. To add a new custom panel MyNewPanel:
|
||||
@@ -453,15 +470,51 @@ public class TestingList extends Panel {
|
||||
*/
|
||||
private void loadCustomPanel(String sPanelClassName){
|
||||
closeCustomPanel();
|
||||
if (sPanelClassName == null || sPanelClassName == "") {
|
||||
if (sPanelClassName == null || sPanelClassName.trim() == "" || sPanelClassName.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//if a custom panel is shown, the tests cannot be run in parallel,
|
||||
//they can only be run in series (one after the other).
|
||||
boolean changeSequenceToAfter = true;// = SwingUtils.OptionResult.No;
|
||||
for (int row = 0; row < jTable1.getRowCount(); row++) {
|
||||
try{
|
||||
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);
|
||||
if(ret == SwingUtils.OptionResult.Yes){
|
||||
changeSequenceToAfter = true ;
|
||||
} else {
|
||||
changeSequenceToAfter = false ;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (NullPointerException ex){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//Set all active tests sequence to "After previous"
|
||||
if(changeSequenceToAfter ){
|
||||
for (int row = 0; row < jTable1.getRowCount(); row++) {
|
||||
boolean bSelected = (boolean) jTable1.getValueAt(row, COL.CHECK.ordinal());
|
||||
if(bSelected){
|
||||
jTable1.setValueAt(StartSequence.AFTER.toString(), row, COL.STARTSEQUENCE.ordinal());
|
||||
}
|
||||
}
|
||||
} else { //user does not wat to change running sequence from parallel to sequential
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
//create a class to visualise the details panel
|
||||
Class panelClass = getController().getClassByName(sPanelClassName);
|
||||
JPanel detailsPanel = (JPanel) panelClass.getConstructor(new Class[]{String.class}).newInstance(new Object[]{""});
|
||||
this.jPanelCustomFrame.add(detailsPanel);
|
||||
this.jLabelCustomPanelName.setText(sPanelClassName);
|
||||
this.jLabelCustomPanelName.setText("Custom panel: "+sPanelClassName);
|
||||
repaint();
|
||||
revalidate();
|
||||
//store custom panel in the properties
|
||||
@@ -483,6 +536,8 @@ public class TestingList extends Panel {
|
||||
Logger.getLogger(TestingList.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* write info into a log file
|
||||
* @param text the info to be logged
|
||||
@@ -1270,6 +1325,7 @@ public class TestingList extends Panel {
|
||||
//if only enabled tests are visible, disable the move buttons
|
||||
this.jButtonMoveUp.setEnabled(!show);
|
||||
this.jButtonMoveDown.setEnabled(!show);
|
||||
//check related checkboxes
|
||||
jCheckBoxMenuShowSelectedTests.setSelected(show);
|
||||
jCheckBoxMenuShowSelectedTests1.setSelected(show);
|
||||
}
|
||||
@@ -1348,6 +1404,7 @@ public class TestingList extends Panel {
|
||||
|
||||
/**
|
||||
* move selected rows up in table
|
||||
*
|
||||
*/
|
||||
private void moveUp() {
|
||||
DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
|
||||
@@ -1443,6 +1500,39 @@ public class TestingList extends Panel {
|
||||
dlg.pack();
|
||||
dlg.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts animating the custom panel, if present
|
||||
*
|
||||
* Note: the custom panel must have the public method "animate(String deviceName)"
|
||||
*
|
||||
* @param deviceName name of the device. The panel should then append the epics PV to the device name for caget/caset
|
||||
*/
|
||||
public void animateCustomPanel(String deviceName) {
|
||||
try {
|
||||
Component customPanel = getCustomPanel();
|
||||
//if no custom panel: nothing to do
|
||||
if(customPanel==null) return;
|
||||
//call the method "animate" of the custom panel (this function must be there)
|
||||
Class[] cArg = new Class[1];
|
||||
cArg[0] = String.class;
|
||||
Method animate = customPanel.getClass().getMethod("animate", cArg);
|
||||
System.out.println("method = " + animate.toString());
|
||||
animate.invoke(customPanel, deviceName);
|
||||
} catch (NoSuchMethodException ex) {
|
||||
System.out.println("animateCustomPanel(): "+String.valueOf(ex));
|
||||
} catch (SecurityException ex) {
|
||||
System.out.println("animateCustomPanel(): "+String.valueOf(ex));
|
||||
} catch (IllegalAccessException ex) {
|
||||
System.out.println("animateCustomPanel(): "+String.valueOf(ex));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
System.out.println("animateCustomPanel(): "+String.valueOf(ex));
|
||||
} catch (InvocationTargetException ex) {
|
||||
System.out.println("animateCustomPanel(): "+String.valueOf(ex));
|
||||
} catch (Exception ex){
|
||||
System.out.println("animateCustomPanel(): "+String.valueOf(ex));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* put the test result in table
|
||||
@@ -1708,7 +1798,7 @@ public class TestingList extends Panel {
|
||||
int[] selectedTestsRows = {};
|
||||
//scan through the table starting from 'position' and execute the first selected test found
|
||||
int row = 0;// position;
|
||||
if (row >= 0 && row < jTable1.getRowCount()) {
|
||||
if (row < jTable1.getRowCount()) {
|
||||
for (row = position; row < jTable1.getRowCount(); row++) {
|
||||
bSelected = (boolean) jTable1.getValueAt(row, COL.CHECK.ordinal());
|
||||
sStartSequence = jTable1.getValueAt(row, COL.STARTSEQUENCE.ordinal()).toString();
|
||||
@@ -1765,7 +1855,7 @@ public class TestingList extends Panel {
|
||||
testArgs.put(testArgNames.STATUS.toString(), false);
|
||||
|
||||
return testArgs;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* convert HashMap string separators to python dictionary string
|
||||
@@ -1871,7 +1961,7 @@ public class TestingList extends Panel {
|
||||
int i = 0;
|
||||
int iTotalEntries = hTests.entrySet().size();
|
||||
HashMap args = new HashMap();
|
||||
System.out.println("hTests: "+hTests.entrySet().toString());
|
||||
//System.out.println("hTests: "+hTests.entrySet().toString());
|
||||
if(hTests.isEmpty()) return iRet;
|
||||
for (Map.Entry<String, HashMap> hTest : hTests.entrySet()) {
|
||||
sTestPath = (String) hTest.getValue().get(testArgNames.TEST_PATH.toString());
|
||||
@@ -1889,7 +1979,10 @@ public class TestingList extends Panel {
|
||||
sParallelizeCommand = sParallelizeCommand + ")))"; //very last part of command "parallelize"
|
||||
}
|
||||
}
|
||||
System.out.println(sParallelizeCommand);
|
||||
//animate the custom panel (if present)
|
||||
animateCustomPanel(sDeviceName);
|
||||
//System.out.println(sParallelizeCommand);
|
||||
//run test(s)
|
||||
Object ret = eval(sParallelizeCommand);
|
||||
System.out.println(ret);
|
||||
String sTestResult, sTestStatus;
|
||||
@@ -1986,6 +2079,10 @@ public class TestingList extends Panel {
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* hide a specific column
|
||||
* @param column column to hide
|
||||
*/
|
||||
private void hideColumn(COL column) {
|
||||
jTable1.getColumnModel().getColumn(column.ordinal()).setMinWidth(0);
|
||||
jTable1.getColumnModel().getColumn(column.ordinal()).setMaxWidth(0);
|
||||
|
||||
Reference in New Issue
Block a user