Class ConsoleFeedback

  • All Implemented Interfaces:
    DFFeedback

    public class ConsoleFeedback
    extends java.lang.Object
    implements DFFeedback
    Implementation of DFFeedback which prints all messages to console or provided stream.
    Author:
    Petr Hamernik
    • Constructor Detail

      • ConsoleFeedback

        public ConsoleFeedback()
      • ConsoleFeedback

        public ConsoleFeedback​(java.io.PrintStream output)
    • 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 returns true, operation should stop as soon as possible.
        Specified by:
        isCancelled in interface DFFeedback
        Returns:
        was this operation cancelled by user?
      • cancel

        public void cancel()
      • getId

        public java.lang.String getId()
        Specified by:
        getId in interface DFFeedback
        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 interface DFFeedback
      • 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 interface DFFeedback
      • 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 interface DFFeedback
      • progress

        public void progress​(int workunit)
        Description copied from interface: DFFeedback
        Notify the user about completed work units.
        Specified by:
        progress in interface DFFeedback
        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 interface DFFeedback
      • addPropertyChangeListener

        public void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)
        Specified by:
        addPropertyChangeListener in interface DFFeedback
        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 interface DFFeedback
        Parameters:
        listener - remove registered propertyChangeListener