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

ben pushed a commit to branch master
in repository autocomplete.

commit 40a2260507c84b610c36f037a6633b9da4e42d32
Author: bobbylight <[email protected]>
Date:   Thu Aug 13 23:40:38 2009 +0000

    Better custom tooltip coloring for Nimbus.  Removed a few stdout debug 
messages.
---
 .../ui/autocomplete/AutoCompleteDescWindow.java    |   65 +----------
 .../ParameterizedCompletionDescriptionToolTip.java |   24 +---
 src/org/fife/ui/autocomplete/TipUtil.java          |  121 ++++++++++++++++++++
 3 files changed, 127 insertions(+), 83 deletions(-)

diff --git a/src/org/fife/ui/autocomplete/AutoCompleteDescWindow.java 
b/src/org/fife/ui/autocomplete/AutoCompleteDescWindow.java
index e90d59c..1049b33 100644
--- a/src/org/fife/ui/autocomplete/AutoCompleteDescWindow.java
+++ b/src/org/fife/ui/autocomplete/AutoCompleteDescWindow.java
@@ -24,10 +24,7 @@
 package org.fife.ui.autocomplete;
 
 import java.awt.BorderLayout;
-import java.awt.Color;
 import java.awt.ComponentOrientation;
-import java.awt.Font;
-import java.awt.SystemColor;
 import java.awt.Window;
 import java.awt.event.ActionEvent;
 import java.io.IOException;
@@ -53,7 +50,6 @@ import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
 import javax.swing.event.HyperlinkEvent;
 import javax.swing.event.HyperlinkListener;
-import javax.swing.text.html.HTMLDocument;
 
 
 /**
@@ -139,10 +135,10 @@ class AutoCompleteDescWindow extends JWindow implements 
HyperlinkListener {
 //             cp.setBorder(BorderFactory.createLineBorder(Color.BLACK));
 
                descArea = new JEditorPane("text/html", null);
-               tweakDescArea();
+               TipUtil.tweakTipEditorPane(descArea);
                descArea.addHyperlinkListener(this);
                scrollPane = new JScrollPane(descArea);
-               
scrollPane.setViewportBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+               scrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
                scrollPane.setBackground(descArea.getBackground());
                
scrollPane.getViewport().setBackground(descArea.getBackground());
                cp.add(scrollPane);
@@ -221,24 +217,6 @@ class AutoCompleteDescWindow extends JWindow implements 
HyperlinkListener {
 
 
        /**
-        * Returns the default background color to use for the description
-        * window.
-        *
-        * @return The default background color.
-        */
-       protected Color getDefaultBackground() {
-               Color c = UIManager.getColor("ToolTip.background");
-               if (c==null) { // Some LookAndFeels like Nimbus
-                       c = UIManager.getColor("info"); // Used by Nimbus (and 
others)
-                       if (c==null) {
-                               c = SystemColor.infoText; // System default
-                       }
-               }
-               return c;
-       }
-
-
-       /**
         * Returns the localized message for the specified key.
         *
         * @param key The key.
@@ -356,47 +334,12 @@ class AutoCompleteDescWindow extends JWindow implements 
HyperlinkListener {
        }
 
        /**
-        * Tweaks the description text area to look good in the current Look
-        * and Feel.
-        */
-       private void tweakDescArea() {
-
-               // Jump through a few hoops to get things looking nice in Nimbus
-               if (UIManager.getLookAndFeel().getName().equals("Nimbus")) {
-                       Color selBG = descArea.getSelectionColor();
-                       Color selFG = descArea.getSelectedTextColor();
-                       descArea.setUI(new 
javax.swing.plaf.basic.BasicEditorPaneUI());
-                       descArea.setSelectedTextColor(selFG);
-                       descArea.setSelectionColor(selBG);
-               }
-
-               descArea.setEditable(false); // Required for links to work!
-
-               // Make selection visible even though we are not focusable.
-               descArea.getCaret().setSelectionVisible(true);
-
-               // Make it use "tool tip" background color.
-               descArea.setBackground(getDefaultBackground());
-
-               // Force JEditorPane to use a certain font even in HTML.
-               // All standard LookAndFeels, even Nimbus (!), define 
Label.font.
-               Font font = UIManager.getFont("Label.font");
-               if (font==null) { // Try to make a sensible default
-                       font = new Font("SansSerif", Font.PLAIN, 12);
-               }
-               HTMLDocument doc = (HTMLDocument)descArea.getDocument();
-               doc.getStyleSheet().addRule("body { font-family: " + 
font.getFamily() +
-                               "; font-size: " + font.getSize() + "pt; }");
-
-       }
-
-
-       /**
         * Called by the parent completion popup window the LookAndFeel is 
updated.
         */
        public void updateUI() {
                SwingUtilities.updateComponentTreeUI(this);
-               tweakDescArea(); // Update the editor pane (font in HTML, etc.)
+               // Update editor pane for new font, bg, selection colors, etc.
+               TipUtil.tweakTipEditorPane(descArea);
                scrollPane.setBackground(descArea.getBackground());
                
scrollPane.getViewport().setBackground(descArea.getBackground());
        }
diff --git 
a/src/org/fife/ui/autocomplete/ParameterizedCompletionDescriptionToolTip.java 
b/src/org/fife/ui/autocomplete/ParameterizedCompletionDescriptionToolTip.java
index f4cd164..c824181 100644
--- 
a/src/org/fife/ui/autocomplete/ParameterizedCompletionDescriptionToolTip.java
+++ 
b/src/org/fife/ui/autocomplete/ParameterizedCompletionDescriptionToolTip.java
@@ -27,7 +27,6 @@ import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Point;
 import java.awt.Rectangle;
