From 73ff2c16d11d91e0ca6c479cf07cb665309d3bbd Mon Sep 17 00:00:00 2001 From: Leo Ufimtsev Date: Fri, 28 Apr 2017 16:10:23 -0400 Subject: Bug 515972: Javadoc hover shows mix of Info and Javadoc colors Part 1: For the HoverControl used by Javadoc hover, set Statusbar colors when foreground/background is set (but only if statusBar is used). Note: - StatusbarLabel isn't always created, sometimes it's not used. We guard against that with null-check. - StatusBarLabel foreground is a blend of background and foreground, to make it slightly 'lighter' than the main foreground. To account for that, we re-blend when we either do background or foreground change. Since color is created, it's lifecycle is treated carefully such that we have no memory leaks. Tests: - With this patch alone, you won't see any changes. You need to apply "Part 2" patch for javadoc to see changes to Javadoc. (See bug) - Tested with child eclipse. No breakage for various popups like - Javadoc hover - jdt.debug.ui's expression viewer - editor markers - Problem info hover This patch should be good for merging. Change-Id: I6b13e06bbb27f49f28a56c4c05d65c2c65c150da Signed-off-by: Leo Ufimtsev --- .../jface/text/AbstractInformationControl.java | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControl.java') diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControl.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControl.java index 2a9a5b05714..374ad6108f5 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControl.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControl.java @@ -244,8 +244,7 @@ public abstract class AbstractInformationControl implements IInformationControl, fStatusLabelFont= new Font(fStatusLabel.getDisplay(), fontDatas); fStatusLabel.setFont(fStatusLabelFont); - fStatusLabelForeground= new Color(fStatusLabel.getDisplay(), Colors.blend(background.getRGB(), foreground.getRGB(), 0.56f)); - setColor(fStatusLabel, fStatusLabelForeground, background); + setStatusLabelColors(foreground, background); setColor(fStatusComposite, foreground, background); } @@ -632,11 +631,30 @@ public abstract class AbstractInformationControl implements IInformationControl, @Override public void setForegroundColor(Color foreground) { fContentComposite.setForeground(foreground); + if (fStatusLabel != null) { + setStatusLabelColors(foreground, fStatusLabel.getBackground()); + } } @Override public void setBackgroundColor(Color background) { fContentComposite.setBackground(background); + if (fStatusComposite != null){ + fStatusComposite.setBackground(background); + } + if (fStatusLabel != null) { + setStatusLabelColors(fStatusLabel.getForeground(), background); + } + } + + private void setStatusLabelColors(Color foreground, Color background) { + if (foreground == null || background == null) return; + if (fStatusLabelForeground != null) { + fStatusLabelForeground.dispose(); + } + fStatusLabelForeground = new Color(fStatusLabel.getDisplay(), Colors.blend(background.getRGB(), foreground.getRGB(), 0.56f)); + fStatusLabel.setForeground(fStatusLabelForeground); + fStatusLabel.setBackground(background); } /** -- cgit v1.2.3