diff options
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, 32 insertions, 1 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 169b5d57479b..0975876055b2 100644 --- a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java +++ b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -828,4 +828,35 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith public void setHorizontalAutoScrollingEnabled(boolean enabled) { myHorizontalAutoScrolling = enabled; } + + /** + * Returns the deepest visible component + * that will be rendered at the specified location. + * + * @param x horizontal location in the tree + * @param y vertical location in the tree + * @return the deepest visible component of the renderer + */ + @Nullable + protected Component getDeepestRendererComponentAt(int x, int y) { + int row = getRowForLocation(x, y); + if (row >= 0) { + TreeCellRenderer renderer = getCellRenderer(); + if (renderer != null) { + TreePath path = getPathForRow(row); + Object node = path.getLastPathComponent(); + Component component = renderer.getTreeCellRendererComponent(this, node, + isRowSelected(row), + isExpanded(row), + getModel().isLeaf(node), + row, true); + Rectangle bounds = getPathBounds(path); + if (bounds != null) { + component.setBounds(bounds); // initialize size to layout complex renderer + return SwingUtilities.getDeepestComponentAt(component, x - bounds.x, y - bounds.y); + } + } + } + return null; + } }
\ No newline at end of file |