about summary refs log tree commit diff stats
path: root/client/trunk/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'client/trunk/src/com')
-rw-r--r--client/trunk/src/com/fourisland/instadisc/InstaDiscThread.java20
-rw-r--r--client/trunk/src/com/fourisland/instadisc/InstaDiscView.java34
2 files changed, 51 insertions, 3 deletions
diff --git a/client/trunk/src/com/fourisland/instadisc/InstaDiscThread.java b/client/trunk/src/com/fourisland/instadisc/InstaDiscThread.java index e2b203e..d4a293c 100644 --- a/client/trunk/src/com/fourisland/instadisc/InstaDiscThread.java +++ b/client/trunk/src/com/fourisland/instadisc/InstaDiscThread.java
@@ -21,6 +21,12 @@ import java.util.logging.Logger;
21public class InstaDiscThread implements Runnable { 21public class InstaDiscThread implements Runnable {
22 22
23 boolean cancelled = false; 23 boolean cancelled = false;
24 InstaDiscView idv;
25
26 public InstaDiscThread(InstaDiscView idv)
27 {
28 this.idv = idv;
29 }
24 30
25 public void cancel() { 31 public void cancel() {
26 cancelled = true; 32 cancelled = true;
@@ -38,7 +44,7 @@ public class InstaDiscThread implements Runnable {
38 try 44 try
39 { 45 {
40 Socket s = svr.accept(); 46 Socket s = svr.accept();
41 HandleItemThread hit = new HandleItemThread(s); 47 HandleItemThread hit = new HandleItemThread(s,idv);
42 Thread hitt = new Thread(hit); 48 Thread hitt = new Thread(hit);
43 hitt.start(); 49 hitt.start();
44 } catch (SocketException ex) 50 } catch (SocketException ex)
@@ -62,12 +68,17 @@ public class InstaDiscThread implements Runnable {
62class HandleItemThread implements Runnable { 68class HandleItemThread implements Runnable {
63 69
64 Socket s; 70 Socket s;
71 InstaDiscView idv;
65 72
66 public HandleItemThread(Socket s) { 73 public HandleItemThread(Socket s, InstaDiscView idv) {
67 this.s = s; 74 this.s = s;
75 this.idv = idv;
68 } 76 }
69 77
70 public void run() { 78 public void run() {
79 idv.startProgress();
80 idv.doText("Downloading Item....");
81
71 try 82 try
72 { 83 {
73 InputStream is = s.getInputStream(); 84 InputStream is = s.getInputStream();
@@ -85,6 +96,9 @@ class HandleItemThread implements Runnable {
85 { 96 {
86 buffer[i] = rs; 97 buffer[i] = rs;
87 } 98 }
99
100 idv.doProgress(buffer.length / (is.available()+1));
101
88 i++; 102 i++;
89 } catch (SocketException ex) 103 } catch (SocketException ex)
90 { 104 {
@@ -135,5 +149,7 @@ class HandleItemThread implements Runnable {
135 { 149 {
136 Logger.getLogger(HandleItemThread.class.getName()).log(Level.SEVERE, null, ex); 150 Logger.getLogger(HandleItemThread.class.getName()).log(Level.SEVERE, null, ex);
137 } 151 }
152
153 idv.doneProgress();
138 } 154 }
139} 155}
diff --git a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java index 198ce2b..b03ce07 100644 --- a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java +++ b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java
@@ -109,7 +109,7 @@ public class InstaDiscView extends FrameView {
109 jList1.setCellRenderer(new IDItemListCellRenderer()); 109 jList1.setCellRenderer(new IDItemListCellRenderer());
110 refreshItemPane(); 110 refreshItemPane();
111 111
112 InstaDiscThread idt = new InstaDiscThread(); 112 InstaDiscThread idt = new InstaDiscThread(this);
113 Thread idtt = new Thread(idt); 113 Thread idtt = new Thread(idt);
114 idtt.start(); 114 idtt.start();
115 115
@@ -436,4 +436,36 @@ public class InstaDiscView extends FrameView {
436 436
437 ipCheckTimer.start(); 437 ipCheckTimer.start();
438 } 438 }
439
440 public synchronized void startProgress()
441 {
442 if (!busyIconTimer.isRunning()) {
443 statusAnimationLabel.setIcon(busyIcons[0]);
444 busyIconIndex = 0;
445 busyIconTimer.start();
446 }
447 progressBar.setVisible(true);
448 progressBar.setIndeterminate(true);
449 }
450
451 public synchronized void doneProgress()
452 {
453 busyIconTimer.stop();
454 statusAnimationLabel.setIcon(idleIcon);
455 progressBar.setVisible(false);
456 progressBar.setValue(0);
457 }
458
459 public synchronized void doText(String text)
460 {
461 statusMessageLabel.setText((text == null) ? "" : text);
462 messageTimer.restart();
463 }
464
465 public synchronized void doProgress(Integer value)
466 {
467 progressBar.setVisible(true);
468 progressBar.setIndeterminate(false);
469 progressBar.setValue(value);
470 }
439} 471}