mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Show tooltip in the Settings tree for the Project icon only.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user