java.lang.Object
org.wicketstuff.progressbar.spring.Task

public class Task extends Object

A Task is some kind of long running action that should be done in the background. The task can update the progress based on the current position in the workload.

Basically what you have to do for your own Task is to override the run() method and frequently call one of the updateProgress methods.

Author:
Christopher Hlubek (hlubek)
  • Constructor Details

    • Task

      public Task()
    • Task

      public Task(Runnable runnable)
  • Method Details

    • run

      protected void run()

      Implement the actual calculation of the task here.

      If iterating and cancelling should be supported you should check for a canceled task in every iteration:

       if (isCancelled())
       {
              return;
       }
       
    • doFinish

      protected void doFinish()
      Will be called after finishing the task
    • isCancelled

      public boolean isCancelled()
    • reset

      public void reset()
    • cancel

      public void cancel()
    • updateProgress

      public void updateProgress(int current, int total)
      Update the current progress with current / total values (e.g. 1st of 5). This should be called from the run method for every iteration.
      Parameters:
      current - The current iteration (counted from zero!)
      total - Total iterations
    • updateProgress

      public void updateProgress(int progressPercent)
      Update progress with percentage value
      Parameters:
      progressPercent - progress in percent in [0, 100]
    • isDone

      public boolean isDone()
    • getProgress

      public int getProgress()
    • info

      public void info(String messageKey, Object... arguments)
      Add an info message
      Parameters:
      messageKey -
      arguments -
    • warn

      public void warn(String messageKey, Object... arguments)
      Add an warn message
      Parameters:
      messageKey -
      arguments -
    • error

      public void error(String messageKey, Object... arguments)
      Add an error message
      Parameters:
      messageKey -
      arguments -
    • getMessages

      public List<Task.Message> getMessages()
      Get generated messages
      Returns:
      generated messages