[autocomplete] 72/143: Popup windows: Working around Nimbus oddities (yet again) with colors. Make "tool tip" style windows use actual tool tip border where possible. JavaLanguageSupport: Improving "go to member" action. Folding: Fixed bug with top-level single-line folded regions.

Benjamin Mesing ben at alioth.debian.org
Sat Oct 19 12:53:20 UTC 2013


This is an automated email from the git hooks/post-receive script.

ben pushed a commit to branch master
in repository autocomplete.

commit 41158e5483546d8ec54f27647088207c3a8c8aa0
Author: bobbylight <robert at fifesoft.com>
Date:   Sun Dec 4 06:45:41 2011 +0000

    Popup windows: Working around Nimbus oddities (yet again) with colors.  Make "tool tip" style windows use actual tool tip border where possible.
    JavaLanguageSupport: Improving "go to member" action.
    Folding: Fixed bug with top-level single-line folded regions.
---
 .../ui/autocomplete/AutoCompleteDescWindow.java    |   22 +++++++-
 src/org/fife/ui/autocomplete/SizeGrip.java         |    4 +-
 src/org/fife/ui/autocomplete/TipUtil.java          |   58 ++++++++++++++++++--
 3 files changed, 75 insertions(+), 9 deletions(-)

diff --git a/src/org/fife/ui/autocomplete/AutoCompleteDescWindow.java b/src/org/fife/ui/autocomplete/AutoCompleteDescWindow.java
index 00fe324..9c4e784 100644
--- a/src/org/fife/ui/autocomplete/AutoCompleteDescWindow.java
+++ b/src/org/fife/ui/autocomplete/AutoCompleteDescWindow.java
@@ -24,7 +24,10 @@
 package org.fife.ui.autocomplete;
 
 import java.awt.BorderLayout;
+import java.awt.Component;
 import java.awt.ComponentOrientation;
+import java.awt.Graphics;
+import java.awt.Insets;
 import java.awt.Window;
 import java.awt.event.ActionEvent;
 import java.io.IOException;
@@ -49,6 +52,8 @@ import javax.swing.JWindow;
 import javax.swing.SwingUtilities;
 import javax.swing.Timer;
 import javax.swing.UIManager;
+import javax.swing.border.AbstractBorder;
+import javax.swing.border.Border;
 import javax.swing.event.HyperlinkEvent;
 import javax.swing.event.HyperlinkListener;
 
