SearchField control and supports
the additional feature of using the selected object as a tag. Tags are shown in front
of the text input field. The control provides an observable list of the currently
added tags. In addition, the field also allows the user to select one or more of
the tags. The selection state is provided by the selection model. The field adds
and removes tags via undoable commands, which means that, for example, a deleted tag
can be recovered by pressing the standard undo (or redo) shortcut.
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private class | |
| private static interface | |
| private class | |
| pack-priv class |
| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| private final DoubleProperty | |
| private final DoubleProperty | |
| private static final int | |
| private final Deque | |
| private final ListProperty | |
| private final ObjectProperty | |
| private final ObjectProperty | |
| private final Deque |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public final void | |
| public final void | |
| public void | commit()
Overrides com. Overridden to modify the behaviour for the tag field. |
| protected Skin | createDefaultSkin()
Overrides com. Create a new instance of the default skin for this control. |
| public final DoubleProperty | Returns: the minimum width of the editorThe minimum width of the editor when it is not used. |
| public final DoubleProperty | Returns: the preferred width of the editorThe preferred width of the editor when it is being used. |
| private void | |
| public Orientation | getContentBias()
Overrides javafx. Returns the orientation of a node's resizing bias for layout purposes. |
| public final double | |
| public final double | |
| public final ObservableList | |
| public final MultipleSelectionModel | |
| public final Callback | |
| public String | getUserAgentStylesheet()
Overrides com. An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. |
| private void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final ObjectProperty | Returns: the selection modelA selection model for the tags shown by the field. |
| public final ListProperty | |
| public final ObjectProperty | Returns: a node factory for the tagsA callback used to create the nodes that represent the tags. |
| private void | |
| protected void | update(Collection<T>
the new suggestions to use for the field newSuggestions)Overrides com. Overridden to remove the already tagged items from the suggestion list. |
| DEFAULT_STYLE_CLASS | back to summary |
|---|---|
| private static final String DEFAULT_STYLE_CLASS | |
| editorMinWidth | back to summary |
|---|---|
| private final DoubleProperty editorMinWidth | |
| editorPrefWidth | back to summary |
|---|---|
| private final DoubleProperty editorPrefWidth | |
| MAX_UNDO_AND_REDO_STEPS | back to summary |
|---|---|
| private static final int MAX_UNDO_AND_REDO_STEPS | |
| redoStack | back to summary |
|---|---|
| private final Deque<TagsField. | |
| tags | back to summary |
|---|---|
| private final ListProperty<T> tags | |
| tagSelectionModel | back to summary |
|---|---|
| private final ObjectProperty<MultipleSelectionModel<T>> tagSelectionModel | |
| tagViewFactory | back to summary |
|---|---|
| private final ObjectProperty<Callback<T, Node>> tagViewFactory | |
| undoStack | back to summary |
|---|---|
| private final Deque<TagsField. | |
| TagsField | back to summary |
|---|---|
| public TagsField() Constructs a new tag field. | |
| addTags | back to summary |
|---|---|
| public final void addTags(T... values) Used to add one or more tags programmatically. This ensures that tags are added via an undoable command.
| |
| clearTags | back to summary |
|---|---|
| public final void clearTags() Used to clear all tags programmatically. This ensures that tags are cleared via an undoable command. | |
| commit | back to summary |
|---|---|
| public void commit() Overrides com. Overridden to modify the behaviour for the tag field. The override method commits the currently selected item to become a tag.
| |
| createDefaultSkin | back to summary |
|---|---|
| protected Skin Overrides com. Doc from javafx. Create a new instance of the default skin for this control. This is called to create a skin for the control if
no skin is provided via CSS
| |
| editorMinWidthProperty | back to summary |
|---|---|
| public final DoubleProperty editorMinWidthProperty() The minimum width of the editor when it is not used.
| |
| editorPrefWidthProperty | back to summary |
|---|---|
| public final DoubleProperty editorPrefWidthProperty() The preferred width of the editor when it is being used.
| |
| execute | back to summary |
|---|---|
| private void execute(TagsField. | |
| getContentBias | back to summary |
|---|---|
| public Orientation getContentBias() Overrides javafx. Doc from javafx. Returns the orientation of a node's resizing bias for layout purposes. If the node type has no bias, returns null. If the node is resizable and it's height depends on its width, returns HORIZONTAL, else if its width depends on its height, returns VERTICAL. Resizable subclasses should override this method to return an appropriate value.
| |
| getEditorMinWidth | back to summary |
|---|---|
| public final double getEditorMinWidth() | |
| getEditorPrefWidth | back to summary |
|---|---|
| public final double getEditorPrefWidth() | |
| getTags | back to summary |
|---|---|
| public final ObservableList | |
| getTagSelectionModel | back to summary |
|---|---|
| public final MultipleSelectionModel | |
| getTagViewFactory | back to summary |
|---|---|
| public final Callback | |
| getUserAgentStylesheet | back to summary |
|---|---|
| public String getUserAgentStylesheet() Overrides com. Doc from javafx. An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. These styles are used in addition to whatever user-agent stylesheets are in use. This provides a mechanism for third parties to introduce styles for custom controls. The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL does not have a [scheme:] component, the URL is considered to be the [path] component only. Any leading '/' character of the [path] is ignored and the [path] is treated as a path relative to the root of the application's classpath. Subclasses overriding this method should not assume any particular implementation approach as to the number and frequency with which it is called. For this reason, attempting any kind of dynamic implementation (i.e. returning different user agent stylesheet values) based on some state change is highly discouraged, as there is no guarantee when, or even if, this method will be called. Some JavaFX CSS implementations may choose to cache this response for an indefinite period of time, and therefore there should be no expectation around when this method is called.
For additional information about using CSS with the scene graph,
see the CSS Reference Guide.
| |
| redo | back to summary |
|---|---|
| private void redo() | |
| removeTags | back to summary |
|---|---|
| public final void removeTags(T... values) Used to remove one or more tags programmatically. This ensures that tags are removed via an undoable command.
| |
| setEditorMinWidth | back to summary |
|---|---|
| public final void setEditorMinWidth(double editorMinWidth) | |
| setEditorPrefWidth | back to summary |
|---|---|
| public final void setEditorPrefWidth(double editorPrefWidth) | |
| setTags | back to summary |
|---|---|
| public final void setTags(ObservableList<T> tags) | |
| setTagSelectionModel | back to summary |
|---|---|
| public final void setTagSelectionModel(MultipleSelectionModel<T> tagSelectionModel) | |
| setTagViewFactory | back to summary |
|---|---|
| public final void setTagViewFactory(Callback<T, Node> tagViewFactory) | |
| tagSelectionModelProperty | back to summary |
|---|---|
| public final ObjectProperty A selection model for the tags shown by the field.
| |
| tagsProperty | back to summary |
|---|---|
| public final ListProperty A list property used to store the tags.
| |
| tagViewFactoryProperty | back to summary |
|---|---|
| public final ObjectProperty A callback used to create the nodes that represent the tags. The default implementation uses labels.
| |
| undo | back to summary |
|---|---|
| private void undo() | |
| update | back to summary |
|---|---|
| protected void update(Collection<T> newSuggestions) Overrides com. Overridden to remove the already tagged items from the suggestion list.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final T[] |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void |
| tags | back to summary |
|---|---|
| private final T[] tags | |
| AddTagCommand | back to summary |
|---|---|
public AddTagCommand(T... tags)
| |
| execute | back to summary |
|---|---|
| public void execute() Implements com.
| |
| undo | back to summary |
|---|---|
| public void undo() Implements com.
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void |
| tags | back to summary |
|---|---|
| private final List<T> tags | |
| ClearTagsCommand | back to summary |
|---|---|
| public ClearTagsCommand(List<T> tags) | |
| execute | back to summary |
|---|---|
| public void execute() Implements com.
| |
| undo | back to summary |
|---|---|
| public void undo() Implements com.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final T[] |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void |
| tags | back to summary |
|---|---|
| private final T[] tags | |
| RemoveTagCommand | back to summary |
|---|---|
public RemoveTagCommand(T... tags)
| |
| execute | back to summary |
|---|---|
| public void execute() Implements com.
| |
| undo | back to summary |
|---|---|
| public void undo() Implements com.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final ObservableList | |
| private final ObservableList |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | clearAndSelect(int index)
Implements abstract javafx. A method that clears any selection prior to setting the selection to the given index. |
| public void | clearSelection(int index)
Implements abstract javafx. This method will clear the selection of the item in the given index. |
| public void | clearSelection()
Implements abstract javafx. Clears the selection model of all selected indices. |
| public ObservableList | getSelectedIndices()
Implements abstract javafx. Returns a read-only ObservableList of all selected indices. |
| public ObservableList | getSelectedItems()
Implements abstract javafx. Returns a read-only ObservableList of all selected items. |
| public boolean | isEmpty()
Implements abstract javafx. This method is available to test whether there are any selected indices/items. |
| public boolean | isSelected(int index)
Implements abstract javafx. This method tests whether the given index is currently selected in this SelectionModel. |
| public void | select(int index)
Implements abstract javafx. This will select the given index in the selection model, assuming the index is within the valid range (i.e. greater than or equal to zero, and less than the total number of items in the underlying data model). |
| public void | select(T tag)
Implements abstract javafx. This method will attempt to select the index that contains the given object. |
| public void | selectAll()
Implements abstract javafx. Convenience method to select all available indices. |
| public void | selectFirst()
Implements abstract javafx. This method will attempt to select the first index in the control. |
| public void | selectIndices(int index, int... indices)
Implements abstract javafx. This method allows for one or more selections to be set at the same time. |
| public void | selectLast()
Implements abstract javafx. This method will attempt to select the last index in the control. |
| public void | selectNext()
Implements abstract javafx. This method will attempt to select the index directly after the current focused index. |
| public void | selectPrevious()
Implements abstract javafx. This method will attempt to select the index directly before the current focused index. |
| public void | selectRange(int start, int end)
Overrides javafx. Selects all indices from the given start index to the item before the given end index. |
| selectedIndices | back to summary |
|---|---|
| private final ObservableList<Integer> selectedIndices | |
| selectedItems | back to summary |
|---|---|
| private final ObservableList<T> selectedItems | |
| TagFieldSelectionModel | back to summary |
|---|---|
| public TagFieldSelectionModel() | |
| clearAndSelect | back to summary |
|---|---|
| public void clearAndSelect(int index) Implements abstract javafx. Doc from javafx. A method that clears any selection prior to setting the selection to the
given index. The purpose of this method is to avoid having to call
| |
| clearSelection | back to summary |
|---|---|
| public void clearSelection(int index) Implements abstract javafx. Doc from javafx. This method will clear the selection of the item in the given index. If the given index is not selected, nothing will happen.
| |
| clearSelection | back to summary |
|---|---|
| public void clearSelection() Implements abstract javafx. Doc from javafx. Clears the selection model of all selected indices.
| |
| getSelectedIndices | back to summary |
|---|---|
| public ObservableList Implements abstract javafx. Doc from javafx. Returns a read-only ObservableList of all selected indices. The
ObservableList will be updated by the selection model to always reflect
changes in selection. This can be observed by adding a
| |
| getSelectedItems | back to summary |
|---|---|
| public ObservableList Implements abstract javafx. Doc from javafx. Returns a read-only ObservableList of all selected items. The
ObservableList will be updated further by the selection model to always reflect
changes in selection. This can be observed by adding a
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Implements abstract javafx. Doc from javafx. This method is available to test whether there are any selected indices/items. It will return true if there are no selected items, and false if there are.
| |
| isSelected | back to summary |
|---|---|
| public boolean isSelected(int index) Implements abstract javafx. Doc from javafx. This method tests whether the given index is currently selected in this SelectionModel.
| |
| select | back to summary |
|---|---|
| public void select(int index) Implements abstract javafx. Doc from javafx. This will select the given index in the selection model, assuming the index is within the valid range (i.e. greater than or equal to zero, and less than the total number of items in the underlying data model). If there is already one or more indices selected in this model, calling
this method will not clear these selections - to do so it is
necessary to first call If the index is already selected, it will not be selected again, or
unselected. However, if multiple selection is implemented, then calling
select on an already selected index will have the effect of making the index
the new selected index (as returned by
| |
| select | back to summary |
|---|---|
| public void select(T tag) Implements abstract javafx. Doc from javafx. This method will attempt to select the index that contains the given object. It will iterate through the underlying data model until it finds an item whose value is equal to the given object. At this point it will stop iterating - this means that this method will not select multiple indices.
| |
| selectAll | back to summary |
|---|---|
| public void selectAll() Implements abstract javafx. Doc from javafx. Convenience method to select all available indices.
| |
| selectFirst | back to summary |
|---|---|
| public void selectFirst() Implements abstract javafx. Doc from javafx. This method will attempt to select the first index in the control. If clearSelection is not called first, this method will have the result of selecting the first index, whilst retaining the selection of any other currently selected indices. If the first index is already selected, calling this method will have no result, and no selection event will take place.
| |
| selectIndices | back to summary |
|---|---|
| public void selectIndices(int index, int... indices) Implements abstract javafx. Doc from javafx. This method allows for one or more selections to be set at the same time. It will ignore any value that is not within the valid range (i.e. greater than or equal to zero, and less than the total number of items in the underlying data model). Any duplication of indices will be ignored. If there is already one or more indices selected in this model, calling this method will not clear these selections - to do so it is necessary to first call clearSelection. The last valid value given will become the selected index / selected item.
| |
| selectLast | back to summary |
|---|---|
| public void selectLast() Implements abstract javafx. Doc from javafx. This method will attempt to select the last index in the control. If clearSelection is not called first, this method will have the result of selecting the last index, whilst retaining the selection of any other currently selected indices. If the last index is already selected, calling this method will have no result, and no selection event will take place.
| |
| selectNext | back to summary |
|---|---|
| public void selectNext() Implements abstract javafx. Doc from javafx. This method will attempt to select the index directly after the current focused index. If clearSelection is not called first, this method will have the result of selecting the next index, whilst retaining the selection of any other currently selected indices. Calling this method will only succeed if:
If any of these conditions is false, no selection event will take place.
| |
| selectPrevious | back to summary |
|---|---|
| public void selectPrevious() Implements abstract javafx. Doc from javafx. This method will attempt to select the index directly before the current focused index. If clearSelection is not called first, this method will have the result of selecting the previous index, whilst retaining the selection of any other currently selected indices. Calling this method will only succeed if:
If any of these conditions is false, no selection event will take place.
| |
| selectRange | back to summary |
|---|---|
| public void selectRange(int start, int end) Overrides javafx. Doc from javafx. Selects all indices from the given start index to the item before the given end index. This means that the selection is inclusive of the start index, and exclusive of the end index. This method will work regardless of whether start < end or start > end: the only constant is that the index before the given end index will become the selected index. If there is already one or more indices selected in this model, calling this method will not clear these selections - to do so it is necessary to first call clearSelection.
| |