Package com.im.commons.progress
Class ConsoleFeedback
- java.lang.Object
-
- com.im.commons.progress.ConsoleFeedback
-
- All Implemented Interfaces:
DFFeedback
public class ConsoleFeedback extends java.lang.Object implements DFFeedback
Implementation ofDFFeedbackwhich prints all messages to console or provided stream.- Author:
- Petr Hamernik
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.im.commons.progress.DFFeedback
DFFeedback.Type
-
-
Field Summary
-
Fields inherited from interface com.im.commons.progress.DFFeedback
DEV_NULL, PROPERTY_CANCEL
-
-
Constructor Summary
Constructors Constructor Description ConsoleFeedback()ConsoleFeedback(java.io.PrintStream output)
-
Method Summary
All Methods Instance Methods Concrete 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)voidcancel()voidfinish()Indicate the task is done.java.lang.StringgetId()java.lang.StringgetMessagePrefix()booleanisCancelled()Return whether this operation was cancelled by user.voidprogress(int workunit)Notify the user about completed work units.voidremovePropertyChangeListener(java.beans.PropertyChangeListener listener)voidsetMessagePrefix(java.lang.String prefix)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.
-
-
-
Method Detail
-
setMessagePrefix
public void setMessagePrefix(java.lang.String prefix)
-
getMessagePrefix
public java.lang.String getMessagePrefix()
-
isCancelled
public boolean isCancelled()
Description copied from interface:DFFeedbackReturn whether this operation was cancelled by user. Operations should periodically check this flag and if it returnstrue, operation should stop as soon as possible.- Specified by:
isCancelledin interfaceDFFeedback- Returns:
- was this operation cancelled by user?
-
cancel
public void cancel()
-
getId
public java.lang.String getId()
- Specified by:
getIdin interfaceDFFeedback- Returns:
- An unique ID suitable for identification the feedback instance
-
addMessage
public void addMessage(DFFeedback.Type type, java.lang.Object message, java.lang.Throwable t)
Description copied from interface:DFFeedbackAdds 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.
- Specified by:
addMessagein interfaceDFFeedback
-
switchToIndeterminate
public void switchToIndeterminate()
Description copied from interface:DFFeedbackCurrently determinate task (with percentage or time estimate) can be switched to indeterminate mode.- Specified by:
switchToIndeterminatein interfaceDFFeedback
-
switchToDeterminate
public void switchToDeterminate(int workunits)
Description copied from interface:DFFeedbackCurrently 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- Specified by:
switchToDeterminatein interfaceDFFeedback
-
progress
public void progress(int workunit)
Description copied from interface:DFFeedbackNotify the user about completed work units.- Specified by:
progressin interfaceDFFeedback- Parameters:
workunit- A cumulative number of work units completed so far
-
finish
public void finish()
Description copied from interface:DFFeedbackIndicate the task is done.- Specified by:
finishin interfaceDFFeedback
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
- Specified by:
addPropertyChangeListenerin interfaceDFFeedback- Parameters:
listener- adds listener to be used for notifications about ie. user initiated cancel
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
- Specified by:
removePropertyChangeListenerin interfaceDFFeedback- Parameters:
listener- remove registered propertyChangeListener
-
-