All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.wizards.core.ProgressTimer
java.lang.Object
|
+----java.lang.Thread
|
+----com.sun.wizards.core.ProgressTimer
- public class ProgressTimer
- extends Thread
This class increments a Tasks' progress occasionally while a
unit is installing. It does its work in a seperate Thread. It can
be used in conjunction with a task that does not supply any status
to march the progress of the task forward. This sample code
creates a ProgressTimer for a task that might take 120 seconds to
complete. Therefore. With a sleep time of 4 seconds, it will
update it will update 30 times in 120 seconds, therefore we will want
it to advance approximately 3 percentage points, so that it will reach
100 percent approximately the same time the task finishes.
In your builder, you would create your task and install it into the WizardState:
Task myTask = new SampleTask(wizardState);
Sequence mySeqence = new Sequence();
mySequence.addTask(myTask);
wizardState.addSequence("SampleKey", mySequence);
Then, at runtime, somewhere in a panel, you would have code to start the
ProgressTimer at the desired time by simply instantiating and starting it:
ProgressTimer myTimer = new ProgressTimer(myTask, 4, 3, 100);
myTimer.start();
-
increment
- How much to update each time (in seconds)
-
maxProgress
- Progress setting at which we stop working (percentage)
-
sleepSeconds
- How long to wait between updates (in seconds)
-
task
- Task which we will be updating while clock is running
-
ProgressTimer(Task, int, int)
- Initializes and begins a new ProgressTimer.
-
ProgressTimer(Task, int, int, int)
- Initializes and begins a new ProgressTimer.
-
run()
-
This method does the main work, updating the proress setting for
this Task until to reaches maxProgrsss.
task
protected Task task
- Task which we will be updating while clock is running
sleepSeconds
protected int sleepSeconds
- How long to wait between updates (in seconds)
increment
protected int increment
- How much to update each time (in seconds)
maxProgress
protected int maxProgress
- Progress setting at which we stop working (percentage)
ProgressTimer
public ProgressTimer(Task myTask,
int sec,
int inc,
int max)
- Initializes and begins a new ProgressTimer.
- Parameters:
- myTask - Task which we will be updating.
- sec - How long to wait between updates (in seconds)
- inc - How much percentage to update each time
- max - Progress percentage at which we stop working
ProgressTimer
public ProgressTimer(Task myTask,
int totalTime,
int max)
- Initializes and begins a new ProgressTimer. This constructor
provides a hint for how long the process is anticipated to take,
and the progress is calculated from that.
- Parameters:
- myTask - Task which we will be updating.
- totalTime - A hint for how long the process should take in milliseconds.
- max - Progress percentage at which we stop working.
run
public void run()
- This method does the main work, updating the proress setting for
this Task until to reaches maxProgrsss.
- Overrides:
- run in class Thread
All Packages Class Hierarchy This Package Previous Next Index