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

ben pushed a commit to branch master
in repository autocomplete.

commit 471986c2e3b9a63dcf663433600afcd013024b52
Author: bobbylight <[email protected]>
Date:   Fri Dec 17 04:50:35 2010 +0000

    Make ParameterChoicesProvider assume Completions as the choice types, and 
allow a custom renderer to be installed for the choices list on AutoComplete 
instances. Make JavaLanguageSupport take advantage of this.
---
 src/org/fife/ui/autocomplete/AutoCompletion.java   |   41 ++++++++++++++++++++
 .../ui/autocomplete/ParameterChoicesProvider.java  |    2 +-
 .../ParameterizedCompletionChoicesWindow.java      |   14 ++++---
 3 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/src/org/fife/ui/autocomplete/AutoCompletion.java 
b/src/org/fife/ui/autocomplete/AutoCompletion.java
index 61ddba0..da89584 100644
--- a/src/org/fife/ui/autocomplete/AutoCompletion.java
+++ b/src/org/fife/ui/autocomplete/AutoCompletion.java
@@ -147,6 +147,13 @@ public class AutoCompletion {
        private boolean parameterAssistanceEnabled;
 
        /**
+        * A renderer used for {@link Completion}s in the optional parameter
+        * choices popup window (displayed when a {@link 
ParameterizedCompletion}
+        * is code-completed).  If this isn't set, a default renderer is used.
+        */
+       private ListCellRenderer paramChoicesRenderer;
+
+       /**
         * The keystroke that triggers the completion window.
         */
        private KeyStroke trigger;
@@ -387,6 +394,21 @@ public class AutoCompletion {
 
 
        /**
+        * Returns the renderer to use for {@link Completion}s in the optional
+        * parameter choices popup window (displayed when a
+        * {@link ParameterizedCompletion} is code-completed).  If this returns
+        * <code>null</code>, a default renderer is used.
+        *
+        * @return The renderer to use.
+        * @see #setParamChoicesRenderer(ListCellRenderer)
+        * @see #isParameterAssistanceEnabled()
+        */
+       public ListCellRenderer getParamChoicesRenderer() {
+               return paramChoicesRenderer;
+       }
+
+
+       /**
         * Returns the text to replace with in the document.  This is a
         * "last-chance" hook for subclasses to make special modifications to 
the
         * completion text inserted.  The default implementation simply returns
@@ -890,6 +912,21 @@ public class AutoCompletion {
 
 
        /**
+        * Sets the renderer to use for {@link Completion}s in the optional
+        * parameter choices popup window (displayed when a
+        * {@link ParameterizedCompletion} is code-completed).  If this isn't 
set,
+        * a default renderer is used.
+        *
+        * @param r The renderer to use.
+        * @see #getParamChoicesRenderer()
+        * @see #setParameterAssistanceEnabled(boolean)
+        */
+       public void setParamChoicesRenderer(ListCellRenderer r) {
+               paramChoicesRenderer = r;
+       }
+
+
+       /**
         * Sets whether parameter assistance is enabled.  If parameter 
assistance
         * is enabled, and a "parameterized" completion (such as a function or
         * method) is inserted, the user will get "assistance" in inserting the
@@ -1008,6 +1045,10 @@ public class AutoCompletion {
                if (descToolTip!=null) {
                        descToolTip.updateUI();
                }
+               // Will practically always be a JComponent (a JLabel)
+               if (paramChoicesRenderer instanceof JComponent) {
+                       ((JComponent)paramChoicesRenderer).updateUI();
+               }
        }
 
 
diff --git a/src/org/fife/ui/autocomplete/ParameterChoicesProvider.java 
b/src/org/fife/ui/autocomplete/ParameterChoicesProvider.java
index 2303202..9e38ad1 100644
--- a/src/org/fife/ui/autocomplete/ParameterChoicesProvider.java
+++ b/src/org/fife/ui/autocomplete/ParameterChoicesProvider.java
@@ -45,7 +45,7 @@ public interface ParameterChoicesProvider {
         * @param tc The text component.
         * @param p The currently focused parameter.
         * @return The list of parameters.  This may be <code>null</code> for
-        *         "no parameters."
+        *         "no parameters," but might also be an empty list.
         */
        public List getParameterChoices(JTextComponent tc,
                                                                
ParameterizedCompletion.Parameter param);
diff --git 
a/src/org/fife/ui/autocomplete/ParameterizedCompletionChoicesWindow.java 
b/src/org/fife/ui/autocomplete/ParameterizedCompletionChoicesWindow.java
index c1f7783..e9aba1c 100644
--- a/src/org/fife/ui/autocomplete/ParameterizedCompletionChoicesWindow.java
+++ b/src/org/fife/ui/autocomplete/ParameterizedCompletionChoicesWindow.java
@@ -86,13 +86,15 @@ public class ParameterizedCompletionChoicesWindow extends 
JWindow {
 
                model = new DefaultListModel();
                list = new JList(model);
+               if (ac.getParamChoicesRenderer()!=null) {
+                       list.setCellRenderer(ac.getParamChoicesRenderer());
+               }
                JScrollPane sp = new JScrollPane(list);
                // Required to easily keep popup wide enough for no horiz. 
scroll bar
                
sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
 
                setContentPane(sp);
                applyComponentOrientation(o);
-
                setFocusableWindowState(false);
 
        }
@@ -105,7 +107,8 @@ public class ParameterizedCompletionChoicesWindow extends 
JWindow {
         *         selected.
         */
        public String getSelectedChoice() {
-               return (String)list.getSelectedValue();
+               Completion c = (Completion)list.getSelectedValue();
+               return c==null ? null : c.toString();
        }
 
 
@@ -209,16 +212,17 @@ public class ParameterizedCompletionChoicesWindow extends 
JWindow {
 
                        List choices = (List)choicesListList.get(param);
                        for (Iterator i=choices.iterator(); i.hasNext(); ) {
-                               String choice = (String)i.next();
+                               Completion c = (Completion)i.next();
+                               String choice = c.getReplacementText();
                                if (prefix==null ||
                                                
Util.startsWithIgnoreCase(choice, prefix)) {
-                                       model.addElement(choice);
+                                       model.addElement(c);
                                }
                        }
 
                        int visibleRowCount = Math.min(model.size(), 10);
                        list.setVisibleRowCount(visibleRowCount);
-
+//list.setPreferredSize(list.getPreferredScrollableViewportSize());
                        // Toggle visibility, if necessary.
                        if (visibleRowCount==0 && isVisible()) {
                                setVisible(false);

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