Class RdcUtilities


  • @Service(RdcUtilities.class)
    public class RdcUtilities
    extends java.lang.Object
    RDC-related utility methods.
    Author:
    harald
    • Constructor Summary

      Constructors 
      Constructor Description
      RdcUtilities()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javafx.scene.input.Dragboard createDragboard​(javafx.scene.Node node, org.tentackle.pdo.PersistentDomainObject<?> pdo)
      Creates the dragboard for a pdo and node.
      <T extends org.tentackle.pdo.PersistentDomainObject<T>>
      void
      displayCrudStage​(T pdo, javafx.collections.ObservableList<T> pdoList, boolean editable, javafx.stage.Modality modality, javafx.stage.Window owner, java.util.function.Consumer<T> updatedPdo, java.util.function.Consumer<PdoCrud<T>> configurator)
      CRUD of a PDO in a separate window.
      <T extends org.tentackle.pdo.PersistentDomainObject<T>>
      void
      displaySearchStage​(T pdo, javafx.stage.Modality modality, javafx.stage.Window owner, boolean createPdoAllowed, java.util.function.Consumer<javafx.collections.ObservableList<T>> selectedItems)
      Searches for PDOs in a separate window.
      <T extends org.tentackle.pdo.PersistentDomainObject<T>>
      void
      displaySearchStage​(T pdo, javafx.stage.Modality modality, javafx.stage.Window owner, boolean createPdoAllowed, java.util.function.Consumer<javafx.collections.ObservableList<T>> selectedItems, java.util.function.Consumer<PdoSearch<T>> configurator)
      Searches for PDOs in a separate window.
      <T extends org.tentackle.pdo.PersistentDomainObject<T>>
      PdoCrud<T>
      getCrud​(T pdo, javafx.collections.ObservableList<T> pdoList, boolean editable, javafx.stage.Modality modality, javafx.stage.Window owner)
      Gets a CRUD for a PDO.
      If the PDO is already being edited the corresponding stage will be brought to front and null is returned.
      static RdcUtilities getInstance()
      The singleton.
      org.tentackle.pdo.PersistentDomainObject<?> getPdoFromDragboard​(javafx.scene.input.Dragboard dragboard, org.tentackle.pdo.DomainContext context)
      Gets the PDO from a dragboard.
      org.tentackle.misc.IdentifiableKey<org.tentackle.pdo.PersistentDomainObject<?>> getPdoKeyFromDragboard​(javafx.scene.input.Dragboard dragboard)
      Gets the PDO key from the dragboard.
      <T extends org.tentackle.pdo.PersistentDomainObject<T>>
      PdoSearch<T>
      getSearch​(T pdo, javafx.stage.Modality modality, javafx.stage.Window owner)
      Gets a search controller for a PDO.
      <V> void runInBackground​(java.util.function.Supplier<V> runner, java.util.function.Consumer<V> updateUI, java.util.function.Consumer<java.lang.RuntimeException> failedUI)
      Runs some code in another thread and optionally updates the UI.
      The method is provided to hide the concrete implementation and make it replaceable.
      Use this method whenever some lengthy operation (database I/O, for example) would otherwise block the event queue.
      void showSaveDiscardCancelDialog​(java.util.function.Consumer<java.lang.Boolean> doIt)
      Shows a question dialog whether to save, discard or cancel editing of a PDO.
      <T extends org.tentackle.pdo.PersistentDomainObject<T>>
      void
      showTree​(T pdo)
      Shows the tree of a PDO in a modal scene.
      • Methods inherited from class java.lang.Object

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

      • RdcUtilities

        public RdcUtilities()
    • Method Detail

      • getInstance

        public static RdcUtilities getInstance()
        The singleton.
        Returns:
        the singleton
      • displayCrudStage

        public <T extends org.tentackle.pdo.PersistentDomainObject<T>> void displayCrudStage​(T pdo,
                                                                                             javafx.collections.ObservableList<T> pdoList,
                                                                                             boolean editable,
                                                                                             javafx.stage.Modality modality,
                                                                                             javafx.stage.Window owner,
                                                                                             java.util.function.Consumer<T> updatedPdo,
                                                                                             java.util.function.Consumer<PdoCrud<T>> configurator)
        CRUD of a PDO in a separate window.
        Type Parameters:
        T - the pdo type
        Parameters:
        pdo - the pdo
        pdoList - the optional list of PDOs to navigate in the list
        editable - true if user may edit the pdo, false if to view only
        modality - the modality
        owner - the owner, null if none
        updatedPdo - the consumer for the possibly changed pdo if modal, null if no consumer
        configurator - optional crud configurator
      • getCrud

        public <T extends org.tentackle.pdo.PersistentDomainObject<T>> PdoCrud<T> getCrud​(T pdo,
                                                                                          javafx.collections.ObservableList<T> pdoList,
                                                                                          boolean editable,
                                                                                          javafx.stage.Modality modality,
                                                                                          javafx.stage.Window owner)
        Gets a CRUD for a PDO.
        If the PDO is already being edited the corresponding stage will be brought to front and null is returned.
        Type Parameters:
        T - the pdo type
        Parameters:
        pdo - the pdo
        pdoList - the optional list of PDOs to navigate in the list
        editable - true if user may edit the pdo, false if to view only
        modality - the modality
        owner - the owner, null if none
        Returns:
        the CRUD, null if there is already a CRUD editing this PDO.
      • displaySearchStage

        public <T extends org.tentackle.pdo.PersistentDomainObject<T>> void displaySearchStage​(T pdo,
                                                                                               javafx.stage.Modality modality,
                                                                                               javafx.stage.Window owner,
                                                                                               boolean createPdoAllowed,
                                                                                               java.util.function.Consumer<javafx.collections.ObservableList<T>> selectedItems)
        Searches for PDOs in a separate window.
        Type Parameters:
        T - the pdo type
        Parameters:
        pdo - the pdo as a template
        modality - the modality
        owner - the owner, null if none
        createPdoAllowed - true if allow to create a new PDO from within the search dialog
        selectedItems - the consumer for the selected PDOs if modal, null if not modal
      • displaySearchStage

        public <T extends org.tentackle.pdo.PersistentDomainObject<T>> void displaySearchStage​(T pdo,
                                                                                               javafx.stage.Modality modality,
                                                                                               javafx.stage.Window owner,
                                                                                               boolean createPdoAllowed,
                                                                                               java.util.function.Consumer<javafx.collections.ObservableList<T>> selectedItems,
                                                                                               java.util.function.Consumer<PdoSearch<T>> configurator)
        Searches for PDOs in a separate window.
        Type Parameters:
        T - the pdo type
        Parameters:
        pdo - the pdo as a template
        modality - the modality
        owner - the owner, null if none
        createPdoAllowed - true if allow to create a new PDO from within the search dialog
        selectedItems - the consumer for the selected PDOs if modal, null if not modal
        configurator - the optional configurator for the PdoSearch
      • getSearch

        public <T extends org.tentackle.pdo.PersistentDomainObject<T>> PdoSearch<T> getSearch​(T pdo,
                                                                                              javafx.stage.Modality modality,
                                                                                              javafx.stage.Window owner)
        Gets a search controller for a PDO.
        Type Parameters:
        T - the pdo type
        Parameters:
        pdo - the pdo
        modality - the modality
        owner - the owner, null if none
        Returns:
        the search controller, never null
      • showSaveDiscardCancelDialog

        public void showSaveDiscardCancelDialog​(java.util.function.Consumer<java.lang.Boolean> doIt)
        Shows a question dialog whether to save, discard or cancel editing of a PDO.
        Parameters:
        doIt - consumer invoked with true to save, false to discard changes, null to cancel and do nothing
      • showTree

        public <T extends org.tentackle.pdo.PersistentDomainObject<T>> void showTree​(T pdo)
        Shows the tree of a PDO in a modal scene.
        Type Parameters:
        T - the PDO type
        Parameters:
        pdo - the PDO
      • runInBackground

        public <V> void runInBackground​(java.util.function.Supplier<V> runner,
                                        java.util.function.Consumer<V> updateUI,
                                        java.util.function.Consumer<java.lang.RuntimeException> failedUI)
        Runs some code in another thread and optionally updates the UI.
        The method is provided to hide the concrete implementation and make it replaceable.
        Use this method whenever some lengthy operation (database I/O, for example) would otherwise block the event queue.

        The default implementation creates a AbstractSessionTask and runs it on behalf of the ModificationTracker. If the runner itself is a SessionDependable it gets the session set as well before it is invoked. The result is then passed to updateUI and executed via Platform.runLater(Runnable).

        Type Parameters:
        V - the type returned by the runner
        Parameters:
        runner - the code running in another thread in parallel to the FX thread
        updateUI - optional UI updater invoked from within the FX event queue, null if none
        failedUI - optional UI updater invoked if execution failed, null if log only as error
      • createDragboard

        public javafx.scene.input.Dragboard createDragboard​(javafx.scene.Node node,
                                                            org.tentackle.pdo.PersistentDomainObject<?> pdo)
        Creates the dragboard for a pdo and node.
        Parameters:
        node - the drag source
        pdo - the pdo
        Returns:
        the dragboard, enull if PDO is not a DnD source
      • getPdoKeyFromDragboard

        public org.tentackle.misc.IdentifiableKey<org.tentackle.pdo.PersistentDomainObject<?>> getPdoKeyFromDragboard​(javafx.scene.input.Dragboard dragboard)
        Gets the PDO key from the dragboard.
        Parameters:
        dragboard - the dragboard
        Returns:
        the key, null if dragboard's string is null or empty
      • getPdoFromDragboard

        public org.tentackle.pdo.PersistentDomainObject<?> getPdoFromDragboard​(javafx.scene.input.Dragboard dragboard,
                                                                               org.tentackle.pdo.DomainContext context)
        Gets the PDO from a dragboard.
        Parameters:
        dragboard - the dragboard
        context - the domain context
        Returns:
        the PDO, null if dragboard doesn't contain a pdo key or no such pdo