Package org.fife.ui.autocomplete
Class AbstractCompletionProvider
- java.lang.Object
-
- org.fife.ui.autocomplete.CompletionProviderBase
-
- org.fife.ui.autocomplete.AbstractCompletionProvider
-
- All Implemented Interfaces:
CompletionProvider
- Direct Known Subclasses:
DefaultCompletionProvider
public abstract class AbstractCompletionProvider extends CompletionProviderBase
A base class for completion providers.Completion
s are kept in a sorted list. To get the list of completions that match a given input, a binary search is done to find the first matching completion, then all succeeding completions that also match are also returned.- Version:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractCompletionProvider.CaseInsensitiveComparator
A comparator that compares the input text of aCompletion
against a String lexicographically, ignoring case.
-
Field Summary
Fields Modifier and Type Field Description protected AbstractCompletionProvider.CaseInsensitiveComparator
comparator
Compares aCompletion
against a String.protected java.util.List<Completion>
completions
The completions this provider is aware of.-
Fields inherited from class org.fife.ui.autocomplete.CompletionProviderBase
EMPTY_STRING
-
-
Constructor Summary
Constructors Constructor Description AbstractCompletionProvider()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCompletion(Completion c)
Adds a single completion to this provider.void
addCompletions(java.util.List<Completion> completions)
AddsCompletion
s to this provider.protected void
addWordCompletions(java.lang.String[] words)
Adds simple completions for a list of words.protected void
checkProviderAndAdd(Completion c)
void
clear()
Removes all completions from this provider.java.util.List<Completion>
getCompletionByInputText(java.lang.String inputText)
Returns a list ofCompletion
s in this provider with the specified input text.protected java.util.List<Completion>
getCompletionsImpl(javax.swing.text.JTextComponent comp)
Does the dirty work of creating a list of completions.boolean
removeCompletion(Completion c)
Removes the specified completion from this provider.-
Methods inherited from class org.fife.ui.autocomplete.CompletionProviderBase
clearParameterizedCompletionParams, getCompletions, getListCellRenderer, getParameterChoicesProvider, getParameterListEnd, getParameterListSeparator, getParameterListStart, getParent, isAutoActivateOkay, setAutoActivationRules, setListCellRenderer, setParameterChoicesProvider, setParameterizedCompletionParams, setParent
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.fife.ui.autocomplete.CompletionProvider
getAlreadyEnteredText, getCompletionsAt, getParameterizedCompletions
-
-
-
-
Field Detail
-
completions
protected java.util.List<Completion> completions
The completions this provider is aware of. Subclasses should ensure that this list is sorted alphabetically (case-insensitively).
-
comparator
protected AbstractCompletionProvider.CaseInsensitiveComparator comparator
Compares aCompletion
against a String.
-
-
Method Detail
-
addCompletion
public void addCompletion(Completion c)
Adds a single completion to this provider. If you are adding multiple completions to this provider, for efficiency reasons please consider usingaddCompletions(List)
instead.- Parameters:
c
- The completion to add.- Throws:
java.lang.IllegalArgumentException
- If the completion's provider isn't thisCompletionProvider
.- See Also:
addCompletions(List)
,removeCompletion(Completion)
,clear()
-
addCompletions
public void addCompletions(java.util.List<Completion> completions)
AddsCompletion
s to this provider.- Parameters:
completions
- The completions to add. This cannot benull
.- Throws:
java.lang.IllegalArgumentException
- If a completion's provider isn't thisCompletionProvider
.- See Also:
addCompletion(Completion)
,removeCompletion(Completion)
,clear()
-
addWordCompletions
protected void addWordCompletions(java.lang.String[] words)
Adds simple completions for a list of words.- Parameters:
words
- The words.- See Also:
BasicCompletion
-
checkProviderAndAdd
protected void checkProviderAndAdd(Completion c)
-
clear
public void clear()
Removes all completions from this provider. This does not affect the parentCompletionProvider
, if there is one.
-
getCompletionByInputText
public java.util.List<Completion> getCompletionByInputText(java.lang.String inputText)
Returns a list ofCompletion
s in this provider with the specified input text.- Parameters:
inputText
- The input text to search for.- Returns:
- A list of
Completion
s, ornull
if there are no matchingCompletion
s.
-
getCompletionsImpl
protected java.util.List<Completion> getCompletionsImpl(javax.swing.text.JTextComponent comp)
Description copied from class:CompletionProviderBase
Does the dirty work of creating a list of completions.- Specified by:
getCompletionsImpl
in classCompletionProviderBase
- Parameters:
comp
- The text component to look in.- Returns:
- The list of possible completions, or an empty list if there are none.
-
removeCompletion
public boolean removeCompletion(Completion c)
Removes the specified completion from this provider. This method will not remove completions from the parent provider, if there is one.- Parameters:
c
- The completion to remove.- Returns:
true
if this provider contained the specified completion.- See Also:
clear()
,addCompletion(Completion)
,addCompletions(List)
-
-