Class DefaultGuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>

  • Type Parameters:
    T - the PDOs class
    All Implemented Interfaces:
    GuiProvider<T>, org.tentackle.pdo.DomainContextProvider, org.tentackle.pdo.PdoHolder<T>
    Direct Known Subclasses:
    SecurityGuiProvider

    public class DefaultGuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
    extends java.lang.Object
    implements GuiProvider<T>
    Default implementation of a GuiProvider.
    Can be used as an adapter.
    Author:
    harald
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultGuiProvider​(T pdo)
      Creates a default GUI provider.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javafx.scene.input.Dragboard createDragboard​(javafx.scene.Node node)
      Creates the dragboard for the pdo.
      PdoEditor<T> createEditor()
      Creates a controller to edit or view this object.
      PdoFinder<T> createFinder()
      Creates a controller to search PDOs.
      javafx.scene.image.ImageView createIcon()
      Gets the PDO's icon.
      The icon is displayed in trees, for example.
      org.tentackle.fx.table.TableConfiguration<T> createTableConfiguration()
      Creates the table configuration.
      org.tentackle.fx.component.FxTableView<T> createTableView()
      Creates the table view for given configuration.
      javafx.scene.control.TreeCell<T> createTreeCell()
      Creates a tree cell for this type of pdo.
      javafx.scene.control.TreeItem<T> createTreeItem()
      Creates the tree item for this pdo.
      void dropDragboard​(javafx.scene.input.Dragboard dragbord)
      Drops the dragboard on the pdo.
      void dropPdo​(org.tentackle.pdo.PersistentDomainObject<?> pdoToDrop)
      Drops the given PDO on the serviced pdo.
      boolean editorExists()
      Returns whether a controller exists to edit or view this object.
      boolean finderExists()
      Returns whether a finder exists to search for PDOs.
      java.util.ResourceBundle getBundle()
      Gets the resource bundle for this provider.
      org.tentackle.pdo.DomainContext getDomainContext()  
      T getPdo()  
      org.tentackle.misc.IdentifiableKey<org.tentackle.pdo.PersistentDomainObject<?>> getPdoKeyFromDragboard​(javafx.scene.input.Dragboard dragboard)
      Gets the PDO key from the dragboard.
      The method is provided to simplify implementing DND as only the methods isDragAccepted(javafx.scene.input.DragEvent) and dropPdo(org.tentackle.pdo.PersistentDomainObject<?>) need to be overridden.
      <P extends org.tentackle.pdo.PersistentDomainObject<P>>
      java.lang.String
      getToolTipText​(P parent)
      Gets the tooltip text with respect to the parent object this object is displayed in a tree.
      <P extends org.tentackle.pdo.PersistentDomainObject<P>>
      java.util.Collection<? extends org.tentackle.pdo.PersistentDomainObject<?>>
      getTreeChildObjects​(P parent)
      Gets the childs with respect to the parent object this object is displayed in the current tree.
      int getTreeExpandMaxDepth()
      Gets the maximum level of expansion allowed in a navigatable object tree.
      The default is 0, i.e.
      <P extends org.tentackle.pdo.PersistentDomainObject<P>>
      java.util.Collection<? extends org.tentackle.pdo.PersistentDomainObject<?>>
      getTreeParentObjects​(P parent)
      Gets the parents with respect to the parent object this object is displayed in the current tree.
      T getTreeRoot()
      Gets the object to be displayed in trees in place of this object.
      <P extends org.tentackle.pdo.PersistentDomainObject<P>>
      java.lang.String
      getTreeText​(P parent)
      Gets the tree text with respect to the parent object this object is displayed in a tree.
      boolean isBundleProvided()
      Returns whether a resource bundle is provided.
      boolean isDragAccepted​(javafx.scene.input.DragEvent event)
      Checks whether drag over the pdo is accepted.
      boolean providesTreeChildObjects()
      Determines whether this object may have child objects that should be visible in a navigatable tree.
      boolean providesTreeParentObjects()
      Determines whether the navigatable object tree should show the parents of this object.
      Objects may be childs of different parents in terms of "being referenced from" or any other relation, for example: the warehouses this customer visited.
      void setPdo​(T pdo)  
      boolean stopTreeExpansion()
      Determines whether tree explansion should stop at this object.
      Sometimes treechilds should not be expanded if in a recursive "expand all".
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.tentackle.pdo.DomainContextProvider

        on, op
      • Methods inherited from interface org.tentackle.pdo.PdoHolder

        on
    • Constructor Detail

      • DefaultGuiProvider

        public DefaultGuiProvider​(T pdo)
        Creates a default GUI provider.
        Parameters:
        pdo - the PDO
    • Method Detail

      • isBundleProvided

        public boolean isBundleProvided()
        Description copied from interface: GuiProvider
        Returns whether a resource bundle is provided.
        Specified by:
        isBundleProvided in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        true if provided, false if no bundle
      • getBundle

        public java.util.ResourceBundle getBundle()
        Description copied from interface: GuiProvider
        Gets the resource bundle for this provider.

        Throws MissingResourceException if no bundle found.

        Specified by:
        getBundle in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the resource bundle
      • getPdo

        public T getPdo()
        Specified by:
        getPdo in interface org.tentackle.pdo.PdoHolder<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • setPdo

        public void setPdo​(T pdo)
        Specified by:
        setPdo in interface org.tentackle.pdo.PdoHolder<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • getDomainContext

        public org.tentackle.pdo.DomainContext getDomainContext()
        Specified by:
        getDomainContext in interface org.tentackle.pdo.DomainContextProvider
      • createIcon

        public javafx.scene.image.ImageView createIcon()
        Description copied from interface: GuiProvider
        Gets the PDO's icon.
        The icon is displayed in trees, for example.
        Specified by:
        createIcon in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the icon
      • editorExists

        public boolean editorExists()
        Description copied from interface: GuiProvider
        Returns whether a controller exists to edit or view this object.
        Specified by:
        editorExists in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        true if a controller exists
        See Also:
        GuiProvider.createEditor()
      • createEditor

        public PdoEditor<T> createEditor()
        Description copied from interface: GuiProvider
        Creates a controller to edit or view this object.
        Specified by:
        createEditor in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the controller
      • finderExists

        public boolean finderExists()
        Description copied from interface: GuiProvider
        Returns whether a finder exists to search for PDOs.
        Specified by:
        finderExists in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        true if controller exists
      • createFinder

        public PdoFinder<T> createFinder()
        Description copied from interface: GuiProvider
        Creates a controller to search PDOs.
        Specified by:
        createFinder in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the controller
      • createDragboard

        public javafx.scene.input.Dragboard createDragboard​(javafx.scene.Node node)
        Description copied from interface: GuiProvider
        Creates the dragboard for the pdo.
        Specified by:
        createDragboard in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Parameters:
        node - the drag source
        Returns:
        the dragboard, null if PDO is not a DnD source
      • isDragAccepted

        public boolean isDragAccepted​(javafx.scene.input.DragEvent event)
        Description copied from interface: GuiProvider
        Checks whether drag over the pdo is accepted.
        Specified by:
        isDragAccepted in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Parameters:
        event - the drag event
        Returns:
        true if accepted, false if PDO does not accept the drag
      • getPdoKeyFromDragboard

        public org.tentackle.misc.IdentifiableKey<org.tentackle.pdo.PersistentDomainObject<?>> getPdoKeyFromDragboard​(javafx.scene.input.Dragboard dragboard)
        Gets the PDO key from the dragboard.
        The method is provided to simplify implementing DND as only the methods isDragAccepted(javafx.scene.input.DragEvent) and dropPdo(org.tentackle.pdo.PersistentDomainObject<?>) need to be overridden.
        Parameters:
        dragboard - the dragboard
        Returns:
        the key, null if dragboard's string is null or empty
      • dropDragboard

        public void dropDragboard​(javafx.scene.input.Dragboard dragbord)
        Description copied from interface: GuiProvider
        Drops the dragboard on the pdo.
        Specified by:
        dropDragboard in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Parameters:
        dragbord - the dragboard
      • dropPdo

        public void dropPdo​(org.tentackle.pdo.PersistentDomainObject<?> pdoToDrop)
        Drops the given PDO on the serviced pdo.
        Parameters:
        pdoToDrop - the PDO to drop
      • createTableConfiguration

        public org.tentackle.fx.table.TableConfiguration<T> createTableConfiguration()
        Description copied from interface: GuiProvider
        Creates the table configuration.
        Specified by:
        createTableConfiguration in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the table configuration
      • createTableView

        public org.tentackle.fx.component.FxTableView<T> createTableView()
        Description copied from interface: GuiProvider
        Creates the table view for given configuration.
        Specified by:
        createTableView in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the view
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • providesTreeChildObjects

        public boolean providesTreeChildObjects()
        Description copied from interface: GuiProvider
        Determines whether this object may have child objects that should be visible in a navigatable tree.
        Specified by:
        providesTreeChildObjects in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        true if object may have childs
      • getTreeChildObjects

        public <P extends org.tentackle.pdo.PersistentDomainObject<P>> java.util.Collection<? extends org.tentackle.pdo.PersistentDomainObject<?>> getTreeChildObjects​(P parent)
        Description copied from interface: GuiProvider
        Gets the childs with respect to the parent object this object is displayed in the current tree.
        Specified by:
        getTreeChildObjects in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Type Parameters:
        P - the parent PDO type
        Parameters:
        parent - the parent object of this object in the tree, null = no parent
        Returns:
        the childs
      • getTreeExpandMaxDepth

        public int getTreeExpandMaxDepth()
        Description copied from interface: GuiProvider
        Gets the maximum level of expansion allowed in a navigatable object tree.
        The default is 0, i.e. no limit.
        Specified by:
        getTreeExpandMaxDepth in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the maximum depth of a subtree of this object, 0 = no limit (default)
      • providesTreeParentObjects

        public boolean providesTreeParentObjects()
        Description copied from interface: GuiProvider
        Determines whether the navigatable object tree should show the parents of this object.
        Objects may be childs of different parents in terms of "being referenced from" or any other relation, for example: the warehouses this customer visited. Trees may provide a button to make these parents visible. The default implementation returns false.
        Specified by:
        providesTreeParentObjects in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        true if showing parents is enabled
      • getTreeParentObjects

        public <P extends org.tentackle.pdo.PersistentDomainObject<P>> java.util.Collection<? extends org.tentackle.pdo.PersistentDomainObject<?>> getTreeParentObjects​(P parent)
        Description copied from interface: GuiProvider
        Gets the parents with respect to the parent object this object is displayed in the current tree.
        Specified by:
        getTreeParentObjects in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Type Parameters:
        P - the parent PDO type
        Parameters:
        parent - the parent object, null if no parent
        Returns:
        the parents
      • getTreeRoot

        public T getTreeRoot()
        Description copied from interface: GuiProvider
        Gets the object to be displayed in trees in place of this object.
        Specified by:
        getTreeRoot in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the object to be displayed in a tree
      • getTreeText

        public <P extends org.tentackle.pdo.PersistentDomainObject<P>> java.lang.String getTreeText​(P parent)
        Description copied from interface: GuiProvider
        Gets the tree text with respect to the parent object this object is displayed in a tree.
        Specified by:
        getTreeText in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Type Parameters:
        P - the parent PDO type
        Parameters:
        parent - is the parent object, null if no parent
        Returns:
        the tree text
      • getToolTipText

        public <P extends org.tentackle.pdo.PersistentDomainObject<P>> java.lang.String getToolTipText​(P parent)
        Description copied from interface: GuiProvider
        Gets the tooltip text with respect to the parent object this object is displayed in a tree.
        Specified by:
        getToolTipText in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Type Parameters:
        P - the parent PDO type
        Parameters:
        parent - is the parent object, null if no parent
        Returns:
        the tooltip text
      • stopTreeExpansion

        public boolean stopTreeExpansion()
        Description copied from interface: GuiProvider
        Determines whether tree explansion should stop at this object.
        Sometimes treechilds should not be expanded if in a recursive "expand all". However they should expand if the user explicitly wants to. If this method returns true, the tree will not further expand this node automatically (only on demand).
        Specified by:
        stopTreeExpansion in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        true if expansion should stop.
      • createTreeItem

        public javafx.scene.control.TreeItem<T> createTreeItem()
        Description copied from interface: GuiProvider
        Creates the tree item for this pdo.
        Specified by:
        createTreeItem in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the tree item
      • createTreeCell

        public javafx.scene.control.TreeCell<T> createTreeCell()
        Description copied from interface: GuiProvider
        Creates a tree cell for this type of pdo.
        Specified by:
        createTreeCell in interface GuiProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the tree cell