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

ben pushed a commit to branch master
in repository autocomplete.

commit 2608e280a52cd2c417972e3fd181b7221087d156
Author: bobbylight <[email protected]>
Date:   Thu Jun 28 03:09:59 2012 +0000

    Integrating TemplateCompletions into JavaScript language support.
---
 .../ui/autocomplete/CompletionCellRenderer.java    |   59 ++++++++++++++++++--
 1 file changed, 54 insertions(+), 5 deletions(-)

diff --git a/src/org/fife/ui/autocomplete/CompletionCellRenderer.java 
b/src/org/fife/ui/autocomplete/CompletionCellRenderer.java
index 309b90d..e3e259f 100644
--- a/src/org/fife/ui/autocomplete/CompletionCellRenderer.java
+++ b/src/org/fife/ui/autocomplete/CompletionCellRenderer.java
@@ -30,6 +30,7 @@ import javax.swing.text.View;
  *    <li>{@link VariableCompletion}s</li>
  *    <li>{@link MarkupTagCompletion}s</li>
  *    <li>{@link ShorthandCompletion}s</li>
+ *    <li>{@link TemplateCompletion}s</li>
  * </ul>
  *
  * @author Robert Futrell
@@ -55,9 +56,21 @@ public class CompletionCellRenderer extends 
DefaultListCellRenderer {
         */
        private boolean showTypes;
 
-private boolean selected;
-private Color realBG;
-private Rectangle paintTextR;
+       /**
+        * During rendering, whether the item being rendered is selected.
+        */
+       private boolean selected;
+
+       /**
+        * During rendering, this is the "real" background color of the item 
being
+        * rendered (i.e., what its background color is if it isn't selected).
+        */
+       private Color realBG;
+
+       /**
+        * Used in rendering calculations.
+        */
+       private Rectangle paintTextR;
 
        /**
         * Keeps the HTML descriptions from "wrapping" in the list, which cuts 
off
@@ -116,8 +129,8 @@ private Rectangle paintTextR;
                if (font!=null) {
                        setFont(font); // Overrides super's 
setFont(list.getFont()).
                }
-this.selected = selected;
-this.realBG = altBG!=null && (index&1)==0 ? altBG : list.getBackground();
+               this.selected = selected;
+               this.realBG = altBG!=null && (index&1)==0 ? altBG : 
list.getBackground();
 
                if (value instanceof FunctionCompletion) {
                        FunctionCompletion fc = (FunctionCompletion)value;
@@ -127,6 +140,10 @@ this.realBG = altBG!=null && (index&1)==0 ? altBG : 
list.getBackground();
                        VariableCompletion vc = (VariableCompletion)value;
                        prepareForVariableCompletion(list, vc, index, selected, 
hasFocus);
                }
+               else if (value instanceof TemplateCompletion) {
+                       TemplateCompletion tc = (TemplateCompletion)value;
+                       prepareForTemplateCompletion(list, tc, index, selected, 
hasFocus);
+               }
                else if (value instanceof MarkupTagCompletion) {
                        MarkupTagCompletion mtc = (MarkupTagCompletion)value;
                        prepareForMarkupTagCompletion(list, mtc, index, 
selected, hasFocus);
@@ -311,6 +328,38 @@ this.realBG = altBG!=null && (index&1)==0 ? altBG : 
list.getBackground();
 
 
        /**
+        * Prepares this renderer to display a template completion.
+        *
+        * @param list The list of choices being rendered.
+        * @param tc The completion to render.
+        * @param index The index into <code>list</code> being rendered.
+        * @param selected Whether the item is selected.
+        * @param hasFocus Whether the item has focus.
+        */
+       protected void prepareForTemplateCompletion(JList list,
+               TemplateCompletion tc, int index, boolean selected, boolean 
hasFocus) {
+
+               StringBuffer sb = new StringBuffer(PREFIX);
+               sb.append(tc.getInputText());
+
+               String definition = tc.getDefinitionString();
+               if (definition!=null) {
+                       sb.append(" - ");
+                       if (!selected) {
+                               sb.append("<font color='#808080'>");
+                       }
+                       sb.append(definition);
+                       if (!selected) {
+                               sb.append("</font>");
+                       }
+               }
+
+               setText(sb.toString());
+
+       }
+
+
+       /**
         * Prepares this renderer to display a variable completion.
         *
         * @param list The list of choices being rendered.

-- 
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