Package org.openstreetmap.josm.gui
Class PleaseWaitRunnable
- java.lang.Object
-
- org.openstreetmap.josm.gui.PleaseWaitRunnable
-
- All Implemented Interfaces:
java.lang.Runnable
,ProgressMonitor.CancelListener
- Direct Known Subclasses:
AbstractChangesetDownloadTask.RunnableDownloadTask
,AbstractPrimitiveTask
,AbstractUploadTask
,AddWMSLayerPanel.GetCapabilitiesRunnable
,ApiUrlTestTask
,ChildRelationBrowser.DownloadTask
,CloseChangesetAction.DownloadOpenChangesetsTask
,CloseChangesetTask
,DownloadFileTask
,DownloadFromOverpassTask
,DownloadGpsTask.DownloadTask
,DownloadNotesTask.DownloadTask
,DownloadOpenChangesetsTask
,DownloadOsmTask.AbstractInternalTask
,DownloadPrimitivesWithReferrersTask
,DownloadReferrersTask
,DownloadRelationMemberTask
,DownloadRelationTask
,DownloadWmsAlongTrackAction.PrecacheWmsTask
,FullyAutomaticAuthorizationUI.FullyAutomaticAuthorisationTask
,HistoryLoadTask
,ImageryLayerInfo.DefaultEntryLoader
,ImagesLoader
,MapPaintDialog.SaveAsAction.SaveToFileTask
,MapPaintStyleLoader
,OpenFileAction.OpenFileTask
,PlaceSelection.NameQueryTask
,PluginDownloadTask
,ReadLocalPluginInformationTask
,ReadRemotePluginInformationTask
,RelationTree.RelationLoader
,SearchAction.SearchTask
,SessionLoadAction.Loader
,SourceEditor.SourceLoader
,TestAccessTokenTask
,UploadNotesTask.UploadTask
,UploadSelectionAction.DeletedParentsChecker
,ValidationTask
,ValidatorDialog.FixTask
,WikimediaCommonsLoader
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
Fields Modifier and Type Field Description private boolean
ignoreException
protected ProgressMonitor
progressMonitor
progress monitorprivate java.lang.String
title
-
Constructor Summary
Constructors Modifier Constructor Description protected
PleaseWaitRunnable(java.awt.Component parent, java.lang.String title, boolean ignoreException)
Create the runnable object with a given message for the userprotected
PleaseWaitRunnable(java.lang.String title)
Create the runnable object with a given message for the user.protected
PleaseWaitRunnable(java.lang.String title, boolean ignoreException)
Create the runnable object with a given message for the user.protected
PleaseWaitRunnable(java.lang.String title, ProgressMonitor progressMonitor, boolean ignoreException)
Create the runnable object with a given message for the user
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
afterFinish()
Can be overridden 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()
Relies the progress monitor.void
operationCanceled()
Called when the operation was canceledprotected abstract void
realRun()
Called in the worker thread to do the actual work.void
run()
-
-
-
Field Detail
-
ignoreException
private final boolean ignoreException
-
title
private final java.lang.String title
-
progressMonitor
protected final ProgressMonitor progressMonitor
progress monitor
-
-
Constructor Detail
-
PleaseWaitRunnable
protected PleaseWaitRunnable(java.lang.String title)
Create the runnable object with a given message for the user.- Parameters:
title
- message for the user
-
PleaseWaitRunnable
protected PleaseWaitRunnable(java.lang.String title, boolean ignoreException)
Create the runnable object with a given message for the user.- Parameters:
title
- message for the userignoreException
- If true, exception will be silently ignored. If false then exception will be handled by showing a dialog. 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
protected PleaseWaitRunnable(java.awt.Component parent, java.lang.String title, boolean ignoreException)
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 userignoreException
- If true, exception will be silently ignored. If false then exception will be handled by showing a dialog. 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
- if parent is null
-
PleaseWaitRunnable
protected PleaseWaitRunnable(java.lang.String title, ProgressMonitor progressMonitor, boolean ignoreException)
Create the runnable object with a given message for the user- Parameters:
title
- message for the userprogressMonitor
- progress monitorignoreException
- If true, exception will be silently ignored. If false then exception will be handled by showing a dialog. 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)
-
-
Method Detail
-
doRealRun
private void doRealRun()
-
afterFinish
protected void afterFinish()
Can be overridden if something needs to run after progress monitor is closed.
-
run
public final void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
operationCanceled
public void operationCanceled()
Description copied from interface:ProgressMonitor.CancelListener
Called when the operation was canceled- Specified by:
operationCanceled
in interfaceProgressMonitor.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
- if a SAX error occursjava.io.IOException
- if an I/O error occursOsmTransferException
- if a communication error with the OSM server occurs
-
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()
Relies the progress monitor.- Returns:
- the progress monitor
-
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
-
-