Class LocalizedTaskWrapper<T,V>

java.lang.Object
io.jmix.flowui.backgroundtask.BackgroundTask<T,V>
io.jmix.flowui.backgroundtask.LocalizedTaskWrapper<T,V>
Type Parameters:
T - task progress measurement unit
V - result type

@Component("flowui_LocalizedTaskWrapper") @Scope("prototype") public class LocalizedTaskWrapper<T,V> extends BackgroundTask<T,V>
INTERNAL! Supposed to use when showing Dialog or some View. For instance if we need to show some dialog when task is running (e.g. updating the progress).

See example in DialogsImpl.BackgroundTaskDialogBuilderImpl.

  • Field Details

  • Constructor Details

    • LocalizedTaskWrapper

      public LocalizedTaskWrapper(BackgroundTask<T,V> wrappedTask)
  • Method Details

    • setMessages

      @Autowired public void setMessages(Messages messages)
    • setNotifications

      @Autowired public void setNotifications(Notifications notifications)
    • getCloseViewHandler

      @Nullable public Consumer<LocalizedTaskWrapper.CloseViewContext> getCloseViewHandler()
    • setCloseViewHandler

      public void setCloseViewHandler(@Nullable Consumer<LocalizedTaskWrapper.CloseViewContext> closeViewHandler)
    • getParams

      public Map<String,Object> getParams()
      Description copied from class: BackgroundTask
      Called by the execution environment in UI thread to prepare some execution parameters. These parameters can be requested by the working thread inside the BackgroundTask.run(TaskLifeCycle) method by calling TaskLifeCycle.getParams().
      Overrides:
      getParams in class BackgroundTask<T,V>
      Returns:
      parameters map or null if parameters are not needed
    • run

      public V run(TaskLifeCycle<T> lifeCycle) throws Exception
      Description copied from class: BackgroundTask
      Main method that performs a task.
      Called by the execution environment in a separate working thread.
      Implementation of this method should support interruption:
      Specified by:
      run in class BackgroundTask<T,V>
      Parameters:
      lifeCycle - lifecycle object that allows the main method to interact with the execution environment
      Returns:
      task result
      Throws:
      Exception - exception in a working thread
    • handleException

      public boolean handleException(Exception ex)
      Description copied from class: BackgroundTask
      Provides exclusive access to this UI from outside a request handling thread if the task BackgroundTask.run(TaskLifeCycle) method raised an exception.

      Please note that the command might be invoked on a different thread or later on the current thread, which means that custom thread locals might not have the expected values when the command is executed. UI.getCurrent(), VaadinSession.getCurrent() and VaadinService.getCurrent() are set according to this UI before executing the command. Other standard CurrentInstance values such as VaadinService.getCurrentRequest() and VaadinService.getCurrentResponse() will not be defined.

      Overrides:
      handleException in class BackgroundTask<T,V>
      Parameters:
      ex - exception
      Returns:
      true if this method implementation actually handles the exception. Used for chaining handlers.
      See Also:
      • UI.access(Command)
    • handleTimeoutException

      public boolean handleTimeoutException()
      Description copied from class: BackgroundTask
      Provides exclusive access to this UI from outside a request handling thread if the task timeout is exceeded.

      Please note that the command might be invoked on a different thread or later on the current thread, which means that custom thread locals might not have the expected values when the command is executed. UI.getCurrent(), VaadinSession.getCurrent() and VaadinService.getCurrent() are set according to this UI before executing the command. Other standard CurrentInstance values such as VaadinService.getCurrentRequest() and VaadinService.getCurrentResponse() will not be defined.

      Overrides:
      handleTimeoutException in class BackgroundTask<T,V>
      Returns:
      true if this method implementation actually handles this event. Used for chaining handlers.
      See Also:
      • UI.access(Command)
    • done

      public void done(V result)
      Description copied from class: BackgroundTask
      Provides exclusive access to this UI from outside a request handling thread when the task is completed.

      Please note that the command might be invoked on a different thread or later on the current thread, which means that custom thread locals might not have the expected values when the command is executed. UI.getCurrent(), VaadinSession.getCurrent() and VaadinService.getCurrent() are set according to this UI before executing the command. Other standard CurrentInstance values such as VaadinService.getCurrentRequest() and VaadinService.getCurrentResponse() will not be defined.

      Overrides:
      done in class BackgroundTask<T,V>
      Parameters:
      result - result of execution returned by BackgroundTask.run(TaskLifeCycle) method
      See Also:
      • UI.access(Command)
    • canceled

      public void canceled()
      Description copied from class: BackgroundTask
      Provides exclusive access to this UI from outside a request handling thread when the task is canceled by BackgroundTaskHandler.cancel() invocation.

      This method is not called in case of timeout expiration or owner view closing.

      Please note that the command might be invoked on a different thread or later on the current thread, which means that custom thread locals might not have the expected values when the command is executed. UI.getCurrent(), VaadinSession.getCurrent() and VaadinService.getCurrent() are set according to this UI before executing the command. Other standard CurrentInstance values such as VaadinService.getCurrentRequest() and VaadinService.getCurrentResponse() will not be defined.

      Overrides:
      canceled in class BackgroundTask<T,V>
      See Also:
      • UI.access(Command)
    • progress

      public void progress(List<T> changes)
      Description copied from class: BackgroundTask
      Provides exclusive access to this UI from outside a request handling thread on progress change.

      Please note that the command might be invoked on a different thread or later on the current thread, which means that custom thread locals might not have the expected values when the command is executed. UI.getCurrent(), VaadinSession.getCurrent() and VaadinService.getCurrent() are set according to this UI before executing the command. Other standard CurrentInstance values such as VaadinService.getCurrentRequest() and VaadinService.getCurrentResponse() will not be defined.

      Overrides:
      progress in class BackgroundTask<T,V>
      Parameters:
      changes - list of changes since previous invocation
      See Also:
      • UI.access(Command)
    • showExecutionError

      protected void showExecutionError(Exception ex)
    • notifyCloseViewHandler

      protected void notifyCloseViewHandler()