jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject [jmeter] 02/02: Bug 64278 - Timers (Gaussian, Poisson, Uniform): Improve UX
Date Sat, 28 Mar 2020 23:34:18 GMT
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

commit bcba6b0e91eb74fd857ede68751552b6d4238c89
Author: pmouawad <p.mouawad@ubik-ingenierie.com>
AuthorDate: Sun Mar 29 00:33:58 2020 +0100

    Bug 64278 - Timers (Gaussian, Poisson, Uniform): Improve UX
---
 .../jmeter/timers/gui/AbstractRandomTimerGui.java  | 30 +++++-----------------
 .../java/org/apache/jmeter/util/JMeterUtils.java   | 14 ++++++++++
 2 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/src/components/src/main/java/org/apache/jmeter/timers/gui/AbstractRandomTimerGui.java
b/src/components/src/main/java/org/apache/jmeter/timers/gui/AbstractRandomTimerGui.java
index 6a1405e..dba9d6c 100644
--- a/src/components/src/main/java/org/apache/jmeter/timers/gui/AbstractRandomTimerGui.java
+++ b/src/components/src/main/java/org/apache/jmeter/timers/gui/AbstractRandomTimerGui.java
@@ -17,12 +17,8 @@
 
 package org.apache.jmeter.timers.gui;
 
-import java.awt.Dimension;
-
 import javax.swing.BorderFactory;
-import javax.swing.Box;
 import javax.swing.JComponent;
-import javax.swing.JLabel;
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JTextField;
@@ -33,6 +29,8 @@ import org.apache.jmeter.timers.RandomTimer;
 import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jorphan.gui.layout.VerticalLayout;
 
+import net.miginfocom.swing.MigLayout;
+
 /**
  * Abstract Random timer GUI.
  *
@@ -117,36 +115,22 @@ public abstract class AbstractRandomTimerGui extends AbstractTimerGui
{
 
         add(makeTitlePanel());
 
-        JPanel threadDelayPropsPanel = new JPanel();
-        threadDelayPropsPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
+        JPanel threadDelayPropsPanel = new JPanel(new MigLayout("fillx, wrap 2", "[][fill,grow]"));
         threadDelayPropsPanel.setBorder(BorderFactory.createTitledBorder(
                 JMeterUtils.getResString("thread_delay_properties")));//$NON-NLS-1$
 
         // DELAY DEVIATION
-        Box delayDevPanel = Box.createHorizontalBox();
-        delayDevPanel.add(new JLabel(getTimerRangeLabelKey()));//$NON-NLS-1$
-        delayDevPanel.add(Box.createHorizontalStrut(5));
-
         rangeField = new JTextField(20);
         rangeField.setText(getDefaultRange());
-        rangeField.setName(RANGE_FIELD);
-        delayDevPanel.add(rangeField);
-
-        threadDelayPropsPanel.add(delayDevPanel);
+        threadDelayPropsPanel.add(JMeterUtils.labelFor(rangeField, getTimerRangeLabelKey(),
RANGE_FIELD));
+        threadDelayPropsPanel.add(rangeField);
 
         // AVG DELAY
-        Box avgDelayPanel = Box.createHorizontalBox();
-        avgDelayPanel.add(new JLabel(getTimerDelayLabelKey()));//$NON-NLS-1$
-        avgDelayPanel.add(Box.createHorizontalStrut(5));
-
         delayField = new JTextField(20);
         delayField.setText(getDefaultDelay());
-        delayField.setName(DELAY_FIELD);
-        avgDelayPanel.add(delayField);
+        threadDelayPropsPanel.add(JMeterUtils.labelFor(delayField, getTimerDelayLabelKey(),
DELAY_FIELD));
+        threadDelayPropsPanel.add(delayField);
 
-        threadDelayPropsPanel.add(avgDelayPanel);
-        threadDelayPropsPanel.setMaximumSize(new Dimension(threadDelayPropsPanel.getMaximumSize().width,
-                threadDelayPropsPanel.getPreferredSize().height));
         add(threadDelayPropsPanel);
     }
 
diff --git a/src/core/src/main/java/org/apache/jmeter/util/JMeterUtils.java b/src/core/src/main/java/org/apache/jmeter/util/JMeterUtils.java
index b6706b6..fc9d021 100644
--- a/src/core/src/main/java/org/apache/jmeter/util/JMeterUtils.java
+++ b/src/core/src/main/java/org/apache/jmeter/util/JMeterUtils.java
@@ -924,6 +924,20 @@ public class JMeterUtils implements UnitTestManager {
     }
 
     /**
+     * Creates {@link JLabel} that is associated with a given {@link Component} instance.
+     * @param component component for the label
+     * @param labelValue label text
+     * @param name JLabel name
+     * @return JLabel instance
+     */
+    public static JLabel labelFor(Component component, String labelValue, String name) {
+        JLabel label = new JLabel(labelValue);
+        label.setName(name);
+        label.setLabelFor(component);
+        return label;
+    }
+
+    /**
      * Takes an array of strings and a tokenizer character, and returns a string
      * of all the strings concatenated with the tokenizer string in between each
      * one.


Mime
View raw message