Class RemoteServiceWorker<T>

java.lang.Object
javax.swing.SwingWorker<T,Void>
cz.fidentis.analyst.gui.elements.RemoteServiceWorker<T>
Type Parameters:
T - The result type returned by this SwingWorker's doInBackground() and SwingWorker.get() methods. Also, input parameter type of the processResults(Object) method.
All Implemented Interfaces:
Runnable, Future<T>, RunnableFuture<T>

public abstract class RemoteServiceWorker<T> extends SwingWorker<T,Void>
Worker for cancelable "atomic" remote services that can't be divided into multiple steps and then visualized by progress bar. This worker enables to show simple "cancel" dialogue of the long-term atomic call.

Usage:

         var worker = new RemoteServiceWorker(gui_component) {
             protected type_t doInBackground() throws RemoteServiceException {
                 return service_call();
             }
             protected void processResults(type_t results) throws Exception {
                 if (process_results(results)) {
                 } else {
                     throw new Exception();
                 }
             }
         }
         worker.execute(); // call the remote service
         worker.showCancelDialogue();
     

  • Constructor Details

    • RemoteServiceWorker

      public RemoteServiceWorker(Component parent, String installationUrl)
      Constructor.
      Parameters:
      parent - Parent GUI component for the shown cancel dialogue window
      installationUrl - Url with service installation instructions
  • Method Details

    • showCancelDialogue

      public void showCancelDialogue()
      Run after worker.execute(); to whot the cancel dialogue.
    • processResults

      protected abstract void processResults(T results) throws Exception
      Parameters:
      results - Values returned by the service, i.e., the doInBackground() method
      Throws:
      Exception - on failure of processing values
    • doInBackground

      protected abstract T doInBackground() throws RemoteServiceException
      The implementation of the service call. The service has to fail with exception.
      Specified by:
      doInBackground in class SwingWorker<T,Void>
      Returns:
      Values returned by the service
      Throws:
      RemoteServiceException - on failer
    • done

      protected void done()
      Overrides:
      done in class SwingWorker<T,Void>
    • showErrorMessage

      protected void showErrorMessage()
    • showInstallationMessage

      protected void showInstallationMessage()