jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1854171 - in /jmeter/trunk: src/core/org/apache/jmeter/gui/action/SearchTreeCommand.java src/core/org/apache/jmeter/gui/action/SearchTreeDialog.java xdocs/changes.xml
Date Fri, 22 Feb 2019 19:49:30 GMT
Author: fschumacher
Date: Fri Feb 22 19:49:30 2019
New Revision: 1854171

URL: http://svn.apache.org/viewvc?rev=1854171&view=rev
Log:
SearchTreeDialog disappears behind master JFrame

Contributed by Benoit Vatan (benoit.vatan at gmail.com)
Bugzilla Id: 63201

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeCommand.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeDialog.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeCommand.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeCommand.java?rev=1854171&r1=1854170&r2=1854171&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeCommand.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeCommand.java Fri Feb 22 19:49:30
2019
@@ -18,10 +18,17 @@
 
 package org.apache.jmeter.gui.action;
 
+import java.awt.Component;
+import java.awt.Window;
 import java.awt.event.ActionEvent;
 import java.util.HashSet;
 import java.util.Set;
 
+import javax.swing.JFrame;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.SwingUtilities;
+
 /**
  * Search nodes for a text
  * TODO Enhance search dialog to select kind of nodes ....
@@ -34,12 +41,51 @@ public class SearchTreeCommand extends A
         commands.add(ActionNames.SEARCH_TREE);
     }
 
-    private SearchTreeDialog dialog = new SearchTreeDialog();
+    private SearchTreeDialog dialog;
+
+    /**
+     * <p>
+     * Create the search dialog from the specified source component.<br>
+     * This method tries to find a JFrame ancestor from the specified source in
+     * order to be the parent of the search dialog.<br>
+     * With no parent set the search dialog might be hidden by the main JFrame when
+     * focus is transfered to that JFrame.
+     * </p>
+     * <p>
+     * If no parent if found, then we give up and build a search dialog with no
+     * parent.
+     * </p>
+     * 
+     * @param source The source object that originated the display of the dialog
+     * @return A freshly created search dialog with the parent frame that could be
+     *         found, or no parent otherwise.
+     */
+    private SearchTreeDialog createSearchDialog(Object source) {
+        JFrame parent = null;
+        if (source instanceof JMenuItem) {
+            JMenuItem item = (JMenuItem) source;
+            Component comp = item.getParent();
+            if (comp instanceof JPopupMenu) {
+                JPopupMenu popup = (JPopupMenu) comp;
+                comp = popup.getInvoker();
+                Window window = SwingUtilities.windowForComponent((Component) comp);
+                if (window instanceof JFrame) {
+                    parent = (JFrame) window;
+                }
+            }
+        }
+        return new SearchTreeDialog(parent);
+    }
+    
     /**
      * @see Command#doAction(ActionEvent)
      */
     @Override
     public void doAction(ActionEvent e) {
+        // we create the dialog upon first display event only
+        if (dialog == null) {
+            dialog = createSearchDialog(e.getSource());
+        }
         dialog.setVisible(true);
     }
 

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeDialog.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeDialog.java?rev=1854171&r1=1854170&r2=1854171&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeDialog.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeDialog.java Fri Feb 22 19:49:30
2019
@@ -111,8 +111,8 @@ public class SearchTreeDialog extends JD
     private List<JMeterTreeNode> lastSearchResult = new ArrayList<>();
     private int currentSearchIndex;
 
-    public SearchTreeDialog() {
-        super((JFrame) null, JMeterUtils.getResString("search_tree_title"), false); //$NON-NLS-1$
+    public SearchTreeDialog(JFrame parent) {
+        super(parent, JMeterUtils.getResString("search_tree_title"), false); //$NON-NLS-1$
         init();
     }
 

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1854171&r1=1854170&r2=1854171&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Fri Feb 22 19:49:30 2019
@@ -157,6 +157,7 @@ Summary
 
 <h3>General</h3>
 <ul>
+    <li><bug>63201</bug>SearchTreeDialog disappears behind master JFrame.
Contributed by Benoit Vatan (benoit.vatan at gmail.com)</li>
 </ul>
 
  <!--  =================== Thanks =================== -->
@@ -166,6 +167,7 @@ Summary
 </p>
 <ul>
     <li><a href="https://ubikloadpack.com">Ubik Load Pack</a></li>
+    <li>Benoit Vatan (benoit.vatan at gmail.com)</li>
 </ul>
 <p>We also thank bug reporters who helped us improve JMeter.</p>
 <ul>



Mime
View raw message