GP-2982 - Added methods to TaskMonitor to address spelling

inconsistencies
This commit is contained in:
dragonmacher 2023-01-05 14:53:26 -05:00
parent 5c4d7a22c8
commit df968a0387
2 changed files with 45 additions and 27 deletions

View file

@ -20,11 +20,10 @@ import ghidra.util.datastruct.WeakSet;
import ghidra.util.exception.CancelledException;
/**
* Create a "do nothing" task monitor that we can pass along to methods that
* need a task monitor. This can be used when methods provide detailed
* task progress information that we don't want to show the user.
* <P>This monitor can be configured to allow cancelling via {@link #setCancelEnabled(boolean)}.
* If this cancelling is enabled, the the monitor may be cancelled programmatically.
* Implementation of {@link TaskMonitor} with most features stubbed out.
* <p>
* This class supports cancelling and cancel listener notification. Cancelling must be enabled
* via {@link #setCancelEnabled(boolean)}.
*/
public class TaskMonitorAdapter implements TaskMonitor {
@ -145,7 +144,7 @@ public class TaskMonitorAdapter implements TaskMonitor {
cancelled = false;
}
// TODO this seems like a mistake, to notify of 'cancelled' when clearning
// TODO this seems like a mistake, to notify of 'cancelled' when clearing
notifyChangeListeners();
}

View file

@ -18,18 +18,20 @@ package ghidra.util.task;
import ghidra.util.exception.CancelledException;
/**
* <CODE>TaskMonitor</CODE> provides an interface by means of which a
* potentially long running task can show its progress and also check if the user
* has cancelled the operation.
* <CODE>TaskMonitor</CODE> provides an interface that allows potentially long running tasks to show
* progress and check for user has cancellation.
* <p>
* Operations that support a task monitor should periodically
* check to see if the operation has been cancelled and abort. If possible, the
* operation should also provide periodic progress information. If it can estimate a
* percentage done, then it should use the <code>setProgress(int)</code> method,
* otherwise it should just call the <code>setMessage(String)</code> method.
* 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 {@link #setProgress(long)}
* method, otherwise it should call {@link #setMessage(String)} method to provide status updates.
*/
public interface TaskMonitor {
/**
* A 'do nothing' task monitor that can be passed to APIs when the client has not progress to
* report.
*/
public static final TaskMonitor DUMMY = new StubTaskMonitor();
/**
@ -114,11 +116,22 @@ public interface TaskMonitor {
public boolean isIndeterminate();
/**
* Check to see if this monitor has been canceled
* (Use {@link #checkCancelled()} instead)
*
* Check to see if this monitor has been cancelled.
* @throws CancelledException if monitor has been cancelled
*/
public void checkCanceled() throws CancelledException;
/**
* Check to see if this monitor has been cancelled
* @throws CancelledException if monitor has been cancelled
*/
public default void checkCancelled() throws CancelledException {
// note: call checkCanceled() until it is removed; this produces the least number of changes
checkCanceled();
}
/**
* A convenience method to increment the current progress by the given value
* @param incrementAmount The amount by which to increment the progress
@ -126,10 +139,8 @@ public interface TaskMonitor {
public void incrementProgress(long 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
* 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
*/
public long getProgress();
@ -163,9 +174,17 @@ public interface TaskMonitor {
public boolean isCancelEnabled();
/**
* (Use {@link #clearCancelled()} instead)
* <p>
* Clear the cancellation so that this TaskMonitor may be reused
*
*/
public void clearCanceled();
/**
* Clear the cancellation so that this TaskMonitor may be reused
*/
public default void clearCancelled() {
// note: call clearCanceled() until it is removed; this produces the least number of changes
clearCanceled();
}
}