Update
This commit is contained in:
@@ -2,9 +2,13 @@
|
||||
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
|
||||
*/
|
||||
|
||||
import ch.psi.pshell.core.Context;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.utils.State;
|
||||
import java.awt.Component;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JButton;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -35,6 +39,7 @@ public class PanelPlugin extends Panel {
|
||||
public void setEnabled(boolean value) {
|
||||
super.setEnabled(value);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
@@ -49,6 +54,8 @@ public class PanelPlugin extends Panel {
|
||||
jSpinner3 = new javax.swing.JSpinner();
|
||||
jRadioButton1 = new javax.swing.JRadioButton();
|
||||
jRadioButton2 = new javax.swing.JRadioButton();
|
||||
buttonExecShellCmd = new javax.swing.JButton();
|
||||
jButton2 = new javax.swing.JButton();
|
||||
|
||||
motorPanel2.setDeviceName("m1");
|
||||
|
||||
@@ -74,6 +81,15 @@ public class PanelPlugin extends Panel {
|
||||
buttonGroup1.add(jRadioButton2);
|
||||
jRadioButton2.setText("jRadioButton2");
|
||||
|
||||
buttonExecShellCmd.setText("Exec Async");
|
||||
buttonExecShellCmd.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonExecShellCmdActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jButton2.setText("Exec Sync");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
@@ -97,7 +113,13 @@ public class PanelPlugin extends Panel {
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jRadioButton2)
|
||||
.addComponent(jRadioButton1))))
|
||||
.addContainerGap(12, Short.MAX_VALUE))
|
||||
.addContainerGap(168, Short.MAX_VALUE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jButton2)
|
||||
.addComponent(buttonExecShellCmd))
|
||||
.addGap(225, 225, 225))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@@ -118,12 +140,39 @@ public class PanelPlugin extends Panel {
|
||||
.addComponent(jRadioButton1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jRadioButton2)
|
||||
.addContainerGap(62, Short.MAX_VALUE))
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(buttonExecShellCmd)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(jButton2)
|
||||
.addContainerGap(35, Short.MAX_VALUE))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void buttonExecShellCmdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExecShellCmdActionPerformed
|
||||
try {
|
||||
String shellCommand="sleep 5; uname";
|
||||
boolean background = false;
|
||||
|
||||
evalAsync("exec_cmd('" + shellCommand + "')", background).handle((ret,ex)->{
|
||||
((JButton)evt.getSource()).setEnabled(true);
|
||||
if (ex!=null){
|
||||
showException((Exception)ex);
|
||||
} else {
|
||||
getContext().scriptingLog(String.format("Shell command '%s' return value: %s", shellCommand, String.valueOf(ret)));
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
|
||||
((JButton)evt.getSource()).setEnabled(false);
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonExecShellCmdActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton buttonExecShellCmd;
|
||||
private javax.swing.ButtonGroup buttonGroup1;
|
||||
private javax.swing.JButton jButton2;
|
||||
private javax.swing.JRadioButton jRadioButton1;
|
||||
private javax.swing.JRadioButton jRadioButton2;
|
||||
private javax.swing.JSpinner jSpinner1;
|
||||
|
||||
Reference in New Issue
Block a user