Class ListSelectionView<T>

Type Parameters:
T - the type of the list items
All Implemented Interfaces:
Styleable, EventTarget, Skinnable

public class ListSelectionView<T> extends Control
A control used to perform a multi-selection via the help of two list views. Items can be moved from one list (source) to the other (target). This can be done by either double clicking on the list items or by using one of the "move" buttons between the two lists. Buttons can be added or removed by altering the list of actions. Each list can be decorated with a header and a footer node. The default header nodes are simply two labels ("Available", "Selected").

Screenshot

Screenshot of ListSelectionView

Code Example

 ListSelectionView<String> view = new ListSelectionView<>();
 view.getSourceItems().add("One", "Two", "Three");
 view.getTargetItems().add("Four", "Five");
 
  • Property Details

  • Constructor Details

    • ListSelectionView

      public ListSelectionView()
      Constructs a new dual list view.
  • Method Details

    • createDefaultSkin

      protected Skin<ListSelectionView<T>> createDefaultSkin()
      Overrides:
      createDefaultSkin in class Control
    • getUserAgentStylesheet

      public String getUserAgentStylesheet()
      Overrides:
      getUserAgentStylesheet in class Region
    • sourceHeaderProperty

      public final ObjectProperty<Node> sourceHeaderProperty()
      A property used to store a reference to a node that will be displayed above the source list view. The default node is a Label displaying the text "Available".
      See Also:
    • getSourceHeader

      public final Node getSourceHeader()
      Returns the value of sourceHeaderProperty().
      Returns:
      the source header node
    • setSourceHeader

      public final void setSourceHeader(Node node)
      Sets the value of sourceHeaderProperty().
      Parameters:
      node - the new header node to use for the source list
    • sourceFooterProperty

      public final ObjectProperty<Node> sourceFooterProperty()
      A property used to store a reference to a node that will be displayed below the source list view. The default node is a node with two buttons for easily selecting / deselecting all elements in the list view.
      See Also:
    • getSourceFooter

      public final Node getSourceFooter()
      Returns the value of sourceFooterProperty().
      Returns:
      the source footer node
    • setSourceFooter

      public final void setSourceFooter(Node node)
      Sets the value of sourceFooterProperty().
      Parameters:
      node - the new node shown below the source list
    • targetHeaderProperty

      public final ObjectProperty<Node> targetHeaderProperty()
      A property used to store a reference to a node that will be displayed above the target list view. The default node is a Label displaying the text "Selected".
      See Also:
    • getTargetHeader

      public final Node getTargetHeader()
      Returns the value of targetHeaderProperty().
      Returns:
      the source header node
    • setTargetHeader

      public final void setTargetHeader(Node node)
      Sets the value of targetHeaderProperty().
      Parameters:
      node - the new node shown above the target list
    • targetFooterProperty

      public final ObjectProperty<Node> targetFooterProperty()
      A property used to store a reference to a node that will be displayed below the target list view. The default node is a node with two buttons for easily selecting / deselecting all elements in the list view.
      See Also:
    • getTargetFooter

      public final Node getTargetFooter()
      Returns the value of targetFooterProperty().
      Returns:
      the source header node
    • setTargetFooter

      public final void setTargetFooter(Node node)
      Sets the value of targetFooterProperty().
      Parameters:
      node - the new node shown below the target list
    • setSourceItems

      public final void setSourceItems(ObservableList<T> value)
      Sets the underlying data model for the ListView. Note that it has a generic type that must match the type of the ListView itself.
    • getSourceItems

      public final ObservableList<T> getSourceItems()
      Returns an ObservableList that contains the items currently being shown to the user in the source list. This may be null if setSourceItems(javafx.collections.ObservableList) has previously been called, however, by default it is an empty ObservableList.
      Returns:
      An ObservableList containing the items to be shown to the user in the source list, or null if the items have previously been set to null.
    • sourceItemsProperty

      public final ObjectProperty<ObservableList<T>> sourceItemsProperty()
      The underlying data model for the source list view. Note that it has a generic type that must match the type of the source list view itself.
      See Also:
    • setTargetItems

      public final void setTargetItems(ObservableList<T> value)
      Sets the underlying data model for the ListView. Note that it has a generic type that must match the type of the ListView itself.
    • getTargetItems

      public final ObservableList<T> getTargetItems()
      Returns an ObservableList that contains the items currently being shown to the user in the target list. This may be null if setTargetItems(javafx.collections.ObservableList) has previously been called, however, by default it is an empty ObservableList.
      Returns:
      An ObservableList containing the items to be shown to the user in the target list, or null if the items have previously been set to null.
    • targetItemsProperty

      public final ObjectProperty<ObservableList<T>> targetItemsProperty()
      The underlying data model for the target list view. Note that it has a generic type that must match the type of the source list view itself.
      See Also:
    • orientationProperty

      public final ObjectProperty<Orientation> orientationProperty()
      The Orientation of the ListSelectionView - this can either be horizontal or vertical.
      See Also:
    • setOrientation

      public final void setOrientation(Orientation value)
      Sets the Orientation of the ListSelectionView - this can either be horizontal or vertical.
    • getOrientation

      public final Orientation getOrientation()
      Returns the Orientation of the ListSelectionView - this can either be horizontal or vertical.
    • setCellFactory

      public final void setCellFactory(Callback<ListView<T>,ListCell<T>> value)
      Sets a new cell factory to use by both list views. This forces all old ListCell's to be thrown away, and new ListCell's created with the new cell factory.
    • getCellFactory

      public final Callback<ListView<T>,ListCell<T>> getCellFactory()
      Returns the current cell factory.
    • cellFactoryProperty

      public final ObjectProperty<Callback<ListView<T>,ListCell<T>>> cellFactoryProperty()

      Setting a custom cell factory has the effect of deferring all cell creation, allowing for total customization of the cell. Internally, the ListView is responsible for reusing ListCells - all that is necessary is for the custom cell factory to return from this function a ListCell which might be usable for representing any item in the ListView.

      Refer to the Cell class documentation for more detail.

      See Also:
    • getActions

      public final ObservableList<Action> getActions()
      The list of actions to be shown in between the two list views. All actions except, ActionUtils.ACTION_SEPARATOR and ActionUtils.ACTION_SPAN, are represented as buttons.

      For actions dependent on both the internal list views, an instance of ListSelectionView.ListSelectionAction should be used.

      By default, the list has 4 actions - ListSelectionView<T>.MoveToTarget, ListSelectionView<T>.MoveToTargetAll, ListSelectionView<T>.MoveToSource and ListSelectionView<T>.MoveToSourceAll. A user may choose to add on top of these actions or replace them depending on their use case.

      Returns:
      An ObservableList of actions.
    • getSourceActions

      public final ObservableList<Action> getSourceActions()
      These actions are shown beside the source list view. An instance of ListActionView.ListAction should be used where actions are dependent on the source ListView.
      Returns:
      An ObservableList of actions.
      See Also:
    • getTargetActions

      public final ObservableList<Action> getTargetActions()
      These actions are shown beside the target list view. An instance of ListActionView.ListAction should be used where actions are dependent on the target ListView.
      Returns:
      An ObservableList of actions.
      See Also:
    • getUserAgentStylesheet

      protected final String getUserAgentStylesheet(Class<?> clazz, String fileName)
      A helper method that ensures that the resource based lookup of the user agent stylesheet only happens once. Caches the external form of the resource.
      Parameters:
      clazz - the class used for the resource lookup
      fileName - the name of the user agent stylesheet
      Returns:
      the external form of the user agent stylesheet (the path)