Class Task
java.lang.Object
org.wicketstuff.progressbar.spring.Task
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)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMessage is a value object for messages during task runtime. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()protected voiddoFinish()Will be called after finishing the taskvoidAdd an error messageGet generated messagesintvoidAdd an info messagebooleanbooleanisDone()voidreset()protected voidrun()Implement the actual calculation of the task here.voidupdateProgress(int progressPercent) Update progress with percentage valuevoidupdateProgress(int current, int total) Update the current progress with current / total values (e.g. 1st of 5).voidAdd an warn message
-
Constructor Details
-
Task
public Task() -
Task
-
-
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
Add an info message- Parameters:
messageKey-arguments-
-
warn
Add an warn message- Parameters:
messageKey-arguments-
-
error
Add an error message- Parameters:
messageKey-arguments-
-
getMessages
Get generated messages- Returns:
- generated messages
-