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 <lufimtse@redhat.com>
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 2a9a5b0..374ad61 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 @@
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 @@
@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);
}
/**