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.
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
- Author:
- Robert Futrell
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A comparator that compares the input text of aCompletion
against a String lexicographically, ignoring case. -
Field Summary
Modifier and TypeFieldDescriptionCompares aCompletion
against 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a single completion to this provider.void
addCompletions
(List<Completion> completions) AddsCompletion
s to this provider.protected void
addWordCompletions
(String[] words) Adds simple completions for a list of words.protected void
void
clear()
Removes all completions from this provider.getCompletionByInputText
(String inputText) Returns a list ofCompletion
s in this provider with the specified input text.protected List<Completion>
Does the dirty work of creating a list of completions.boolean
Removes 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, setParent
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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 aCompletion
against 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
AddsCompletion
s 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. -
getCompletionByInputText
Returns a list ofCompletion
s 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
Completion
s, ornull
if there are no matchingCompletion
s.
-
getCompletionsImpl
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
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:
-