diff --git a/src/main/java/org/fife/ui/autocomplete/AbstractCompletion.java b/src/main/java/org/fife/ui/autocomplete/AbstractCompletion.java
index 8c6d2dc..351fc29 100644
--- a/src/main/java/org/fife/ui/autocomplete/AbstractCompletion.java
+++ b/src/main/java/org/fife/ui/autocomplete/AbstractCompletion.java
@@ -79,7 +79,7 @@ public int compareTo(Completion c2) {
return 0;
}
else if (c2!=null) {
- return toString().compareToIgnoreCase(c2.toString());
+ return getInputText().compareToIgnoreCase(c2.getInputText());
}
return -1;
}
diff --git a/src/main/java/org/fife/ui/autocomplete/AutoCompletion.java b/src/main/java/org/fife/ui/autocomplete/AutoCompletion.java
index 8a68e78..ac8bcd1 100644
--- a/src/main/java/org/fife/ui/autocomplete/AutoCompletion.java
+++ b/src/main/java/org/fife/ui/autocomplete/AutoCompletion.java
@@ -10,10 +10,11 @@
import java.awt.*;
import java.awt.event.*;
-import java.beans.*;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.util.List;
+
import javax.swing.*;
-import javax.swing.Timer;
import javax.swing.event.*;
import javax.swing.text.*;
@@ -295,24 +296,30 @@ public void doCompletion() {
*/
protected void fireAutoCompletionEvent(AutoCompletionEvent.Type type) {
- // Guaranteed to return a non-null array
- Object[] listeners = this.listeners.getListenerList();
- AutoCompletionEvent e = null;
-
- // Process the listeners last to first, notifying those that are
- // interested in this event
- for (int i=listeners.length-2; i>=0; i-=2) {
- if (listeners[i] == AutoCompletionListener.class) {
- if (e==null) {
- e = new AutoCompletionEvent(this, type);
- }
- ((AutoCompletionListener)listeners[i+1]).autoCompleteUpdate(e);
- }
- }
+ fireAutoCompletionEvent(new AutoCompletionEvent(this, type));
}
+ /**
+ * Fires an {@link AutoCompletionEvent}.
+ * @param event
+ */
+ protected void fireAutoCompletionEvent(AutoCompletionEvent event) {
+
+ // Guaranteed to return a non-null array
+ Object[] listeners = this.listeners.getListenerList();
+
+ // Process the listeners last to first, notifying those that are
+ // interested in this event
+ for (int i=listeners.length-2; i>=0; i-=2) {
+ if (listeners[i] == AutoCompletionListener.class) {
+ ((AutoCompletionListener)listeners[i+1]).autoCompleteUpdate(event);
+ }
+ }
+
+ }
+
/**
* Returns the delay between when the user types a character and when the
* code completion popup should automatically appear (if applicable).
@@ -611,6 +618,28 @@ protected void insertCompletion(Completion c,
}
}
+
+ /**
+ * Method called when the {@link ParameterizedCompletionContext} is active and the assistance ends.
+ * You can use {@link ParameterizedCompletionContext#getParameterValues()}, to get the values of the parameters entered by the user.
+ * @param context
+ */
+ protected void onParameterizedCompletionFinish( ParameterizedCompletionContext context ){
+ fireAutoCompletionEvent(new ParameterizedCompletionEvent(context, AutoCompletionEvent.Type.PARAMETER_COMPLETION_FINISH));
+ }
+
+ /**
+ * Method called when the {@link ParameterChoicesProvider} is active and the user selects the parameter in the list of available values.
+ * The default implementation simply replaces the text of the current selection with the 'choice'.
+ * @param context
+ */
+ protected void onParameterizedCompletionSelect( ParameterizedCompletionContext context , int paramIndex , String choice ){
+ textComponent.replaceSelection(choice);
+ ParameterizedCompletionEvent event = new ParameterizedCompletionEvent(context, AutoCompletionEvent.Type.PARAMETER_COMPLETION_SELECT);
+ event.setParamIndex(paramIndex);
+ event.setChoice(choice);
+ fireAutoCompletionEvent(event);
+ }
/**
@@ -1141,7 +1170,7 @@ public void setTriggerKey(KeyStroke ks) {
* @param typedParamListStartChar Whether the parameterized completion list
* starting character was typed.
*/
- private void startParameterizedCompletionAssistance(
+ public void startParameterizedCompletionAssistance(
ParameterizedCompletion pc, boolean typedParamListStartChar) {
// Get rid of the previous tool tip window, if there is one.
diff --git a/src/main/java/org/fife/ui/autocomplete/AutoCompletionEvent.java b/src/main/java/org/fife/ui/autocomplete/AutoCompletionEvent.java
index 9174a4c..0abc9b0 100644
--- a/src/main/java/org/fife/ui/autocomplete/AutoCompletionEvent.java
+++ b/src/main/java/org/fife/ui/autocomplete/AutoCompletionEvent.java
@@ -64,7 +64,13 @@ public Type getEventType() {
*/
public static enum Type {
POPUP_SHOWN,
- POPUP_HIDDEN
+ POPUP_HIDDEN,
+ /** Type of {@link ParameterizedCompletionEvent}
+ * @see {@link AutoCompletion#onParameterizedCompletionFinish(ParameterizedCompletionContext)}*/
+ PARAMETER_COMPLETION_FINISH,
+ /** Type of {@link ParameterizedCompletionEvent}
+ * @see {@link AutoCompletion#onParameterizedCompletionSelect(ParameterizedCompletionContext, int, String)*/
+ PARAMETER_COMPLETION_SELECT
}
diff --git a/src/main/java/org/fife/ui/autocomplete/FunctionCompletion.java b/src/main/java/org/fife/ui/autocomplete/FunctionCompletion.java
index 94d9622..54d7e75 100644
--- a/src/main/java/org/fife/ui/autocomplete/FunctionCompletion.java
+++ b/src/main/java/org/fife/ui/autocomplete/FunctionCompletion.java
@@ -10,6 +10,7 @@
import java.util.ArrayList;
import java.util.List;
+
import javax.swing.text.BadLocationException;
import javax.swing.text.JTextComponent;
import javax.swing.text.Position;
@@ -318,5 +319,4 @@ public void setReturnValueDescription(String desc) {
this.returnValDesc = desc;
}
-
}
\ No newline at end of file
diff --git a/src/main/java/org/fife/ui/autocomplete/ParameterChoicesProvider.java b/src/main/java/org/fife/ui/autocomplete/ParameterChoicesProvider.java
index dc80325..f01bdc5 100644
--- a/src/main/java/org/fife/ui/autocomplete/ParameterChoicesProvider.java
+++ b/src/main/java/org/fife/ui/autocomplete/ParameterChoicesProvider.java
@@ -29,12 +29,12 @@ public interface ParameterChoicesProvider {
* Returns a list of choices for a specific parameter.
*
* @param tc The text component.
+ * @param pc The currently ParameterizedCompletion
* @param param The currently focused parameter.
* @return The list of parameters. This may be null for
* "no parameters," but might also be an empty list.
*/
- public List getParameterChoices(JTextComponent tc,
- ParameterizedCompletion.Parameter param);
+ public List getParameterChoices(JTextComponent tc, ParameterizedCompletion pc , ParameterizedCompletion.Parameter param);
}
\ No newline at end of file
diff --git a/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletion.java b/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletion.java
index e13ada0..601d139 100644
--- a/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletion.java
+++ b/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletion.java
@@ -61,7 +61,6 @@ public ParameterizedCompletionInsertionInfo getInsertionInfo(
*/
public boolean getShowParameterToolTip();
-
/**
* A parameter passed to a parameterized {@link Completion}.
*/
diff --git a/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletionChoicesWindow.java b/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletionChoicesWindow.java
index 6cc5a1e..266b5ed 100644
--- a/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletionChoicesWindow.java
+++ b/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletionChoicesWindow.java
@@ -171,7 +171,7 @@ public void initialize(ParameterizedCompletion pc) {
for (int i=0; i choices = pcp.getParameterChoices(tc, param);
+ List choices = pcp.getParameterChoices(tc, pc, param);
choicesListList.add(choices);
}
diff --git a/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletionContext.java b/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletionContext.java
index 7eda9d5..8f06fec 100644
--- a/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletionContext.java
+++ b/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletionContext.java
@@ -18,7 +18,9 @@
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
+
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ActionMap;
@@ -58,7 +60,7 @@
* @author Robert Futrell
* @version 1.0
*/
-class ParameterizedCompletionContext {
+public class ParameterizedCompletionContext {
/**
* The parent window.
@@ -98,6 +100,8 @@ class ParameterizedCompletionContext {
* The tags for the highlights around parameters.
*/
private List