From de03e88c8a71b89bcf689a138feafd6960bacda3 Mon Sep 17 00:00:00 2001 From: ebner Date: Wed, 27 Jun 2012 15:18:33 +0200 Subject: [PATCH] Changed Shell Action Panel to support exit value check and exit value. NOTE: the newer versions of netbeans have a strange behavior the Bundles.properties gets generated inside the src/main/java folder but they need to be manually copied to the src/main/resources folder once the form is saved. Otherwise things will crash... --- .../ui/ce/panels/model/ShellActionPanel.form | 64 ++++++++++++++++- .../ui/ce/panels/model/ShellActionPanel.java | 68 ++++++++++++++++++- .../fda/ui/ce/panels/model/Bundle.properties | 6 ++ 3 files changed, 132 insertions(+), 6 deletions(-) diff --git a/fda.ui.ce/src/main/java/ch/psi/fda/ui/ce/panels/model/ShellActionPanel.form b/fda.ui.ce/src/main/java/ch/psi/fda/ui/ce/panels/model/ShellActionPanel.form index 5da2a0c..ebe74aa 100644 --- a/fda.ui.ce/src/main/java/ch/psi/fda/ui/ce/panels/model/ShellActionPanel.form +++ b/fda.ui.ce/src/main/java/ch/psi/fda/ui/ce/panels/model/ShellActionPanel.form @@ -1,4 +1,4 @@ - +
@@ -16,12 +16,28 @@ - + + + + + + + + + + + - + + + + + + + @@ -39,5 +55,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fda.ui.ce/src/main/java/ch/psi/fda/ui/ce/panels/model/ShellActionPanel.java b/fda.ui.ce/src/main/java/ch/psi/fda/ui/ce/panels/model/ShellActionPanel.java index 168d5ab..e64b111 100644 --- a/fda.ui.ce/src/main/java/ch/psi/fda/ui/ce/panels/model/ShellActionPanel.java +++ b/fda.ui.ce/src/main/java/ch/psi/fda/ui/ce/panels/model/ShellActionPanel.java @@ -33,6 +33,8 @@ import java.awt.Component; import java.util.HashMap; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; /** @@ -58,12 +60,16 @@ public class ShellActionPanel extends javax.swing.JPanel implements ObjectProvid HashMap managedFields = new HashMap(); managedFields.put(jTextField1, new ComponentMetadata(true)); + managedFields.put(jCheckBox1, new ComponentMetadata(false)); + managedFields.put(jTextField2, new ComponentMetadata(false, "0")); this.panelSupport = new PanelSupport(); this.panelSupport.analyze(managedFields); // Update view this.jTextField1.setText(action.getCommand()); + this.jCheckBox1.setSelected(action.isCheckExitValue()); + this.jTextField2.setText(""+action.getExitValue()); // Establish bindings jTextField1.getDocument().addDocumentListener(new DocumentAdapter() { @@ -73,9 +79,29 @@ public class ShellActionPanel extends javax.swing.JPanel implements ObjectProvid action.setCommand(panelSupport.getRealFieldValue(jTextField1)); } }); + jCheckBox1.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent ce) { + modified = true; + action.setCheckExitValue(jCheckBox1.isSelected()); + } + }); + jTextField1.getDocument().addDocumentListener(new DocumentAdapter() { + @Override + public void valueChange(DocumentEvent de) { + modified = true; + try{ + action.setExitValue(new Integer(panelSupport.getRealFieldValue(jTextField2))); + } + catch(Exception e){ + jTextField2.setText(""+action.getExitValue()); + } + + } + }); - this.panelSupport.manage(this, managedFields, null); + this.panelSupport.manage(this, managedFields, jButton1); } /** This method is called from within the constructor to @@ -88,26 +114,62 @@ public class ShellActionPanel extends javax.swing.JPanel implements ObjectProvid private void initComponents() { jTextField1 = new javax.swing.JTextField(); + jButton1 = new javax.swing.JButton(); + jCheckBox1 = new javax.swing.JCheckBox(); + jTextField2 = new javax.swing.JTextField(); + jLabel1 = new javax.swing.JLabel(); jTextField1.setText(org.openide.util.NbBundle.getMessage(ShellActionPanel.class, "ShellActionPanel.jTextField1.text")); // NOI18N jTextField1.setToolTipText(org.openide.util.NbBundle.getMessage(ShellActionPanel.class, "ShellActionPanel.jTextField1.toolTipText")); // NOI18N jTextField1.setPreferredSize(new java.awt.Dimension(200, 28)); + jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ch/psi/fda/ui/ce/icons/plus.png"))); // NOI18N + jButton1.setText(org.openide.util.NbBundle.getMessage(ShellActionPanel.class, "ShellActionPanel.jButton1.text_1")); // NOI18N + jButton1.setBorderPainted(false); + jButton1.setContentAreaFilled(false); + + jCheckBox1.setText(org.openide.util.NbBundle.getMessage(ShellActionPanel.class, "ShellActionPanel.jCheckBox1.text")); // NOI18N + jCheckBox1.setName(org.openide.util.NbBundle.getMessage(ShellActionPanel.class, "ShellActionPanel.jCheckBox1.name")); // NOI18N + + jTextField2.setText(org.openide.util.NbBundle.getMessage(ShellActionPanel.class, "ShellActionPanel.jTextField2.text")); // NOI18N + jTextField2.setName(org.openide.util.NbBundle.getMessage(ShellActionPanel.class, "ShellActionPanel.jTextField2.name")); // NOI18N + + jLabel1.setLabelFor(jTextField2); + jLabel1.setText(org.openide.util.NbBundle.getMessage(ShellActionPanel.class, "ShellActionPanel.jLabel1.text")); // NOI18N + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jCheckBox1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton1)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton1) + .addComponent(jCheckBox1) + .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1)) ); }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JCheckBox jCheckBox1; + private javax.swing.JLabel jLabel1; private javax.swing.JTextField jTextField1; + private javax.swing.JTextField jTextField2; // End of variables declaration//GEN-END:variables diff --git a/fda.ui.ce/src/main/resources/ch/psi/fda/ui/ce/panels/model/Bundle.properties b/fda.ui.ce/src/main/resources/ch/psi/fda/ui/ce/panels/model/Bundle.properties index da86d45..5350e1c 100644 --- a/fda.ui.ce/src/main/resources/ch/psi/fda/ui/ce/panels/model/Bundle.properties +++ b/fda.ui.ce/src/main/resources/ch/psi/fda/ui/ce/panels/model/Bundle.properties @@ -260,3 +260,9 @@ LinearPositionerPanel.Asynchronous.text=Asynchronous DiscreteStepPositionerPanel.Asynchronous.text=Asynchronous: DiscreteStepPositionerPanel.jLabel7.text=Type: PseudoPositionerPanel.jLabel7.text=Type: +ShellActionPanel.jButton1.text_1= +ShellActionPanel.jCheckBox1.text=Check ReturnValue +ShellActionPanel.jCheckBox1.name=Check ReturnValue +ShellActionPanel.jTextField2.text= +ShellActionPanel.jLabel1.text=Return Value +ShellActionPanel.jTextField2.name=Return Value