You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2018/07/05 20:34:30 UTC

svn commit: r1835187 - in /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui: ProxyControlGui.java RecorderDialog.java

Author: pmouawad
Date: Thu Jul  5 20:34:29 2018
New Revision: 1835187

URL: http://svn.apache.org/viewvc?rev=1835187&view=rev
Log:
Bug 62212 : Recorder : Improve UX by providing a popup above all windows to be able to change Transaction names and pauses while using Browser 

Add a stop button to popup
Make dialog automatically disappear after 7 seconds
Bugzilla Id: 62212

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/RecorderDialog.java

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java?rev=1835187&r1=1835186&r2=1835187&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java Thu Jul  5 20:34:29 2018
@@ -58,6 +58,8 @@ import javax.swing.JScrollPane;
 import javax.swing.JTabbedPane;
 import javax.swing.JTable;
 import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+import javax.swing.Timer;
 
 import org.apache.jmeter.control.Controller;
 import org.apache.jmeter.control.gui.LogicControllerGui;
@@ -424,11 +426,7 @@ public class ProxyControlGui extends Log
         }
 
         if (command.equals(ACTION_STOP)) {
-            model.stopProxy();
-            stop.setEnabled(false);
-            start.setEnabled(true);
-            restart.setEnabled(false);
-            recorderDialog.setVisible(false);
+            stopRecorder();
         } else if (command.equals(ACTION_START)) {
             if(startProxy()) {
                 recorderDialog.setVisible(true);
@@ -473,6 +471,17 @@ public class ProxyControlGui extends Log
     }
 
     /**
+     * 
+     */
+    void stopRecorder() {
+        model.stopProxy();
+        stop.setEnabled(false);
+        start.setEnabled(true);
+        restart.setEnabled(false);
+        recorderDialog.setVisible(false);
+    }
+
+    /**
      * Delete row from table, select one if possible and enable restart button 
      * @param tableModel {@link PowerTableModel} 
      * @param table {@link JTable}
@@ -601,9 +610,14 @@ public class ProxyControlGui extends Log
                     sb.append("<li>").append(detail).append("</li>");
                 }
                 sb.append("</ul>").append("</html>");
-                
+
+                // Make dialog disappear after 7 seconds
+                JLabel messageLabel = new JLabel(sb.toString());
+                Timer timer = new Timer(7000, evt -> SwingUtilities.getWindowAncestor(messageLabel).dispose());
+                timer.setRepeats(false);
+                timer.start();
                 JOptionPane.showMessageDialog(this,
-                    sb.toString(),
+                        messageLabel,
                     JMeterUtils.getResString("proxy_daemon_msg_rootca_cert") + SPACE // $NON-NLS-1$
                     + KeyToolUtils.ROOT_CACERT_CRT_PFX + SPACE
                     + JMeterUtils.getResString("proxy_daemon_msg_created_in_bin"), // $NON-NLS-1$
@@ -741,12 +755,8 @@ public class ProxyControlGui extends Log
         start.setActionCommand(ACTION_START);
         start.setEnabled(true);
         
-        stop = new JButton(JMeterUtils.getResString("stop")); // $NON-NLS-1$
-        ImageIcon stopImage = JMeterUtils.getImage("toolbar/" + iconSize + "/process-stop-4.png");
-        stop.setIcon(stopImage);
+        stop = createStopButton(iconSize);
         stop.addActionListener(this);
-        stop.setActionCommand(ACTION_STOP);
-        stop.setEnabled(false);
 
         ImageIcon restartImage = JMeterUtils.getImage("toolbar/" + iconSize + "/edit-redo-7.png");
         restart = new JButton(JMeterUtils.getResString("restart")); // $NON-NLS-1$
@@ -766,6 +776,18 @@ public class ProxyControlGui extends Log
         return panel;
     }
 
+    /**
+     * @param iconSize
+     */
+    JButton createStopButton(String iconSize) {
+        JButton stop = new JButton(JMeterUtils.getResString("stop")); // $NON-NLS-1$
+        ImageIcon stopImage = JMeterUtils.getImage("toolbar/" + iconSize + "/process-stop-4.png");
+        stop.setIcon(stopImage);
+        stop.setActionCommand(ACTION_STOP);
+        stop.setEnabled(false);
+        return stop;
+    }
+
     private JPanel createPortPanel() {
         portField = new JTextField(ProxyControl.DEFAULT_PORT_S, 20);
         portField.setName(PORT_FIELD_NAME);

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/RecorderDialog.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/RecorderDialog.java?rev=1835187&r1=1835186&r2=1835187&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/RecorderDialog.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/RecorderDialog.java Thu Jul  5 20:34:29 2018
@@ -21,7 +21,9 @@ package org.apache.jmeter.protocol.http.
 import java.awt.BorderLayout;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
+import java.awt.GridLayout;
 import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import java.awt.event.KeyEvent;
@@ -33,6 +35,7 @@ import javax.swing.ActionMap;
 import javax.swing.BorderFactory;
 import javax.swing.DefaultComboBoxModel;
 import javax.swing.InputMap;
+import javax.swing.JButton;
 import javax.swing.JComboBox;
 import javax.swing.JComponent;
 import javax.swing.JDialog;
@@ -44,13 +47,14 @@ import javax.swing.JRootPane;
 import javax.swing.JTextField;
 
 import org.apache.jmeter.gui.action.KeyStrokes;
+import org.apache.jmeter.gui.util.JMeterToolBar;
 import org.apache.jmeter.util.JMeterUtils;
 
 /**
  * Dialog for Recorder
  * @since 4.1
  */
-public class RecorderDialog extends JDialog implements ItemListener, KeyListener { // NOSONAR
+public class RecorderDialog extends JDialog implements ItemListener, KeyListener, ActionListener { // NOSONAR
 
 
     /**
@@ -72,6 +76,8 @@ public class RecorderDialog extends JDia
 
     private ProxyControlGui recorderGui;
 
+    private JButton stop;
+
     /**
      * For tests Only
      */
@@ -157,7 +163,16 @@ public class RecorderDialog extends JDia
         gbc.fill = GridBagConstraints.HORIZONTAL;
         panel.add(proxyPauseHTTPSample, gbc.clone());
 
-        this.getContentPane().add(panel, BorderLayout.NORTH);
+        this.getContentPane().add(panel, BorderLayout.CENTER);
+        
+        String iconSize = JMeterUtils.getPropDefault(JMeterToolBar.TOOLBAR_ICON_SIZE, JMeterToolBar.DEFAULT_TOOLBAR_ICON_SIZE); 
+        stop = recorderGui.createStopButton(iconSize);
+        stop.addActionListener(this);
+
+        GridLayout gridLayout = new GridLayout(1, 1);
+        JPanel panelStop = new JPanel(gridLayout);
+        panelStop.add(stop);
+        this.getContentPane().add(panelStop, BorderLayout.WEST);
         this.pack();
         this.setLocation(5, 10);
         prefixHTTPSampleName.requestFocusInWindow();
@@ -169,6 +184,7 @@ public class RecorderDialog extends JDia
     @Override
     public void setVisible(boolean b) {
         super.setVisible(b);
+        stop.setEnabled(true);
         prefixHTTPSampleName.requestFocusInWindow();
         prefixHTTPSampleName.setText(recorderGui.getPrefixHTTPSampleName());
         httpSampleNamingMode.setSelectedIndex(recorderGui.getHTTPSampleNamingMode());
@@ -224,4 +240,8 @@ public class RecorderDialog extends JDia
             recorderGui.enableRestart();
         }
     }
+    @Override
+    public void actionPerformed(ActionEvent event) {
+        recorderGui.stopRecorder();
+    }
 }