Package ghidra.util.task

# Interface TaskMonitor

All Known Subinterfaces:
  `CloseableTaskMonitor`

All Known Implementing Classes:
  `CancelOnlyWrappingTaskMonitor`, `ConsoleTaskMonitor`, `DummyCancellableTaskMonitor`, `GTaskMonitor`, `HeadlessTimedTaskMonitor`, `PreserveStateWrappingTaskMonitor`, `PyGhidraTaskMonitor`, `TaskDialog`, `TaskMonitorAdapter`, `TaskMonitorComponent`, `TimeoutTaskMonitor`, `TreeTaskMonitor`, `UnknownProgressWrappingTaskMonitor`, `WrappingTaskMonitor`

public interface TaskMonitor
`TaskMonitor` provides an interface that allows potentially long running tasks to show progress and check for user has cancellation.

Tasks that support a task monitor should periodically check to see if the operation has been cancelled and abort. If possible, the task should also provide periodic progress information. If your task can estimate the amount of work done, then it should use the `setProgress(long)` method, otherwise it should call `setMessage(String)` method to provide status updates.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final TaskMonitor`
  `DUMMY`
  A 'do nothing' task monitor that can be passed to APIs when the client has not progress to report.
  `static final int`
  `NO_PROGRESS_VALUE`
  A value to indicate that this monitor has no progress value set

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addCancelledListener(CancelledListener listener)`
  Add cancelled listener
  `void`
  `cancel()`
  Cancel the task
  `void`
  `checkCanceled()`
  Deprecated.
  Use `checkCancelled()` instead
  `default void`
  `checkCancelled()`
  Check to see if this monitor has been cancelled
  `void`
  `clearCanceled()`
  Deprecated.
  Use `clearCancelled()` instead
  `default void`
  `clearCancelled()`
  Clear the cancellation so that this TaskMonitor may be reused
  `static TaskMonitor`
  `dummyIfNull(TaskMonitor tm)`
  Returns the given task monitor if it is not `null`.
  `long`
  `getMaximum()`
  Returns the current maximum value for progress
  `String`
  `getMessage()`
  Gets the last set message of this monitor
  `long`
  `getProgress()`
  Returns the current progress value or `NO_PROGRESS_VALUE` if there is no value set
  `default void`
  `increment()`
  Increases the progress value by 1, and checks if this monitor has been cancelled.
  `default void`
  `increment(long incrementAmount)`
  Changes the progress value by the specified amount, and checks if this monitor has been cancelled.
  `default void`
  `incrementProgress()`
  Increases the progress value by 1.
  `void`
  `incrementProgress(long incrementAmount)`
  Changes the progress value by the specified amount.
  `void`
  `initialize(long max)`
  Initialized this TaskMonitor to the given max values.
  `default void`
  `initialize(long max, String message)`
  Initializes the progress value to 0, sets the max value and message of this monitor.
  `boolean`
  `isCancelEnabled()`
  Returns true if cancel ability is enabled
  `boolean`
  `isCancelled()`
  Returns true if the user has cancelled the operation
  `boolean`
  `isIndeterminate()`
  Returns true if this monitor shows no progress
  `void`
  `removeCancelledListener(CancelledListener listener)`
  Remove cancelled listener
  `void`
  `setCancelEnabled(boolean enable)`
  Set the enablement of the Cancel button
  `void`
  `setIndeterminate(boolean indeterminate)`
  An indeterminate task monitor may choose to show an animation instead of updating progress
  `void`
  `setMaximum(long max)`
  Set the progress maximum value
  `void`
  `setMessage(String message)`
  Sets the message displayed on the task monitor
  `void`
  `setProgress(long value)`
  Sets the current progress value
  `void`
  `setShowProgressValue(boolean showProgressValue)`
  True (the default) signals to paint the progress information inside of the progress bar

- ## Field Details

  - ### DUMMY

    static final TaskMonitor DUMMY
    A 'do nothing' task monitor that can be passed to APIs when the client has not progress to report.

  - ### NO_PROGRESS_VALUE

    static final int NO_PROGRESS_VALUE
    A value to indicate that this monitor has no progress value set
    See Also:
      - Constant Field Values

