Top Description Inners Fields Constructors Methods
com.dlsc.gemsfx

public Class FilterView<T>

extends Control
Class Inheritance
Type Parameters
<T>
the type of the model objects filtered by the view
Imports
com.dlsc.gemsfx.skins.FilterViewSkin, javafx.beans.InvalidationListener, .Observable, javafx.beans.property.BooleanProperty, .IntegerProperty, .ListProperty, .ObjectProperty, .ReadOnlyListProperty, .ReadOnlyListWrapper, .ReadOnlyObjectProperty, .ReadOnlyObjectWrapper, .SimpleBooleanProperty, .SimpleIntegerProperty, .SimpleListProperty, .SimpleObjectProperty, .SimpleStringProperty, .StringProperty, javafx.collections.FXCollections, .ListChangeListener.Change, .ObservableList, javafx.collections.transformation.FilteredList, .SortedList, javafx.scene.Node, javafx.scene.control.Control, .Skin, javafx.scene.layout.Region, javafx.util.Callback, org.apache.commons.lang3.StringUtils, java.util.ArrayList, .HashMap, .List, .Map, .Objects, java.util.function.Predicate

A view for presenting a set of predefined filter groups, each one with a list of filters. The user can select one or more filters from each group. Elements found in the resulting filtered list have to match ALL filters. The selected filters will be shown as "chips" (see @link ChipView).

Items can be added via the getItems() list. Table or list views have to use the getFilteredItems() list. This filtered list can also be wrapped via a SortedList and then added to a table or list view.

An input field for filtering based on text input will appear as soon as a text filter provider has been defined. See setTextFilterProvider(Callback).

Applications with additional filtering needs can utilize the additionalFilterPredicateProperty().

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
FilterView.Filter<
the type of the model objects managed by the filter view
T
>

A filter is a predicate that will be used for filtering the elements of an observable list.

public static class
FilterView.FilterGroup<
the type of the model objects managed by the filter view
T
>

A filter group consists of a group of filters and has a name.

Field Summary

Modifier and TypeField and Description
private final ObjectProperty<Predicate<T>>
private final ObjectProperty<Node>
private final ReadOnlyListWrapper<T>
private final ListProperty<FilterView.FilterGroup<T>>
private final ReadOnlyObjectWrapper<Predicate<T>>
private final ListProperty<FilterView.Filter<T>>
private final StringProperty
private final ListProperty<T>
private final IntegerProperty
private final SearchTextField
private final BooleanProperty
private final StringProperty
private final ObjectProperty<Node>
private final ObjectProperty<Callback<String, Predicate<T>>>
private final StringProperty
private final ObjectProperty<Node>
private final StringProperty
private final ObjectProperty<Node>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final ObjectProperty<Predicate<T>>
protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

public final ObjectProperty<Node>

Returns:

the extra node
extrasProperty
()

An extra node that can be added to the header of the filter view.

public final ReadOnlyListProperty<T>
public final ListProperty<FilterView.FilterGroup<T>>
public final ReadOnlyObjectProperty<Predicate<T>>
public ListProperty<FilterView.Filter<T>>
public final StringProperty

Returns:

the filter text
filterTextProperty
()

Stores the filter text entered by the user inside the filter text field.

public final Predicate<T>
public final Node
public final ObservableList<T>
public final ObservableList<FilterView.FilterGroup<T>>
public final Predicate<T>
public ObservableList<FilterView.Filter<T>>
public final String
public final ObservableList<T>
public int
public final SearchTextField

Returns:

the search text field
getSearchTextField
()

Returns the search text field used for entering filter terms.

public final String
public Node
public final Callback<String, Predicate<T>>
public final String
public final Node
public final String
public final Node
public String
getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method.

public final boolean
public final ListProperty<T>

Returns:

the model
itemsProperty
()

The list of items that will be managed by the view.

public IntegerProperty
scrollThresholdProperty()

The threshold number of filters at which a ScrollPane is introduced to handle large number of elements.

public final void
setAdditionalFilterPredicate(Predicate<T> additionalFilterPredicate)

