Skip to content

Commit

Permalink
Show context menu for the full row, not just for the tree label
Browse files Browse the repository at this point in the history
  • Loading branch information
vlsi committed Mar 15, 2020
1 parent 8eec476 commit 96b1774
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.jmeter.gui.tree;

import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
Expand Down Expand Up @@ -167,12 +168,19 @@ public void mousePressed(MouseEvent e) {
MainFrame mainFrame = GuiPackage.getInstance().getMainFrame();
// Close any Main Menu that is open
mainFrame.closeMenu();
int selRow = tree.getRowForLocation(e.getX(), e.getY());
if (tree.getPathForLocation(e.getX(), e.getY()) != null) {
log.debug("mouse pressed, updating currentPath");
currentPath = tree.getPathForLocation(e.getX(), e.getY());
TreePath closestPath = tree.getClosestPathForLocation(e.getX(), e.getY());
if (closestPath == null) {
log.debug("ClosestPathForLocation is not found for x={}, y={}", e.getX(), e.getY());
return;
}
if (selRow != -1 && isRightClick(e)) {
Rectangle bounds = tree.getPathBounds(closestPath);
if (bounds == null || bounds.y > e.getY() || e.getY() > bounds.y + bounds.height) {
log.debug("Mouse click was outside of node {}. bounds={}, event.x={}, event.y={}",
closestPath, bounds, e.getX(), e.getY());
return;
}
currentPath = closestPath;
if (isRightClick(e)) {
if (tree.getSelectionCount() < 2) {
tree.setSelectionPath(currentPath);
}
Expand Down
2 changes: 2 additions & 0 deletions xdocs/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ are gray. It is purely a UI change, and the behavior is not altered.

<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>

<p>Tree context menu is shown for the full row, not for the label only</p>
<!--
<ch_title>Functions</ch_title>
-->
Expand Down

0 comments on commit 96b1774

Please sign in to comment.