Top Description Inners Fields Constructors Methods
org.controlsfx.control.textfield

public abstract Class AutoCompletionBinding<T>

extends Object
implements EventTarget
Class Inheritance
All Implemented Interfaces
javafx.event.EventTarget
Known Direct Subclasses
impl.org.controlsfx.autocompletion.AutoCompletionTextFieldBinding
Type Parameters
<T>
Model-Type of the suggestions
Imports
com.sun.javafx.event.EventHandlerManager, impl.org.controlsfx.skin.AutoCompletePopup, .AutoCompletePopupSkin, javafx.application.Platform, javafx.beans.property.ObjectProperty, .ObjectPropertyBase, .DoubleProperty, .IntegerProperty, javafx.concurrent.Task, javafx.event.*, javafx.scene.Node, javafx.scene.control.ListView, .Skin, javafx.util.Callback, .StringConverter, java.util.Collection, .UUID

The AutoCompletionBinding is the abstract base class of all auto-completion bindings. This class is the core logic for the auto-completion feature but highly customizable.

To use the autocompletion functionality, refer to the TextFields class. The popup size can be modified through its setVisibleRowCount(int) for the height and all the usual methods for the width.

See Also
TextFields

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
AutoCompletionBinding.AutoCompletionEvent<TE>

Represents an Event which is fired after an auto completion.

private class
AutoCompletionBinding.FetchSuggestionsTask

This task is responsible to fetch suggestions asynchronous by using the current defined suggestionProvider

public static interface
AutoCompletionBinding.ISuggestionRequest

Represents a suggestion fetch request

Field Summary

Modifier and TypeField and Description
private final AutoCompletePopup<T>
private final Node
completionTarget

* Private fields * *

private long
pack-priv final EventHandlerManager
eventHandlerManager

* EventTarget Implementation * *

private boolean
private ObjectProperty<EventHandler<AutoCompletionBinding.AutoCompletionEvent<T>>>
private Callback<AutoCompletionBinding.ISuggestionRequest, Collection<T>>
private AutoCompletionBinding<T>.FetchSuggestionsTask
private final Object

Constructor Summary

AccessConstructor and Description
protected
AutoCompletionBinding(Node
The target node to which auto-completion shall be added
completionTarget
,
Callback<AutoCompletionBinding.ISuggestionRequest, Collection<T>>
The strategy to retrieve suggestions
suggestionProvider
,
StringConverter<T>
The converter to be used to convert suggestions to strings
converter
)

Creates a new AutoCompletionBinding

Method Summary

Modifier and TypeMethod and Description
public <
the specific event class of the handler
E extends Event
>
void
addEventHandler(EventType<E>
the type of the events to receive by the handler
eventType
,
EventHandler<? super E>
the handler to register
eventHandler
)

Overrides default javafx.event.EventTarget.addEventHandler.

Registers an event handler to this EventTarget.

public EventDispatchChain
buildEventDispatchChain(EventDispatchChain tail)

Implements javafx.event.EventTarget.buildEventDispatchChain.

Construct an event dispatch chain for this target.

protected abstract void
completeUserInput(T completion)

Complete the current user-input with the provided completion.

public abstract void
dispose()

Disposes the binding.

protected void
fireAutoCompletion(T completion)

public AutoCompletePopup<T>

Returns:

the AutoCompletePopup used by this binding
getAutoCompletionPopup
()

Get the AutoCompletePopup used by this binding.

public Node

Returns:

the target node for auto completion
getCompletionTarget
()

Gets the target node for auto completion

public final double

Returns:

the max width of the popup.
getMaxWidth
()

Return the max width of the popup.

public final double

Returns:

the min width of the popup.
getMinWidth
()

Return the min width of the popup.

public final EventHandler<AutoCompletionBinding.AutoCompletionEvent<T>>
public final double

Returns:

the pref width of the popup.
getPrefWidth
()

Return the pref width of the popup.

public final int

Returns:

the maximum number of rows to be visible in the popup when it is showing.
getVisibleRowCount
()

Return the maximum number of rows to be visible in the popup when it is showing.

protected void
hidePopup()

Hide the auto completion targets

private boolean
isIgnoreInputChanges()

Shall changes to the user input be ignored?

public final DoubleProperty
maxWidthProperty()

Return the property associated with the max width.

public final DoubleProperty
minWidthProperty()

Return the property associated with the min width.

public final ObjectProperty<EventHandler<AutoCompletionBinding.AutoCompletionEvent<T>>>
private final void
onUserInputChanged(final String userText)

Occurs when the user text has changed and the suggestions require an update

public final DoubleProperty
prefWidthProperty()

Return the property associated with the pref width.

public <
the specific event class of the handler
E extends Event
>
void
removeEventHandler(EventType<E>
the event type from which to unregister
eventType
,
EventHandler<? super E>
the handler to unregister
eventHandler
)