- ## Method Details

  - ### dummyIfNull

    static TaskMonitor dummyIfNull(TaskMonitor tm)
    Returns the given task monitor if it is not `null`. Otherwise, a `DUMMY` monitor is returned.
    Parameters:
      `tm` - the monitor to check for `null`
    Returns:
      a non-null task monitor

  - ### isCancelled

    boolean isCancelled()
    Returns true if the user has cancelled the operation
    Returns:
      true if the user has cancelled the operation

  - ### setShowProgressValue

    void setShowProgressValue(boolean showProgressValue)
    True (the default) signals to paint the progress information inside of the progress bar
    Parameters:
      `showProgressValue` - true to paint the progress value; false to not

  - ### setMessage

    void setMessage(String message)
    Sets the message displayed on the task monitor
    Parameters:
      `message` - the message to display

  - ### getMessage

    String getMessage()
    Gets the last set message of this monitor
    Returns:
      the message

  - ### setProgress

    void setProgress(long value)
    Sets the current progress value
    Parameters:
      `value` - progress value

  - ### initialize

    void initialize(long max)
    Initialized this TaskMonitor to the given max values. The current value of this monitor will be set to zero.
    Parameters:
      `max` - maximum value for progress

  - ### initialize

    default void initialize(long max, String message)
    Initializes the progress value to 0, sets the max value and message of this monitor.
    Parameters:
      `max` - maximum value for progress
      `message` - the message to display

  - ### setMaximum

    void setMaximum(long max)
    Set the progress maximum value

    Note: setting this value will reset the progress to be the max if the progress is currently greater than the new max value.

    Parameters:
      `max` - maximum value for progress

  - ### getMaximum

    long getMaximum()
    Returns the current maximum value for progress
    Returns:
      the maximum progress value

  - ### setIndeterminate

    void setIndeterminate(boolean indeterminate)
    An indeterminate task monitor may choose to show an animation instead of updating progress
    Parameters:
      `indeterminate` - true if indeterminate

  - ### isIndeterminate

    boolean isIndeterminate()
    Returns true if this monitor shows no progress
    Returns:
      true if this monitor shows no progress

  - ### checkCanceled

    @Deprecated(since="10.3") void checkCanceled() throws CancelledException
    Deprecated.
    Use `checkCancelled()` instead
    Check to see if this monitor has been cancelled
    Throws:
      `CancelledException` - if monitor has been cancelled

  - ### checkCancelled

    default void checkCancelled() throws CancelledException
    Check to see if this monitor has been cancelled
    Throws:
      `CancelledException` - if monitor has been cancelled

  - ### incrementProgress

    default void incrementProgress()
    Increases the progress value by 1.

  - ### incrementProgress

    void incrementProgress(long incrementAmount)
    Changes the progress value by the specified amount.
    Parameters:
      `incrementAmount` - The amount by which to increment the progress

  - ### increment

    default void increment() throws CancelledException
    Increases the progress value by 1, and checks if this monitor has been cancelled.
    Throws:
      `CancelledException` - if monitor has been cancelled

  - ### increment

    default void increment(long incrementAmount) throws CancelledException
    Changes the progress value by the specified amount, and checks if this monitor has been cancelled.
    Parameters:
      `incrementAmount` - The amount by which to increment the progress
    Throws:
      `CancelledException` - if monitor has been cancelled

  - ### getProgress

    long getProgress()
    Returns the current progress value or `NO_PROGRESS_VALUE` if there is no value set
    Returns:
      the current progress value or `NO_PROGRESS_VALUE` if there is no value set

  - ### cancel

    void cancel()
    Cancel the task

  - ### addCancelledListener

    void addCancelledListener(CancelledListener listener)
    Add cancelled listener
    Parameters:
      `listener` - the cancel listener

  - ### removeCancelledListener

    void removeCancelledListener(CancelledListener listener)
    Remove cancelled listener
    Parameters:
      `listener` - the cancel listener

  - ### setCancelEnabled

    void setCancelEnabled(boolean enable)
    Set the enablement of the Cancel button
    Parameters:
      `enable` - true means to enable the cancel button

  - ### isCancelEnabled

    boolean isCancelEnabled()
    Returns true if cancel ability is enabled
    Returns:
      true if cancel ability is enabled

  - ### clearCanceled

    @Deprecated(since="10.3") void clearCanceled()
    Deprecated.
    Use `clearCancelled()` instead
    Clear the cancellation so that this TaskMonitor may be reused

  - ### clearCancelled

    default void clearCancelled()
    Clear the cancellation so that this TaskMonitor may be reused