org.openstreetmap.josm.gui
Class PleaseWaitRunnable

java.lang.Object
  extended by org.openstreetmap.josm.gui.PleaseWaitRunnable
All Implemented Interfaces:
java.lang.Runnable, ProgressMonitor.CancelListener
Direct Known Subclasses:
AbstractUploadTask, ApiUrlTestTask, ChangesetContentDownloadTask, ChangesetHeaderDownloadTask, ChangesetQueryTask, ChildRelationBrowser.DownloadAllChildrenTask, ChildRelationBrowser.DownloadRelationSetTask, CloseChangesetAction.DownloadOpenChangesetsTask, CloseChangesetTask, ContributorTermsUpdateRunnable, DownloadFileTask, DownloadGpsTask.DownloadTask, DownloadOpenChangesetsTask, DownloadOsmTask.DownloadTask, DownloadPrimitivesTask, DownloadReferrersTask, DownloadRelationMemberTask, DownloadRelationTask, FullyAutomaticAuthorizationUI.FullyAutomaticAuthorisationTask, GeoImageLayer.Loader, HistoryLoadTask, MapPaintDialog.SaveAsAction.SaveToFileTask, MapPaintStyles.MapPaintStyleLoader, OpenFileAction.OpenFileTask, ParentRelationLoadingTask, PlaceSelection.NameQueryTask, PluginDownloadTask, ReadLocalPluginInformationTask, ReadRemotePluginInformationTask, RelationTree.RelationLoader, RetrieveAccessTokenTask, RetrieveRequestTokenTask, SessionLoadAction.Loader, SourceEditor.SourceLoader, TestAccessTokenTask, UpdatePrimitivesTask, UploadSelectionAction.DeletedParentsChecker, ValidateAction.ValidationTask, ValidatorDialog.FixTask

public abstract class PleaseWaitRunnable
extends java.lang.Object
implements java.lang.Runnable, ProgressMonitor.CancelListener

Instanced of this thread will display a "Please Wait" message in middle of JOSM to indicate a progress being executed.


Field Summary
private  boolean canceled
           
private  boolean ignoreException
           
protected  ProgressMonitor progressMonitor
           
private  java.lang.String title
           
 
Constructor Summary
PleaseWaitRunnable(java.awt.Component parent, java.lang.String title, boolean ignoreException)
          Create the runnable object with a given message for the user
PleaseWaitRunnable(java.lang.String title)
          Create the runnable object with a given message for the user.
PleaseWaitRunnable(java.lang.String title, boolean ignoreException)
          Create the runnable object with a given message for the user.
PleaseWaitRunnable(java.lang.String title, ProgressMonitor progressMonitor, boolean ignoreException)
           
 
Method Summary
protected  void afterFinish()
          Can be overriden if something needs to run after progress monitor is closed.
protected abstract  void cancel()
          User pressed cancel button.
 ProgressTaskId canRunInBackground()
          Task can run in background if returned value <> null.
private  void doRealRun()
           
protected abstract  void finish()
          Finish up the data work.
 ProgressMonitor getProgressMonitor()
           
 void operationCanceled()
           
protected abstract  void realRun()
          Called in the worker thread to do the actual work.
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

canceled

private boolean canceled

ignoreException

private boolean ignoreException

title

private final java.lang.String title

progressMonitor

protected final ProgressMonitor progressMonitor
Constructor Detail

PleaseWaitRunnable

public PleaseWaitRunnable(java.lang.String title)
Create the runnable object with a given message for the user.


PleaseWaitRunnable

public PleaseWaitRunnable(java.lang.String title,
                          boolean ignoreException)
Create the runnable object with a given message for the user.

Parameters:
title - message for the user
ignoreException - If true, exception will be propagated to calling code. If false then exception will be thrown directly in EDT. When this runnable is executed using executor framework then use false unless you read result of task (because exception will get lost if you don't)

PleaseWaitRunnable

public PleaseWaitRunnable(java.awt.Component parent,
                          java.lang.String title,
                          boolean ignoreException)
                   throws java.lang.IllegalArgumentException
Create the runnable object with a given message for the user

Parameters:
parent - the parent component for the please wait dialog. Must not be null.
title - message for the user
ignoreException - If true, exception will be propagated to calling code. If false then exception will be thrown directly in EDT. When this runnable is executed using executor framework then use false unless you read result of task (because exception will get lost if you don't)
Throws:
java.lang.IllegalArgumentException - thrown if parent is null

PleaseWaitRunnable

public PleaseWaitRunnable(java.lang.String title,
                          ProgressMonitor progressMonitor,
                          boolean ignoreException)
Method Detail

doRealRun

private void doRealRun()

afterFinish

protected void afterFinish()
Can be overriden if something needs to run after progress monitor is closed.


run

public final void run()
Specified by:
run in interface java.lang.Runnable

operationCanceled

public void operationCanceled()
Specified by:
operationCanceled in interface ProgressMonitor.CancelListener

cancel

protected abstract void cancel()
User pressed cancel button.


realRun

protected abstract void realRun()
                         throws org.xml.sax.SAXException,
                                java.io.IOException,
                                OsmTransferException
Called in the worker thread to do the actual work. When any of the exception is thrown, a message box will be displayed and closeDialog is called. finish() is called in any case.

Throws:
org.xml.sax.SAXException
java.io.IOException
OsmTransferException

finish

protected abstract void finish()
Finish up the data work. Is guaranteed to be called if realRun is called. Finish is called in the gui thread just after the dialog disappeared.


getProgressMonitor

public ProgressMonitor getProgressMonitor()

canRunInBackground

public ProgressTaskId canRunInBackground()
Task can run in background if returned value <> null. Note that it's tasks responsibility to ensure proper synchronization, PleaseWaitRunnable doesn't with it.

Returns:
If returned value is <> null then task can run in background. TaskId could be used in future for "Always run in background" checkbox


JOSM