Module org.controlsfx.controls
Class SuggestionProvider<T>
- java.lang.Object
-
- impl.org.controlsfx.autocompletion.SuggestionProvider<T>
-
- Type Parameters:
T
- Type of suggestions
- All Implemented Interfaces:
Callback<AutoCompletionBinding.ISuggestionRequest,Collection<T>>
public abstract class SuggestionProvider<T> extends Object implements Callback<AutoCompletionBinding.ISuggestionRequest,Collection<T>>
This is a simple implementation of a generic suggestion provider callback. The complexity of suggestion generation is O(n) where n is the number of possible suggestions.
-
-
Property Summary
Properties Type Property Description BooleanProperty
showAllIfEmpty
Gets showAllIfEmptyProperty
-
Constructor Summary
Constructors Constructor Description SuggestionProvider()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addPossibleSuggestions(Collection<T> newPossible)
Add the given new possible suggestions to this SuggestionProvidervoid
addPossibleSuggestions(T... newPossible)
Add the given new possible suggestions to this SuggestionProviderCollection<T>
call(AutoCompletionBinding.ISuggestionRequest request)
void
clearSuggestions()
Remove all current possible suggestionsstatic <T> SuggestionProvider<T>
create(Collection<T> possibleSuggestions)
Create a default suggestion provider based on the toString() method of the generic objectsstatic <T> SuggestionProvider<T>
create(Callback<T,String> stringConverter, Collection<T> possibleSuggestions)
Create a default suggestion provider based on the toString() method of the generic objects using the provided stringConverterprotected abstract Comparator<T>
getComparator()
Get the comparator to order the suggestionsprotected abstract boolean
isMatch(T suggestion, AutoCompletionBinding.ISuggestionRequest request)
Check the given possible suggestion is a match (is a valid suggestion)boolean
isShowAllIfEmpty()
Gets the value of the property showAllIfEmptyPropertyvoid
setShowAllIfEmpty(boolean showAllIfEmpty)
Sets the value of the property showAllIfEmptyPropertyBooleanProperty
showAllIfEmptyProperty()
Gets showAllIfEmptyProperty
-
-
-
Property Detail
-
showAllIfEmpty
public final BooleanProperty showAllIfEmptyProperty
Gets showAllIfEmptyProperty- See Also:
isShowAllIfEmpty()
,setShowAllIfEmpty(boolean)
-
-
Method Detail
-
showAllIfEmptyProperty
public final BooleanProperty showAllIfEmptyProperty()
Gets showAllIfEmptyProperty- See Also:
isShowAllIfEmpty()
,setShowAllIfEmpty(boolean)
-
isShowAllIfEmpty
public final boolean isShowAllIfEmpty()
Gets the value of the property showAllIfEmptyProperty- Returns:
- the value of the property
-
setShowAllIfEmpty
public final void setShowAllIfEmpty(boolean showAllIfEmpty)
Sets the value of the property showAllIfEmptyProperty- Parameters:
showAllIfEmpty
- if true, the provider will show all suggestions if empty text given
-
addPossibleSuggestions
public void addPossibleSuggestions(T... newPossible)
Add the given new possible suggestions to this SuggestionProvider- Parameters:
newPossible
-
-
addPossibleSuggestions
public void addPossibleSuggestions(Collection<T> newPossible)
Add the given new possible suggestions to this SuggestionProvider- Parameters:
newPossible
-
-
clearSuggestions
public void clearSuggestions()
Remove all current possible suggestions
-
call
public Collection<T> call(AutoCompletionBinding.ISuggestionRequest request)
- Specified by:
call
in interfaceCallback<AutoCompletionBinding.ISuggestionRequest,Collection<T>>
-
getComparator
protected abstract Comparator<T> getComparator()
Get the comparator to order the suggestions- Returns:
-
isMatch
protected abstract boolean isMatch(T suggestion, AutoCompletionBinding.ISuggestionRequest request)
Check the given possible suggestion is a match (is a valid suggestion)- Parameters:
suggestion
-request
-- Returns:
-
create
public static <T> SuggestionProvider<T> create(Collection<T> possibleSuggestions)
Create a default suggestion provider based on the toString() method of the generic objects- Parameters:
possibleSuggestions
- All possible suggestions- Returns:
-
create
public static <T> SuggestionProvider<T> create(Callback<T,String> stringConverter, Collection<T> possibleSuggestions)
Create a default suggestion provider based on the toString() method of the generic objects using the provided stringConverter- Parameters:
stringConverter
- A stringConverter which converts generic T into a stringpossibleSuggestions
- All possible suggestions- Returns:
-
-