Top Description Inners Fields Constructors Methods
impl.org.controlsfx.autocompletion

public abstract Class SuggestionProvider<T>

extends Object
implements Callback<AutoCompletionBinding.ISuggestionRequest, Collection<T>>
Class Inheritance
All Implemented Interfaces
javafx.util.Callback
Known Direct Subclasses
impl.org.controlsfx.autocompletion.SuggestionProvider.SuggestionProviderString
Type Parameters
<T>
Type of suggestions
Imports
java.util.ArrayList, .Arrays, .Collection, .Collections, .Comparator, .List, javafx.beans.property.BooleanProperty, .SimpleBooleanProperty, javafx.util.Callback, org.controlsfx.control.textfield.AutoCompletionBinding.ISuggestionRequest

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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
SuggestionProvider.SuggestionProviderString<T>

This is a simple string based suggestion provider.

Field Summary

Modifier and TypeField and Description
private final List<T>
private final Object
private final BooleanProperty
showAllIfEmptyProperty

Tell the provider to show all suggestions if empty text given

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addPossibleSuggestions(T... newPossible)

Add the given new possible suggestions to this SuggestionProvider

public void
addPossibleSuggestions(Collection<T> newPossible)

Add the given new possible suggestions to this SuggestionProvider

public Collection<T>
call(final AutoCompletionBinding.ISuggestionRequest request)

Implements javafx.util.Callback.call.

The call method is called when required, and is given a single argument of type P, with a requirement that an object of type R is returned.

public void
clearSuggestions()

Remove all current possible suggestions

public static <T> SuggestionProvider<T>
create(Collection<T>
All possible suggestions
possibleSuggestions
)

Create a default suggestion provider based on the toString() method of the generic objects

public static <T> SuggestionProvider<T>
create(Callback<T, String>
A stringConverter which converts generic T into a string
stringConverter
,
Collection<T>
All possible suggestions
possibleSuggestions
)

Create a default suggestion provider based on the toString() method of the generic objects using the provided stringConverter

protected abstract Comparator<T>
getComparator()

Get the comparator to order the suggestions

protected abstract boolean
isMatch(T suggestion, AutoCompletionBinding.ISuggestionRequest request)

Check the given possible suggestion is a match (is a valid suggestion)

public final boolean

Returns:

the value of the property
isShowAllIfEmpty
()

Gets the value of the property showAllIfEmptyProperty

public final void
setShowAllIfEmpty(boolean
if true, the provider will show all suggestions if empty text given
showAllIfEmpty
)

Sets the value of the property showAllIfEmptyProperty

public final BooleanProperty

Returns:

the property
showAllIfEmptyProperty
()

Gets showAllIfEmptyProperty

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

possibleSuggestionsback to summary
private final List<T> possibleSuggestions
possibleSuggestionsLockback to summary
private final Object possibleSuggestionsLock
showAllIfEmptyPropertyback to summary
private final BooleanProperty showAllIfEmptyProperty

Tell the provider to show all suggestions if empty text given

Default Value
false

Constructor Detail

SuggestionProviderback to summary
public SuggestionProvider()

Method Detail

addPossibleSuggestionsback to summary
public void addPossibleSuggestions(T... newPossible)

Add the given new possible suggestions to this SuggestionProvider

addPossibleSuggestionsback to summary
public void addPossibleSuggestions(Collection<T> newPossible)

Add the given new possible suggestions to this SuggestionProvider

callback to summary
public Collection<T> call(final AutoCompletionBinding.ISuggestionRequest request)

Implements javafx.util.Callback.call.

Doc from javafx.util.Callback.call.

The call method is called when required, and is given a single argument of type P, with a requirement that an object of type R is returned.

Annotations
@Override
clearSuggestionsback to summary
public void clearSuggestions()

Remove all current possible suggestions

createback to summary
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:Collection<T>

All possible suggestions

createback to summary
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:Callback<T, String>

A stringConverter which converts generic T into a string

possibleSuggestions:Collection<T>

All possible suggestions

getComparatorback to summary
protected abstract Comparator<T> getComparator()

Get the comparator to order the suggestions

isMatchback to summary
protected abstract boolean isMatch(T suggestion, AutoCompletionBinding.ISuggestionRequest request)

Check the given possible suggestion is a match (is a valid suggestion)

isShowAllIfEmptyback to summary
public final boolean isShowAllIfEmpty()

Gets the value of the property showAllIfEmptyProperty

Returns:boolean

the value of the property

setShowAllIfEmptyback to summary
public final void setShowAllIfEmpty(boolean showAllIfEmpty)

Sets the value of the property showAllIfEmptyProperty

Parameters
showAllIfEmpty:boolean

if true, the provider will show all suggestions if empty text given

showAllIfEmptyPropertyback to summary
public final BooleanProperty showAllIfEmptyProperty()

Gets showAllIfEmptyProperty

Returns:BooleanProperty

the property

impl.org.controlsfx.autocompletion back to summary

private Class SuggestionProvider.SuggestionProviderString<T>

extends SuggestionProvider<T>
Class Inheritance

This is a simple string based suggestion provider. All generic suggestions T are turned into strings for processing.

Field Summary

Modifier and TypeField and Description
private final Comparator<T>
private Callback<T, String>

Constructor Summary

AccessConstructor and Description
public
SuggestionProviderString(Callback<T, String> stringConverter)

Create a new SuggestionProviderString

Method Summary

Modifier and TypeMethod and Description
protected Comparator<T>
getComparator()

Implements abstract impl.org.controlsfx.autocompletion.SuggestionProvider.getComparator.

Get the comparator to order the suggestions

protected boolean
isMatch(T suggestion, AutoCompletionBinding.ISuggestionRequest request)

Implements abstract impl.org.controlsfx.autocompletion.SuggestionProvider.isMatch.

Check the given possible suggestion is a match (is a valid suggestion)

Inherited from impl.org.controlsfx.autocompletion.SuggestionProvider:
addPossibleSuggestionsaddPossibleSuggestionscallclearSuggestionscreatecreateisShowAllIfEmptysetShowAllIfEmptyshowAllIfEmptyProperty

Field Detail

stringComparatorback to summary
private final Comparator<T> stringComparator
stringConverterback to summary
private Callback<T, String> stringConverter

Constructor Detail

SuggestionProviderStringback to summary
public SuggestionProviderString(Callback<T, String> stringConverter)

Create a new SuggestionProviderString

Method Detail

getComparatorback to summary
protected Comparator<T> getComparator()

Implements abstract impl.org.controlsfx.autocompletion.SuggestionProvider.getComparator.

Doc from impl.org.controlsfx.autocompletion.SuggestionProvider.getComparator.

Get the comparator to order the suggestions

Annotations
@Override
isMatchback to summary
protected boolean isMatch(T suggestion, AutoCompletionBinding.ISuggestionRequest request)

Implements abstract impl.org.controlsfx.autocompletion.SuggestionProvider.isMatch.

Doc from impl.org.controlsfx.autocompletion.SuggestionProvider.isMatch.

Check the given possible suggestion is a match (is a valid suggestion)

Annotations
@Override