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 classTreeOperations.ActorDialogEnumeration for actor dialogs.static classTreeOperations.InsertPositionEnumeration for how to insert a node.
-
Field Summary
Fields Modifier and Type Field Description protected GenericObjectEditorDialogm_DialogProcessActorsthe dialog for processing actors.protected Treem_Ownerthe 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 voidaddActor(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.voidaddActor(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.voidaddActor(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.booleancheckForStandalones(Actor[] actors, Node parent)Checks whether standalones can be placed beneath the parent actor.booleancheckForStandalones(Actor actor, Node parent)Checks whether standalones can be placed beneath the parent actor.protected BooleanConditionchooseBooleanCondition(BooleanCondition defCond)Lets the user choose a boolean condition.voidcleanUp()Cleans up data structures, frees up memory.voidcleanUpActorName(TreePath[] paths)Cleans up the names of actors.AbstractItemFilterconfigureFilter(TreePath path, TreeOperations.InsertPosition position)Configures a filter for the ClassTree.ActorSuggestion.SuggestionDataconfigureSuggestionContext(TreePath[] paths)Returns the context for making external actor suggestions.ActorSuggestion.SuggestionDataconfigureSuggestionContext(TreePath path, TreeOperations.InsertPosition position)Returns the context for making actor suggestions.voidcreateCallableActor(TreePath path, Class handler)Turns the selected actor into a callable actor using the specified enclosing handler type.voideditActor(TreePath path)Brings up the GOE dialog for editing the selected actor.voideditFlow(TreePath path)Brings up a flow window for editing the selected external actor's flow.voidencloseActor(TreePath[] paths, ActorHandler handler)Encloses the selected actors in the specified actor handler.voidexternalizeActor(TreePath[] paths, Actor suggestion)Opens a new FlowEditor window with the currently selected sub-flow.protected voidexternalizeActor(TreePath path, boolean checkCallActors, Actor suggestion)Opens a new FlowEditor window with the currently selected sub-flow.voidexternalizeActor(TreePath path, Actor suggestion)Opens a new FlowEditor window with the currently selected sub-flow.voidfavoriteActor(TreePath path, TreeOperations.InsertPosition position, boolean record)Lets the user select an actor from a dialog of favorites.List<String>findActorLocations(Actor actor)Locates all the occurrences of this actor.List<String>findStorageNames(Actor actor)Tries to locate the storage name in the actor's options.List<String>findVariableNames(Actor actor)Tries to locate the variable names in the actor's options.static ActorgetActorFromClipboard()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.TreegetOwner()Returns the owning tree.GenericObjectEditorDialoggetProcessActorsDialog(String title)Returns the dialog for processing actors.static booleanhasNodesOnClipboard()Checks whether any nodes in nested listed form are on the clipboard.voidinspectMemoryDetails(TreePath path, Flow flow)Displays the memory consumption of the selected actor, broken by class.voidinspectMemorySize(TreePath path, Flow flow)Displays the memory consumption of the selected subtree (just the size).voidmakeConditional(TreePath path)Turns the selected actor into its conditional equivalent.voidmakeInteractive(TreePath[] paths)Turns the selected Setvariable standalines into a subflow with EnterManyValues for prompting the user.voidmakeTimed(TreePath path)Turns the selected actor into its timed equivalent.voidpasteNodes(TreePath path, Node[] nodes, TreeOperations.InsertPosition position)For pasting nodes.voidprocessActor(TreePath path, ActorProcessor processor)Processes the specified actor with the specified actor processor.voidprocessActor(TreePath path, ActorProcessor processor, Runnable after)Processes the specified actor with the specified actor processor.voidpullUpActors(TreePath path)Pulls up the actors of the selected mutable actor.voidrenameActor(TreePath path)Renames an actor.voidrenameActor(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.voidswapActor(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.protected ComponentwrapActorProcessorGraphicalOutput(GraphicalActorProcessorHandler handler, Component comp, TreePath path, ActorProcessor processor)Wraps the graphical output of actor processors to make them re-runnable, adding a rerun button.
-
-
-
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
-
wrapActorProcessorGraphicalOutput
protected Component wrapActorProcessorGraphicalOutput(GraphicalActorProcessorHandler handler, Component comp, TreePath path, ActorProcessor processor)
Wraps the graphical output of actor processors to make them re-runnable, adding a rerun button.- Parameters:
handler- the handler in usecomp- the output of the actor processor to wrappath- the current pathprocessor- the current processor- Returns:
- the wrapped component
-
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()
-
findVariableNames
public List<String> findVariableNames(Actor actor)
Tries to locate the variable names in the actor's options.- Parameters:
actor- the actor to search- Returns:
- the variable names, empty if none found
-
findStorageNames
public List<String> findStorageNames(Actor actor)
Tries to locate the storage name in the actor's options.- Parameters:
actor- the actor to search- Returns:
- the storage name, empty if none found
-
findActorLocations
public List<String> findActorLocations(Actor actor)
Locates all the occurrences of this actor.- Parameters:
actor- the actor to look for- Returns:
- the actor paths
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUpin interfaceCleanUpHandler
-
-