com.im.commons 6.0

com.im.commons.progress
Interface DFFeedback

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 the DFFeedback to report information to the user.

There are two simple default implementations:


Nested Class Summary
static class DFFeedback.Type
          Types of messages to be used in DFFeedback.
 
Field Summary
static DFFeedback DEV_NULL
          "Empty device" - all feedback is ignored.
static String PROPERTY_CANCEL
          Used by PropertyChangeListener for notifying about user-initiated cancel.
 
Method Summary
 void addMessage(DFFeedback.Type type, Object message, Throwable t)
          Adds a message to the feedback.
 void addPropertyChangeListener(PropertyChangeListener listener)
           
 void finish()
          Indicate the task is done.
 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(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 String PROPERTY_CANCEL
Used by PropertyChangeListener 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 use ConsoleFeedback.

Method Detail

isCancelled

boolean isCancelled()
Return whether this operation was cancelled by user. Operations should periodically check this flag and if it returns true, operation should stop as soon as possible.

Returns:
was this operation cancelled by user?

getId

String getId()
Returns:
An unique ID suitable for identification the feedback instance

addMessage

void addMessage(DFFeedback.Type type,
                Object message,
                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

Parameters:
type -
message -
t -

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(PropertyChangeListener listener)
Parameters:
listener - adds listener to be used for notifications about ie. user initiated cancel

removePropertyChangeListener

void removePropertyChangeListener(PropertyChangeListener listener)
Parameters:
listener - remove registered propertyChangeListener

com.im.commons 6.0