Top Description Inners Fields Constructors Methods
com.dlsc.gemsfx

public Class SimpleFilterView

extends HBox
Class Inheritance
Imports
com.dlsc.gemsfx.daterange.DateRange, .DateRangePicker, com.dlsc.gemsfx.util.EnumStringConverter, javafx.beans.InvalidationListener, javafx.beans.binding.Bindings, javafx.beans.property.ListProperty, .ObjectProperty, .SimpleListProperty, .SimpleObjectProperty, javafx.collections.FXCollections, .ListChangeListener, .ObservableList, javafx.css.PseudoClass, javafx.scene.Node, javafx.scene.control.CheckBox, .DatePicker, .SelectionMode, .TextField, javafx.scene.layout.HBox, .Priority, .Region, javafx.util.StringConverter, org.apache.commons.lang3.StringUtils, org.controlsfx.control.textfield.CustomTextField, java.time.LocalDate, java.util.Collection, .HashMap, .List, .Map, .Objects

A control for creating filters based on various other controls such as the SelectionBox, the DateRangePicker, the SearchTextField, etc... The control automatically manages a list of ChipView instances based on the current selection. These chip views can be displayed by the ChipsViewContainer. To do so bind the observable list of chips views of the filter view with the one provided by the ChipsViewContainer.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
SimpleFilterView.LayoutMode

An enumeration of possible layouts supported by the filter view.

Field Summary

Modifier and TypeField and Description
private final InvalidationListener
private final ListProperty<ChipView<?>>
private boolean
private static final PseudoClass
private final ObjectProperty<SimpleFilterView.LayoutMode>
private final Map<Node, Map<Object, ChipView<?>>>
private final ObjectProperty<Runnable>

Constructor Summary

AccessConstructor and Description
public
SimpleFilterView()

Constructs a new instance of SimpleFilterView.

Method Summary

Modifier and TypeMethod and Description
public final CalendarPicker

Returns:

the newly created and configured DatePicker instance
addCalendarPicker
(String
the prompt text to display in the date picker
text
)

Adds a calendar picker to the filter view with the specified prompt text.

public final CheckBox

Returns:

the created CheckBox instance
addCheckBox
(String
the text to display alongside the created CheckBox
text
)

Adds a new CheckBox with the specified text to the control.

private <T> void
addChips(List<? extends T> addedList, SelectionBox<T> box)

public final DatePicker

Returns:

the newly created and configured DatePicker instance
addDatePicker
(String
the prompt text to display in the date picker
text
)

Adds a date picker to the filter view with the specified prompt text.

public final DateRangePicker

Returns:

the newly created and configured DateRangePicker instance
addDateRangePicker
(String
the prompt text to display in the date range picker
text
)

Adds a date range picker to the filter view and configures it with the specified prompt text.

public final SearchTextField

Returns:

the new text field
addSearchTextField
(String
the initial prompt text
promptText
)

Add a new instance of a search text field.

public final <
the enum type
T extends Enum<T>
>
SelectionBox<T>

Returns:

the newly added selection box
addSelectionBox
(String
the prompt text
text
,
Class<T>
the type of the enum
clz
)

Adds a selection box to the UI with the given prompt name and the values of the given enum type.

public final <
the enum type
T extends Enum<T>
>
SelectionBox<T>

Returns:

the newly added selection box
addSelectionBox
(String
the prompt text
text
,
T...
the possible values
values
)

Adds a selection box to the UI with the given prompt name and the given values.

public final <
the type of the items in the selection box
T
>
SelectionBox<T>

Returns:

the newly added selection box
addSelectionBox
(String
the prompt text
text
,
Collection<T>
the possible values collection
values
)

Adds a selection box to the UI with the given prompt name and the list of the given values.

public final <
the type of the items in the selection box
T
>
SelectionBox<T>

Returns:

the newly added selection box
addSelectionBox
(String
the prompt text
text
,
T...
the possible values
values
)

Adds a selection box to the UI with the given prompt name and the list of the given values.

public final <
the type of the items in the selection box
T
>
SelectionBox<T>

Returns:

the newly created and configured SelectionBox instance
addSelectionBox
(String
the prompt text to display in the selection box
text
)

