2 * konsultationProgress.java
4 * Created on 30. april 2005, 15:15
7 package drno
.swingui
.guiController
;
10 import java
.text
.DateFormat
;
11 import java
.util
.GregorianCalendar
;
17 public class konsultationProgress
{
18 int konsultationLength
=0;
22 boolean canceled
= false;
23 boolean clockDone
= false;
25 String statMessage
,clockString
;
26 //TableHandler th = new TableHandler();
28 /** Creates a new instance of konsultationProgress */
29 public konsultationProgress() {
34 GregorianCalendar c
= new GregorianCalendar();
35 kstart
= (c
.getTime()).getTime()/1000;
36 final SwingWorker worker
= new SwingWorker() {
37 public Object
construct() {
42 return new ActualTask();
48 public void goClock(){
49 final SwingWorker worker2
= new SwingWorker(){
50 public Object
construct(){
59 * Called from ProgressBarDemo to find out how much work needs
62 public int getLengthOfTask() {
63 return konsultationLength
;
65 public void setLengthOfTask(int length
) {
66 konsultationLength
= length
*60;
70 * Called from ProgressBarDemo to find out how much has been done.
72 public long getCurrent() {
82 * Called from ProgressBarDemo to find out if the task has completed.
84 public boolean isDone() {
89 * Returns the most recent status message, or null
90 * if there is no current status message.
92 public String
getMessage() {
101 GregorianCalendar c
= new GregorianCalendar();
102 DateFormat df
= DateFormat
.getTimeInstance(DateFormat
.MEDIUM
);
103 timeCurrent
=c
.getTime();
104 clockString
= df
.format(c
.getTime());
105 //System.out.println(clockString);
114 public String
getTimeString(){
117 public Date
getTime(){
122 * The actual long running task. This runs in a SwingWorker thread.
127 //making a random amount of progress every second.
128 while (!canceled
&& !done
) {
130 Thread
.sleep(1000); //sleep for a second
131 GregorianCalendar c
= new GregorianCalendar();
132 kcurrent
= (c
.getTime()).getTime()/1000;
133 taskCurrent
= kcurrent
-kstart
;
134 if (taskCurrent
>= konsultationLength
) {
136 taskCurrent
= konsultationLength
;
138 statMessage
= "Completed " + taskCurrent
+
139 " out of " + konsultationLength
+ ".";
140 } catch (Exception e
) {
141 System
.out
.println("ActualTask interrupted");