-import java.awt.SystemColor;
 import java.awt.Window;
 import java.awt.event.ActionEvent;
 import java.awt.event.FocusEvent;
@@ -36,7 +35,6 @@ import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
 import java.util.ArrayList;
 import java.util.List;
-
 import javax.swing.AbstractAction;
 import javax.swing.Action;
 import javax.swing.ActionMap;
@@ -151,11 +149,11 @@ class ParameterizedCompletionDescriptionToolTip {
                this.pc = pc;
 
                descLabel = new JLabel();
-               descLabel.setOpaque(true);
                descLabel.setBorder(BorderFactory.createCompoundBorder(
                                        
BorderFactory.createLineBorder(Color.BLACK),
                                        BorderFactory.createEmptyBorder(2, 5, 
2, 5)));
-               descLabel.setBackground(getDefaultBackground());
+               descLabel.setOpaque(true);
+               descLabel.setBackground(TipUtil.getToolTipBackground());
                tooltip.setContentPane(descLabel);
 
                lastSelectedParam = -1;
@@ -170,24 +168,6 @@ class ParameterizedCompletionDescriptionToolTip {
        }
 
 
-       /**
-        * Returns the default background color to use for the description
-        * window.
-        *
-        * @return The default background color.
-        */
-       protected Color getDefaultBackground() {
-               Color c = UIManager.getColor("ToolTip.background");
-               if (c==null) { // Some LookAndFeels like Nimbus
-                       c = UIManager.getColor("info"); // Used by Nimbus (and 
others)
-                       if (c==null) {
-                               c = SystemColor.infoText; // System default
-                       }
-               }
-               return c;
-       }
-
-
        private List getParameterHighlights() {
                List paramHighlights = new ArrayList(1);
                JTextComponent tc = ac.getTextComponent();
diff --git a/src/org/fife/ui/autocomplete/TipUtil.java 
b/src/org/fife/ui/autocomplete/TipUtil.java
new file mode 100644
index 0000000..ea06265
--- /dev/null
+++ b/src/org/fife/ui/autocomplete/TipUtil.java
@@ -0,0 +1,121 @@
+/*
+ * 08/13/2009
+ *
+ * TipUtil.java - Utility methods for homemade tool tips.
+ * Copyright (C) 2009 Robert Futrell
+ * robert_futrell at users.sourceforge.net
+ * http://fifesoft.com/rsyntaxtextarea
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA.
+ */
+package org.fife.ui.autocomplete;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.SystemColor;
+import javax.swing.BorderFactory;
+import javax.swing.JEditorPane;
+import javax.swing.UIManager;
+import javax.swing.plaf.ColorUIResource;
+import javax.swing.text.html.HTMLDocument;
+
+
+/**
+ * Static utility methods for homemade tool tips.<p>
+ *
+ * This is blatantly ripped off from RSyntaxTextArea's "FocusableTips" class
+ * of the same name, but isn't re-used to prevent a hard dependency on the
+ * RSTA library.
+ *
+ * @author Robert Futrell
+ * @version 1.0
+ */
+class TipUtil {
+
+
+       private TipUtil() {
+       }
+
+
+       /**
+        * Returns the default background color to use for tool tip windows.
+        *
+        * @return The default background color.
+        */
+       public static Color getToolTipBackground() {
+
+               Color c = UIManager.getColor("ToolTip.background");
+
+               // Tooltip.background is wrong color on Nimbus (!)
+               if (c==null || 
UIManager.getLookAndFeel().getName().equals("Nimbus")) {
+                       c = UIManager.getColor("info"); // Used by Nimbus (and 
others)
+                       if (c==null) {
+                               c = SystemColor.info; // System default
+                       }
+               }
+
+               // Workaround for a bug (?) with Nimbus - calling 
JLabel.setBackground()
+               // with a ColorUIResource does nothing, must be a normal Color
+               if (c instanceof ColorUIResource) {
+                       c = new Color(c.getRGB());
+               }
+
+               return c;
+
+       }
+
+
+       /**
+        * 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>.
+        *
+        * @param textArea The editor pane to tweak.
+        */
+       public static void tweakTipEditorPane(JEditorPane textArea) {
+
+               // Jump through a few hoops to get things looking nice in Nimbus
+               if (UIManager.getLookAndFeel().getName().equals("Nimbus")) {
+                       Color selBG = textArea.getSelectionColor();
+                       Color selFG = textArea.getSelectedTextColor();
+                       textArea.setUI(new 
javax.swing.plaf.basic.BasicEditorPaneUI());
+                       textArea.setSelectedTextColor(selFG);
+                       textArea.setSelectionColor(selBG);
+               }
+
+               textArea.setEditable(false); // Required for links to work!
+               textArea.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+
+               // Make selection visible even though we are not (initially) 
focusable.
+               textArea.getCaret().setSelectionVisible(true);
+
+               // Make it use the "tool tip" background color.
+               textArea.setBackground(TipUtil.getToolTipBackground());
+
+               // Force JEditorPane to use a certain font even in HTML.
+               // All standard LookAndFeels, even Nimbus (!), define 
Label.font.
+               Font font = UIManager.getFont("Label.font");
+               if (font == null) { // Try to make a sensible default
+                       font = new Font("SansSerif", Font.PLAIN, 12);
+               }
+               HTMLDocument doc = (HTMLDocument) textArea.getDocument();
+               doc.getStyleSheet().addRule(
+                               "body { font-family: " + font.getFamily() + "; 
font-size: "
+                                               + font.getSize() + "pt; }");
+
+       }
+
+
+}
\ No newline at end of file

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

_______________________________________________
pkg-java-commits mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

Reply via email to