Adds a selection box to the filter view with the specified prompt text.

public final CustomTextField

Returns:

the new text field
addTextField
(String
the initial prompt text
promptText
)

Creates a new instance of a textfield.

public final ListProperty<ChipView<?>>

Returns:

the list of chip views
chipsProperty
()

An observable list containing the currently managed chip views.

public final void
clear()

Clears all selections and values in the filter view.

protected CalendarPicker

Returns:

a new instance of CalendarPicker.
createCalendarPicker
()

Factory method for creating a new CalendarPicker instance.

protected CheckBox
protected DatePicker

Returns:

a new instance of DatePicker.
createDatePicker
()

Factory method for creating a new DatePicker instance.

protected DateRangePicker

Returns:

a date range picker
createDateRangePicker
()

Factory method for creating the date range picker that will be added to the view.

protected SearchTextField

Returns:

a search text field
createSearchTextField
()

Factory method for creating the search text field that will be added to the view.

protected <
the type of the items that the selection box will manage
T
>
SelectionBox<T>

Returns:

a new instance of SelectionBox configured with default settings
createSelectionBox
()

Creates a new instance of a SelectionBox.

protected CustomTextField

Returns:

a text field
createTextField
()

Factory method for creating a text field that will be added to the view.

public final ObservableList<ChipView<?>>
public final SimpleFilterView.LayoutMode
public final Runnable
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 ObjectProperty<SimpleFilterView.LayoutMode>

Returns:

the layout mode
layoutModeProperty
()

The layout used by the control, either "standard" or "compact" / "unified".

public final ObjectProperty<Runnable>

Returns:

the runnable to executed upon change
onChangeProperty
()

Will be invoked whenever anything changes within the filter settings.

private <T> void
removeChips(List<? extends T> removedList, SelectionBox<T> box)

public final void
public final void
public final void
private void
private void
Inherited from javafx.scene.layout.HBox:
alignmentPropertyclearConstraintscomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthfillHeightPropertygetAlignmentgetBaselineOffsetgetClassCssMetaDatagetContentBiasgetCssMetaDatagetHgrowgetMargingetSpacingisFillHeightlayoutChildrenrequestLayoutsetAlignmentsetFillHeightsetHgrowsetMarginsetSpacingspacingProperty

Field Detail

changeListenerback to summary
private final InvalidationListener changeListener
chipsback to summary
private final ListProperty<ChipView<?>> chips
clearingback to summary
private boolean clearing
COMPACT_PSEUDO_CLASSback to summary
private static final PseudoClass COMPACT_PSEUDO_CLASS
layoutModeback to summary
private final ObjectProperty<SimpleFilterView.LayoutMode> layoutMode
mapback to summary
private final Map<Node, Map<Object, ChipView<?>>> map
onChangeback to summary
private final ObjectProperty<Runnable> onChange

Constructor Detail

SimpleFilterViewback to summary
public SimpleFilterView()

Constructs a new instance of SimpleFilterView.

Method Detail

addCalendarPickerback to summary
public final CalendarPicker addCalendarPicker(String text)

Adds a calendar picker to the filter view with the specified prompt text. The calendar picker allows users to select a date, and the selected date is represented as a chip in the filter view. The method initializes the calendar picker, sets its default properties, and adds listeners to handle changes in the selected date. When a date is selected, it is displayed as a chip, and the chip can be removed by the user, clearing the date from the picker.

Parameters
text:String

the prompt text to display in the date picker

Returns:CalendarPicker

the newly created and configured DatePicker instance

addCheckBoxback to summary
public final CheckBox addCheckBox(String text)

Adds a new CheckBox with the specified text to the control. The CheckBox is configured with listeners to manage its interaction with associated chip views and the internal state of the control.

Parameters
text:String

the text to display alongside the created CheckBox

Returns:CheckBox

the created CheckBox instance

addChipsback to summary
private <T> void addChips(List<? extends T> addedList, SelectionBox<T> box)
addDatePickerback to summary
public final DatePicker addDatePicker(String text)

Adds a date picker to the filter view with the specified prompt text. The date picker allows users to select a date, and the selected date is represented as a chip in the filter view. The method initializes the date picker, sets its default properties, and adds listeners to handle changes in the selected date. When a date is selected, it is displayed as a chip, and the chip can be removed by the user, clearing the date from the picker.

