public interface IMonitorWithCancellation
This interface is designed with three goals in mind. First, it is intended to support applications that run a graphical user interface and have a need to monitor the progress of time-consuming operations. Second, it should provide an application with a mechanism for requesting that the time-consuming processes perform a voluntary termination (in the event that a user action makes this necessary). And finally, it explicitly avoids any dependency on a particular user-interface environment such as Swing, JFace, or JavaFX.
Because time-consuming processes usually operate in background threads rather than from within the Event Dispatch Thread (or equivalent), implementations are expected to handle thread-safety issues appropriately. For example, a class that extended the Java Swing JProgressBar or BoundedRangeModel would invoke their setValue() methods using the SwingUtility class to ensure the operation executed in the Event Dispatch Thread.
void reportProgress(int progressValueInPercent){ final int value = progressValueInPercent; SwingUtilities.invokeLater(new Runnable(){ setValue(value); }); }
Modifier and Type | Method and Description |
---|---|
int |
getReportingIntervalInPercent()
Gets the minimum interval for reporting progress, thus indicating
the frequency with which the reportProgress method should be
called.
|
boolean |
isCanceled()
Indicates whether the calling application would like this
process to terminate voluntarily.
|
void |
postMessage(String message)
Permits the monitor to post a message for use by the calling
application.
|
void |
reportDone()
Called when the progress is done.
|
void |
reportProgress(int progressValueInPercent)
Report progress to monitoring implementation.
|
int getReportingIntervalInPercent()
void reportProgress(int progressValueInPercent)
progressValueInPercent
- the estimated degree of completion, in percentvoid reportDone()
void postMessage(String message)
message
- a valid stringboolean isCanceled()
Copyright © 2021. All rights reserved.