Class ToolTaskManager

  • All Implemented Interfaces:
    java.lang.Runnable

    public class ToolTaskManager
    extends java.lang.Object
    implements java.lang.Runnable
    Manages a queue of background tasks that execute commands.
    • 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 execute
        obj - 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 command
        obj - 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 scheduled
        obj - 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:
        run in interface java.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/redo
        task - background command task that has completed
        monitor - 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/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)