Package adams.gui.goe

Class FlowHelper


  • public class FlowHelper
    extends Object
    A helper class for flow-related queries.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • FlowHelper

        public FlowHelper()
    • Method Detail

      • getTree

        public static Tree getTree​(Container cont)
        Tries to obtain the current flow editor tree.
        Parameters:
        cont - the container to start the search from
        Returns:
        the tree, null if none found
      • isFlowEdited

        public static boolean isFlowEdited​(Container cont)
        Checks whether a flow is currently being edited (in the flow editor).
        Parameters:
        cont - the container to start the search from
        Returns:
        true if a flow is being edited
      • getEditedParent

        public static Node getEditedParent​(Container cont)
        Returns the parent of the node that is currently being edited or the node below a node is added.
        Parameters:
        cont - the container to start the search from
        Returns:
        the parent node, null if none being edited
      • getEditedNode

        public static Node getEditedNode​(Container cont)
        Returns the node that is currently being edited.
        Parameters:
        cont - the container to start the search from
        Returns:
        the node, null if none being edited
      • getDatabaseConnection

        public static AbstractDatabaseConnection getDatabaseConnection​(Container cont,
                                                                       Class actorCls,
                                                                       AbstractDatabaseConnection defDbCon)
        Returns the database connection that needs to be used in the GOE.
        Parameters:
        cont - the container to start the search from
        actorCls - the database connection actor class to look for
        defDbCon - the default database connection if none found in tree
        Returns:
        the database connection to be used
      • getDatabaseConnection

        public static AbstractDatabaseConnection getDatabaseConnection​(Node parent,
                                                                       Class actorCls,
                                                                       AbstractDatabaseConnection defDbCon)
        Returns the database connection that needs to be used in the GOE.
        Parameters:
        parent - the node to start the search from
        actorCls - the database connection actor class to look for
        defDbCon - the default database connection if none found in tree
        Returns:
        the database connection to be used
      • getDatabaseConnection

        protected static AbstractDatabaseConnection getDatabaseConnection​(Node parent,
                                                                          Class actorCls,
                                                                          AbstractDatabaseConnection defDbCon,
                                                                          boolean up)
        Returns the database connection that needs to be used in the GOE.
        Parameters:
        parent - the node to start the search from
        actorCls - the database connection actor class to look for
        defDbCon - the default database connection if none found in tree
        up - whether to go up in the actor tree
        Returns:
        the database connection to be used
      • isRestricted

        protected static boolean isRestricted​(Class actor,
                                              HashSet<Class> restrict)
        Checks whether the actor is listed in the restricted classes (specific class or superclass/interface).
        Parameters:
        actor - the class to check
        restrict - the restrictions if any
        Returns:
        true if restricted
      • findCallableActorsHandler

        public static List<Node> findCallableActorsHandler​(Node parent,
                                                           Class[] restrict)
        Locates all nodes representing ActorReferenceHandler actors.
        Parameters:
        parent - the parent node
        restrict - the classes to restrict the results to
        Returns:
        the nodes with ActorReferenceHandler found
      • findTopCallableActors

        public static List<Node> findTopCallableActors​(Container cont)
        Locates all top nodes representing CallableActors actors.
        Parameters:
        cont - the container to get the root node from
        Returns:
        the nodes with CallableActors found
      • findTopCallableActors

        public static List<Node> findTopCallableActors​(Node parent)
        Locates all top nodes representing CallableActors actors.
        Parameters:
        parent - the parent node
        Returns:
        the nodes with CallableActors found
      • findNodes

        public static List<Node> findNodes​(Container cont,
                                           Class type)
        Locates all nodes representing the specified type of actors.
        Parameters:
        cont - the container to start the search from
        type - the type of actors to find
        Returns:
        the nodes found
      • findNodes

        public static List<Node> findNodes​(Node parent,
                                           Class type)
        Locates all nodes representing the specified type of actors.
        Parameters:
        parent - the parent node
        type - the type of actors to find
        Returns:
        the nodes found
      • findNodes

        public static List<Node> findNodes​(Node parent,
                                           Class[] restrict,
                                           Class type)
        Locates all nodes representing the specified type of actors.
        Parameters:
        parent - the parent node
        restrict - the classes to restrict the results to
        Returns:
        the nodes found
      • findNodesMatch

        protected static boolean findNodesMatch​(Class type,
                                                HashSet<Class> restrict,
                                                Actor actor)
        Checks whether the actor is a match for the type/restrictions.
        Parameters:
        type - the type the actor has to be
        restrict - whether to restrict the classes
        actor - the actor to check
        Returns:
        true if a match
        See Also:
        findNodes(Node, boolean, HashSet, Class)
      • findNodes

        protected static List<Node> findNodes​(Node parent,
                                              boolean up,
                                              HashSet<Class> restrict,
                                              Class type)
        Locates all nodes representing the specified type of actors.
        Parameters:
        parent - the parent node
        up - whether to go up in the actor tree
        restrict - the classes to restrict the results to, null if no restrictions
        Returns:
        the nodes found
      • findTopNodes

        public static List<Node> findTopNodes​(Container cont,
                                              Class type)
        Locates all top nodes representing CallableActors actors.
        Parameters:
        cont - the container to get the root node from
        type - the type of actor to locate
        Returns:
        the nodes with CallableActors found
      • findTopNodes

        public static List<Node> findTopNodes​(Node parent,
                                              Class type)
        Locates all top nodes representing the specified type.
        Parameters:
        parent - the parent node
        type - the type of actor to locate
        Returns:
        the nodes with actors found