Package ghidra.util.task
Interface TaskMonitor
-
- All Known Implementing Classes:
CancelOnlyWrappingTaskMonitor,ConsoleTaskMonitor,DummyCancellableTaskMonitor,GTaskMonitor,HeadlessTimedTaskMonitor,TaskDialog,TaskMonitorAdapter,TaskMonitorComponent,TimeoutTaskMonitor,UnknownProgressWrappingTaskMonitor,WrappingTaskMonitor
public interface TaskMonitorTaskMonitorprovides 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. 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 thesetProgress(int)method, otherwise it should just call thesetMessage(String)method.
-
-
Field Summary
Fields Modifier and Type Field Description static TaskMonitorDUMMYstatic intNO_PROGRESS_VALUEA value to indicate that this monitor has no progress value set.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddCancelledListener(CancelledListener listener)Add cancelled listener.voidaddIssueListener(IssueListener listener)Add an issue listener to this monitor.voidcancel()Cancel the task.voidcheckCanceled()Check to see if this monitor has been canceled.voidclearCanceled()Clear the cancellation so that this TaskMonitor may be reused.longgetMaximum()Returns the current maximum value for progress.longgetProgress()Returns the current progress value orNO_PROGRESS_VALUEif there is no value set.voidincrementProgress(long incrementAmount)A convenience method to increment the current progress by the given value.voidinitialize(long max)Initialized this TaskMonitor to the given max values.booleanisCancelEnabled()Returns true if cancel ability is enabledbooleanisCancelled()Returns true if the user has cancelled the operation.voidremoveCancelledListener(CancelledListener listener)Remove cancelled listener.voidremoveIssueListener(IssueListener listener)Removes an issue listener to this monitor.voidreportIssue(Issue issue)Notify that an issue occurred while processing.voidsetCancelEnabled(boolean enable)Set the enablement of the Cancel button.voidsetIndeterminate(boolean indeterminate)An indeterminate task monitor may choose to show an animation instead of updating progress.voidsetMaximum(long max)Set the progress maximum value.voidsetMessage(java.lang.String message)Sets a message giving additional information about the current progress.voidsetProgress(long value)Sets the current progress value.voidsetShowProgressValue(boolean showProgressValue)True (the default) signals to paint the progress information inside of the progress bar.
-
-
-
Field Detail
-
DUMMY
static final TaskMonitor DUMMY
-
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 Detail
-
isCancelled
boolean isCancelled()
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(java.lang.String message)
Sets a message giving additional information about the current progress.- Parameters:
message- more information
-
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
-
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 new max value.
- Parameters:
max- maximum value for progress
-
getMaximum
long getMaximum()
Returns the current maximum value for progress.- Returns:
-
setIndeterminate
void setIndeterminate(boolean indeterminate)
An indeterminate task monitor may choose to show an animation instead of updating progress.
-
checkCanceled
void checkCanceled() throws CancelledExceptionCheck to see if this monitor has been canceled.- Throws:
CancelledException- if monitor has been cancelled.
-
incrementProgress
void incrementProgress(long incrementAmount)
A convenience method to increment the current progress by the given value.- Parameters:
incrementAmount- The amount by which to increment the progress.
-
getProgress
long getProgress()
Returns the current progress value orNO_PROGRESS_VALUEif there is no value set.- Returns:
- the current progress value or
NO_PROGRESS_VALUEif there is no value set.
-
reportIssue
void reportIssue(Issue issue)
Notify that an issue occurred while processing.- Parameters:
issue- the issue that was encountered
-
cancel
void cancel()
Cancel the task.
-
addCancelledListener
void addCancelledListener(CancelledListener listener)
Add cancelled listener.- Parameters:
listener-
-
removeCancelledListener
void removeCancelledListener(CancelledListener listener)
Remove cancelled listener.- Parameters:
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
-
clearCanceled
void clearCanceled()
Clear the cancellation so that this TaskMonitor may be reused.
-
addIssueListener
void addIssueListener(IssueListener listener)
Add an issue listener to this monitor.- Parameters:
listener- the listener
-
removeIssueListener
void removeIssueListener(IssueListener listener)
Removes an issue listener to this monitor.- Parameters:
listener- the listener
-
-