@@ -154,13 +159,15 @@ class AutoCompleteDescWindow extends JWindow implements HyperlinkListener {
 		ComponentOrientation o = ac.getTextComponentOrientation();
 		
 		JPanel cp = new JPanel(new BorderLayout());
-//		cp.setBorder(BorderFactory.createLineBorder(Color.BLACK));
+		cp.setBorder(TipUtil.getToolTipBorder());
 
 		descArea = new JEditorPane("text/html", null);
 		TipUtil.tweakTipEditorPane(descArea);
 		descArea.addHyperlinkListener(this);
 		scrollPane = new JScrollPane(descArea);
-		scrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
+		Border b = BorderFactory.createEmptyBorder();
+		scrollPane.setBorder(b);
+		scrollPane.setViewportBorder(b);
 		scrollPane.setBackground(descArea.getBackground());
 		scrollPane.getViewport().setBackground(descArea.getBackground());
 		cp.add(scrollPane);
@@ -173,6 +180,16 @@ class AutoCompleteDescWindow extends JWindow implements HyperlinkListener {
 		descWindowNavBar.add(new JButton(forwardAction));
 
 		bottomPanel = new JPanel(new BorderLayout());
+		b = new AbstractBorder() {
+			public Insets getBorderInsets(Component c) { 
+				return new Insets(1, 0, 0, 0);
+			}
+			public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
+				g.setColor(UIManager.getColor("controlDkShadow"));
+				g.drawLine(x,y, x+w-1,y);
+			}
+		};
+		bottomPanel.setBorder(b);
 		SizeGrip rp = new SizeGrip();
 		bottomPanel.add(descWindowNavBar, BorderLayout.LINE_START);
 		bottomPanel.add(rp, BorderLayout.LINE_END);
@@ -378,6 +395,7 @@ class AutoCompleteDescWindow extends JWindow implements HyperlinkListener {
 		TipUtil.tweakTipEditorPane(descArea);
 		scrollPane.setBackground(descArea.getBackground());
 		scrollPane.getViewport().setBackground(descArea.getBackground());
+		((JPanel)getContentPane()).setBorder(TipUtil.getToolTipBorder());
 	}
 
 
diff --git a/src/org/fife/ui/autocomplete/SizeGrip.java b/src/org/fife/ui/autocomplete/SizeGrip.java
index 637268d..ffe65f6 100644
--- a/src/org/fife/ui/autocomplete/SizeGrip.java
+++ b/src/org/fife/ui/autocomplete/SizeGrip.java
@@ -122,14 +122,14 @@ class SizeGrip extends JPanel {
 		super.paintComponent(g);
 
 		Dimension dim = getSize();
-		Color c1 = UIManager.getColor("Label.disabledShadow");
-		Color c2 = UIManager.getColor("Label.disabledForeground");
 
 		if (osxSizeGrip!=null) {
 			g.drawImage(osxSizeGrip, dim.width-16, dim.height-16, null);
 			return;
 		}
 
+		Color c1 = UIManager.getColor("Label.disabledShadow");
+		Color c2 = UIManager.getColor("Label.disabledForeground");
 		ComponentOrientation orientation = getComponentOrientation();
 
 		if (orientation.isLeftToRight()) {
diff --git a/src/org/fife/ui/autocomplete/TipUtil.java b/src/org/fife/ui/autocomplete/TipUtil.java
index cbf838a..654ecc7 100644
--- a/src/org/fife/ui/autocomplete/TipUtil.java
+++ b/src/org/fife/ui/autocomplete/TipUtil.java
@@ -29,6 +29,7 @@ import java.net.URL;
 import javax.swing.BorderFactory;
 import javax.swing.JEditorPane;
 import javax.swing.UIManager;
+import javax.swing.border.Border;
 import javax.swing.plaf.ColorUIResource;
 import javax.swing.text.html.HTMLDocument;
 
@@ -60,9 +61,10 @@ class TipUtil {
 		Color c = UIManager.getColor("ToolTip.background");
 
 		// Tooltip.background is wrong color on Nimbus (!)
-		if (c==null || UIManager.getLookAndFeel().getName().equals("Nimbus")) {
+		boolean isNimbus = isNimbusLookAndFeel();
+		if (c==null || isNimbus) {
 			c = UIManager.getColor("info"); // Used by Nimbus (and others)
-			if (c==null) {
+			if (c==null || (isNimbus && isDerivedColor(c))) {
 				c = SystemColor.info; // System default
 			}
 		}
@@ -79,6 +81,51 @@ class TipUtil {
 
 
 	/**
+	 * Returns the border used by tool tips in this look and feel.
+	 *
+	 * @return The border.
+	 */
+	public static Border getToolTipBorder() {
+
+		Border border = UIManager.getBorder("ToolTip.border");
+
+		if (border==null || isNimbusLookAndFeel()) {
+			border = UIManager.getBorder("nimbusBorder");
+			if (border==null) {
+				border = BorderFactory.createLineBorder(SystemColor.controlDkShadow);
+			}
+		}
+
+		return border;
+
+	}
+
+
+	/**
+	 * Returns whether a color is a Nimbus DerivedColor, which is troublesome
+	 * in that it doesn't use its RGB values (uses HSB instead?) and so
+	 * querying them is useless.
+	 *
+	 * @param c The color to check.
+	 * @return Whether it is a DerivedColor
+	 */
+	private static final boolean isDerivedColor(Color c) {
+		return c!=null && (c.getClass().getName().endsWith(".DerivedColor") ||
+				c.getClass().getName().endsWith(".DerivedColor$UIResource"));
+	}
+
+
+	/**
+	 * Returns whether the Nimbus Look and Feel is installed.
+	 *
+	 * @return Whether the current LAF is Nimbus.
+	 */
+	private static final boolean isNimbusLookAndFeel() {
+		return UIManager.getLookAndFeel().getName().equals("Nimbus");
+	}
+
+
+	/**
 	 * Tweaks a <code>JEditorPane</code> so it can be used to render the
 	 * content in a focusable pseudo-tool tip.  It is assumed that the editor
 	 * pane is using an <code>HTMLDocument</code>.
@@ -88,7 +135,8 @@ class TipUtil {
 	public static void tweakTipEditorPane(JEditorPane textArea) {
 
 		// Jump through a few hoops to get things looking nice in Nimbus
-		if (UIManager.getLookAndFeel().getName().equals("Nimbus")) {
+		boolean isNimbus = isNimbusLookAndFeel();
+		if (isNimbus) {
 			Color selBG = textArea.getSelectionColor();
 			Color selFG = textArea.getSelectedTextColor();
 			textArea.setUI(new javax.swing.plaf.basic.BasicEditorPaneUI());
@@ -106,8 +154,8 @@ class TipUtil {
 		// default foreground becomes black, which may not match all LAF's
 		// (e.g. Substance).
 		Color fg = UIManager.getColor("Label.foreground");
-		if (fg==null) {
-			fg = SystemColor.text;
+		if (fg==null || (isNimbus && isDerivedColor(fg))) {
+			fg = SystemColor.textText;
 		}
 		textArea.setForeground(fg);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/autocomplete.git



More information about the pkg-java-commits mailing list