From 2ec041e77937b265b5cf8b82d070c3089674a2b0 Mon Sep 17 00:00:00 2001 From: "Vassiliy.Kudryashov" Date: Tue, 14 Feb 2017 12:32:22 +0300 Subject: [PATCH] IDEA-155088 Double click on tree's expand icon triggers double click listener --- .../com/intellij/ui/treeStructure/Tree.java | 38 ++++++------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java index 4e2b2ad8e101..2eb40da41462 100644 --- a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java +++ b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java @@ -410,6 +410,18 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith super.processMouseEvent(e2); } + /** + * Returns true if mouseX falls + * in the area of row that is used to expand/collapse the node and + * the node at row does not represent a leaf. + */ + protected boolean isLocationInExpandControl(@Nullable TreePath path, int mouseX) { + if (path == null) return false; + Rectangle bounds = getRowBounds(getRowForPath(path)); + return isLocationInExpandControl(path, mouseX, bounds.y + bounds.height / 2); + } + + private boolean isLocationInExpandControl(final TreePath path, final int x, final int y) { final TreeUI ui = getUI(); if (!(ui instanceof BasicTreeUI)) return false; @@ -682,32 +694,6 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith e.consume(); } } - /* - Returns true if mouseX falls - in the area of row that is used to expand/collapse the node and - the node at row does not represent a leaf. - */ - } - - protected boolean isLocationInExpandControl(@Nullable TreePath path, int mouseX) { - if (path == null) return false; - TreeUI ui = getUI(); - if (!(ui instanceof BasicTreeUI)) return false; - BasicTreeUI treeUI = (BasicTreeUI)ui; - if (!treeModel.isLeaf(path.getLastPathComponent())) { - Insets insets = this.getInsets(); - int boxWidth = treeUI.getExpandedIcon() != null ? treeUI.getExpandedIcon().getIconWidth() : 8; - int boxLeftX = treeUI.getLeftChildIndent() + treeUI.getRightChildIndent() * (path.getPathCount() - 1); - if (getComponentOrientation().isLeftToRight()) { - boxLeftX = boxLeftX + insets.left - treeUI.getRightChildIndent() + 1; - } - else { - boxLeftX = getWidth() - boxLeftX - insets.right + treeUI.getRightChildIndent() - 1; - } - boxLeftX -= getComponentOrientation().isLeftToRight() ? (int)Math.ceil(boxWidth / 2.0) : (int)Math.floor(boxWidth / 2.0); - return mouseX >= boxLeftX && mouseX < boxLeftX + boxWidth; - } - return false; } /**