Class Progress

java.lang.Object
com.inet.viewer.Progress
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
ExportProgress, PrinterJobProgress

public abstract class Progress extends Object implements Runnable
Class for all progresses, which should be handled as a Progress of the report viewer. A progress encapsulates a special task with a state (such as idle, running or complete) and a value (23 of 120) of its progress. To start the progress call the startProgress() method and the progress will perform its run method. In this method call setProgress(int), setTotalProgress(int), setStatus(int) to propagate the status of the progress. The progress will be registered at the ProgressPool and will inform its listeners about property changes such as its status, current step and total steps. Depending on the progress type the progress will be displayed at the StatusBar or not.
Since:
7.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The property ProgressIndeterminate for PropertyChangeEvents
    static final String
    The property ProgressStatus for PropertyChangeEvents
    static final String
    The property ProgressStep for PropertyChangeEvents
    static final String
    The property ProgressTotal for PropertyChangeEvents
    protected final PropertyChangeSupport
    FOR INTERNAL USE ONLY
    static final int
    The progress was canceled
    static final int
    The progress was successfully completed
    static final int
    The progress was canceled due to an error
    static final int
    The progress idles
    static final int
    The progress has been created but has not been started yet
    static final int
    The progress has not been created yet
    static final int
    The progress is running
    static final int
    The type is export progress, which means the progress will be shown as export progress in the status bar
    static final int
    The type is invisible, do not show this progress in the status bar *
    static final int
    The type is navigation progress, which means the progress will be shown as navigation progress in the status bar
    static final int
    The type is print progress, which means the progress will be shown as printing progress in the status bar
    static final int
    The type is search progress, which means the progress will be shown as search progress in the status bar
  • Constructor Summary

    Constructors
    Constructor
    Description
    Progress(ReportView reportView, int type)
    Creates a new progress object with the given type and sets it as being "indeterminate" (that is, a "busy"/"not busy" progress) or determinate (that is, with clearly defined steps - step 1 of 5, step 2 of 5, etc.)
    Progress(Component parent, ViewerContext viewerContext, int type)
    Creates a new progress object with the given type and sets it as being "indeterminate" (that is, a "busy"/"not busy" progress) or determinate (that is, with clearly defined steps - step 1 of 5, step 2 of 5, etc.)
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a PropertyChangeListener to this progress.
    abstract void
    Call this method to force a cancel of the progress - which must also set both of the states "finished" and "canceled" to true.
    protected void
    Final clean up of the progress: unregister all property change listeners, etc.
    Returns the last error message of this Progress.
    abstract String
    The name of the daemon thread.
    int
    Use this method to get the current step of this progress .
    Returns the ReportView to which this progress belongs.
    int
    Returns the status of this Progress.
    int
    Use this method to get the total steps (e.g. pages) to go.
    int
    Returns the type of the progress, which can be one of the following types.
    boolean
    Returns whether this progress has been canceled - progresses which can be canceled should overload this method.
    boolean
    Returns whether this progress has been stopped due to an error - progresses which can be stopped due to an error should overload this method.
    boolean
    Return true if the progress has stopped its task.
    boolean
    Returns whether this progress is indeterminate, that is, only a "busy" or "not busy" progress.
    void
    Removes a PropertyChangeListener from this progress.
    void
    Sets an error message for this progress to pass failure information to the viewer.
    void
    setIndeterminate(boolean indeterminate)
    Set the status of the progress to indeterminate or determined.
    void
    setProgress(int step)
    Use this method to set the progress and to inform all registered listeners about the current step.
    void
    setStatus(int status)
    Call this method to set the status of this progress.
    void
    setTotalProgress(int total)
    Use this method to inform all registered listeners about the total steps (e.g. pages) to go.
    void
    Shows an error dialog for this error message.
    final void
    Call this method to start the progress.
    void
    This method will block until the progress has finished it task.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Runnable

    run
  • Field Details

    • TYPE_PAGELOADER

      public static final int TYPE_PAGELOADER
      The type is navigation progress, which means the progress will be shown as navigation progress in the status bar
      Since:
      7.0
      See Also:
    • TYPE_PRINT

      public static final int TYPE_PRINT
      The type is print progress, which means the progress will be shown as printing progress in the status bar
      Since:
      7.0
      See Also:
    • TYPE_EXPORT

      public static final int TYPE_EXPORT
      The type is export progress, which means the progress will be shown as export progress in the status bar
      Since:
      7.0
      See Also:
    • TYPE_INVISIBLE

      public static final int TYPE_INVISIBLE
      The type is invisible, do not show this progress in the status bar *
      Since:
      7.0
      See Also:
    • STATUS_NOT_INITIALIZED

      public static final int STATUS_NOT_INITIALIZED
      The progress has not been created yet
      Since:
      7.0
      See Also:
    • STATUS_INITIALIZED

      public static final int STATUS_INITIALIZED
      The progress has been created but has not been started yet
      Since:
      7.0
      See Also:
    • STATUS_RUNNING

      public static final int STATUS_RUNNING
      The progress is running
      Since:
      7.0
      See Also:
    • STATUS_COMPLETED

      public static final int STATUS_COMPLETED
      The progress was successfully completed
      Since:
      7.0
      See Also:
    • STATUS_CANCELED

      public static final int STATUS_CANCELED
      The progress was canceled
      Since:
      7.0
      See Also:
    • STATUS_ERROR

      public static final int STATUS_ERROR
      The progress was canceled due to an error
      Since:
      7.0
      See Also:
    • STATUS_IDLE

      public static final int STATUS_IDLE
      The progress idles
      Since:
      7.0
      See Also:
    • PROP_PROGRESS_STATUS

      public static final String PROP_PROGRESS_STATUS
      The property ProgressStatus for PropertyChangeEvents
      Since:
      7.0
      See Also:
    • PROP_PROGRESS_TOTAL

      public static final String PROP_PROGRESS_TOTAL
      The property ProgressTotal for PropertyChangeEvents
      Since:
      7.0
      See Also:
    • PROP_PROGRESS_STEP

      public static final String PROP_PROGRESS_STEP
      The property ProgressStep for PropertyChangeEvents
      Since:
      7.0
      See Also:
    • PROP_PROGRESS_INDETERMINATE

      public static final String PROP_PROGRESS_INDETERMINATE
      The property ProgressIndeterminate for PropertyChangeEvents
      Since:
      7.0
      See Also:
    • propertySupporter

      protected final PropertyChangeSupport propertySupporter
      FOR INTERNAL USE ONLY
  • Constructor Details

    • Progress

      public Progress(ReportView reportView, int type)
      Creates a new progress object with the given type and sets it as being "indeterminate" (that is, a "busy"/"not busy" progress) or determinate (that is, with clearly defined steps - step 1 of 5, step 2 of 5, etc.) The Progress will register itself to the viewer ProgressPool, which handles all progresses.
      Parameters:
      reportView - The ReportView of this progress.
      type - E.g. NAVIGATION, PRINT, EXPORT, SEARCH or a custom defined constant.
      Since:
      7.0
    • Progress

      public Progress(Component parent, ViewerContext viewerContext, int type)
      Creates a new progress object with the given type and sets it as being "indeterminate" (that is, a "busy"/"not busy" progress) or determinate (that is, with clearly defined steps - step 1 of 5, step 2 of 5, etc.) This Progress will NOT registered to the viewer ProgressPool. It is useful for export without report preview.
      Parameters:
      parent - Component, used for showError
      viewerContext - ViewerContext, used for showError
      type - E.g. NAVIGATION, PRINT, EXPORT, SEARCH or a custom defined constant.
      Since:
      7.6
  • Method Details

    • startProgress

      public final void startProgress()
      Call this method to start the progress. The progress will register itself at the ProgressPool of the Viewer.
      Throws:
      ViewerException - when progress is already running
      Since:
      7.0
    • getName

      public abstract String getName()
      The name of the daemon thread.
      Returns:
      the name of the daemon thread.
      Since:
      7.0
    • cancel

      public abstract void cancel()
      Call this method to force a cancel of the progress - which must also set both of the states "finished" and "canceled" to true. Please note: some progresses may not be stoppable.
      Since:
      7.0
    • getType

      public int getType()
      Returns the type of the progress, which can be one of the following types.
      Returns:
      Type of the progress
      Since:
      7.0
      See Also:
    • waitUntilFinished

      public void waitUntilFinished()
      This method will block until the progress has finished it task.
      Since:
      7.0
    • isIndeterminate

      public boolean isIndeterminate()
      Returns whether this progress is indeterminate, that is, only a "busy" or "not busy" progress. If not, this progress has specific steps and can be determined how far it is finished.
      Returns:
      Whether this progress is indeterminate, that is, only a "busy" or "not busy" progress.
      Since:
      7.0
    • setIndeterminate

      public void setIndeterminate(boolean indeterminate)
      Set the status of the progress to indeterminate or determined.
      Parameters:
      indeterminate - True if the progress should be indeterminate.
      Since:
      7.0
    • setStatus

      public void setStatus(int status)
      Call this method to set the status of this progress. The status could be STATUS_INITIALIZED, STATUS_RUNNING, STATUS_IDLE, STATUS_CANCELED, STATUS_COMPLETED, STATUS_ERROR. If the status is STATUS_ERROR used setErrorMessage(String), showError(Throwable) to give a reason for this error. All registered listeners will be informed about this change.
      Parameters:
      status - Status of this progress
      Since:
      7.0
    • isFinished

      public boolean isFinished()
      Return true if the progress has stopped its task. The status of the Progress can be complete, canceled or error.
      Returns:
      whether the progress has stopped
      Since:
      7.0
    • isCanceled

      public boolean isCanceled()
      Returns whether this progress has been canceled - progresses which can be canceled should overload this method.
      Returns:
      Whether this progress has been canceled
      Since:
      7.0
    • isErrored

      public boolean isErrored()
      Returns whether this progress has been stopped due to an error - progresses which can be stopped due to an error should overload this method.
      Returns:
      Whether this progress has been stopped due to an error
      Since:
      7.0
    • setTotalProgress

      public void setTotalProgress(int total)
      Use this method to inform all registered listeners about the total steps (e.g. pages) to go. If total is set to zero the progress will be declared as inactive (status = Progress.STATUS_IDLE).
      Parameters:
      total - steps to go
      Since:
      7.0
    • getTotalProgress

      public int getTotalProgress()
      Use this method to get the total steps (e.g. pages) to go.
      Returns:
      steps to go
      Since:
      7.0
    • setProgress

      public void setProgress(int step)
      Use this method to set the progress and to inform all registered listeners about the current step.
      Parameters:
      step - Steps made in the progress so far (1-based)
      Since:
      7.0
    • getProgress

      public int getProgress()
      Use this method to get the current step of this progress .
      Returns:
      current step of the progress
      Since:
      7.0
    • getReportView

      public ReportView getReportView()
      Returns the ReportView to which this progress belongs.
      Returns:
      The ReportView of this progress.
      Since:
      7.0
    • getStatus

      public int getStatus()
      Returns the status of this Progress. The could be STATUS_INITIALIZED, STATUS_RUNNING, STATUS_IDLE, STATUS_CANCELED, STATUS_COMPLETED, STATUS_ERROR
      Returns:
      Return the status of this Progress
      Since:
      7.0
    • getErrorMessage

      public String getErrorMessage()
      Returns the last error message of this Progress.
      Returns:
      The last error of this Progress.
      Since:
      7.0
    • setErrorMessage

      public void setErrorMessage(String msg)
      Sets an error message for this progress to pass failure information to the viewer.
      Parameters:
      msg - error message
      Since:
      7.0
    • showError

      public void showError(Throwable th)
      Shows an error dialog for this error message. If there is no ReportView it will print a stacktrace to the console. It is calling setErrorMessage(String) and setStatus(STATUS_ERROR) before the error message is show.
      Parameters:
      th - The exception to show in the error dialog.
      Since:
      7.0
      See Also:
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener l)
      Adds a PropertyChangeListener to this progress. All registered listeners will be informed if the status of the progress changes.
      Parameters:
      l - PropertyChangeListener
      Since:
      7.0
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener l)
      Removes a PropertyChangeListener from this progress.
      Parameters:
      l - PropertyChangeListener
      Since:
      7.0
    • cleanUp

      protected void cleanUp()
      Final clean up of the progress: unregister all property change listeners, etc.
      Since:
      8.0