Overrides default javafx.event.EventTarget.removeEventHandler.

Unregisters a previously registered event handler from this EventTarget.

private void
selectFirstSuggestion(AutoCompletePopup<?> autoCompletionPopup)

Selects the first suggestion (if any), so the user can choose it by pressing enter immediately.

public final void
setDelay(long delay)

Sets the delay in ms between a key press and the suggestion popup being displayed.

public void
setHideOnEscape(boolean value)

Specifies whether the PopupWindow should be hidden when an unhandled escape key is pressed while the popup has focus.

private void
setIgnoreInputChanges(boolean state)

If IgnoreInputChanges is set to true, all changes to the user input are ignored.

public final void
setMaxWidth(double value)

Sets the maxWidth of the popup.

public final void
setMinWidth(double value)

Sets the minWidth of the popup.

public final void
setOnAutoCompleted(EventHandler<AutoCompletionBinding.AutoCompletionEvent<T>> value)

Set a event handler which is invoked after an auto completion.

public final void
setPrefWidth(double value)

Sets the prefWidth of the popup.

public final void
setUserInput(String userText)

Set the current text the user has entered

public final void
setVisibleRowCount(int value)

Set the maximum number of rows to be visible in the popup when it is showing.

protected void
showPopup()

Show the auto completion popup

public final IntegerProperty

Returns:

an property representing the maximum number of rows to be visible in the popup when it is showing.
visibleRowCountProperty
()

Return an property representing the maximum number of rows to be visible in the popup when it is showing.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

autoCompletionPopupback to summary
private final AutoCompletePopup<T> autoCompletionPopup
completionTargetback to summary
private final Node completionTarget

* Private fields * *

delayback to summary
private long delay
eventHandlerManagerback to summary
pack-priv final EventHandlerManager eventHandlerManager

* EventTarget Implementation * *

ignoreInputChangesback to summary
private boolean ignoreInputChanges
onAutoCompletedback to summary
private ObjectProperty<EventHandler<AutoCompletionBinding.AutoCompletionEvent<T>>> onAutoCompleted
suggestionProviderback to summary
private Callback<AutoCompletionBinding.ISuggestionRequest, Collection<T>> suggestionProvider
suggestionsTaskback to summary
private AutoCompletionBinding<T>.FetchSuggestionsTask suggestionsTask
suggestionsTaskLockback to summary
private final Object suggestionsTaskLock

Constructor Detail

AutoCompletionBindingback to summary
protected AutoCompletionBinding(Node completionTarget, Callback<AutoCompletionBinding.ISuggestionRequest, Collection<T>> suggestionProvider, StringConverter<T> converter)

Creates a new AutoCompletionBinding

Parameters
completionTarget:Node

The target node to which auto-completion shall be added

suggestionProvider:Callback<AutoCompletionBinding.ISuggestionRequest, Collection<T>>

The strategy to retrieve suggestions

converter:StringConverter<T>

The converter to be used to convert suggestions to strings

Method Detail

addEventHandlerback to summary
public <E extends Event> void addEventHandler(EventType<E> eventType, EventHandler<? super E> eventHandler)

Overrides default javafx.event.EventTarget.addEventHandler.

Registers an event handler to this EventTarget. The handler is called when the menu item receives an Event of the specified type during the bubbling phase of event delivery.

Parameters
<E>
the specific event class of the handler
eventType:EventType<E>

the type of the events to receive by the handler

eventHandler:EventHandler<? super E>

the handler to register

Exceptions
NullPointerException:
if the event type or handler is null
buildEventDispatchChainback to summary
public EventDispatchChain buildEventDispatchChain(EventDispatchChain tail)

Implements javafx.event.EventTarget.buildEventDispatchChain.

Doc from javafx.event.EventTarget.buildEventDispatchChain.

Construct an event dispatch chain for this target. The event dispatch chain contains event dispatchers which might be interested in processing of events targeted at this EventTarget. This event target is not automatically added to the chain, so if it wants to process events, it needs to add an EventDispatcher for itself to the chain.

In the case the event target is part of some hierarchy, the chain for it is usually built from event dispatchers collected from the root of the hierarchy to the event target.

The event dispatch chain is constructed by modifications to the provided initial event dispatch chain. The returned chain should have the initial chain at its end so the dispatchers should be prepended to the initial chain.

The caller shouldn't assume that the initial chain remains unchanged nor that the returned value will reference a different chain.

Annotations
@Override
completeUserInputback to summary
protected abstract void completeUserInput(T completion)

Complete the current user-input with the provided completion. Sub-classes have to provide a concrete implementation.

disposeback to summary
public abstract void dispose()

Disposes the binding.

