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 ofDFFeedback
which 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 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
cancel()
void
finish()
Indicate the task is done.java.lang.String
getId()
java.lang.String
getMessagePrefix()
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
setMessagePrefix(java.lang.String prefix)
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.
-
-
-
Method Detail
-
setMessagePrefix
public void setMessagePrefix(java.lang.String prefix)
-
getMessagePrefix
public java.lang.String getMessagePrefix()
-
isCancelled
public boolean isCancelled()
Description copied from interface:DFFeedback
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.- Specified by:
isCancelled
in interfaceDFFeedback
- Returns:
- was this operation cancelled by user?
-
cancel
public void cancel()
-
getId
public java.lang.String getId()
- Specified by:
getId
in 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:DFFeedback
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.
- Specified by:
addMessage
in interfaceDFFeedback
-
switchToIndeterminate
public void switchToIndeterminate()
Description copied from interface:DFFeedback
Currently determinate task (with percentage or time estimate) can be switched to indeterminate mode.- Specified by:
switchToIndeterminate
in interfaceDFFeedback
-
switchToDeterminate
public void switchToDeterminate(int workunits)
Description copied from interface:DFFeedback
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- Specified by:
switchToDeterminate
in interfaceDFFeedback
-
progress
public void progress(int workunit)
Description copied from interface:DFFeedback
Notify the user about completed work units.- Specified by:
progress
in interfaceDFFeedback
- Parameters:
workunit
- A cumulative number of work units completed so far
-
finish
public void finish()
Description copied from interface:DFFeedback
Indicate the task is done.- Specified by:
finish
in interfaceDFFeedback
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
- Specified by:
addPropertyChangeListener
in 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:
removePropertyChangeListener
in interfaceDFFeedback
- Parameters:
listener
- remove registered propertyChangeListener
-
-