This is an automated email from the ASF dual-hosted git repository.

pmouawad pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new f8c73d5  Bug 64280 IfController: Improve UX
f8c73d5 is described below

commit f8c73d5c64b6a8ac162749e97fb3f43ee8a07314
Author: pmouawad <p.moua...@ubik-ingenierie.com>
AuthorDate: Sun Mar 29 13:20:12 2020 +0200

    Bug 64280 IfController: Improve UX
---
 .../jmeter/control/gui/IfControllerPanel.java      | 63 +++++++++++++++-------
 .../apache/jmeter/resources/messages.properties    |  4 +-
 .../apache/jmeter/resources/messages_fr.properties |  4 +-
 xdocs/changes.xml                                  |  3 +-
 4 files changed, 52 insertions(+), 22 deletions(-)

diff --git 
a/src/core/src/main/java/org/apache/jmeter/control/gui/IfControllerPanel.java 
b/src/core/src/main/java/org/apache/jmeter/control/gui/IfControllerPanel.java
index c2a2f91..f064887 100644
--- 
a/src/core/src/main/java/org/apache/jmeter/control/gui/IfControllerPanel.java
+++ 
b/src/core/src/main/java/org/apache/jmeter/control/gui/IfControllerPanel.java
@@ -18,8 +18,12 @@
 package org.apache.jmeter.control.gui;
 
 import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 
+import javax.swing.BorderFactory;
 import javax.swing.ImageIcon;
+import javax.swing.JButton;
 import javax.swing.JCheckBox;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
@@ -38,6 +42,8 @@ import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jorphan.gui.JFactory;
 import org.apache.jorphan.gui.JMeterUIDefaults;
 
+import net.miginfocom.swing.MigLayout;
+
 /**
  * The user interface for a controller which specifies that its subcomponents
  * should be executed while a condition holds. This component can be used
@@ -46,10 +52,12 @@ import org.apache.jorphan.gui.JMeterUIDefaults;
  */
 @GUIMenuSortOrder(1)
 @TestElementMetadata(labelResource = "if_controller_title")
