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 diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java index 0659d9d02a0e..e0ab24815ece 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java @@ -409,12 +409,11 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl myProjectIcon.setBackground(selected ? getSelectionBackground() : getBackground()); myProjectIcon.setIcon(selected ? AllIcons.General.ProjectConfigurableSelected : AllIcons.General.ProjectConfigurable); myProjectIcon.setVisible(true); - tree.setToolTipText(OptionsBundle.message(project.isDefault() + myProjectIcon.setToolTipText(OptionsBundle.message(project.isDefault() ? "configurable.default.project.tooltip" : "configurable.current.project.tooltip")); } else { myProjectIcon.setVisible(false); - tree.setToolTipText(null); } return result; } @@ -627,6 +626,24 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl setOpaque(true); } + @Override + public final String getToolTipText(MouseEvent event) { + if (event != null) { + Point point = event.getPoint(); + Component component = getDeepestRendererComponentAt(point.x, point.y); + if (component instanceof JLabel) { + JLabel label = (JLabel)component; + if (label.getIcon() != null) { + String text = label.getToolTipText(); + if (text != null) { + return text; + } + } + } + } + return super.getToolTipText(event); + } + @Override protected boolean paintNodes() { return false;