java.lang.Object
de.grogra.pf.ui.autocomplete.impl.CompletionProviderBase
de.grogra.pf.ui.autocomplete.impl.AbstractCompletionProvider
- All Implemented Interfaces:
CompletionProvider
- Direct Known Subclasses:
ChildrenCompletionProvider,ClassCompletionProvider,DefaultCompletionProvider
A base class for completion providers.
Completions 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
- Author:
- Robert Futrell
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA comparator that compares the input text of aCompletionagainst a String lexicographically, ignoring case. -
Field Summary
FieldsModifier and TypeFieldDescriptionCompares aCompletionagainst a String.protected List<Completion> The completions this provider is aware of.Fields inherited from class de.grogra.pf.ui.autocomplete.impl.CompletionProviderBase
EMPTY_STRING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a single completion to this provider.voidaddCompletions(List<Completion> completions) AddsCompletions to this provider.protected voidaddWordCompletions(String[] words) Adds simple completions for a list of words.protected voidvoidclear()Removes all completions from this provider.getCompletionByInputText(String inputText) Returns a list ofCompletions in this provider with the specified input text.protected List<Completion> Does the dirty work of creating a list of completions.booleanRemoves the specified completion from this provider.Methods inherited from class de.grogra.pf.ui.autocomplete.impl.CompletionProviderBase
clearParameterizedCompletionParams, getCompletions, getListCellRenderer, getParameterChoicesProvider, getParameterListEnd, getParameterListSeparator, getParameterListStart, getParent, isAutoActivateOkay, setAutoActivationRules, setListCellRenderer, setParameterChoicesProvider, setParameterizedCompletionParams, setParentMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.grogra.pf.ui.autocomplete.impl.CompletionProvider
getAlreadyEnteredText, getCompletionsAt, getParameterizedCompletions, isValidChar
-
Field Details
-
completions
The completions this provider is aware of. Subclasses should ensure that this list is sorted alphabetically (case-insensitively). -
comparator
Compares aCompletionagainst a String.
-
-
Constructor Details
-
AbstractCompletionProvider
public AbstractCompletionProvider()Constructor.
-
-
Method Details
-
addCompletion
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:
IllegalArgumentException- If the completion's provider isn't thisCompletionProvider.- See Also:
-
addCompletions
AddsCompletions to this provider.- Parameters:
completions- The completions to add. This cannot benull.- Throws:
IllegalArgumentException- If a completion's provider isn't thisCompletionProvider.- See Also:
-
addWordCompletions
Adds simple completions for a list of words.- Parameters:
words- The words.- See Also:
-
checkProviderAndAdd
-
clear
public void clear()Removes all completions from this provider. This does not affect the parentCompletionProvider, if there is one.- See Also:
-
getCompletionByInputText
Returns a list ofCompletions in this provider with the specified input text. This returns the completions with the Exact matches- Parameters:
inputText- The input text to search for.- Returns:
- A list of
Completions, ornullif there are no matchingCompletions.
-
getCompletionsImpl
Description copied from class:CompletionProviderBaseDoes the dirty work of creating a list of completions.- Specified by:
getCompletionsImplin classCompletionProviderBase- Parameters:
comp- The text component to look in.- Returns:
- The list of possible completions, or an empty list if there are none.
-
removeCompletion
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:
trueif this provider contained the specified completion.- See Also:
-