diff --git a/plugins/TestingList.java b/plugins/TestingList.java index b2fcb76..81a3575 100644 --- a/plugins/TestingList.java +++ b/plugins/TestingList.java @@ -27,10 +27,6 @@ import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.table.DefaultTableModel; - -/** - * - */ public class TestingList extends Panel { Task task = new Task() { @@ -40,19 +36,47 @@ public class TestingList extends Panel { return true; } }; + @Override protected JPanel create() { return new NetbeansPluginPanel(); } + //listen to script end of execution and get return value + @Override + protected void onExecutedFile(String fileName) { + try { + switch(fileName){ + case "power-supply": + Object ret = eval("ret"); + if (ret != null) { + SwingUtils.showMessage(getComponent(), "", ret.toString() + " - " + ret.getClass().getName()); + //showResult(ret.toString()); + } + break; + } + } + catch (Exception ex) { + SwingUtils.showException(getComponent(), ex); + } + } + + + + + public class NetbeansPluginPanel extends MonitoredPanel { public NetbeansPluginPanel() { - initComponents(); - buildGUI(); - hookUpEvents(); + initComponents(); + buildTable(); } @SuppressWarnings("unchecked") + + public void showResult(String res){ + txtOutput.setText(res); + } + // //GEN-BEGIN:initComponents private void initComponents() { @@ -141,50 +165,7 @@ public class TestingList extends Panel { DefaultTableModel model = new DefaultTableModel(data, columnNames); - } - - - //dynamically added checkbboxes - JButton remove; - JButton appear; - JCheckBox cb[]=new JCheckBox[10]; - - public void buildGUI() { - JFrame fr=new JFrame(); - JPanel p=new JPanel(); - remove=new JButton("remove"); - appear=new JButton("appear"); - for(int i=0;i<10;i++) { - cb[i]=new JCheckBox("checkbox:"+i); - cb[i].setVisible(false); - } - fr.add(p); - p.add(remove); - p.add(appear); - for(int i=0;i<10;i++) { - p.add(cb[i]); - } - fr.setVisible(true); - fr.setSize(400,400); - } - - public void hookUpEvents() { - remove.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent ae) { - for(int i=0;i<10;i++) { - cb[i].setVisible(false); - } - } - }); - - appear.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent ae) { - for(int i=0;i<10;i++) { - cb[i].setVisible(true); - } - } - }); - } + } } } diff --git a/plugins/TestingPanel.java b/plugins/TestingPanel.java index fc3cf8d..b371d8b 100644 --- a/plugins/TestingPanel.java +++ b/plugins/TestingPanel.java @@ -59,6 +59,8 @@ public class TestingPanel extends Panel { motorPanel.setDevice(motor); } + //listen to script end of execution and get return value + @Override protected void onExecutedFile(String fileName) { try { switch(fileName){ @@ -353,10 +355,7 @@ public class TestingPanel extends Panel { args.put("relative", var1); args.put("steps", var2); run("power-supply", args); - Object ret = eval("ret"); - //try to print the result - txtTestPSRes.setText(ret.toString()); - + //evalAsync("run('args', locals = {'relative':" + (var1 ? "True" :"False") + ", 'steps':" + var2 + "})");