Parameters
text:String

the prompt text to display in the date picker

Returns:DatePicker

the newly created and configured DatePicker instance

addDateRangePickerback to summary
public final DateRangePicker addDateRangePicker(String text)

Adds a date range picker to the filter view and configures it with the specified prompt text. This date range picker allows users to select a range of dates, and selected ranges are represented as chips in the filter view. The method initialises the date range picker, adds listeners to handle changes in selection, and manages the associated chip view for each selected range. It ensures proper update of the UI elements when ranges are added or removed.

Parameters
text:String

the prompt text to display in the date range picker

Returns:DateRangePicker

the newly created and configured DateRangePicker instance

addSearchTextFieldback to summary
public final SearchTextField addSearchTextField(String promptText)

Add a new instance of a search text field.

Parameters
promptText:String

the initial prompt text

Returns:SearchTextField

the new text field

See Also
SearchTextField
addSelectionBoxback to summary
public final <T extends Enum<T>> SelectionBox<T> addSelectionBox(String text, Class<T> clz)

Adds a selection box to the UI with the given prompt name and the values of the given enum type.

Parameters
<T>
the enum type
text:String

the prompt text

clz:Class<T>

the type of the enum

Returns:SelectionBox<T>

the newly added selection box

addSelectionBoxback to summary
public final <T extends Enum<T>> SelectionBox<T> addSelectionBox(String text, T... values)

Adds a selection box to the UI with the given prompt name and the given values.

Parameters
<T>
the enum type
text:String

the prompt text

values:T[]

the possible values

Returns:SelectionBox<T>

the newly added selection box

Annotations
@SafeVarargs
addSelectionBoxback to summary
public final <T> SelectionBox<T> addSelectionBox(String text, Collection<T> values)

Adds a selection box to the UI with the given prompt name and the list of the given values.

Parameters
<T>
the type of the items in the selection box
text:String

the prompt text

values:Collection<T>

the possible values collection

Returns:SelectionBox<T>

the newly added selection box

addSelectionBoxback to summary
public final <T> SelectionBox<T> addSelectionBox(String text, T... values)

Adds a selection box to the UI with the given prompt name and the list of the given values.

Parameters
<T>
the type of the items in the selection box
text:String

the prompt text

values:T[]

the possible values

Returns:SelectionBox<T>

the newly added selection box

Annotations
@SafeVarargs
addSelectionBoxback to summary
public final <T> SelectionBox<T> addSelectionBox(String text)

Adds a selection box to the filter view with the specified prompt text. The selection box allows users to select multiple items, and the selected items are represented as chips in the filter view. The method initializes the selection box with default properties, sets up listeners to handle changes in the selected items, and manages the associated chip view for each selected item. It ensures proper updates to the UI elements when items are added or removed from the selection box.

Parameters
<T>
the type of the items in the selection box
text:String

the prompt text to display in the selection box

Returns:SelectionBox<T>

the newly created and configured SelectionBox instance

addTextFieldback to summary
public final CustomTextField addTextField(String promptText)

Creates a new instance of a textfield.

Parameters
promptText:String

the initial prompt text

Returns:CustomTextField

the new text field

chipsPropertyback to summary
public final ListProperty<ChipView<?>> chipsProperty()

An observable list containing the currently managed chip views. Each chip view represents one selected filter criteria.

Returns:ListProperty<ChipView<?>>

the list of chip views

clearback to summary
public final void clear()

Clears all selections and values in the filter view. This method iterates through the filter components, such as selection boxes and pickers, and resets their values or selections to the default state. It also clears any associated mappings and updates the UI accordingly. If an unknown node type is encountered, this method will throw an IllegalStateException. After clearing, if a change listener is defined, it will be executed. This operation ensures that the filter view is in a clean state and ready for new inputs or selections.

Note

During the execution of this method, a flag is set to avoid triggering unwanted actions due to internal state changes.

Exceptions
IllegalStateException:
- if an unsupported node type is found during iteration.
See Also
setOnChange(Runnable)
createCalendarPickerback to summary
protected CalendarPicker createCalendarPicker()

