Package ghidra.framework.plugintool.mgr
Class ToolTaskManager
- java.lang.Object
-
- ghidra.framework.plugintool.mgr.ToolTaskManager
-
- All Implemented Interfaces:
java.lang.Runnable
public class ToolTaskManager extends java.lang.Object implements java.lang.RunnableManages a queue of background tasks that execute commands.
-
-
Constructor Summary
Constructors Constructor Description ToolTaskManager(PluginTool tool)Construct a new ToolTaskManager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancelCurrentTask()Cancel the current task.voidclearQueuedCommands(UndoableDomainObject obj)Clear the queue of scheduled commands.voidclearTasks()Clear the list of tasks.voidclearTasks(UndoableDomainObject obj)Clear all tasks associated with specified domain object.voiddispose()Clear list of tasks and queue of scheduled commands.booleanexecute(Command cmd, DomainObject obj)Execute the given command in the foregroundvoidexecuteCommand(BackgroundCommand cmd, UndoableDomainObject obj)Execute the given command in the backgroundjavax.swing.JComponentgetMonitorComponent()Get the monitor component that shows progress and has a cancel button.java.lang.ThreadGroupgetTaskThreadGroup()Returns the thread group associated with all background tasks run by this manager and their instantiated threads.booleanhasTasksForDomainObject(DomainObject domainObject)booleanisBusy()Return true if a task is executingvoidrun()voidscheduleFollowOnCommand(BackgroundCommand cmd, UndoableDomainObject obj)Schedule the given background command when the current command completes.voidstop(boolean wait)Cancel the currently running task and clear all commands that are scheduled to run.voidtaskCompleted(UndoableDomainObject obj, ghidra.framework.plugintool.mgr.BackgroundCommandTask task, TaskMonitor monitor)Notification from the BackgroundCommandTask that it has completed; queued or scheduled commands are executed.voidtaskFailed(UndoableDomainObject obj, BackgroundCommand taskCmd, TaskMonitor monitor)Notification from the BackgroundCommandTask that the given command failed.
-
-
-
Constructor Detail
-
ToolTaskManager
public ToolTaskManager(PluginTool tool)
Construct a new ToolTaskManager.- Parameters:
tool- tool associated with this ToolTaskManager
-
-
Method Detail
-
getTaskThreadGroup
public java.lang.ThreadGroup getTaskThreadGroup()
Returns the thread group associated with all background tasks run by this manager and their instantiated threads.- Returns:
- task thread group
-
getMonitorComponent
public javax.swing.JComponent getMonitorComponent()
Get the monitor component that shows progress and has a cancel button.- Returns:
- the monitor component
-
isBusy
public boolean isBusy()
Return true if a task is executing- Returns:
- true if a task is executing
-
execute
public boolean execute(Command cmd, DomainObject obj)
Execute the given command in the foreground- Parameters:
cmd- command to executeobj- domain object to which the command will be applied- Returns:
- the completion status of the command
- See Also:
Command.applyTo(DomainObject)
-
executeCommand
public void executeCommand(BackgroundCommand cmd, UndoableDomainObject obj)
Execute the given command in the background- Parameters:
cmd- background commandobj- domain object that supports undo/redo
-
scheduleFollowOnCommand
public void scheduleFollowOnCommand(BackgroundCommand cmd, UndoableDomainObject obj)
Schedule the given background command when the current command completes.- Parameters:
cmd- background command to be scheduledobj- domain object that supports undo/redo
-
stop
public void stop(boolean wait)
Cancel the currently running task and clear all commands that are scheduled to run. Block until the currently running task ends.- Parameters:
wait- if true wait for current task to cancel cleanly
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable- See Also:
Runnable.run()
-
taskCompleted
public void taskCompleted(UndoableDomainObject obj, ghidra.framework.plugintool.mgr.BackgroundCommandTask task, TaskMonitor monitor)
Notification from the BackgroundCommandTask that it has completed; queued or scheduled commands are executed.- Parameters:
obj- domain object that supports undo/redotask- background command task that has completedmonitor- task monitor
-
clearQueuedCommands
public void clearQueuedCommands(UndoableDomainObject obj)
Clear the queue of scheduled commands.
-
clearTasks
public void clearTasks(UndoableDomainObject obj)
Clear all tasks associated with specified domain object.- Parameters:
obj- domain object
-
taskFailed
public void taskFailed(UndoableDomainObject obj, BackgroundCommand taskCmd, TaskMonitor monitor)
Notification from the BackgroundCommandTask that the given command failed. Any scheduled commands are cleared from the queue.- Parameters:
obj- domain object that supports undo/redotaskCmd- background command that failedmonitor- task monitor for the background task
-
dispose
public void dispose()
Clear list of tasks and queue of scheduled commands.
-
clearTasks
public void clearTasks()
Clear the list of tasks.
-
cancelCurrentTask
public void cancelCurrentTask()
Cancel the current task.
-
hasTasksForDomainObject
public boolean hasTasksForDomainObject(DomainObject domainObject)
-
-