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 Details

  • Constructor Details

    • PleaseWaitRunnable

      protected PleaseWaitRunnable(String title)
      Create the runnable object with a given message for the user.
      Parameters:
      title - message for the user
    • PleaseWaitRunnable

      protected PleaseWaitRunnable(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 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(Component parent, 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 user
      ignoreException - 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 user
      progressMonitor - progress monitor
      ignoreException - 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

      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 interface Runnable
    • operationCanceled

      public void operationCanceled()
      Description copied from interface: ProgressMonitor.CancelListener
      Called when the operation was canceled
      Specified by:
      operationCanceled in interface ProgressMonitor.CancelListener
    • cancel

      protected abstract void cancel()
      User pressed cancel button.
    • realRun

      protected abstract void realRun() throws SAXException, 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:
      SAXException - if a SAX error occurs
      IOException - if an I/O error occurs
      OsmTransferException - 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

      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