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

View file

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