|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.SwingWorker<T,V>
com.ehsbe.commons.gui.util.StatusTask<T,V>
T - the result type returned by this StatusTask's
doInBackground and get methodsV - the type used for carrying out intermediate results by this
StatusTask's publish and process methodspublic abstract class StatusTask<T,V>
An message property enhanced SwingWorker, which lets one easily notify property change listeners from "message" events. Usually used to inform a statusbar about the message, which should be displayed.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.SwingWorker |
|---|
SwingWorker.StateValue |
| Field Summary | |
|---|---|
static String |
MSG_PROPNAME
the property name to use for notifying the statusbar about changes wrt. |
static String |
PROGRESS_PROPNAME
the property name to use for notifying the statusbar about changes wrt. |
| Constructor Summary | |
|---|---|
StatusTask()
|
|
| Method Summary | |
|---|---|
protected T |
doInBackground()
Computes a result by calling doInBackgroundSafe(). |
protected T |
doInBackgroundSafe()
Computes a result, or throws an exception if unable to do so. |
Throwable |
getException()
Get the last throwable, which has been caught when executing doInBackgroundSafe() or getSafe() or
getSafe(long, TimeUnit). |
String |
getMessage()
Get the current message to be displayed in the statusbar. |
String |
getName()
Get the name of this task. |
boolean |
getPaintProgressString()
Check, whether the progress bar string should be painted for this task. |
String |
getProgressString()
Gets the value of the progress bar string. |
T |
getSafe()
Calls SwingWorker.get() but catches any throwable. |
T |
getSafe(long timeout,
TimeUnit unit)
Calls SwingWorker.get(long, TimeUnit) but catches any throwable. |
protected void |
setMessage(String message)
Set the message, which should be displayed on the statusbar and notifies the statusbar by sending a property change "message", |
void |
setName(String name)
Set the name of this task |
protected void |
setPaintProgressString(boolean enable)
Set, whether the progress bar string should be painted for this task. |
protected void |
setProgress(int value,
String sval)
A slightly more efficient version of the call sequence setProgressString(String); SwingWorker.setProgress(int). |
protected void |
setProgressString(String value)
Sets the value of the progress bar string. |
| Methods inherited from class javax.swing.SwingWorker |
|---|
addPropertyChangeListener, cancel, done, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, process, publish, removePropertyChangeListener, run, setProgress |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String MSG_PROPNAME
public static final String PROGRESS_PROPNAME
| Constructor Detail |
|---|
public StatusTask()
| Method Detail |
|---|
protected void setMessage(String message)
message - the message to display. If null it means, clear
the related display.public String getMessage()
nullprotected void setPaintProgressString(boolean enable)
enable - if true paint the progress bar string,
otherwise not.public boolean getPaintProgressString()
true if the progress bar string should be painted.protected void setProgressString(String value)
value - value to show or null to reset to the default.setPaintProgressString(boolean),
JProgressBar.setString(String)public String getProgressString()
null if the default format is used, the string value
otherwise.getPaintProgressString(),
JProgressBar.getString()
protected void setProgress(int value,
String sval)
setProgressString(String); SwingWorker.setProgress(int).
Fires a "progress" property change event with either
String or Integers on success, whereby the later may indicate a change
wrt. to the displayed String value as well.
value - value to show or null to reset to the default.sval - progress bar value to set.public void setName(String name)
name - name to set.public String getName()
protected T doInBackground()
doInBackgroundSafe(). If a
Throwable gets fired during its exection, it gets caught, its
root cause logged a null returned. So this is actually a
convinience method to avoid a lot of boiler plate code.
Note: this method is executed only once in a background thread.
You may overwrite it, if you wanna do your own exception handling or
to postpone the throwing of the caught Throwable, until the
SwingWorker.get() method or one of its derivations gets called (the
default behavior of SwingWorker).
doInBackground in class SwingWorker<T,V>null if a throwable has been caught.doInBackgroundSafe(),
SwingWorker.doInBackground()protected T doInBackgroundSafe()
Per default it gets called by doInBackground(), only.
Overwrite this method instead of doInBackground(), if you want
to get rid of the boiler plate code for Exception handling.
null by defaultdoInBackground()public T getSafe()
SwingWorker.get() but catches any throwable. Thus it is a
convinience method to avoid boiler plate code.
null if a throwable has been caught, the result of the
background comptation otherwise.doInBackground(),
SwingWorker.get()
public T getSafe(long timeout,
TimeUnit unit)
SwingWorker.get(long, TimeUnit) but catches any throwable.
Thus it is a convinience method to avoid boiler plate code.
timeout - the maximum time to waitunit - the time unit of the timeout argument
null if a throwable has been caught, the result of the
background comptation otherwise.doInBackground(),
SwingWorker.get()public Throwable getException()
doInBackgroundSafe() or getSafe() or
getSafe(long, TimeUnit).
null if no throwable has been caugth, the last caught
throwable otherwise.
|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||