-public class IfControllerPanel extends AbstractControllerGui implements 
ChangeListener {
+public class IfControllerPanel extends AbstractControllerGui implements 
ChangeListener, ActionListener {
 
     private static final long serialVersionUID = 240L;
 
+    private static final String USE_LAST_SAMPLE_OK = "use_last_sample_ok";
+
     /**
      * Used to warn about performance penalty
      */
@@ -73,6 +81,8 @@ public class IfControllerPanel extends AbstractControllerGui 
implements ChangeLi
      */
     private boolean displayName = true;
 
+    private JButton useLastSampleStatusButton;
+
     /**
      * Create a new LoopControlPanel as a standalone component.
      */
@@ -165,11 +175,7 @@ public class IfControllerPanel extends 
AbstractControllerGui implements ChangeLi
             setLayout(new BorderLayout(0, 5));
             setBorder(makeBorder());
             add(makeTitlePanel(), BorderLayout.NORTH);
-
-            JPanel mainPanel = new JPanel(new BorderLayout());
-            mainPanel.add(createConditionPanel(), BorderLayout.NORTH);
-            add(mainPanel, BorderLayout.CENTER);
-
+            add(createConditionPanel(), BorderLayout.CENTER);
         } else {
             // Embedded
             setLayout(new BorderLayout());
@@ -183,35 +189,40 @@ public class IfControllerPanel extends 
AbstractControllerGui implements ChangeLi
      * @return a GUI panel containing the condition components
      */
     private JPanel createConditionPanel() {
-        JPanel conditionPanel = new JPanel(new BorderLayout(5, 0));
+        JPanel conditionPanel = new JPanel(new MigLayout("fillx, wrap 2", 
"[][fill,grow]"));
+        conditionPanel.setBorder(BorderFactory.createEtchedBorder()); // 
$NON-NLS-1$
 
-        // Condition LABEL
-        conditionLabel = new 
JLabel(JMeterUtils.getResString("if_controller_label")); // $NON-NLS-1$
-        conditionPanel.add(conditionLabel, BorderLayout.WEST);
         ImageIcon image = JMeterUtils.getImage("warning.png");
-        warningLabel = new 
JLabel(JMeterUtils.getResString("if_controller_warning"), image, 
SwingConstants.CENTER); // $NON-NLS-1$
+        warningLabel = new 
JLabel(JMeterUtils.getResString("if_controller_warning"), image, 
SwingConstants.LEFT); // $NON-NLS-1$
         JFactory.warning(warningLabel);
+        conditionPanel.add(warningLabel, "span 2");
+
+        // Condition LABEL
+        conditionLabel = new 
JLabel(JMeterUtils.getResString("if_controller_label")); // $NON-NLS-1$
+        conditionPanel.add(conditionLabel);
+        conditionLabel.setName("if_controller_label");
 
         // Condition
         theCondition = JSyntaxTextArea.getInstance(5, 50); // $NON-NLS-1$
         conditionLabel.setLabelFor(theCondition);
-        conditionPanel.add(JTextScrollPane.getInstance(theCondition), 
BorderLayout.CENTER);
-
-        conditionPanel.add(warningLabel, BorderLayout.NORTH);
-
+        conditionPanel.add(JTextScrollPane.getInstance(theCondition));
 
-        JPanel optionPanel = new JPanel();
+        JLabel ifControllerTipLabel = new 
JLabel(JMeterUtils.getResString("if_controller_tip"));
+        useLastSampleStatusButton = new 
JButton(JMeterUtils.getResString("if_controller_use_last_sample_ok"));
+        useLastSampleStatusButton.setActionCommand(USE_LAST_SAMPLE_OK);
+        useLastSampleStatusButton.addActionListener(this);
+        conditionPanel.add(useLastSampleStatusButton);
+        conditionPanel.add(ifControllerTipLabel);
 
         // Use expression instead of Javascript
         useExpression = new 
JCheckBox(JMeterUtils.getResString("if_controller_expression")); // $NON-NLS-1$
         useExpression.addChangeListener(this);
-        optionPanel.add(useExpression);
+        conditionPanel.add(useExpression, "span 2");
 
         // Evaluate All checkbox
         evaluateAll = new 
JCheckBox(JMeterUtils.getResString("if_controller_evaluate_all")); // 
$NON-NLS-1$
-        optionPanel.add(evaluateAll);
+        conditionPanel.add(evaluateAll, "span 2");
 
-        conditionPanel.add(optionPanel,BorderLayout.SOUTH);
         return conditionPanel;
     }
 
@@ -222,11 +233,25 @@ public class IfControllerPanel extends 
AbstractControllerGui implements ChangeLi
             if(useExpression.isSelected()) {
                 colorId = JMeterUIDefaults.LABEL_WARNING_FOREGROUND;
                 
conditionLabel.setText(JMeterUtils.getResString("if_controller_expression_label"));
+                useLastSampleStatusButton.setEnabled(true);
             } else {
                 colorId = JMeterUIDefaults.LABEL_ERROR_FOREGROUND;
                 
conditionLabel.setText(JMeterUtils.getResString("if_controller_label"));
+                useLastSampleStatusButton.setEnabled(false);
             }
             warningLabel.setForeground(UIManager.getColor(colorId));
         }
     }
+
+    /**
+     * Fill theCondition 
+     * @param e {@link ActionEvent}
+     */
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        String action = e.getActionCommand();
+        if (action.equals(USE_LAST_SAMPLE_OK)) {
+            
theCondition.setText(theCondition.getText()+"${JMeterThread.last_sample_ok}");
+        }
+    }
 }
