Package org.openstreetmap.josm.gui
Class PleaseWaitRunnable
java.lang.Object
org.openstreetmap.josm.gui.PleaseWaitRunnable
- All Implemented Interfaces:
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 Object
implements 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
FieldsModifier and TypeFieldDescriptionprivate final booleanprotected final ProgressMonitorprogress monitorprivate final String -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPleaseWaitRunnable(Component parent, String title, boolean ignoreException) Create the runnable object with a given message for the userprotectedPleaseWaitRunnable(String title) Create the runnable object with a given message for the user.protectedPleaseWaitRunnable(String title, boolean ignoreException) Create the runnable object with a given message for the user.protectedPleaseWaitRunnable(String title, ProgressMonitor progressMonitor, boolean ignoreException) Create the runnable object with a given message for the user -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCan be overridden if something needs to run after progress monitor is closed.protected abstract voidcancel()User pressed cancel button.Task can run in background if returned value != null.private voidprotected abstract voidfinish()Finish up the data work.Relies the progress monitor.voidCalled when the operation was canceledprotected abstract voidrealRun()Called in the worker thread to do the actual work.final voidrun()
-
Field Details
-
ignoreException
-
title
-
progressMonitor
progress monitor
-
-
Constructor Details
-
PleaseWaitRunnable
Create the runnable object with a given message for the user.- Parameters:
title- message for the user
-
PleaseWaitRunnable
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
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:
IllegalArgumentException- if parent is null
-
PleaseWaitRunnable
protected PleaseWaitRunnable(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 Details
-
doRealRun
-
afterFinish
Can be overridden if something needs to run after progress monitor is closed. -
run
-
operationCanceled
Description copied from interface:ProgressMonitor.CancelListenerCalled when the operation was canceled- Specified by:
operationCanceledin interfaceProgressMonitor.CancelListener
-
cancel
User pressed cancel button. -
realRun
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:
SAXException- if a SAX error occursIOException- if an I/O error occursOsmTransferException- if a communication error with the OSM server occurs
-
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
Relies the progress monitor.- Returns:
- the progress monitor
-
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
-