public final void
setExtras(Node extras)

public final void
public void
public final void
setFilterText(String filterText)

public final void
public void
setScrollThreshold(int scrollThreshold)

public final void
setShowHeader(boolean showHeader)

public final void
setSubtitle(String subtitle)

public void
setSubtitleGraphic(Node subtitleGraphic)

public final void
public final void
public final void
setTitleGraphic(Node titleGraphic)

public final void
setTitlePostfix(String titlePostfix)

public final void
setTitlePostfixGraphic(Node titlePostfixGraphic)

public final BooleanProperty

Returns:

true if the header will be shown (default is "true")
showHeaderProperty
()

A flag to control whether the title, subtitle, and the search field will be shown or not.

public ObjectProperty<Node>
subtitleGraphicProperty()

The graphic node displayed alongside the subtitle label.

public final StringProperty

Returns:

the subtitle text
subtitleProperty
()

The subtitle text for the filter view.

public final ObjectProperty<Callback<String, Predicate<T>>>

Returns:

the text filter predicate provider
textFilterProviderProperty
()

Returns a filter predicate for a given text.

public final ObjectProperty<Node>
titleGraphicProperty()

The graphic node displayed alongside the title label.

public final ObjectProperty<Node>
titlePostfixGraphicProperty()

The graphic node displayed alongside the title postfix label.

public final StringProperty

Returns:

the title postfix text
titlePostfixProperty
()

A text that can be added to the title text.

public final StringProperty

Returns:

the title text
titleProperty
()

The title for the filter view

Inherited from javafx.scene.control.Control:
computeMaxHeightcomputeMaxWidthcomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthcontextMenuPropertyexecuteAccessibleActiongetBaselineOffsetgetClassCssMetaDatagetContextMenugetControlCssMetaDatagetCssMetaDatagetInitialFocusTraversablegetSkingetTooltipisResizablelayoutChildrenqueryAccessibleAttributesetContextMenusetSkinsetTooltipskinPropertytooltipProperty

Field Detail

additionalFilterPredicateback to summary
private final ObjectProperty<Predicate<T>> additionalFilterPredicate
extrasback to summary
private final ObjectProperty<Node> extras
filteredItemsback to summary
private final ReadOnlyListWrapper<T> filteredItems
filterGroupsback to summary
private final ListProperty<FilterView.FilterGroup<T>> filterGroups
filterPredicateback to summary
private final ReadOnlyObjectWrapper<Predicate<T>> filterPredicate
filtersback to summary
private final ListProperty<FilterView.Filter<T>> filters
filterTextback to summary
private final StringProperty filterText
itemsback to summary
private final ListProperty<T> items
scrollThresholdback to summary
private final IntegerProperty scrollThreshold
searchTextFieldback to summary
private final SearchTextField searchTextField
showHeaderback to summary
private final BooleanProperty showHeader
subtitleback to summary
private final StringProperty subtitle
subtitleGraphicback to summary
private final ObjectProperty<Node> subtitleGraphic
textFilterProviderback to summary
private final ObjectProperty<Callback<String, Predicate<T>>> textFilterProvider
titleback to summary
private final StringProperty title
titleGraphicback to summary
private final ObjectProperty<Node> titleGraphic
titlePostfixback to summary
private final StringProperty titlePostfix
titlePostfixGraphicback to summary
private final ObjectProperty<Node> titlePostfixGraphic

Constructor Detail

FilterViewback to summary
public FilterView()

Method Detail

additionalFilterPredicatePropertyback to summary
public final ObjectProperty<Predicate<T>> additionalFilterPredicateProperty()
createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Doc from javafx.scene.control.Control.createDefaultSkin.

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 -fx-skin or set explicitly in a sub-class with setSkin(...).

Annotations
@Override
extrasPropertyback to summary
public final ObjectProperty<Node> extrasProperty()

An extra node that can be added to the header of the filter view. The node will appear to the right of the (optional) text filter field.

Returns:ObjectProperty<Node>

the extra node

