jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vladimirsitni...@apache.org
Subject [jmeter] branch master updated: Fix context menu UX: show it on right-click no matter what was the selection
Date Sun, 15 Mar 2020 20:46:07 GMT
This is an automated email from the ASF dual-hosted git repository.

vladimirsitnikov 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 8eec476  Fix context menu UX: show it on right-click no matter what was the selection
8eec476 is described below

commit 8eec476532f4c2d754e853b8c5b38bb81e229616
Author: Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
AuthorDate: Sun Mar 15 23:40:41 2020 +0300

    Fix context menu UX: show it on right-click no matter what was the selection
    
    Previously popup menu was not shown if the tree node was not selected.
---
 src/core/src/main/java/org/apache/jmeter/gui/GuiPackage.java      | 5 ++---
 .../main/java/org/apache/jmeter/gui/tree/JMeterTreeListener.java  | 8 ++++++--
 xdocs/changes.xml                                                 | 3 +++
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/core/src/main/java/org/apache/jmeter/gui/GuiPackage.java b/src/core/src/main/java/org/apache/jmeter/gui/GuiPackage.java
index 847bb80..8cc80d9 100644
--- a/src/core/src/main/java/org/apache/jmeter/gui/GuiPackage.java
+++ b/src/core/src/main/java/org/apache/jmeter/gui/GuiPackage.java
@@ -633,10 +633,9 @@ public final class GuiPackage implements LocaleChangeListener, HistoryListener
{
         if (popup != null) {
             log.debug("Showing pop up for {} at x,y = {},{}", invoker, e.getX(), e.getY());
 
-            popup.pack();
+            // Enforce heavyweight popup to show shadows on macOS
+            popup.setLightWeightPopupEnabled(false);
             popup.show(invoker, e.getX(), e.getY());
-            popup.setVisible(true);
-            popup.requestFocusInWindow();
         }
     }
 
diff --git a/src/core/src/main/java/org/apache/jmeter/gui/tree/JMeterTreeListener.java b/src/core/src/main/java/org/apache/jmeter/gui/tree/JMeterTreeListener.java
index a008e1f..99f659a 100644
--- a/src/core/src/main/java/org/apache/jmeter/gui/tree/JMeterTreeListener.java
+++ b/src/core/src/main/java/org/apache/jmeter/gui/tree/JMeterTreeListener.java
@@ -27,6 +27,7 @@ import java.awt.event.MouseListener;
 
 import javax.swing.JPopupMenu;
 import javax.swing.JTree;
+import javax.swing.SwingUtilities;
 import javax.swing.event.TreeSelectionEvent;
 import javax.swing.event.TreeSelectionListener;
 import javax.swing.tree.TreePath;
@@ -154,7 +155,6 @@ public class JMeterTreeListener implements TreeSelectionListener, MouseListener,
 
     @Override
     public void mouseReleased(MouseEvent e) {
-        GuiPackage.getInstance().getMainFrame().repaint();
     }
 
     @Override
@@ -234,6 +234,10 @@ public class JMeterTreeListener implements TreeSelectionListener, MouseListener,
 
     private void displayPopUp(MouseEvent e) {
         JPopupMenu pop = getCurrentNode().createPopupMenu();
-        GuiPackage.getInstance().displayPopUp(e, pop);
+        // invokeLater ensures popup does not disappear when user right-clicks an inactive
node
+        // In other words: right-click different nodes and verify if menu is shown every
time.
+        // invokeLater seems to be required as long as tree.requestFocusInWindow(); is used
+        // in valueChanged
+        SwingUtilities.invokeLater(() -> GuiPackage.getInstance().displayPopUp(e, pop));
     }
 }
diff --git a/xdocs/changes.xml b/xdocs/changes.xml
index 86de2e9..c7d3b55 100644
--- a/xdocs/changes.xml
+++ b/xdocs/changes.xml
@@ -80,6 +80,9 @@ For instance, <code>While Contoller</code> is disabled in the
following tree, so
 are gray. It is purely a UI change, and the behavior is not altered.
 </p>
 <figure width="223" height="256" image="changes/5.3/disabled_subtree.png">While controller
is disabled, so its children are gray</figure>
+
+<p>Tree context menu is shown even in case the node selection is changed. Previously
+    the popup did disappear and it was required to select a node first and only then launch
popup.</p>
 <!--
 <ch_title>Functions</ch_title>
 -->


Mime
View raw message