Package com.im.commons.progress
Interface DFFeedback
-
- All Known Subinterfaces:
EnvUtils.DFFeedbackWithCancel
- All Known Implementing Classes:
ConsoleFeedback
public interface DFFeedbackProvides call backs for displaying progress and information as processes run in the DIF tier. A client can use theDFFeedbackto report information to the user.There are two simple default implementations:
DEV_NULLfor ignoring all feedbackConsoleFeedbackfor output to console or anotherPrintStream
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classDFFeedback.TypeTypes of messages to be used in DFFeedback.
-
Field Summary
Fields Modifier and Type Field Description static DFFeedbackDEV_NULL"Empty device" - all feedback is ignored.static java.lang.StringPROPERTY_CANCELUsed byPropertyChangeListenerfor notifying about user-initiated cancel.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddMessage(DFFeedback.Type type, java.lang.Object message, java.lang.Throwable t)Adds a message to the feedback.voidaddPropertyChangeListener(java.beans.PropertyChangeListener listener)voidfinish()Indicate the task is done.java.lang.StringgetId()booleanisCancelled()Return whether this operation was cancelled by user.voidprogress(int workunit)Notify the user about completed work units.voidremovePropertyChangeListener(java.beans.PropertyChangeListener listener)voidswitchToDeterminate(int workunits)Currently indeterminate task can be switched to show percentage completed.voidswitchToIndeterminate()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 byPropertyChangeListenerfor 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
-
-