Class OperableManagerController<I,E extends DetailModel<I>>

java.lang.Object
cz.masci.springfx.mvci.controller.impl.OperableManagerController<I,E>
Type Parameters:
I - the type of the id of the elements
E - the type of the elements that can be managed

public class OperableManagerController<I,E extends DetailModel<I>> extends Object
The OperableManagerController class is a generic class that provides operations for managing objects in a list. It supports adding and removing elements, selecting and focusing elements, updating dirty elements, and discarding changes.
  • Constructor Summary

    Constructors
    Constructor
    Description
    OperableManagerController(T model, javafx.collections.ObservableList<E> elements)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(E element)
    Adds an element to the list of elements managed by the OperableManagerController.
    void
    addAll(List<E> newElements)
    Adds all elements from the given list to the elements managed by the OperableManagerController.
    void
    Discards changes made to the dirty elements in the list of elements managed by the OperableManagerController.
    protected Stream<E>
     
    void
    update(BiConsumer<E,Consumer<E>> updateAction)
    Updates the elements in the list of elements managed by the OperableManagerController.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OperableManagerController

      public OperableManagerController(T model, javafx.collections.ObservableList<E> elements)
  • Method Details

    • add

      public void add(E element)
      Adds an element to the list of elements managed by the OperableManagerController. Does the following: 1. Adds the element to the elements list. 2. Selects the element using the Selectable interface. 3. Focuses on the element using the Focusable interface.
      Parameters:
      element - the element to be added
    • addAll

      public void addAll(List<E> newElements)
      Adds all elements from the given list to the elements managed by the OperableManagerController. This method performs the following operations: 1. Unselects the currently selected element by calling the select() method of the Selectable interface with a null argument. 2. Clears the elements list. 3. Adds all elements from the given list to the elements list.
      Parameters:
      newElements - the list of new elements to be added
    • update

      public void update(BiConsumer<E,Consumer<E>> updateAction)
      Updates the elements in the list of elements managed by the OperableManagerController. 1. Filters the dirty elements that are valid. 2. For each valid dirty element, the updateAction is executed by accepting the element and the updatedElement consumer. 3. If the element is transient, the id of the element is set to the id of the updatedElement. 4. The element is rebaselined.
      Parameters:
      updateAction - the action to update the element Accepts the element to be updated and the consumer to accept the updated element The consumer is responsible for updating the element and can provide the updated element
    • discard

      public void discard()
      Discards changes made to the dirty elements in the list of elements managed by the OperableManagerController. If an element is transient, it is removed from the list. If an element is not transient, it is reset to its original state.
    • getDirtyElements

      protected Stream<E> getDirtyElements()