fireAutoCompletionback to summary
protected void fireAutoCompletion(T completion)
getAutoCompletionPopupback to summary
public AutoCompletePopup<T> getAutoCompletionPopup()

Get the AutoCompletePopup used by this binding. Note that this gives access to the internal API and should be used with great care (and in the expectation that things may break in the future). All relevant methods of the popup are already exposed in this class.

The only reason this is exposed is to allow custom skins for the popup.

Returns:AutoCompletePopup<T>

the AutoCompletePopup used by this binding

getCompletionTargetback to summary
public Node getCompletionTarget()

Gets the target node for auto completion

Returns:Node

the target node for auto completion

getMaxWidthback to summary
public final double getMaxWidth()

Return the max width of the popup.

Returns:double

the max width of the popup.

getMinWidthback to summary
public final double getMinWidth()

Return the min width of the popup.

Returns:double

the min width of the popup.

getOnAutoCompletedback to summary
public final EventHandler<AutoCompletionBinding.AutoCompletionEvent<T>> getOnAutoCompleted()
getPrefWidthback to summary
public final double getPrefWidth()

Return the pref width of the popup.

Returns:double

the pref width of the popup.

getVisibleRowCountback to summary
public final int getVisibleRowCount()

Return the maximum number of rows to be visible in the popup when it is showing.

Returns:int

the maximum number of rows to be visible in the popup when it is showing.

hidePopupback to summary
protected void hidePopup()

Hide the auto completion targets

isIgnoreInputChangesback to summary
private boolean isIgnoreInputChanges()

Shall changes to the user input be ignored?

maxWidthPropertyback to summary
public final DoubleProperty maxWidthProperty()

Return the property associated with the max width.

minWidthPropertyback to summary
public final DoubleProperty minWidthProperty()

Return the property associated with the min width.

onAutoCompletedPropertyback to summary
public final ObjectProperty<EventHandler<AutoCompletionBinding.AutoCompletionEvent<T>>> onAutoCompletedProperty()
onUserInputChangedback to summary
private final void onUserInputChanged(final String userText)

Occurs when the user text has changed and the suggestions require an update

prefWidthPropertyback to summary
public final DoubleProperty prefWidthProperty()

Return the property associated with the pref width.

removeEventHandlerback to summary
public <E extends Event> void removeEventHandler(EventType<E> eventType, EventHandler<? super E> eventHandler)

Overrides default javafx.event.EventTarget.removeEventHandler.

Unregisters a previously registered event handler from this EventTarget. One handler might have been registered for different event types, so the caller needs to specify the particular event type from which to unregister the handler.

Parameters
<E>
the specific event class of the handler
eventType:EventType<E>

the event type from which to unregister

eventHandler:EventHandler<? super E>

the handler to unregister

Exceptions
NullPointerException:
if the event type or handler is null
selectFirstSuggestionback to summary
private void selectFirstSuggestion(AutoCompletePopup<?> autoCompletionPopup)

Selects the first suggestion (if any), so the user can choose it by pressing enter immediately.

setDelayback to summary
public final void setDelay(long delay)

Sets the delay in ms between a key press and the suggestion popup being displayed.

setHideOnEscapeback to summary
public void setHideOnEscape(boolean value)

Specifies whether the PopupWindow should be hidden when an unhandled escape key is pressed while the popup has focus.

setIgnoreInputChangesback to summary
private void setIgnoreInputChanges(boolean state)

If IgnoreInputChanges is set to true, all changes to the user input are ignored. This is primary used to avoid self triggering while auto completing.

setMaxWidthback to summary
public final void setMaxWidth(double value)

Sets the maxWidth of the popup.

setMinWidthback to summary
public final void setMinWidth(double value)

Sets the minWidth of the popup.

setOnAutoCompletedback to summary
public final void setOnAutoCompleted(EventHandler<AutoCompletionBinding.AutoCompletionEvent<T>> value)

Set a event handler which is invoked after an auto completion.

setPrefWidthback to summary
public final void setPrefWidth(double value)

Sets the prefWidth of the popup.

setUserInputback to summary
public final void setUserInput(String userText)

Set the current text the user has entered

setVisibleRowCountback to summary
public final void setVisibleRowCount(int value)

Set the maximum number of rows to be visible in the popup when it is showing.

showPopupback to summary
protected void showPopup()

Show the auto completion popup

visibleRowCountPropertyback to summary
public final IntegerProperty visibleRowCountProperty()

Return an property representing the maximum number of rows to be visible in the popup when it is showing.

Returns:IntegerProperty

an property representing the maximum number of rows to be visible in the popup when it is showing.

org.controlsfx.control.textfield back to summary

public Class AutoCompletionBinding.AutoCompletionEvent<TE>

extends Event
Class Inheritance
Annotations
@SuppressWarnings:serial

Represents an Event which is fired after an auto completion.

Field Summary

