diff --git a/Ghidra/Framework/Utility/src/main/java/ghidra/util/task/TaskMonitor.java b/Ghidra/Framework/Utility/src/main/java/ghidra/util/task/TaskMonitor.java index af895e3872..75d947e38b 100644 --- a/Ghidra/Framework/Utility/src/main/java/ghidra/util/task/TaskMonitor.java +++ b/Ghidra/Framework/Utility/src/main/java/ghidra/util/task/TaskMonitor.java @@ -88,6 +88,17 @@ public interface TaskMonitor { */ public void initialize(long max); + /** + * Initializes the progress value to 0, sets the max value and message of this monitor. + * + * @param max maximum value for progress + * @param message the message to display + */ + default public void initialize(long max, String message) { + initialize(max); + setMessage(message); + } + /** * Set the progress maximum value *

@@ -133,11 +144,41 @@ public interface TaskMonitor { } /** - * A convenience method to increment the current progress by the given value + * Increases the progress value by 1. + */ + default public void incrementProgress() { + incrementProgress(1); + } + + /** + * Changes the progress value by the specified amount. + * * @param incrementAmount The amount by which to increment the progress */ public void incrementProgress(long incrementAmount); + /** + * Increases the progress value by 1, and checks if this monitor has been cancelled. + * + * @throws CancelledException if monitor has been cancelled + */ + default public void increment() throws CancelledException { + checkCancelled(); + incrementProgress(1); + } + + /** + * Changes the progress value by the specified amount, and checks if this monitor has + * been cancelled. + * + * @param incrementAmount The amount by which to increment the progress + * @throws CancelledException if monitor has been cancelled + */ + default public void increment(long incrementAmount) throws CancelledException { + checkCancelled(); + incrementProgress(incrementAmount); + } + /** * Returns the current progress value or {@link #NO_PROGRESS_VALUE} if there is no value set * @return the current progress value or {@link #NO_PROGRESS_VALUE} if there is no value set