import ch.psi.pshell.framework.Context; import ch.psi.pshell.framework.Panel; import javax.swing.JButton; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author gac-x11ma */ public class Initialization extends Panel { /** * Creates new form Initialization */ public Initialization() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ // //GEN-BEGIN:initComponents private void initComponents() { buttonExecShellCmd = new javax.swing.JButton(); buttonExecShellCmd.setText("Init"); buttonExecShellCmd.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { buttonExecShellCmdActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(49, 49, 49) .addComponent(buttonExecShellCmd, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(100, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(30, 30, 30) .addComponent(buttonExecShellCmd) .addContainerGap(243, Short.MAX_VALUE)) ); }// //GEN-END:initComponents private void buttonExecShellCmdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExecShellCmdActionPerformed try { String shellCommand = "exec_cmd(\"ls\")"; boolean background = false; evalAsync(shellCommand, background).handle((ret, ex) -> { ((JButton) evt.getSource()).setEnabled(true); if (ex != null) { showException((Exception) ex); } else { Context.getInterpreter().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; // End of variables declaration//GEN-END:variables }