Package ghidra.util.task
Interface TaskMonitor
- All Known Implementing Classes:
CancelOnlyWrappingTaskMonitor
,ConsoleTaskMonitor
,DummyCancellableTaskMonitor
,GTaskMonitor
,HeadlessTimedTaskMonitor
,TaskDialog
,TaskMonitorAdapter
,TaskMonitorComponent
,TimeoutTaskMonitor
,TreeTaskMonitor
,UnknownProgressWrappingTaskMonitor
,WrappingTaskMonitor
public interface TaskMonitor
TaskMonitor
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.
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 setProgress(int)
method,
otherwise it should just call the setMessage(String)
method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TaskMonitor
static final int
A value to indicate that this monitor has no progress value set -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCancelledListener
(CancelledListener listener) Add cancelled listenervoid
cancel()
Cancel the taskvoid
Check to see if this monitor has been canceledvoid
Clear the cancellation so that this TaskMonitor may be reusedstatic TaskMonitor
Returns the given task monitor if it is notnull
.long
Returns the current maximum value for progressGets the last set message of this monitorlong
Returns the current progress value orNO_PROGRESS_VALUE
if there is no value setvoid
incrementProgress
(long incrementAmount) A convenience method to increment the current progress by the given valuevoid
initialize
(long max) Initialized this TaskMonitor to the given max values.boolean
Returns true if cancel ability is enabledboolean
Returns true if the user has cancelled the operationboolean
Returns true if this monitor shows no progressvoid
removeCancelledListener
(CancelledListener listener) Remove cancelled listenervoid
setCancelEnabled
(boolean enable) Set the enablement of the Cancel buttonvoid
setIndeterminate
(boolean indeterminate) An indeterminate task monitor may choose to show an animation instead of updating progressvoid
setMaximum
(long max) Set the progress maximum valuevoid
setMessage
(String message) Sets the message displayed on the task monitorvoid
setProgress
(long value) Sets the current progress valuevoid
setShowProgressValue
(boolean showProgressValue) True (the default) signals to paint the progress information inside of the progress bar
-
Field Details
-
DUMMY
-
NO_PROGRESS_VALUE
static final int NO_PROGRESS_VALUEA value to indicate that this monitor has no progress value set- See Also:
-
-
Method Details
-
dummyIfNull
Returns the given task monitor if it is notnull
. Otherwise, aDUMMY
monitor is returned.- Parameters:
tm
- the monitor to check fornull
- 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
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
-
setMaximum
void setMaximum(long max) Set the progress maximum valueNote: 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:
- 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
Check 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_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
Add cancelled listener- Parameters:
listener
- the cancel listener
-
removeCancelledListener
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
void clearCanceled()Clear the cancellation so that this TaskMonitor may be reused
-