java.lang.Object
de.grogra.pf.ui.autocomplete.impl.AbstractCompletion
- All Implemented Interfaces:
Completion,Comparable<Completion>
- Direct Known Subclasses:
BasicCompletion,ClassCompletion,MarkupTagCompletion,TemplateCompletion
Base class for possible completions. Most, if not all,
Completion
implementations can extend this class. It remembers the
CompletionProvider that returns this completion, and also implements
Comparable, allowing such completions to be compared
lexicographically (ignoring case).
This implementation assumes the input text and replacement text are the
same value. It also returns the input text from its toString()
method (which is what DefaultListCellRenderer uses to render
objects). Subclasses that wish to override any of this behavior can simply
override the corresponding method(s) needed to do so.
- Version:
- 1.0
- Author:
- Robert Futrell
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractCompletion(CompletionProvider provider) Constructor.protectedAbstractCompletion(CompletionProvider provider, Icon icon) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(Completion c2) Compares this completion to another one lexicographically, ignoring case.Returns the portion of this completion that has already been entered into the text component.Return the String used for comparing this Completion to othersgetIcon()Returns the icon to use for this completion.Returns the text the user has to (start) typing for this completion to be offered.Returns the provider that returned this completion.intReturns the "relevance" of this completion.The default implementation returnsnull.voidSets the icon to use for this completion.voidsetRelevance(int relevance) Sets the relevance of this completion.toString()Returns a string representation of this completion.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface de.grogra.pf.ui.autocomplete.impl.Completion
getReplacementText, getSummary
-
Constructor Details
-
AbstractCompletion
Constructor.- Parameters:
provider- The provider that created this completion.
-
AbstractCompletion
Constructor.- Parameters:
provider- The provider that created this completion.icon- The icon for this completion.
-
-
Method Details
-
compareTo
Description copied from interface:CompletionCompares this completion to another one lexicographically, ignoring case.- Specified by:
compareToin interfaceComparable<Completion>- Specified by:
compareToin interfaceCompletion- Parameters:
c2- Another completion instance.- Returns:
- How this completion compares to the other one.
-
getAlreadyEntered
Description copied from interface:CompletionReturns the portion of this completion that has already been entered into the text component. The match is case-insensitive.This is a convenience method for:
getProvider().getAlreadyEnteredText(comp).- Specified by:
getAlreadyEnteredin interfaceCompletion- Parameters:
comp- The text component.- Returns:
- The already-entered portion of this completion.
-
getIcon
Description copied from interface:CompletionReturns the icon to use for this completion.- Specified by:
getIconin interfaceCompletion- Returns:
- The icon, or
nullfor none.
-
getCompareString
Description copied from interface:CompletionReturn the String used for comparing this Completion to others- Specified by:
getCompareStringin interfaceCompletion- Returns:
-
getInputText
Returns the text the user has to (start) typing for this completion to be offered. The default implementation simply returnsCompletion.getReplacementText().- Specified by:
getInputTextin interfaceCompletion- Returns:
- The text the user has to (start) typing for this completion.
- See Also:
-
getProvider
Description copied from interface:CompletionReturns the provider that returned this completion.- Specified by:
getProviderin interfaceCompletion- Returns:
- The provider.
-
getRelevance
public int getRelevance()Description copied from interface:CompletionReturns the "relevance" of this completion. This is used when sorting completions by their relevance. It is an abstract concept that may mean different things to different languages, and may depend on the context of the completion.By default, all completions have a relevance of
0. The higher the value returned by this method, the higher up in the list this completion will be; the lower the value returned, the lower it will be.Completions with equal relevance values will be sorted alphabetically.- Specified by:
getRelevancein interfaceCompletion- Returns:
- The relevance of this completion.
-
getToolTipText
The default implementation returnsnull. Subclasses can override this method.- Specified by:
getToolTipTextin interfaceCompletion- Returns:
- The tool tip text.
-
setIcon
Sets the icon to use for this completion.- Parameters:
icon- The icon to use.- See Also:
-
setRelevance
public void setRelevance(int relevance) Sets the relevance of this completion.- Parameters:
relevance- The new relevance of this completion.- See Also:
-
toString
Returns a string representation of this completion. The default implementation returnsgetInputText().
-