Package com.im.commons.progress
Interface DFFeedback
-
- All Known Subinterfaces:
EnvUtils.DFFeedbackWithCancel
- All Known Implementing Classes:
ConsoleFeedback
public interface DFFeedback
Provides call backs for displaying progress and information as processes run in the DIF tier. A client can use theDFFeedback
to report information to the user.There are two simple default implementations:
DEV_NULL
for ignoring all feedbackConsoleFeedback
for output to console or anotherPrintStream
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
DFFeedback.Type
Types of messages to be used in DFFeedback.
-
Field Summary
Fields Modifier and Type Field Description static DFFeedback
DEV_NULL
"Empty device" - all feedback is ignored.static java.lang.String
PROPERTY_CANCEL
Used byPropertyChangeListener
for notifying about user-initiated cancel.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addMessage(DFFeedback.Type type, java.lang.Object message, java.lang.Throwable t)
Adds a message to the feedback.void
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
void
finish()
Indicate the task is done.java.lang.String
getId()
boolean
isCancelled()
Return whether this operation was cancelled by user.void
progress(int workunit)
Notify the user about completed work units.void
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
void
switchToDeterminate(int workunits)
Currently indeterminate task can be switched to show percentage completed.void
switchToIndeterminate()
Currently determinate task (with percentage or time estimate) can be switched to indeterminate mode.
-
-
-
Field Detail
-
PROPERTY_CANCEL
static final java.lang.String PROPERTY_CANCEL
Used byPropertyChangeListener
for notifying about user-initiated cancel.- See Also:
- Constant Field Values
-
DEV_NULL
static final DFFeedback DEV_NULL
"Empty device" - all feedback is ignored. You can use this instance if you are not interested in any progress or messages. It's generally better to print messages at least to console. In this case you can useConsoleFeedback
.
-
-
Method Detail
-
isCancelled
boolean isCancelled()
Return whether this operation was cancelled by user. Operations should periodically check this flag and if it returnstrue
, operation should stop as soon as possible.- Returns:
- was this operation cancelled by user?
-
getId
java.lang.String getId()
- Returns:
- An unique ID suitable for identification the feedback instance
-
addMessage
void addMessage(DFFeedback.Type type, java.lang.Object message, java.lang.Throwable t)
Adds a message to the feedback. This form does not add a simple message, but a structure, which is then formatted and presented to the user according to the user preferences (e.g. the locale).This method is yet TBD - probably the passed message should have an typeID or something. The main reason for providing it is the IJC server, which cannot anticipate user's locale.
-
switchToIndeterminate
void switchToIndeterminate()
Currently determinate task (with percentage or time estimate) can be switched to indeterminate mode.
-
switchToDeterminate
void switchToDeterminate(int workunits)
Currently indeterminate task can be switched to show percentage completed. A common use case is to calculate the amount of work in the beginning showing in indeterminate mode and later switch to the progress with known steps
-
progress
void progress(int workunit)
Notify the user about completed work units.- Parameters:
workunit
- A cumulative number of work units completed so far
-
finish
void finish()
Indicate the task is done.
-
addPropertyChangeListener
void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
- Parameters:
listener
- adds listener to be used for notifications about ie. user initiated cancel
-
removePropertyChangeListener
void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
- Parameters:
listener
- remove registered propertyChangeListener
-
-