|
Extension SDK | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectoracle.jdeveloper.cm.dt.ProgressRunnable
The ProgressRunnable
class provides a mechanism for performing
connection related operations on another thread. A progress dialog with a
cancel button is presented to the user. If the user elects to cancel the
operation, control is returned. If, after a certain amount of time, the
background thread is still running, it will be stopped. This means that a
certain amount of care should be taken when using ProgressRunnable
;
as stopping a thread is somewhat risky, developer should ensure that
the background thread will not leave any data in an unstable state if stopped.
Also, note that canceling the dialog does not abort the operation; it just returns control to the user. The operation may actually complete if it is within a certain amount of time. As such, developers should also take care to ensure that the operation is something that can be allowed to complete in the background. One example of this is connection to a database; if the user cancels the connection, completing the connection in the background but then ignoring the results should be harmless.
Any exceptions that occur during the operation will be passed back to the calling code so that they can be displayed to the user (for example, errors that occur when a connection attempt fails).
To use ProgressRunnable
, developers need to create a concrete
subclass. In this subclass, the doWork
method must be implemented. This
method will be called on the background thread to perform the work. Additionally,
the finish
can be overridden in order to perform any post-work
operations back on the original thread.
Constructor Summary | |
ProgressRunnable()
Creates a new ProgressRunnable instance. |
Method Summary | |
protected abstract java.lang.Object |
doWork()
The actually operation that should be performed by this ProgressRunnable. |
protected void |
finish(java.lang.Object result)
Called back on the original thread after the operation has completed or was canceled. |
java.lang.String |
getMessage()
Retrieves the message that will be displayed in the progress dialog while the operation is proceeding. |
java.lang.String |
getTitle()
Retrieves the title that will be used by the progress dialog. |
boolean |
isCancelable()
|
void |
run()
|
void |
setCancelable(boolean canCancel)
|
void |
setMessage(java.lang.String msg)
Sets the message that will be displayed in the progress dialog while the operation is proceeding. |
void |
setTitle(java.lang.String title)
Sets the title that will be used by the progress dialog. |
void |
start(boolean useThread)
Starts the operation. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ProgressRunnable()
Method Detail |
public final void setTitle(java.lang.String title)
public final java.lang.String getTitle()
public final void setMessage(java.lang.String msg)
public final java.lang.String getMessage()
public final void setCancelable(boolean canCancel)
public final boolean isCancelable()
public final void start(boolean useThread) throws CMException
useThread
- whether the work should be done on a different thread
or not.
CMException
- thrown if an error occurs during operationpublic final void run()
run
in interface java.lang.Runnable
protected abstract java.lang.Object doWork() throws CMException
finish
method.
CMException
- if any exception occurs during operation.protected void finish(java.lang.Object result)
result
- the result of the operation, or null
if the
operation was cancelled.
|
Extension SDK | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright ©1997, 2003, Oracle. All rights reserved.