root / trunk / libraries / libUIComponent / src-test / org / gvsig / gui / beans / progressPanel / TestProgressPanel.java @ 10818
History | View | Annotate | Download (2.88 KB)
1 | 10818 | bsanchez | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | */
|
||
19 | package org.gvsig.gui.beans.progressPanel; |
||
20 | /**
|
||
21 | * <code>TestProgressPanel</code>. Test para comprobar el funcionamiento del
|
||
22 | * objeto <code>TestProgressPanel</code>
|
||
23 | *
|
||
24 | * @version 20/03/2007
|
||
25 | * @author Borja Sanchez Zamorano (borja.sanchez@iver.es)
|
||
26 | */
|
||
27 | public class TestProgressPanel { |
||
28 | private static final long serialVersionUID = 3008529181447712097L; |
||
29 | |||
30 | private tryPanel frame = null; |
||
31 | |||
32 | public class tryPanel extends Thread { |
||
33 | private ProgressPanel frame = new ProgressPanel(); |
||
34 | |||
35 | public void showWindow() { |
||
36 | frame.setTitle("Actualizando datos");
|
||
37 | frame.showLog(true);
|
||
38 | frame.show(); |
||
39 | if (this.isAlive()) |
||
40 | this.resume();
|
||
41 | else
|
||
42 | this.start();
|
||
43 | } |
||
44 | |||
45 | public synchronized void run() { |
||
46 | int i = 0; |
||
47 | frame.addLineLog("Realizando testeo...");
|
||
48 | while (i < 1000) { |
||
49 | if (i==0) |
||
50 | frame.addLineLog("Testeo 1 completado al 0%");
|
||
51 | if ((i>=0) && (i<=100)) |
||
52 | frame.replaceLastLineLog("Testeo 1 completado al " + i + "%"); |
||
53 | if (i==100) { |
||
54 | frame.replaceLastLineLog("Testeo 1 completado");
|
||
55 | frame.addLineLog("Testeo 2 completado al 0%");
|
||
56 | } |
||
57 | if ((i>=100) && (i<=800)) |
||
58 | frame.replaceLastLineLog("Testeo 2 completado al " + (int)((i-100)*100)/700 + "%"); |
||
59 | if (i==800) { |
||
60 | frame.replaceLastLineLog("Testeo 2 completado");
|
||
61 | frame.addLineLog("Testeo 3 completado al 0%");
|
||
62 | } |
||
63 | if ((i>=800) && (i<=1000)) |
||
64 | frame.replaceLastLineLog("Testeo 3 completado al " + (int)((i-800)*100)/200 + "%"); |
||
65 | i++; |
||
66 | |||
67 | frame.setPercent((int) (i*100)/1000); |
||
68 | try {
|
||
69 | sleep(50);
|
||
70 | } catch (InterruptedException e) { |
||
71 | e.printStackTrace(); |
||
72 | } |
||
73 | } |
||
74 | // Cerramos la ventana
|
||
75 | frame.hide(); |
||
76 | frame = null;
|
||
77 | |||
78 | this.suspend();
|
||
79 | } |
||
80 | } |
||
81 | |||
82 | /**
|
||
83 | * @param args
|
||
84 | */
|
||
85 | public static void main(String[] args) { |
||
86 | // TODO Auto-generated method stub
|
||
87 | new TestProgressPanel();
|
||
88 | } |
||
89 | |||
90 | /**
|
||
91 | * This is the default constructor
|
||
92 | */
|
||
93 | public TestProgressPanel() {
|
||
94 | super();
|
||
95 | initialize(); |
||
96 | } |
||
97 | |||
98 | /**
|
||
99 | * This method initializes this
|
||
100 | *
|
||
101 | * @return void
|
||
102 | */
|
||
103 | private void initialize() { |
||
104 | frame = new tryPanel();
|
||
105 | frame.showWindow(); |
||
106 | frame.run(); |
||
107 | } |
||
108 | } |