mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Platform: empty text was not clickable in JBTables (IDEA-84737)
(cherry-picked from b21afdb)
This commit is contained in:
@@ -36,7 +36,7 @@ public class JBViewport extends JViewport implements ZoomableViewport {
|
||||
Component child = e.getChild();
|
||||
if (child instanceof JBTable) {
|
||||
myEmptyText = ((ComponentWithEmptyText)child).getEmptyText();
|
||||
myEmptyText.attachTo(JBViewport.this);
|
||||
myEmptyText.attachTo(JBViewport.this, child);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ public abstract class StatusText {
|
||||
|
||||
@Nullable
|
||||
private Component myOwner;
|
||||
private Component myMouseTarget;
|
||||
private final MouseMotionListener myMouseMotionListener;
|
||||
private final ClickListener myClickListener;
|
||||
|
||||
@@ -67,10 +68,10 @@ public abstract class StatusText {
|
||||
@Override
|
||||
public void mouseMoved(final MouseEvent e) {
|
||||
if (findActionListenerAt(e.getPoint()) != null) {
|
||||
myOwner.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
myMouseTarget.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
}
|
||||
else {
|
||||
myOwner.setCursor(Cursor.getDefaultCursor());
|
||||
myMouseTarget.setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -82,25 +83,32 @@ public abstract class StatusText {
|
||||
}
|
||||
|
||||
public void attachTo(@Nullable Component owner) {
|
||||
if (myOwner != null) {
|
||||
myClickListener.uninstall(myOwner);
|
||||
myOwner.removeMouseMotionListener(myMouseMotionListener);
|
||||
attachTo(owner, owner);
|
||||
}
|
||||
|
||||
public void attachTo(@Nullable Component owner, @Nullable Component mouseTarget) {
|
||||
if (myMouseTarget != null) {
|
||||
myClickListener.uninstall(myMouseTarget);
|
||||
myMouseTarget.removeMouseMotionListener(myMouseMotionListener);
|
||||
}
|
||||
|
||||
myOwner = owner;
|
||||
myMouseTarget = mouseTarget;
|
||||
|
||||
if (myOwner != null) {
|
||||
myClickListener.installOn(myOwner);
|
||||
myOwner.addMouseMotionListener(myMouseMotionListener);
|
||||
if (myMouseTarget != null) {
|
||||
myClickListener.installOn(myMouseTarget);
|
||||
myMouseTarget.addMouseMotionListener(myMouseMotionListener);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean isStatusVisible();
|
||||
|
||||
@Nullable
|
||||
private ActionListener findActionListenerAt(final Point point) {
|
||||
private ActionListener findActionListenerAt(Point point) {
|
||||
if (!isStatusVisible()) return null;
|
||||
|
||||
point = SwingUtilities.convertPoint(myMouseTarget, point, myOwner);
|
||||
|
||||
Rectangle b = getTextComponentBound();
|
||||
if (b.contains(point)) {
|
||||
int index = myComponent.findFragmentAt(point.x - b.x);
|
||||
|
||||
Reference in New Issue
Block a user