diff options
author | Tor Norbye <tnorbye@google.com> | 2013-05-08 15:46:07 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2013-05-08 15:46:07 -0700 |
commit | a6eac331b3d9f0d4168b12356ea256c83f4e9c05 (patch) | |
tree | 923ceb497c43ea183351321bb4b9e388851a7854 /platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java | |
parent | 934b9431b0b827a132df794e307fe5a2b70de00b (diff) | |
download | idea-a6eac331b3d9f0d4168b12356ea256c83f4e9c05.tar.gz |
Snapshot f5ae6e3be7e12e1ef9e12f48fe3a674266288e4e from master branch of git://git.jetbrains.org/idea/community.git
Change-Id: I756af70fb2910aa2687e94e28338fb9727bce518
Diffstat (limited to 'platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java')
-rw-r--r-- | platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java | 33 |
1 files changed, 33 insertions, 0 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 29a9f2813db6..0d2bf4c4a7e8 100644 --- a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java +++ b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java @@ -683,6 +683,39 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith } } } + + @Override + public void mouseReleased(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2 && isLocationInExpandControl(getClosestPathForLocation(e.getX(), e.getY()), e.getX())) { + e.consume(); + } + } + /** + * Returns true if <code>mouseX</code> falls + * in the area of row that is used to expand/collapse the node and + * the node at <code>row</code> 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 = Tree.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; } /** |