Modifier and TypeField and Description
public static final EventType<AutoCompletionBinding.AutoCompletionEvent<?>>
AUTO_COMPLETED

The event type that should be listened to by people interested in knowing when an auto completion has been performed.

private final TE
Inherited from javafx.event.Event:
ANYconsumedeventTypeNULL_SOURCE_TARGETtarget

Constructor Summary

AccessConstructor and Description
public
AutoCompletionEvent(TE completion)

Creates a new event that can subsequently be fired.

Method Summary

Modifier and TypeMethod and Description
public TE
getCompletion()

Returns the chosen completion.

Inherited from javafx.event.Event:
cloneconsumecopyForfireEventgetEventTypegetTargetisConsumed

Field Detail

AUTO_COMPLETEDback to summary
public static final EventType<AutoCompletionBinding.AutoCompletionEvent<?>> AUTO_COMPLETED

The event type that should be listened to by people interested in knowing when an auto completion has been performed.

completionback to summary
private final TE completion

Constructor Detail

AutoCompletionEventback to summary
public AutoCompletionEvent(TE completion)

Creates a new event that can subsequently be fired.

Method Detail

getCompletionback to summary
public TE getCompletion()

Returns the chosen completion.

org.controlsfx.control.textfield back to summary

private Class AutoCompletionBinding.FetchSuggestionsTask

extends Task<Void>
implements ISuggestionRequest
Class Inheritance
All Implemented Interfaces
org.controlsfx.control.textfield.AutoCompletionBinding.ISuggestionRequest

This task is responsible to fetch suggestions asynchronous by using the current defined suggestionProvider

Field Summary

Modifier and TypeField and Description
private final long
private final String

Constructor Summary

AccessConstructor and Description
public
FetchSuggestionsTask(String userText, long delay)

Method Summary

Modifier and TypeMethod and Description
protected Void
call()

Implements abstract javafx.concurrent.Task.call.

Invoked when the Task is executed, the call method must be overridden and implemented by subclasses.

public String
getUserText()

Implements org.controlsfx.control.textfield.AutoCompletionBinding.ISuggestionRequest.getUserText.

Get the user text to which suggestions shall be found

Inherited from javafx.concurrent.Task:
addEventFilteraddEventHandlerbuildEventDispatchChaincancelcancelcancelledexceptionPropertyfailedfireEventgetExceptiongetMessagegetOnCancelledgetOnFailedgetOnRunninggetOnScheduledgetOnSucceededgetProgressgetStategetTitlegetTotalWorkgetValuegetWorkDoneisRunningmessagePropertyonCancelledPropertyonFailedPropertyonRunningPropertyonScheduledPropertyonSucceededPropertyprogressPropertyremoveEventFilterremoveEventHandlerrunningrunningPropertyscheduledsetEventHandlersetOnCancelledsetOnFailedsetOnRunningsetOnScheduledsetOnSucceededstatePropertysucceededtitlePropertytotalWorkPropertyupdateMessageupdateProgressupdateProgressupdateTitleupdateValuevaluePropertyworkDoneProperty

Field Detail

delayback to summary
private final long delay
userTextback to summary
private final String userText

Constructor Detail

FetchSuggestionsTaskback to summary
public FetchSuggestionsTask(String userText, long delay)

Method Detail

callback to summary
protected Void call() throws Exception

Implements abstract javafx.concurrent.Task.call.

Doc from javafx.concurrent.Task.call.

Invoked when the Task is executed, the call method must be overridden and implemented by subclasses. The call method actually performs the background thread logic. Only the updateProgress, updateMessage, updateValue and updateTitle methods of Task may be called from code within this method. Any other interaction with the Task from the background thread will result in runtime exceptions.

Annotations
@Override
Exceptions
Exception:
an unhandled exception which occurred during the background operation
getUserTextback to summary
public String getUserText()

Implements org.controlsfx.control.textfield.AutoCompletionBinding.ISuggestionRequest.getUserText.

Doc from org.controlsfx.control.textfield.AutoCompletionBinding.ISuggestionRequest.getUserText.

Get the user text to which suggestions shall be found

Annotations
@Override
org.controlsfx.control.textfield back to summary

public Interface AutoCompletionBinding.ISuggestionRequest

Known Direct Implementers
org.controlsfx.control.textfield.AutoCompletionBinding.FetchSuggestionsTask

Represents a suggestion fetch request

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

String containing the user text
getUserText
()

Get the user text to which suggestions shall be found

public boolean

Returns:

true if the request is canceled, otherwise false
isCancelled
()

Is this request canceled?

Method Detail

getUserTextback to summary
public String getUserText()

Get the user text to which suggestions shall be found

Returns:String

String containing the user text

isCancelledback to summary
public boolean isCancelled()

Is this request canceled?

Returns:boolean

true if the request is canceled, otherwise false