filteredItemsPropertyback to summary
public final ReadOnlyListProperty<T> filteredItemsProperty()
filterGroupsPropertyback to summary
public final ListProperty<FilterView.FilterGroup<T>> filterGroupsProperty()
filterPredicatePropertyback to summary
public final ReadOnlyObjectProperty<Predicate<T>> filterPredicateProperty()
filtersPropertyback to summary
public ListProperty<FilterView.Filter<T>> filtersProperty()
filterTextPropertyback to summary
public final StringProperty filterTextProperty()

Stores the filter text entered by the user inside the filter text field.

Returns:StringProperty

the filter text

See Also
setTextFilterProvider(Callback)
getAdditionalFilterPredicateback to summary
public final Predicate<T> getAdditionalFilterPredicate()
getExtrasback to summary
public final Node getExtras()
getFilteredItemsback to summary
public final ObservableList<T> getFilteredItems()
getFilterGroupsback to summary
public final ObservableList<FilterView.FilterGroup<T>> getFilterGroups()
getFilterPredicateback to summary
public final Predicate<T> getFilterPredicate()
getFiltersback to summary
public ObservableList<FilterView.Filter<T>> getFilters()
getFilterTextback to summary
public final String getFilterText()
getItemsback to summary
public final ObservableList<T> getItems()
getScrollThresholdback to summary
public int getScrollThreshold()
getSearchTextFieldback to summary
public final SearchTextField getSearchTextField()

Returns the search text field used for entering filter terms.

Returns:SearchTextField

the search text field

getSubtitleback to summary
public final String getSubtitle()
getSubtitleGraphicback to summary
public Node getSubtitleGraphic()
getTextFilterProviderback to summary
public final Callback<String, Predicate<T>> getTextFilterProvider()
getTitleback to summary
public final String getTitle()
getTitleGraphicback to summary
public final Node getTitleGraphic()
getTitlePostfixback to summary
public final String getTitlePostfix()
getTitlePostfixGraphicback to summary
public final Node getTitlePostfixGraphic()
getUserAgentStylesheetback to summary
public String getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

Doc from javafx.scene.layout.Region.getUserAgentStylesheet.

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.



