Startup
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
//<editor-fold defaultstate="collapsed" desc="import">
|
||||
|
||||
import ch.psi.pshell.core.Controller;
|
||||
import ch.psi.pshell.core.Context;
|
||||
import ch.psi.pshell.scripting.StatementException;
|
||||
import ch.psi.pshell.security.AccessLevel;
|
||||
import ch.psi.pshell.ui.App;
|
||||
@@ -12,7 +12,6 @@ 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.psaf.Task;
|
||||
import java.awt.Component;
|
||||
import java.awt.Point;
|
||||
import java.io.BufferedReader;
|
||||
@@ -72,12 +71,7 @@ import static org.python.bouncycastle.util.Arrays.append;
|
||||
*/
|
||||
public class TestingList extends Panel {
|
||||
Properties properties = new Properties();
|
||||
Task task = new Task() {
|
||||
@Override
|
||||
protected Object execute() throws Exception {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public TestingList() throws Exception {
|
||||
initialise();
|
||||
@@ -309,7 +303,7 @@ public class TestingList extends Panel {
|
||||
try {
|
||||
loadTests();
|
||||
//if not administrator, then show only enabled tests
|
||||
boolean bShow = Controller.getInstance().getLevel()==AccessLevel.administrator;
|
||||
boolean bShow = getContext().getInstance().getLevel()==AccessLevel.administrator;
|
||||
jCheckBoxMenuShowSelectedTests1.setEnabled(bShow);
|
||||
} catch (Exception ex) {
|
||||
getLogger().severe(ex.getMessage());
|
||||
@@ -540,7 +534,7 @@ public class TestingList extends Panel {
|
||||
|
||||
try {
|
||||
//create a class to visualise the details panel
|
||||
Class panelClass = getController().getClassByName(sPanelClassName);
|
||||
Class panelClass = getContext().getClassByName(sPanelClassName);
|
||||
JPanel detailsPanel = (JPanel) panelClass.getConstructor(new Class[]{String.class}).newInstance(new Object[]{""});
|
||||
this.jPanelCustomFrame.add(detailsPanel);
|
||||
this.jLabelCustomPanelName.setText("Custom panel: "+sPanelClassName);
|
||||
@@ -616,7 +610,7 @@ public class TestingList extends Panel {
|
||||
*/
|
||||
private void log(Object text) {
|
||||
try {
|
||||
getController().getDataManager().appendLog(String.valueOf(text));
|
||||
getContext().getDataManager().appendLog(String.valueOf(text));
|
||||
} catch (Exception ex) {
|
||||
System.out.println("animateCustomPanel(): "+String.valueOf(ex));
|
||||
}
|
||||
@@ -1074,7 +1068,7 @@ public class TestingList extends Panel {
|
||||
//check if pshell is still initialising: if so, don't start the tests
|
||||
try {
|
||||
//invoke python method
|
||||
pshellStatus = eval("controller.state");
|
||||
pshellStatus = eval("get_context().state");
|
||||
if(String.valueOf(pshellStatus)=="Initializing"){
|
||||
bWait = true;
|
||||
}
|
||||
@@ -1091,14 +1085,18 @@ public class TestingList extends Panel {
|
||||
updateStatus();
|
||||
executeTests();
|
||||
} else {
|
||||
setToStopped();
|
||||
try {
|
||||
setToStopped();
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(TestingList.class.getName()).log(Level.WARNING, null, ex);
|
||||
}
|
||||
}
|
||||
}//GEN-LAST:event_jButtonRunActionPerformed
|
||||
|
||||
/**
|
||||
* reaction to Stop
|
||||
*/
|
||||
private void setButtonToStop() {
|
||||
private void setButtonToStop() throws InterruptedException {
|
||||
abort();
|
||||
this.jButtonRun.setToolTipText("Run enabled tests");
|
||||
jButtonRun.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/play-circled-64-000000.png")));
|
||||
@@ -1171,7 +1169,7 @@ public class TestingList extends Panel {
|
||||
jTable1.setRowSelectionInterval(rowAtPoint, rowAtPoint);
|
||||
}
|
||||
//enable jMenuItemShowDetails depending on user privileges
|
||||
this.jMenuItemShowDetails.setEnabled(Controller.getInstance().getLevel()==AccessLevel.administrator);
|
||||
this.jMenuItemShowDetails.setEnabled(Context.getInstance().getLevel()==AccessLevel.administrator);
|
||||
//enable action Show Test Details only if one row is selected
|
||||
this.jMenuItemShowDetails.setEnabled(jTable1.getSelectedRows().length == 1);
|
||||
this.jMenuItemRunSingleTest.setEnabled(jTable1.getSelectedRows().length == 1);
|
||||
@@ -1233,9 +1231,9 @@ public class TestingList extends Panel {
|
||||
|
||||
private void jButtonOptionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOptionsActionPerformed
|
||||
//enable some menu items only for administrator access control level
|
||||
this.jMenuItemEditScript.setEnabled(Controller.getInstance().getLevel()==AccessLevel.administrator);
|
||||
this.jMenuItemNewTest.setEnabled(Controller.getInstance().getLevel()==AccessLevel.administrator);
|
||||
this.jMenuItemNewDevice.setEnabled(Controller.getInstance().getLevel()==AccessLevel.administrator);
|
||||
this.jMenuItemEditScript.setEnabled(Context.getInstance().getLevel()==AccessLevel.administrator);
|
||||
this.jMenuItemNewTest.setEnabled(Context.getInstance().getLevel()==AccessLevel.administrator);
|
||||
this.jMenuItemNewDevice.setEnabled(Context.getInstance().getLevel()==AccessLevel.administrator);
|
||||
jPopupMenuOptions.show(jButtonOptions, 0, jButtonOptions.getHeight());
|
||||
}//GEN-LAST:event_jButtonOptionsActionPerformed
|
||||
|
||||
@@ -1486,7 +1484,7 @@ public class TestingList extends Panel {
|
||||
try {
|
||||
JDialog dlg = new JDialog(getView(), "New "+ type, true);
|
||||
//create a class to visualise the details panel
|
||||
Class testingListDetailsClass = getController().getClassByName("NewTest");
|
||||
Class testingListDetailsClass = getContext().getClassByName("NewTest");
|
||||
JPanel detailsPanel = (JPanel) testingListDetailsClass.getConstructor(new Class[]{String.class}).newInstance(new Object[]{type});
|
||||
dlg.getContentPane().add(detailsPanel);
|
||||
dlg.pack();
|
||||
@@ -1609,7 +1607,7 @@ public class TestingList extends Panel {
|
||||
//open details panel
|
||||
JDialog dlg = new JDialog(getView(), "Test Details - " + sTestName, true);
|
||||
//create a class to visualise the details panel
|
||||
Class testingListDetailsClass = getController().getClassByName("TestingListDetails");
|
||||
Class testingListDetailsClass = getContext().getClassByName("TestingListDetails");
|
||||
JPanel detailsPanel = (JPanel) testingListDetailsClass.getConstructor(new Class[]{HashMap.class}).newInstance(new Object[]{details});
|
||||
|
||||
dlg.getContentPane().add(detailsPanel);
|
||||
@@ -1627,7 +1625,7 @@ public class TestingList extends Panel {
|
||||
|
||||
JDialog dlg = new JDialog(getView(), "Add/remove tests", true);
|
||||
//create a class to visualise the edit panel
|
||||
Class editTestingListClass = getController().getClassByName("EditTestingList");
|
||||
Class editTestingListClass = getContext().getClassByName("EditTestingList");
|
||||
JPanel detailsPanel = (JPanel) editTestingListClass.getConstructor(new Class[]{TableModel.class}).newInstance(jTable1.getModel());
|
||||
|
||||
dlg.getContentPane().add(detailsPanel);
|
||||
@@ -1646,11 +1644,11 @@ public class TestingList extends Panel {
|
||||
* @param status String status returned by the test
|
||||
* @return int index of the row of the device in table
|
||||
*/
|
||||
public int showResult(String deviceName, String testPath, String res, String status) {
|
||||
public int showResult(String deviceName, String testPath, String res, String status) throws InterruptedException {
|
||||
int rowD = -1;
|
||||
testPath = testPath.replace("\\\\", "\\");
|
||||
String sTestName = testPath;
|
||||
//getController().getDataManager().appendLog(str(log));
|
||||
//getContext().getDataManager().appendLog(str(log));
|
||||
|
||||
//System.out.println("Looking for: deviceName: " + deviceName + "; testPath: " + testPath + " in table.");
|
||||
|
||||
@@ -1752,7 +1750,7 @@ public class TestingList extends Panel {
|
||||
/**
|
||||
* set the tests to stopped
|
||||
*/
|
||||
private void setToStopped() {
|
||||
private void setToStopped() throws InterruptedException {
|
||||
//No more tests to play. Stop
|
||||
setButtonToStop();
|
||||
logger.log(Level.INFO, "End of tests.");
|
||||
@@ -1787,7 +1785,7 @@ public class TestingList extends Panel {
|
||||
*
|
||||
* @param resultMessage the message that will be shown as Result of each stopped test
|
||||
*/
|
||||
public void stopAll(String resultMessage){
|
||||
public void stopAll(String resultMessage) throws InterruptedException{
|
||||
setToStopped();
|
||||
String testInProgress[] = getTestInProgress();
|
||||
while(testInProgress[0]!=""){
|
||||
@@ -1888,7 +1886,11 @@ public class TestingList extends Panel {
|
||||
public void run() {
|
||||
// code in the other thread, can reference "var" variable
|
||||
loadCustomPanel(getCustomPanel());
|
||||
executeTest(0);
|
||||
try {
|
||||
executeTest(0);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(TestingList.class.getName()).log(Level.WARNING, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1896,7 +1898,7 @@ public class TestingList extends Panel {
|
||||
*
|
||||
* @param position row number from which to start executing tests
|
||||
*/
|
||||
private void executeTest(int position) {
|
||||
private void executeTest(int position) throws InterruptedException {
|
||||
boolean bSelected = false;
|
||||
String sStartSequence, sStatus;
|
||||
int[] selectedTestsRows = {};
|
||||
@@ -2010,7 +2012,7 @@ public class TestingList extends Panel {
|
||||
* corresponding row
|
||||
* @return return value: 0 means ok, <0 means problem
|
||||
*/
|
||||
private int executeParallelTestsGroup(int[] rowsToExecute) {
|
||||
private int executeParallelTestsGroup(int[] rowsToExecute) throws InterruptedException {
|
||||
int iRet = -1;
|
||||
HashMap args2 = new HashMap(); //this is the global map that will contain one map per test.
|
||||
HashMap testArgs; //this is the map for a test.
|
||||
|
||||
Reference in New Issue
Block a user