root / trunk / libraries / libUIComponent / src-test / org / gvsig / gui / beans / incrementableTask / TestIncrementableTask.java @ 10962
History | View | Annotate | Download (1.35 KB)
1 |
package org.gvsig.gui.beans.incrementableTask; |
---|---|
2 |
|
3 |
import org.gvsig.gui.beans.incrementabletask.IIncrementable; |
4 |
import org.gvsig.gui.beans.incrementabletask.IncrementableTask; |
5 |
import org.gvsig.gui.beans.progresspanel.LogControl; |
6 |
|
7 |
public class TestIncrementableTask { |
8 |
class ClassProcess extends Thread implements IIncrementable { |
9 |
int i = 0; |
10 |
long j = 0; |
11 |
LogControl log = new LogControl();
|
12 |
|
13 |
public ClassProcess() {
|
14 |
this.start();
|
15 |
} |
16 |
|
17 |
public synchronized void run(){ |
18 |
for (j=0; j<=65535; j++) { |
19 |
for (long i=0; i<=65535; i++); |
20 |
log.replaceLastLine(j + "");
|
21 |
if ((j%1000)==0) { |
22 |
log.addLine(j + "");
|
23 |
} |
24 |
} |
25 |
} |
26 |
|
27 |
public String getLabel() { |
28 |
return "Etiqueta " + j; |
29 |
} |
30 |
|
31 |
public String getLog() { |
32 |
return log.getText();
|
33 |
} |
34 |
|
35 |
public int getPercent() { |
36 |
return (int) ((j*100)/65535); |
37 |
} |
38 |
|
39 |
public String getTitle() { |
40 |
return "TestIncrementTask"; |
41 |
} |
42 |
|
43 |
public void canceled() { |
44 |
this.suspend();
|
45 |
} |
46 |
|
47 |
public void closed() { |
48 |
this.suspend();
|
49 |
} |
50 |
|
51 |
public void resumed() { |
52 |
this.resume();
|
53 |
} |
54 |
|
55 |
public void suspended() { |
56 |
this.suspend();
|
57 |
} |
58 |
} |
59 |
|
60 |
ClassProcess ncp = new ClassProcess();
|
61 |
|
62 |
public TestIncrementableTask() {
|
63 |
super();
|
64 |
initialize(); |
65 |
} |
66 |
|
67 |
private void initialize() { |
68 |
IncrementableTask it = new IncrementableTask(ncp);
|
69 |
it.showWindow(); |
70 |
} |
71 |
|
72 |
public static void main(String[] args) { |
73 |
new TestIncrementableTask();
|
74 |
} |
75 |
} |