package com.example.javafx.app;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class MyApp extends Application {

    @Override public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        scene.getStylesheets().add("/com/example/javafx/app/mystyles.css");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
For additional information about using CSS with the scene graph, see the CSS Reference Guide.
Annotations
@Override
isShowHeaderback to summary
public final boolean isShowHeader()
itemsPropertyback to summary
public final ListProperty<T> itemsProperty()

The list of items that will be managed by the view.

Returns:ListProperty<T>

the model

scrollThresholdPropertyback to summary
public IntegerProperty scrollThresholdProperty()

The threshold number of filters at which a ScrollPane is introduced to handle large number of elements. If the number of filters is equal to or exceeds this value, the filters will be displayed within a ScrollPane.

setAdditionalFilterPredicateback to summary
public final void setAdditionalFilterPredicate(Predicate<T> additionalFilterPredicate)
setExtrasback to summary
public final void setExtras(Node extras)
setFilterGroupsback to summary
public final void setFilterGroups(ObservableList<FilterView.FilterGroup<T>> filterGroups)
setFiltersback to summary
public void setFilters(ObservableList<FilterView.Filter<T>> filters)
setFilterTextback to summary
public final void setFilterText(String filterText)
setItemsback to summary
public final void setItems(ObservableList<T> items)
setScrollThresholdback to summary
public void setScrollThreshold(int scrollThreshold)
setShowHeaderback to summary
public final void setShowHeader(boolean showHeader)
setSubtitleback to summary
public final void setSubtitle(String subtitle)
setSubtitleGraphicback to summary
public void setSubtitleGraphic(Node subtitleGraphic)
setTextFilterProviderback to summary
public final void setTextFilterProvider(Callback<String, Predicate<T>> textFilterProvider)
setTitleback to summary
public final void setTitle(String title)
setTitleGraphicback to summary
public final void setTitleGraphic(Node titleGraphic)
setTitlePostfixback to summary
public final void setTitlePostfix(String titlePostfix)
setTitlePostfixGraphicback to summary
public final void setTitlePostfixGraphic(Node titlePostfixGraphic)
showHeaderPropertyback to summary
public final BooleanProperty showHeaderProperty()

A flag to control whether the title, subtitle, and the search field will be shown or not.

Returns:BooleanProperty

true if the header will be shown (default is "true")

subtitleGraphicPropertyback to summary
public ObjectProperty<Node> subtitleGraphicProperty()

The graphic node displayed alongside the subtitle label.

subtitlePropertyback to summary
public final StringProperty subtitleProperty()

The subtitle text for the filter view.

Returns:StringProperty

the subtitle text

textFilterProviderPropertyback to summary
public final ObjectProperty<Callback<String, Predicate<T>>> textFilterProviderProperty()

Returns a filter predicate for a given text. This predicate will be added to the list of internally managed predicates. The input field for text will only appear if this predicate has been specified.

Returns:ObjectProperty<Callback<String, Predicate<T>>>

the text filter predicate provider

titleGraphicPropertyback to summary
public final ObjectProperty<Node> titleGraphicProperty()

The graphic node displayed alongside the title label.

titlePostfixGraphicPropertyback to summary
public final ObjectProperty<Node> titlePostfixGraphicProperty()

The graphic node displayed alongside the title postfix label.

titlePostfixPropertyback to summary
public final StringProperty titlePostfixProperty()

A text that can be added to the title text.

Returns:StringProperty

the title postfix text

titlePropertyback to summary
public final StringProperty titleProperty()

The title for the filter view

Returns:StringProperty

the title text

com.dlsc.gemsfx back to summary

public abstract Class FilterView.Filter<T>

extends Object
implements Predicate<T>
Class Inheritance
All Implemented Interfaces
java.util.function.Predicate
Type Parameters
<T>
the type of the model objects managed by the filter view

A filter is a predicate that will be used for filtering the elements of an observable list. A filter may only be added to one FilterGroup.
See Also
FilterGroup#getFilters(), FilteredList#setPredicate(Predicate)

Field Summary

Modifier and TypeField and Description
private FilterView.FilterGroup<T>
private final StringProperty
private final StringProperty
private boolean

Constructor Summary

AccessConstructor and Description
public
Filter(String
the name of the filter (e.g. "Male")
name
,
String
the id of the filter
id
)

Constructs a new filter with the given name.

public
Filter(String
the name of the filter (e.g. "Male")
name
)

Constructs a new filter with the given name.

public
Filter(String
the name of the filter (e.g., "Male")
name
,
boolean
the default selected state of the filter; true if the filter should be selected by default, false otherwise
selected
)

Constructs a new filter with the given name, setting it to the default selected state.

public
Filter(String
the name of the filter (e.g., "Male")
name
,
String
the id of the filter
id
,
boolean
the default selected state of the filter; true if the filter should be selected by default, false otherwise
selected
)

Constructs a new filter with the given name and id, setting it to the default selected state.

Method Summary

Modifier and TypeMethod and Description
public FilterView.FilterGroup<T>

Returns:

the filter's "parent" group
getGroup
()

Returns the group to which the filter belongs.

public final String
public final String
public final StringProperty

Returns:

the ID of the filter group
idProperty
()

An identifier, useful for persisting session state of the filter view.

public boolean

Returns:

true if the filter is selected by default, false otherwise
isSelected
()

Returns the default selected state of the filter.

public final StringProperty

Returns:

the filter's name
nameProperty
()

The name of the filter as shown inside the UI.

pack-priv void
public final void
public final void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

groupback to summary
private FilterView.FilterGroup<T> group
idback to summary
private final StringProperty id
nameback to summary
private final StringProperty name
selectedback to summary
private boolean selected

Constructor Detail

Filterback to summary
public Filter(String name, String id)

Constructs a new filter with the given name.

Parameters
name:String

the name of the filter (e.g. "Male")

id:String

the id of the filter

Filterback to summary
public Filter(String name)

Constructs a new filter with the given name.

Parameters
name:String

the name of the filter (e.g. "Male")

Filterback to summary
public Filter(String name, boolean selected)

Constructs a new filter with the given name, setting it to the default selected state.

Parameters
name:String

the name of the filter (e.g., "Male")

selected:boolean

the default selected state of the filter; true if the filter should be selected by default, false otherwise

Filterback to summary
public Filter(String name, String id, boolean selected)

Constructs a new filter with the given name and id, setting it to the default selected state.

Parameters
name:String

the name of the filter (e.g., "Male")

id:String

the id of the filter

selected:boolean

the default selected state of the filter; true if the filter should be selected by default, false otherwise

Method Detail

getGroupback to summary
public FilterView.FilterGroup<T> getGroup()

Returns the group to which the filter belongs.

Returns:FilterView.FilterGroup<T>

the filter's "parent" group

See Also
FilterGroup#getFilters()
getIdback to summary
public final String getId()
getNameback to summary
public final String getName()
idPropertyback to summary
public final StringProperty idProperty()

An identifier, useful for persisting session state of the filter view.

Returns:StringProperty

the ID of the filter group

isSelectedback to summary
public boolean isSelected()

Returns the default selected state of the filter.

Returns:boolean

true if the filter is selected by default, false otherwise

namePropertyback to summary
public final StringProperty nameProperty()

The name of the filter as shown inside the UI.

Returns:StringProperty

the filter's name

setGroupback to summary
pack-priv void setGroup(FilterView.FilterGroup<T> group)
setIdback to summary
public final void setId(String id)
setNameback to summary
public final void setName(String name)
com.dlsc.gemsfx back to summary

public Class FilterView.FilterGroup<T>

extends Object
Class Inheritance
Type Parameters
<T>
the type of the model objects managed by the filter view

A filter group consists of a group of filters and has a name. The name is displayed in the UI as part of the dropdown list that expostes the available filters.

Field Summary

Modifier and TypeField and Description
private final ListProperty<FilterView.Filter<T>>
private final StringProperty
private final StringProperty

Constructor Summary

AccessConstructor and Description
public
FilterGroup(String
the name that will be shown in the UI, e.g. "Gender"
name
,
String
the id of the group
id
)

Constructs a new group.

public

Method Summary

Modifier and TypeMethod and Description
public final ListProperty<FilterView.Filter<T>>
public final ObservableList<FilterView.Filter<T>>
public final String
public final String
public final StringProperty

Returns:

the ID of the filter group
idProperty
()

An identifier, useful for persisting session state of the filter view.

public final StringProperty

Returns:

the filter name
nameProperty
()

The name of the filter as shown in the filter group's dropdown list.

public final void
public final void
public final void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

filtersback to summary
private final ListProperty<FilterView.Filter<T>> filters
idback to summary
private final StringProperty id
nameback to summary
private final StringProperty name

Constructor Detail

FilterGroupback to summary
public FilterGroup(String name, String id)

Constructs a new group.

Parameters
name:String

the name that will be shown in the UI, e.g. "Gender"

id:String

the id of the group

FilterGroupback to summary
public FilterGroup(String name)

Method Detail

filtersPropertyback to summary
public final ListProperty<FilterView.Filter<T>> filtersProperty()
getFiltersback to summary
public final ObservableList<FilterView.Filter<T>> getFilters()
getIdback to summary
public final String getId()
getNameback to summary
public final String getName()
idPropertyback to summary
public final StringProperty idProperty()

An identifier, useful for persisting session state of the filter view.

Returns:StringProperty

the ID of the filter group

namePropertyback to summary
public final StringProperty nameProperty()

The name of the filter as shown in the filter group's dropdown list.

Returns:StringProperty

the filter name

setFiltersback to summary
public final void setFilters(ObservableList<FilterView.Filter<T>> filters)
setIdback to summary
public final void setId(String id)
setNameback to summary
public final void setName(String name)