Interface SingleSelection<T>

Type Parameters:
T - the item type
All Known Subinterfaces:
FilterListSelection<T>, FilterTreeSelection<T>, MultiSelection<T>, TreeSelection<T>

public interface SingleSelection<T>
A selection model managing a single selected item.
  • Method Details

    • present

      ObservableState present()
      Returns:
      an ObservableState indicating whether a selection is present
    • changing

      Sensor changing()
      To prevent a selection change, add a listener throwing a CancelException.

      Note that this is a best-effort warning mechanism, not a transactional revert: throwing a CancelException lets a listener react before the change (for example to save unsaved edits), but does not roll the selection or model back to a consistent state - temporary inconsistency is tolerated.

      Returns:
      a sensor notified when the selection is about to change
    • item

      Value<T> item()

      Returns the Value controlling the selected item.

      Notifies when the selected item changes, and when the instance the selection refers to is replaced, as happens when the items are refreshed or replaced, the replacement being the same item by equals() but not the same object, which suits state derived from the item. A listener acting on another item being selected, loading it or moving to it, belongs on Observable.changed(), notified only when the item differs by equals(): item().changed().current().addConsumer(this::load).

      Returns:
      the Value controlling the selected item
    • clear

      void clear()
      Clears the selection
    • singleSelection

      static <T> SingleSelection<T> singleSelection()
      Type Parameters:
      T - the item type
      Returns:
      a default SingleSelection implementation