public abstract class Progress
extends java.lang.Object
implements java.lang.Runnable
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.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PROP_PROGRESS_INDETERMINATE
The property ProgressIndeterminate for PropertyChangeEvents
|
static java.lang.String |
PROP_PROGRESS_STATUS
The property ProgressStatus for PropertyChangeEvents
|
static java.lang.String |
PROP_PROGRESS_STEP
The property ProgressStep for PropertyChangeEvents
|
static java.lang.String |
PROP_PROGRESS_TOTAL
The property ProgressTotal for PropertyChangeEvents
|
static int |
STATUS_CANCELED
The progress was canceled
|
static int |
STATUS_COMPLETED
The progress was successfully completed
|
static int |
STATUS_ERROR
The progress was canceled due to an error
|
static int |
STATUS_IDLE
The progress idles
|
static int |
STATUS_INITIALIZED
The progress has been created but has not been started yet
|
static int |
STATUS_NOT_INITIALIZED
The progress has not been created yet
|
static int |
STATUS_RUNNING
The progress is running
|
static int |
TYPE_EXPORT
The type is export progress, which means the progress will be shown as export progress in
the status bar
|
static int |
TYPE_INVISIBLE
The type is invisible, do not show this progress in the status bar *
|
static int |
TYPE_PAGELOADER
The type is navigation progress, which means the progress will be shown as navigation progress in
the status bar
|
static int |
TYPE_PRINT
The type is print progress, which means the progress will be shown as printing progress in
the status bar
|
static int |
TYPE_SEARCH
The type is search progress, which means the progress will be shown as search progress in
the status bar
|
Constructor and 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(java.awt.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.)
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a PropertyChangeListener to this progress.
|
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.
|
protected void |
cleanUp()
Final clean up of the progress: unregister all property change listeners, etc.
|
java.lang.String |
getErrorMessage()
Returns the last error message of this Progress.
|
abstract java.lang.String |
getName()
The name of the daemon thread.
|
int |
getProgress()
Use this method to get the current step of this progress .
|
ReportView |
getReportView()
Returns the ReportView to which this progress belongs.
|
int |
getStatus()
Returns the status of this Progress.
|
int |
getTotalProgress()
Use this method to get the total steps (e.g. pages)
to go.
|
int |
getType()
Returns the type of the progress, which can be one of the following types.
|
boolean |
isCanceled()
Returns whether this progress has been canceled
- progresses which can be canceled should overload
this method.
|
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.
|
boolean |
isFinished()
Return true if the progress has stopped its task.
|
boolean |
isIndeterminate()
Returns whether this progress is indeterminate, that is, only a "busy" or "not busy" progress.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a PropertyChangeListener from this progress.
|
void |
setErrorMessage(java.lang.String msg)
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 |
showError(java.lang.Throwable th)
Shows an error dialog for this error message.
|
void |
startProgress()
Call this method to start the progress.
|
void |
waitUntilFinished()
This method will block until the progress has finished
it task.
|
public static final int TYPE_PAGELOADER
public static final int TYPE_PRINT
public static final int TYPE_EXPORT
public static final int TYPE_SEARCH
public static final int TYPE_INVISIBLE
public static final int STATUS_NOT_INITIALIZED
public static final int STATUS_INITIALIZED
public static final int STATUS_RUNNING
public static final int STATUS_COMPLETED
public static final int STATUS_CANCELED
public static final int STATUS_ERROR
public static final int STATUS_IDLE
public static final java.lang.String PROP_PROGRESS_STATUS
public static final java.lang.String PROP_PROGRESS_TOTAL
public static final java.lang.String PROP_PROGRESS_STEP
public static final java.lang.String PROP_PROGRESS_INDETERMINATE
public Progress(ReportView reportView, int type)
reportView
- The ReportView of this progress.type
- E.g. NAVIGATION, PRINT, EXPORT, SEARCH or a custom defined constant.public Progress(java.awt.Component parent, ViewerContext viewerContext, int type)
parent
- Component, used for showErrorviewerContext
- ViewerContext, used for showErrortype
- E.g. NAVIGATION, PRINT, EXPORT, SEARCH or a custom defined constant.public final void startProgress()
ViewerException
- when progress is already runningpublic abstract java.lang.String getName()
public abstract void cancel()
public int getType()
TYPE_EXPORT
,
TYPE_PAGELOADER
,
TYPE_PRINT
,
TYPE_SEARCH
,
TYPE_INVISIBLE
public void waitUntilFinished()
public boolean isIndeterminate()
public void setIndeterminate(boolean indeterminate)
indeterminate
- True if the progress should be indeterminate.public void setStatus(int status)
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.status
- Status of this progresspublic boolean isFinished()
public boolean isCanceled()
public boolean isErrored()
public void setTotalProgress(int total)
total
- steps to gopublic int getTotalProgress()
public void setProgress(int step)
step
- Steps made in the progress so far (1-based)public int getProgress()
public ReportView getReportView()
public int getStatus()
STATUS_INITIALIZED
, STATUS_RUNNING
, STATUS_IDLE
, STATUS_CANCELED
, STATUS_COMPLETED
, STATUS_ERROR
public java.lang.String getErrorMessage()
public void setErrorMessage(java.lang.String msg)
msg
- error messagepublic void showError(java.lang.Throwable th)
th
- The exception to show in the error dialog.setErrorMessage(String)
,
setStatus(int)
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
l
- PropertyChangeListenerpublic void removePropertyChangeListener(java.beans.PropertyChangeListener l)
l
- PropertyChangeListenerprotected void cleanUp()
Copyright © 1999-2020 by i-net software GmbH