Package adams.gui.flow.tree
Class TreeOperations
- java.lang.Object
-
- adams.gui.flow.tree.TreeOperations
-
- All Implemented Interfaces:
CleanUpHandler
,Serializable
public class TreeOperations extends Object implements Serializable, CleanUpHandler
Performs complex operations on the tree, like adding, removing, enclosing actors.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TreeOperations.ActorDialog
Enumeration for actor dialogs.static class
TreeOperations.InsertPosition
Enumeration for how to insert a node.
-
Field Summary
Fields Modifier and Type Field Description protected GenericObjectEditorDialog
m_DialogProcessActors
the dialog for processing actors.protected Tree
m_Owner
the tree to operate on.
-
Constructor Summary
Constructors Constructor Description TreeOperations(Tree owner)
Initializes the object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addActor(TreePath path, Actor actor, TreeOperations.InsertPosition position)
Brings up the GOE dialog for adding an actor if no actor supplied, otherwise just adds the given actor at the position specified by the path.void
addActor(TreePath path, Actor actor, TreeOperations.InsertPosition position, boolean record)
Brings up the GOE dialog for adding an actor if no actor supplied, otherwise just adds the given actor at the position specified by the path.void
addActor(TreePath path, Actor actor, TreeOperations.InsertPosition position, boolean record, TreeOperations.ActorDialog dialogType)
Brings up the GOE dialog for adding an actor if no actor supplied, otherwise just adds the given actor at the position specified by the path.boolean
checkForStandalones(Actor[] actors, Node parent)
Checks whether standalones can be placed beneath the parent actor.boolean
checkForStandalones(Actor actor, Node parent)
Checks whether standalones can be placed beneath the parent actor.protected BooleanCondition
chooseBooleanCondition(BooleanCondition defCond)
Lets the user choose a boolean condition.void
cleanUp()
Cleans up data structures, frees up memory.void
cleanUpActorName(TreePath[] paths)
Cleans up the names of actors.AbstractItemFilter
configureFilter(TreePath path, TreeOperations.InsertPosition position)
Configures a filter for the ClassTree.ActorSuggestion.SuggestionData
configureSuggestionContext(TreePath[] paths)
Returns the context for making external actor suggestions.ActorSuggestion.SuggestionData
configureSuggestionContext(TreePath path, TreeOperations.InsertPosition position)
Returns the context for making actor suggestions.void
createCallableActor(TreePath path, Class handler)
Turns the selected actor into a callable actor using the specified enclosing handler type.void
editActor(TreePath path)
Brings up the GOE dialog for editing the selected actor.void
editFlow(TreePath path)
Brings up a flow window for editing the selected external actor's flow.void
encloseActor(TreePath[] paths, ActorHandler handler)
Encloses the selected actors in the specified actor handler.void
externalizeActor(TreePath[] paths, Actor suggestion)
Opens a new FlowEditor window with the currently selected sub-flow.protected void
externalizeActor(TreePath path, boolean checkCallActors, Actor suggestion)
Opens a new FlowEditor window with the currently selected sub-flow.void
externalizeActor(TreePath path, Actor suggestion)
Opens a new FlowEditor window with the currently selected sub-flow.void
favoriteActor(TreePath path, TreeOperations.InsertPosition position, boolean record)
Lets the user select an actor from a dialog of favorites.static Actor
getActorFromClipboard()
Returns the actor stored on the clipboard.static List[]
getListsFromClipboard()
Returns the nested lists stored on the clipboard.static Node[]
getNodesFromClipboard()
Returns the nodes stored on the clipboard.Tree
getOwner()
Returns the owning tree.GenericObjectEditorDialog
getProcessActorsDialog(String title)
Returns the dialog for processing actors.static boolean
hasNodesOnClipboard()
Checks whether any nodes in nested listed form are on the clipboard.void
inspectMemoryDetails(TreePath path, Flow flow)
Displays the memory consumption of the selected actor, broken by class.void
inspectMemorySize(TreePath path, Flow flow)
Displays the memory consumption of the selected subtree (just the size).void
makeConditional(TreePath path)
Turns the selected actor into its conditional equivalent.void
makeInteractive(TreePath[] paths)
Turns the selected Setvariable standalines into a subflow with EnterManyValues for prompting the user.void
makeTimed(TreePath path)
Turns the selected actor into its timed equivalent.void
pasteNodes(TreePath path, Node[] nodes, TreeOperations.InsertPosition position)
For pasting nodes.void
processActor(TreePath path, ActorProcessor processor)
Processes the specified actor with the specified actor processor.void
processActor(TreePath path, ActorProcessor processor, Runnable after)
Processes the specified actor with the specified actor processor.void
pullUpActors(TreePath path)
Pulls up the actors of the selected mutable actor.void
renameActor(TreePath path)
Renames an actor.void
renameActor(TreePath path, String newName)
Renames an actor.Actor[]
suggestActors(TreePath path, TreeOperations.InsertPosition position)
Tries to figure what actors fit best in the tree at the given position.Actor[]
suggestExternalActors(TreePath[] paths)
Tries to figure what external actors fit best using the given selection of actors.void
swapActor(TreePath sourcePath, Actor target)
Swaps the actor handler of the node with the new node, keeping the children intact, as well as some basic options.
-
-
-
Field Detail
-
m_Owner
protected Tree m_Owner
the tree to operate on.
-
m_DialogProcessActors
protected GenericObjectEditorDialog m_DialogProcessActors
the dialog for processing actors.
-
-
Constructor Detail
-
TreeOperations
public TreeOperations(Tree owner)
Initializes the object.- Parameters:
owner
- the tree to operate on
-
-
Method Detail
-
getOwner
public Tree getOwner()
Returns the owning tree.- Returns:
- the tree
-
checkForStandalones
public boolean checkForStandalones(Actor actor, Node parent)
Checks whether standalones can be placed beneath the parent actor. If the actor isn't a standalone, this method returns true, of course. In case the actor is a standalone and the parent doesn't allow standalones to be placed, an error message pops up and informs the user.- Parameters:
actor
- the actor to place beneath the parentparent
- the parent to place the actor beneath- Returns:
- true if actor can be placed, false if not
-
checkForStandalones
public boolean checkForStandalones(Actor[] actors, Node parent)
Checks whether standalones can be placed beneath the parent actor. If the actors contain no standalones, this method returns true, of course. In case the actors contain a standalone and the parent doesn't allow standalones to be placed, an error message pops up and informs the user.- Parameters:
actors
- the actors to place beneath the parentparent
- the parent to place the actor beneath- Returns:
- true if actor can be placed, false if not
-
configureFilter
public AbstractItemFilter configureFilter(TreePath path, TreeOperations.InsertPosition position)
Configures a filter for the ClassTree.- Parameters:
path
- the path where to insert the actorposition
- where to add the actor, if null "editing" an existing actor is assumed- Returns:
- the configured filter
-
addActor
public void addActor(TreePath path, Actor actor, TreeOperations.InsertPosition position)
Brings up the GOE dialog for adding an actor if no actor supplied, otherwise just adds the given actor at the position specified by the path.- Parameters:
path
- the path to the actor to add the new actor siblingactor
- the actor to add, if null a GOE dialog is presentedposition
- where to insert the actor
-
addActor
public void addActor(TreePath path, Actor actor, TreeOperations.InsertPosition position, boolean record)
Brings up the GOE dialog for adding an actor if no actor supplied, otherwise just adds the given actor at the position specified by the path.- Parameters:
path
- the path to the actor to add the new actor siblingactor
- the actor to add, if null a GOE dialog is presentedposition
- where to insert the actorrecord
- whether to record the addition
-
addActor
public void addActor(TreePath path, Actor actor, TreeOperations.InsertPosition position, boolean record, TreeOperations.ActorDialog dialogType)
Brings up the GOE dialog for adding an actor if no actor supplied, otherwise just adds the given actor at the position specified by the path.- Parameters:
path
- the path to the actor to add the new actor siblingactor
- the actor to add, if null a GOE dialog is presentedposition
- where to insert the actorrecord
- whether to record the additiondialogType
- the dialog type to use
-
pasteNodes
public void pasteNodes(TreePath path, Node[] nodes, TreeOperations.InsertPosition position)
For pasting nodes.- Parameters:
path
- the path to the actor to add the new actor siblingnodes
- the nodes to pasteposition
- how to insert the nodes
-
favoriteActor
public void favoriteActor(TreePath path, TreeOperations.InsertPosition position, boolean record)
Lets the user select an actor from a dialog of favorites.- Parameters:
path
- the path to the actor to add the new actor siblingposition
- where to insert the actorrecord
- whether to record the addition
-
editActor
public void editActor(TreePath path)
Brings up the GOE dialog for editing the selected actor.- Parameters:
path
- the path to the actor
-
renameActor
public void renameActor(TreePath path)
Renames an actor.- Parameters:
path
- the path to the actor
-
renameActor
public void renameActor(TreePath path, String newName)
Renames an actor.- Parameters:
path
- the path to the actornewName
- the new name for the actor
-
cleanUpActorName
public void cleanUpActorName(TreePath[] paths)
Cleans up the names of actors.- Parameters:
paths
- the paths to the actors
-
encloseActor
public void encloseActor(TreePath[] paths, ActorHandler handler)
Encloses the selected actors in the specified actor handler.- Parameters:
paths
- the (paths to the) actors to wrap in the control actorhandler
- the handler to use
-
pullUpActors
public void pullUpActors(TreePath path)
Pulls up the actors of the selected mutable actor.- Parameters:
path
- the (paths to the) actors to wrap in the control actor
-
swapActor
public void swapActor(TreePath sourcePath, Actor target)
Swaps the actor handler of the node with the new node, keeping the children intact, as well as some basic options.- Parameters:
sourcePath
- the path to the actor to swap outtarget
- the new handler to use
-
configureSuggestionContext
public ActorSuggestion.SuggestionData configureSuggestionContext(TreePath path, TreeOperations.InsertPosition position)
Returns the context for making actor suggestions.- Parameters:
path
- the path where to insert the actorsposition
- how the actors are to be inserted- Returns:
- the context
-
suggestActors
public Actor[] suggestActors(TreePath path, TreeOperations.InsertPosition position)
Tries to figure what actors fit best in the tree at the given position.- Parameters:
path
- the path where to insert the actorsposition
- how the actors are to be inserted- Returns:
- the actors
-
configureSuggestionContext
public ActorSuggestion.SuggestionData configureSuggestionContext(TreePath[] paths)
Returns the context for making external actor suggestions.- Parameters:
paths
- the paths of the actors to externalize- Returns:
- the context
-
suggestExternalActors
public Actor[] suggestExternalActors(TreePath[] paths)
Tries to figure what external actors fit best using the given selection of actors.- Parameters:
paths
- the paths of the actors to externalize- Returns:
- the actors
-
getProcessActorsDialog
public GenericObjectEditorDialog getProcessActorsDialog(String title)
Returns the dialog for processing actors.- Parameters:
title
- the title for the dialog, null for default- Returns:
- the dialog
-
processActor
public void processActor(TreePath path, ActorProcessor processor)
Processes the specified actor with the specified actor processor. NB: The options of the specified actor will get processed.- Parameters:
path
- the path of the actor, if null the root actor is usedprocessor
- the processor to use, null if to prompt user
-
processActor
public void processActor(TreePath path, ActorProcessor processor, Runnable after)
Processes the specified actor with the specified actor processor. NB: The options of the specified actor will get processed.- Parameters:
path
- the path of the actor, if null the root actor is usedprocessor
- the processor to use, null if to prompt userafter
- runnable to execute after actors have been processed, null for none
-
createCallableActor
public void createCallableActor(TreePath path, Class handler)
Turns the selected actor into a callable actor using the specified enclosing handler type.- Parameters:
path
- the (path to the) actor to turn into callable actorhandler
- the callable actors handler
-
editFlow
public void editFlow(TreePath path)
Brings up a flow window for editing the selected external actor's flow.- Parameters:
path
- the path to the node
-
externalizeActor
public void externalizeActor(TreePath[] paths, Actor suggestion)
Opens a new FlowEditor window with the currently selected sub-flow. Checks for callable actors and diplays confirmation dialog if so.- Parameters:
paths
- the (paths to the) actors to externalizesuggestion
- the suggested actor to replace with
-
externalizeActor
public void externalizeActor(TreePath path, Actor suggestion)
Opens a new FlowEditor window with the currently selected sub-flow. Checks for callable actors and diplays confirmation dialog if so.- Parameters:
path
- the (path to the) actor to externalizesuggestion
- the suggested actor to replace with
-
externalizeActor
protected void externalizeActor(TreePath path, boolean checkCallActors, Actor suggestion)
Opens a new FlowEditor window with the currently selected sub-flow.- Parameters:
path
- the (path to the) actor to externalizecheckCallActors
- whether to check for callable actorssuggestion
- the suggested actor to replace with
-
chooseBooleanCondition
protected BooleanCondition chooseBooleanCondition(BooleanCondition defCond)
Lets the user choose a boolean condition.- Parameters:
defCond
- the default condition, can be null- Returns:
- the boolean condition or null if dialog canceled
-
makeConditional
public void makeConditional(TreePath path)
Turns the selected actor into its conditional equivalent.- Parameters:
path
- the (path to the) actor to turn into its conditional equivalent
-
makeTimed
public void makeTimed(TreePath path)
Turns the selected actor into its timed equivalent.- Parameters:
path
- the (path to the) actor to turn into its timed equivalent
-
makeInteractive
public void makeInteractive(TreePath[] paths)
Turns the selected Setvariable standalines into a subflow with EnterManyValues for prompting the user.- Parameters:
paths
- the (paths to the) actors to turn interactive
-
inspectMemoryDetails
public void inspectMemoryDetails(TreePath path, Flow flow)
Displays the memory consumption of the selected actor, broken by class.- Parameters:
path
- the path of the actorflow
- the running flow
-
inspectMemorySize
public void inspectMemorySize(TreePath path, Flow flow)
Displays the memory consumption of the selected subtree (just the size).- Parameters:
path
- the path of the actorflow
- the running flow
-
getActorFromClipboard
public static Actor getActorFromClipboard()
Returns the actor stored on the clipboard.- Returns:
- the actor or null if none available
-
hasNodesOnClipboard
public static boolean hasNodesOnClipboard()
Checks whether any nodes in nested listed form are on the clipboard.- Returns:
- true if nodes available
-
getListsFromClipboard
public static List[] getListsFromClipboard()
Returns the nested lists stored on the clipboard.- Returns:
- the nodes or null if none available
-
getNodesFromClipboard
public static Node[] getNodesFromClipboard()
Returns the nodes stored on the clipboard. Note: usehasNodesOnClipboard()
if you just want a fast check whether there is anything on the clipboard.- Returns:
- the nodes or null if none available
- See Also:
hasNodesOnClipboard()
,getListsFromClipboard()
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUp
in interfaceCleanUpHandler
-
-