From be26859396453645f9732c945a25d6f4e90055b0 Mon Sep 17 00:00:00 2001 From: Sergey Karashevich Date: Tue, 14 Nov 2017 14:44:45 +0300 Subject: [PATCH] [gui-test] update text rectangle bounds before clicking the LinkLabel Added a LinkLabel#isInClickableArea method before calculating center of text in a LinkLabel. This method should update textR (rectangle of text bounds) and fix a zero point issue, when it returned textR with zero values. --- .../intellij/ui/components/labels/LinkLabel.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java b/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java index 6f8d9473df10..65f2fbbc40d2 100644 --- a/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java +++ b/platform/platform-api/src/com/intellij/ui/components/labels/LinkLabel.java @@ -182,7 +182,7 @@ public class LinkLabel extends JLabel { g.drawLine(bounds.x, lineY, bounds.x + bounds.width, lineY); } - if (isFocusOwner()){ + if (isFocusOwner()) { g.setColor(UIUtil.getTreeSelectionBorderColor()); UIUtil.drawLabelDottedRectangle(this, g, getTextBounds()); } @@ -196,8 +196,8 @@ public class LinkLabel extends JLabel { protected Color getTextColor() { return myIsLinkActive ? getActive() : - myUnderline ? getHover() : - isVisited() ? getVisited() : getNormal(); + myUnderline ? getHover() : + isVisited() ? getVisited() : getNormal(); } public void setPaintUnderline(boolean paintUnderline) { @@ -206,8 +206,9 @@ public class LinkLabel extends JLabel { public void removeNotify() { super.removeNotify(); - if (ScreenUtil.isStandardAddRemoveNotify(this)) + if (ScreenUtil.isStandardAddRemoveNotify(this)) { disableUnderline(); + } } private void setActive(boolean isActive) { @@ -254,6 +255,7 @@ public class LinkLabel extends JLabel { //for GUI tests public Point getTextRectangleCenter() { + isInClickableArea(new Point(0, 0)); //to update textR before clicking return new Point(textR.x + textR.width / 2, textR.y + textR.height / 2); } @@ -388,7 +390,8 @@ public class LinkLabel extends JLabel { if (i == 0) { doClick(); return true; - } else { + } + else { return false; } }