Factory method for creating a new CalendarPicker instance. This method is used to instantiate a CalendarPicker with default properties. Subclasses can override this method to customize the behavior or appearance of the CalendarPicker.

Returns:CalendarPicker

a new instance of CalendarPicker.

createCheckBoxback to summary
protected CheckBox createCheckBox()
createDatePickerback to summary
protected DatePicker createDatePicker()

Factory method for creating a new DatePicker instance. This method can be overridden to provide a customized implementation of the DatePicker.

Returns:DatePicker

a new instance of DatePicker.

createDateRangePickerback to summary
protected DateRangePicker createDateRangePicker()

Factory method for creating the date range picker that will be added to the view. This method can be overridden to provide a custom date range picker implementation.

Returns:DateRangePicker

a date range picker

createSearchTextFieldback to summary
protected SearchTextField createSearchTextField()

Factory method for creating the search text field that will be added to the view. This method can be overridden to provide a custom search field implementation.

Returns:SearchTextField

a search text field

createSelectionBoxback to summary
protected <T> SelectionBox<T> createSelectionBox()

Creates a new instance of a SelectionBox. This method serves as a factory for creating selection boxes, in case customization or modification of the default selection box behavior is required. Subclasses can override this method to provide a different implementation.

Parameters
<T>
the type of the items that the selection box will manage
Returns:SelectionBox<T>

a new instance of SelectionBox configured with default settings

createTextFieldback to summary
protected CustomTextField createTextField()

Factory method for creating a text field that will be added to the view. This method can be overridden to provide a custom text field implementation.

Returns:CustomTextField

a text field

getChipsback to summary
public final ObservableList<ChipView<?>> getChips()
getLayoutModeback to summary
public final SimpleFilterView.LayoutMode getLayoutMode()
getOnChangeback to summary
public final Runnable getOnChange()
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
layoutModePropertyback to summary
public final ObjectProperty<SimpleFilterView.LayoutMode> layoutModeProperty()

The layout used by the control, either "standard" or "compact" / "unified".

Returns:ObjectProperty<SimpleFilterView.LayoutMode>

the layout mode

onChangePropertyback to summary
public final ObjectProperty<Runnable> onChangeProperty()

Will be invoked whenever anything changes within the filter settings.

Returns:ObjectProperty<Runnable>

the runnable to executed upon change

removeChipsback to summary
private <T> void removeChips(List<? extends T> removedList, SelectionBox<T> box)
setChipsback to summary
public final void setChips(ObservableList<ChipView<?>> chips)
setLayoutModeback to summary
public final void setLayoutMode(SimpleFilterView.LayoutMode layoutMode)
setOnChangeback to summary
public final void setOnChange(Runnable onChange)
updateNodeStylesback to summary
private void updateNodeStyles(Node node)
updatePseudoClassback to summary
private void updatePseudoClass()
com.dlsc.gemsfx back to summary

public final Enum SimpleFilterView.LayoutMode

extends Enum<SimpleFilterView.LayoutMode>
Class Inheritance

An enumeration of possible layouts supported by the filter view.

Field Summary

Modifier and TypeField and Description
public static final SimpleFilterView.LayoutMode
COMPACT

The filter elements will be laid out right next to each other to create a compact visualization.

public static final SimpleFilterView.LayoutMode
STANDARD

The filter elements (selection boxes, date pickers, etc.) will be laid out one after the other with standard spacing and each element styled in its own standard way.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static SimpleFilterView.LayoutMode
public static SimpleFilterView.LayoutMode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

COMPACTback to summary
public static final SimpleFilterView.LayoutMode COMPACT

The filter elements will be laid out right next to each other to create a compact visualization. The styling will ensure a unified look of the overall filter view.

STANDARDback to summary
public static final SimpleFilterView.LayoutMode STANDARD

The filter elements (selection boxes, date pickers, etc.) will be laid out one after the other with standard spacing and each element styled in its own standard way.

Constructor Detail

LayoutModeback to summary
private LayoutMode()

Method Detail

valueOfback to summary
public static SimpleFilterView.LayoutMode valueOf(String name)
valuesback to summary
public static SimpleFilterView.LayoutMode[] values()