public class DasProgressPanel extends java.lang.Object implements ProgressMonitor
monitor.setTaskSize( 100 ) monitor.started() for i in range(100): if ( i>50 and monitor.isCancelled() ): raise Exception('cancel pressed') print i java.lang.Thread.sleep(100) monitor.setTaskProgress(i) monitor.finished()
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MSG_CANCEL_TASK |
static java.lang.String |
MSG_TASK_CANNOT_BE_CANCELED |
static java.lang.String |
PROP_CANCELLED
true if the task is cancelled.
|
static java.lang.String |
PROP_FINISHED |
static java.lang.String |
PROP_STARTED |
SIZE_INDETERMINATE
Modifier | Constructor and Description |
---|---|
protected |
DasProgressPanel(java.lang.String label) |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener) |
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener) |
boolean |
canBeCancelled()
return true if the process appears to support cancel.
|
void |
cancel()
Notifies the
ProgressMonitor that the task
being monitored should be canceled. |
static DasProgressPanel |
createComponent(java.lang.String label)
return a progress panel which can be embedded within a GUI.
|
static DasProgressPanel |
createComponentPanel(DasCanvasComponent component,
java.lang.String initialMessage)
return a new progress panel with component indicating status for the component.
|
static DasProgressPanel |
createComponentPanel(DasCanvas canvas,
java.lang.String initialMessage)
return a new progress panel with component indicating status for the canvas.
|
static DasProgressPanel |
createFramed(java.lang.String label)
this may be called from off the event thread, but it does assume that the
event thread is free.
|
static DasProgressPanel |
createFramed(java.awt.Window parent,
java.lang.String label)
creates a dialog object that follows a parent
|
void |
finished()
Notifies the
ProgressMonitor that the task
being monitored has finished. |
java.awt.Component |
getComponent()
returns the JPanel component.
|
java.lang.Exception |
getConsumer() |
java.lang.String |
getLabel()
Return the label string displayed, which is a concise string that
describes the task being performed.
|
java.lang.Exception |
getSource() |
ProgressMonitor |
getSubtaskMonitor(int start,
int end,
java.lang.String label)
return a monitor to use for a subtask.
|
ProgressMonitor |
getSubtaskMonitor(java.lang.String label)
get the subtask monitor when the current task length is indeterminate.
|
long |
getTaskProgress()
Returns the current progress of the monitored task.
|
long |
getTaskSize()
Return the size of the task.
|
boolean |
isCancelled()
Returns
true if the operation being tracked
should be cancelled. |
boolean |
isFinished()
true if the process has indicated that it is finished
|
boolean |
isStarted()
true if the process has indicated that it has started.
|
boolean |
isValidateRoot()
Returning true here keeps the progress bar from forcing the whole canvas
to repaint when the label of the progress bar changes.
|
boolean |
isVisible() |
static void |
maybeCenter(ProgressMonitor mon,
java.awt.Component window)
provide convenient code which will center DasProgressMonitors on window.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener) |
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener) |
void |
setAdditionalInfo(java.lang.String s)
Deprecated.
|
void |
setContextComponent(java.awt.Component window)
set the component where this progress monitor is understood.
|
void |
setLabel(java.lang.String label)
Set a concise string that describes the task being performed.
|
void |
setProgressMessage(java.lang.String message)
Provides additional feedback as to what's going on in the process.
|
void |
setShowProgressRate(boolean showProgressRate)
Setter for property showProgressRate.
|
void |
setTaskProgress(long position)
Notifies the ProgressMonitor of a change in the progress
of the task.
|
void |
setTaskSize(long taskSize)
Sets the maximum value for the task progress of this
ProgressMonitor . |
void |
setVisible(boolean visible)
make the progressPanel visible or hide it.
|
void |
started()
Notifies the
ProgressMonitor that the task
being monitored has started. |
java.lang.String |
toString() |
public static final java.lang.String MSG_CANCEL_TASK
public static final java.lang.String MSG_TASK_CANNOT_BE_CANCELED
public static final java.lang.String PROP_STARTED
public static final java.lang.String PROP_FINISHED
public static final java.lang.String PROP_CANCELLED
public ProgressMonitor getSubtaskMonitor(int start, int end, java.lang.String label)
ProgressMonitor
getSubtaskMonitor
in interface ProgressMonitor
start
- start position on this monitor.end
- end position on this monitor (exclusive).label
- a label for the subtask, often this is handled as progress message; or null.public ProgressMonitor getSubtaskMonitor(java.lang.String label)
ProgressMonitor
getSubtaskMonitor
in interface ProgressMonitor
label
- a label for the subtask, often this is handled as progress message; or null.public java.awt.Component getComponent()
public void setContextComponent(java.awt.Component window)
window
- public static void maybeCenter(ProgressMonitor mon, java.awt.Component window)
mon
- the monitor, which may be a DasProgressPanel.window
- the component about which to center the monitor.public static DasProgressPanel createComponentPanel(DasCanvasComponent component, java.lang.String initialMessage)
component
- the canvas component providing a context for the progress, for example a DasPlot which will load some data.initialMessage
- initial message for the monitorpublic static DasProgressPanel createComponentPanel(DasCanvas canvas, java.lang.String initialMessage)
canvas
- the canvas client providing a context for the task.initialMessage
- initial message for the monitorpublic boolean isValidateRoot()
public static DasProgressPanel createFramed(java.lang.String label)
label
- label describing the task.public static DasProgressPanel createFramed(java.awt.Window parent, java.lang.String label)
parent
- the Window that owns this popup gui.label
- label describing the task.public static DasProgressPanel createComponent(java.lang.String label)
label
- string label for the label.getComponent()
public void setLabel(java.lang.String label)
ProgressMonitor
setLabel
in interface ProgressMonitor
label
- the label describing the task.public java.lang.String getLabel()
ProgressMonitor
getLabel
in interface ProgressMonitor
public void finished()
ProgressMonitor
ProgressMonitor
that the task
being monitored has finished. This must only be called once, and note that isFinished() must return
the state of this monitor.finished
in interface ProgressMonitor
public void setTaskProgress(long position) throws java.lang.IllegalStateException
ProgressMonitor
setTaskProgress
in interface ProgressMonitor
position
- the current task positionjava.lang.IllegalStateException
public boolean canBeCancelled()
ProgressMonitor
canBeCancelled
in interface ProgressMonitor
@Deprecated public void setAdditionalInfo(java.lang.String s)
ProgressMonitor
setAdditionalInfo
in interface ProgressMonitor
s
- the message, such as (50KB/s)public long getTaskProgress()
ProgressMonitor
getTaskProgress
in interface ProgressMonitor
public long getTaskSize()
ProgressMonitor
getTaskSize
in interface ProgressMonitor
public void setTaskSize(long taskSize)
ProgressMonitor
ProgressMonitor
.setTaskSize
in interface ProgressMonitor
taskSize
- maximum value for the task progress. A taskSize of -1 indicates the taskSize is indeterminate.public void setVisible(boolean visible)
visible
- true if the progressPanel should be visible.public boolean isVisible()
public void started()
ProgressMonitor
ProgressMonitor
that the task
being monitored has started. If the ProgressMonitor
is in a cancelled state when this method is called, that
ProgressMonitor
should be 'uncancelled'.started
in interface ProgressMonitor
public void cancel()
ProgressMonitor
ProgressMonitor
that the task
being monitored should be canceled. After this method is
called, implementations should return true
on
any subsequent calls to ProgressMonitor.isCancelled()
and should
throw an IllegalStateException on any subsequent calls to
ProgressMonitor.setTaskProgress(long)
.cancel
in interface ProgressMonitor
public boolean isCancelled()
ProgressMonitor
true
if the operation being tracked
should be cancelled. For example, the human operator has pressed
the cancel button indicating that the process should be stopped. Note
that if the process is not checking the cancel status, the cancel button
should be disabled.isCancelled
in interface ProgressMonitor
true
if the operation being tracked
should be cancelled.public java.lang.Exception getSource()
public java.lang.Exception getConsumer()
public void setShowProgressRate(boolean showProgressRate)
showProgressRate
- New value of property showProgressRate.public java.lang.String toString()
toString
in class java.lang.Object
public void setProgressMessage(java.lang.String message)
ProgressMonitor
setProgressMessage
in interface ProgressMonitor
message
- the message describing the state of progress.public boolean isStarted()
ProgressMonitor
isStarted
in interface ProgressMonitor
public boolean isFinished()
ProgressMonitor
isFinished
in interface ProgressMonitor
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)