diff --git 
a/src/core/src/main/resources/org/apache/jmeter/resources/messages.properties 
b/src/core/src/main/resources/org/apache/jmeter/resources/messages.properties
index 4e997ea..847188e 100644
--- 
a/src/core/src/main/resources/org/apache/jmeter/resources/messages.properties
+++ 
b/src/core/src/main/resources/org/apache/jmeter/resources/messages.properties
@@ -479,8 +479,10 @@ if_controller_evaluate_all=Evaluate for all children?
 if_controller_expression=Interpret Condition as Variable Expression?
 if_controller_expression_label=Expression (must evaluate to true or false)
 if_controller_label=Condition (evaluated with javascript)
+if_controller_use_last_sample_ok=Use status of last sample
+if_controller_tip=${JMeterThread.last_sample_ok} can be used to test if last 
sampler was successful
 if_controller_title=If Controller
-if_controller_warning=<html>For performance it is advised to check "Interpret 
Condition as Variable Expression"<br> and use __jexl3 or __groovy evaluating to 
true or false or a variable that contains true or false.<br> 
${JMeterThread.last_sample_ok} can be used to test if last sampler was 
successful<br></html>
+if_controller_warning=<html>For performance it is advised to check "Interpret 
Condition as Variable Expression"<br> and use __jexl3 or __groovy evaluating to 
true or false or a variable that contains true or false.</html>
 ignore_subcontrollers=Ignore sub-controller blocks
 include_controller=Include Controller
 include_equals=Include Equals?
diff --git 
a/src/core/src/main/resources/org/apache/jmeter/resources/messages_fr.properties
 
b/src/core/src/main/resources/org/apache/jmeter/resources/messages_fr.properties
index 35ccb5f..5bf1b41 100644
--- 
a/src/core/src/main/resources/org/apache/jmeter/resources/messages_fr.properties
+++ 
b/src/core/src/main/resources/org/apache/jmeter/resources/messages_fr.properties
@@ -473,8 +473,10 @@ if_controller_evaluate_all=Evaluer pour tous les fils ?
 if_controller_expression=Interpréter la condition comme une expression
 if_controller_expression_label=Expression (doit contenir true ou false)
 if_controller_label=Condition (évalué en Javascript) \:
+if_controller_tip=${JMeterThread.last_sample_ok} permet de tester si le 
dernier  échantillon a réussi
 if_controller_title=Contrôleur Si (If)
-if_controller_warning=<html>Pour les performances il est conseillé de cocher  
"Interpréter la condition comme une expression"<br> et d'' utiliser __jexl3 ou 
__groovy ou une variable contenant true ou false.<br> 
${JMeterThread.last_sample_ok} peut être utilisé pour tester si le dernier 
sampler a réussi<br></html>
+if_controller_use_last_sample_ok=Utiliser statut du dernier échantillon
+if_controller_warning=<html>Pour les performances il est conseillé de cocher  
"Interpréter la condition comme une expression"<br> et d'' utiliser __jexl3 ou 
__groovy ou une variable contenant true ou false.</html>
 ignore_subcontrollers=Ignorer les sous-blocs de contrôleurs
 include_controller=Contrôleur Inclusion
 include_equals=Inclure égal ?
diff --git a/xdocs/changes.xml b/xdocs/changes.xml
index f652130..b42b7d2 100644
--- a/xdocs/changes.xml
+++ b/xdocs/changes.xml
@@ -117,6 +117,8 @@ For instance: log viewer, JSR223 code editor were not 
previously scaled with zoo
 
 <h3>Controllers</h3>
 <ul>
+    <li><bug>64277</bug>ForEach Controller: Improve UX</li>
+    <li><bug>64280</bug>If Controller: Improve UX</li>
 </ul>
 
 <h3>Listeners</h3>
@@ -152,7 +154,6 @@ For instance: log viewer, JSR223 code editor were not 
previously scaled with zoo
   <li><bug>64148</bug>Use gray icons for disabled elements in the tree, 
display subtree as gray</li>
   <li><bug>64198</bug>Allow spaces in <code>${...}</code> expressions around 
functions.</li>
   <li><bug>64276</bug>Search popup: Improve UX</li>
-  <li><bug>64277</bug>ForEach Controller: Improve UX</li>
 </ul>
 
 <ch_section>Non-functional changes</ch_section>

Reply via email to