Class SynchronousJFXCaller<T>

java.lang.Object
edu.wisc.ssec.mcidasv.util.nativepathchooser.SynchronousJFXCaller<T>
Type Parameters:
T - Return type of the Callable.

public class SynchronousJFXCaller<T> extends Object
A utility class to execute a Callable synchronously on the JavaFX event thread.
  • Field Details

  • Constructor Details

    • SynchronousJFXCaller

      public SynchronousJFXCaller(Callable<T> callable)
      Constructs a new caller that will execute the provided callable. The callable is accessed from the JavaFX event thread, so it should either be immutable or at least its state shouldn't be changed randomly while the call() method is in progress.
      Parameters:
      callable - Action to execute on the JFX event thread.
  • Method Details

    • call

      public T call(long startTimeout, TimeUnit startTimeoutUnit) throws Exception
      Executes the Callable.

      A specialized task is run using Platform.runLater(). The calling thread then waits first for the task to start, then for it to return a result. Any exception thrown by the Callable will be rethrown in the calling thread.

      Parameters:
      startTimeout - time to wait for Platform.runLater() to start the dialog-showing task
      startTimeoutUnit - the time unit of the startTimeout argument
      Returns:
      whatever the Callable returns
      Throws:
      IllegalStateException - if Platform.runLater() fails to start the task within the given timeout
      InterruptedException - if the calling (this) thread is interrupted while waiting for the task to start or to get its result (note that the task will still run anyway and its result will be ignored)
      Exception