java.lang.Object
de.grogra.pf.ui.autocomplete.impl.CompletionProviderBase
de.grogra.pf.ui.autocomplete.impl.AbstractCompletionProvider
de.grogra.pf.ui.autocomplete.impl.DefaultCompletionProvider
- All Implemented Interfaces:
CompletionProvider
A basic completion provider implementation. This provider has no
understanding of language semantics. It simply checks the text entered up
to the caret position for a match against known completions. This is all
that is needed in the majority of cases.
- Version:
- 1.0
- Author:
- Robert Futrell
-
Nested Class Summary
Nested classes/interfaces inherited from class de.grogra.pf.ui.autocomplete.impl.AbstractCompletionProvider
AbstractCompletionProvider.CaseInsensitiveComparator -
Field Summary
Fields inherited from class de.grogra.pf.ui.autocomplete.impl.AbstractCompletionProvider
comparator, completionsFields inherited from class de.grogra.pf.ui.autocomplete.impl.CompletionProviderBase
EMPTY_STRING -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.DefaultCompletionProvider(String[] words) Creates a completion provider that provides completion for a simple list of words. -
Method Summary
Modifier and TypeMethodDescriptionReturns the text just before the current caret position that could be the start of something auto-completable.Returns the completions that have been entered at the specified visual location.Returns a list of parameterized completions that have been entered at the current caret position of a text component (and thus can have their completion choices displayed).protected voidinit()Initializes this completion provider.booleanisValidChar(char ch) Returns whether the specified character is valid in an auto-completion.Methods inherited from class de.grogra.pf.ui.autocomplete.impl.AbstractCompletionProvider
addCompletion, addCompletions, addWordCompletions, checkProviderAndAdd, clear, getCompletionByInputText, getCompletionsImpl, removeCompletionMethods inherited from class de.grogra.pf.ui.autocomplete.impl.CompletionProviderBase
clearParameterizedCompletionParams, getCompletions, getListCellRenderer, getParameterChoicesProvider, getParameterListEnd, getParameterListSeparator, getParameterListStart, getParent, isAutoActivateOkay, setAutoActivationRules, setListCellRenderer, setParameterChoicesProvider, setParameterizedCompletionParams, setParent
-
Constructor Details
-
DefaultCompletionProvider
public DefaultCompletionProvider()Constructor. The returned provider will not be aware of any completions.- See Also:
-
DefaultCompletionProvider
Creates a completion provider that provides completion for a simple list of words.- Parameters:
words- The words to offer as completion suggestions. If this isnull, no completions will be known.- See Also:
-
-
Method Details
-
getAlreadyEnteredText
Returns the text just before the current caret position that could be the start of something auto-completable.This method returns all characters before the caret that are matched by
isValidChar(char).Returns the text just before the current caret position that could be the start of something auto-completable.
- Parameters:
comp- The text component.- Returns:
- The text. A return value of
nullmeans nothing should be auto-completed; a value of an empty string ("") means auto-completion should still be considered (i.e., all possible choices are valid).
-
getCompletionsAt
Description copied from interface:CompletionProviderReturns the completions that have been entered at the specified visual location. This can be used for tool tips when the user hovers the mouse over completed text.- Parameters:
tc- The text component.p- The position, usually from aMouseEvent.- Returns:
- The completions, or an empty list if there are none.
-
getParameterizedCompletions
Description copied from interface:CompletionProviderReturns a list of parameterized completions that have been entered at the current caret position of a text component (and thus can have their completion choices displayed).- Parameters:
tc- The text component.- Returns:
- The list of
ParameterizedCompletions. If no completions are available, this may benull.
-
init
protected void init()Initializes this completion provider. -
isValidChar
public boolean isValidChar(char ch) Returns whether the specified character is valid in an auto-completion. The default implementation is equivalent to "Character.isLetterOrDigit(ch) || ch=='_'". Subclasses can override this method to change what characters are matched.- Parameters:
ch- The character.- Returns:
- Whether the character is valid.
-