Class ToolTaskManager

java.lang.Object
ghidra.framework.plugintool.mgr.ToolTaskManager
All Implemented Interfaces:
Runnable

public class ToolTaskManager extends Object implements Runnable
Manages a queue of background tasks that execute commands.
  • Constructor Details

    • ToolTaskManager

      public ToolTaskManager(PluginTool tool)
      Construct a new ToolTaskManager.
      Parameters:
      tool - tool associated with this ToolTaskManager
  • Method Details

    • getTaskThreadGroup

      public 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 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 <T extends DomainObject> boolean execute(String commandName, T domainObject, Function<T,Boolean> f)
      Execute the given command in the foreground. Required domain object transaction will be started with delayed end to ensure that any follow-on analysis starts prior to transaction end.
      Type Parameters:
      T - DomainObject implementation interface
      Parameters:
      commandName - command name to be associated with transaction
      domainObject - domain object to be modified
      f - command function callback which should return true on success or false on failure.
      Returns:
      result from command function callback
    • execute

      public <T extends DomainObject> boolean execute(Command<T> cmd, T obj)
      Execute the given command in the foreground. Required domain object transaction will be started with delayed end to ensure that any follow-on analysis starts prior to transaction end.
      Parameters:
      cmd - command to execute
      obj - domain object to which the command will be applied
      Returns:
      the completion status of the command
      See Also:
    • executeCommand

      public <T extends DomainObject> void executeCommand(BackgroundCommand<T> cmd, T obj)
      Execute the given command in the background
      Parameters:
      cmd - background command
      obj - domain object that supports undo/redo
    • scheduleFollowOnCommand

      public <T extends DomainObject> void scheduleFollowOnCommand(BackgroundCommand<T> cmd, T obj)
      Schedule the given background command when the current command completes.
      Parameters:
      cmd - background command to be scheduled
      obj - domain object that supports undo/redo
    • stop

      public void stop(TaskMonitor monitor)
      Cancel the currently running task and clear all commands that are scheduled to run. Block until the currently running task ends.
      Parameters:
      monitor - a monitor to cancel waiting for the task to finish
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • taskCompleted

      public <T extends DomainObject> void taskCompleted(T obj, ghidra.framework.plugintool.mgr.BackgroundCommandTask<T> task, TaskMonitor monitor)
      Notification from the BackgroundCommandTask that it has completed; queued or scheduled commands are executed.
      Parameters:
      obj - domain object that supports undo/redo
      task - background command task that has completed
      monitor - task monitor
    • clearQueuedCommands

      public void clearQueuedCommands(DomainObject obj)
      Clear the queue of scheduled commands.
      Parameters:
      obj - domain object
    • clearTasks

      public void clearTasks(DomainObject obj)
      Clear all tasks associated with specified domain object.
      Parameters:
      obj - domain object
    • taskFailed

      public <T extends DomainObject> void taskFailed(T obj, BackgroundCommand<T> 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/redo
      taskCmd - background command that failed
      monitor - 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)