Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / test / java / org / gvsig / gui / beans / progresspanel / Test2ProgressPanel.java @ 40561

History | View | Annotate | Download (3.36 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.gui.beans.progresspanel;
25

    
26
import java.awt.event.ComponentAdapter;
27
import java.awt.event.ComponentEvent;
28

    
29
import org.apache.log4j.Logger;
30
import org.gvsig.gui.beans.Messages;
31
import org.gvsig.gui.beans.incrementabletask.IncrementableTask;
32

    
33

    
34
/* gvSIG. Geographic Information System of the Valencian Government
35
 *
36
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
37
 * of the Valencian Government (CIT)
38
 * 
39
 * This program is free software; you can redistribute it and/or
40
 * modify it under the terms of the GNU General Public License
41
 * as published by the Free Software Foundation; either version 2
42
 * of the License, or (at your option) any later version.
43
 * 
44
 * This program is distributed in the hope that it will be useful,
45
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
46
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
47
 * GNU General Public License for more details.
48
 *  
49
 * You should have received a copy of the GNU General Public License
50
 * along with this program; if not, write to the Free Software
51
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
52
 * MA  02110-1301, USA.
53
 * 
54
 */
55

    
56
/**
57
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
58
 */
59
public class Test2ProgressPanel {
60

    
61
        public static void main(String[] args) {
62
                SampleProcess iprocess = new SampleProcess("Proceso de ejemplo",
63
                                Messages.getText("Ongoing_process_please_wait"));
64

    
65
                IncrementableTask iTask = new IncrementableTask(iprocess, new ProgressPanel(false));
66
                iTask.addIncrementableListener(iprocess);
67
                iprocess.setIncrementableTask(iTask);
68

    
69
                final SampleProcess f_iprocess = iprocess;
70
                final IncrementableTask f_iTask = iTask;
71
                
72
                iTask.getProgressPanel().addComponentListener(new ComponentAdapter() {
73
                        /*
74
                         * (non-Javadoc)
75
                         * @see java.awt.event.ComponentAdapter#componentHidden(java.awt.event.ComponentEvent)
76
                         */
77
                        public void componentHidden(ComponentEvent e) {
78
                                f_iTask.getProgressPanel().dispose();
79

    
80
                                /* Writes in the gvSIG log the results of the process */
81
                                String text = "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n" +
82
                                        "Resumen del proceso:\n" +
83
                                        f_iprocess.getLog() +
84
                                        "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n";
85
                                Logger.getLogger(getClass().getName()).debug(text);
86
                        }
87
                });
88

    
89
                /* Starts the process */
90
                iprocess.start();
91
                iTask.start();
92
        }
93
}