|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.spi.wizard.DeferredWizardResult
public abstract class DeferredWizardResult extends java.lang.Object
Object which can be returned from
WizardPage.WizardResultProducer.finish()
or WizardPanelProvider.finish()
. A DeferredWizardResult does
not immediately calculate its result; it is used for cases where some
time consuming work needs to be performed to compute the result (such as
creating files on disk), and a progress bar should be shown until the work
is completed.
ResultProgressHandle
Constructor and Description |
---|
DeferredWizardResult()
Creates a new instance of DeferredWizardResult which cannot be aborted and shows a progress bar. |
DeferredWizardResult(boolean canAbort)
Creates a new instance of DeferredWizardResult which may or may not be able to be aborted. |
DeferredWizardResult(boolean canAbort,
boolean useBusy)
Creates a new instance of DeferredWizardResult which may or may not be able to be aborted, and which may simply disable the wizard's UI instead of showing a progress bar while the background work runs. |
Modifier and Type | Method and Description |
---|---|
void |
abort()
Abort computation of the result. |
boolean |
canAbort()
If true, the background thread can be aborted. |
boolean |
isUseBusy()
Determine if the UI should be completely disabled while the background work is running (i.e. |
abstract void |
start(java.util.Map settings,
ResultProgressHandle progress)
Begin computing the result. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DeferredWizardResult()
public DeferredWizardResult(boolean canAbort)
canAbort
- determine if background computation can be aborted by
calling the abort()
methodpublic DeferredWizardResult(boolean canAbort, boolean useBusy)
canAbort
- useBusy
- Method Detail |
---|
public abstract void start(java.util.Map settings, ResultProgressHandle progress)
settings
- The settings gathered over the course of the wizardprogress
- A handle which can be used to affect the progress bar.public final boolean canAbort()
public void abort()
start() has been called, and before
finished()
has been called on the ResultProgressHandle
that is passed to start()
, for example, if the user clicks
the close button on the dialog showing the wizard while the result is
being computed.
This method does nothing by default - it is left empty so
that people who do not want to support aborting background work do not
have to override it. It is up to the implementor
to set a flag or otherwise notify the background thread to halt
computation. A simple method for doing so is as follows:
volatile Thread thread;
public void start (Map settings, ResultProgressHandle handle) {
try {
synchronized (this) {
thread = Thread.currentThread();
}
//do the background computation, update progress. Every so often,
//check Thread.interrupted() and exit if true
} finally {
synchronized (this) {
thread = null;
}
}
}
public synchronized void abort() {
if (thread != null) thread.interrupt();
}
or you can use a volatile boolean
flag that you set in
abort()
and periodically check in the body of start()
.
public final boolean isUseBusy()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |