Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / libraries / libUI / src / org / gvsig / gui / beans / ProgressDialog.java @ 22057

History | View | Annotate | Download (5.04 KB)

1
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib��ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41

    
42
/* CVS MESSAGES:
43
 *
44
 * $Id: ProgressDialog.java 22057 2008-07-04 07:55:28Z vcaballero $
45
 * $Log$
46
 * Revision 1.4.2.5  2006-11-28 13:13:10  jmvivo
47
 * quitadas dependencias de andami
48
 *
49
 * Revision 1.4.2.4  2006/11/28 09:47:16  ppiqueras
50
 * Actualización desde HEAD a v10 de libUI fruto de cambio de dependencia de libUI con el proyecto _fwAndami. (cambiado PluginServices.getText(..., ...) por Messages.getText(...)
51
 *
52
 * Revision 1.5  2006/09/14 08:31:58  cesar
53
 * Replace PluginServices.getText by the new Messages bridge class from libUI
54
 *
55
 * Revision 1.4.2.1  2006/09/13 13:13:19  cesar
56
 * Replace PluginServices.getText by the new Messages bridge class from libUI
57
 *
58
 * Revision 1.4  2006/08/29 07:56:08  cesar
59
 * Rename the *View* family of classes to *Window* (ie: SingletonView to SingletonWindow, ViewInfo to WindowInfo, etc)
60
 *
61
 * Revision 1.3  2006/06/15 15:47:25  jaume
62
 * *** empty log message ***
63
 *
64
 * Revision 1.2  2006/05/19 06:27:09  jaume
65
 * *** empty log message ***
66
 *
67
 * Revision 1.1  2006/05/17 17:20:11  jaume
68
 * *** empty log message ***
69
 *
70
 *
71
 */
72
package org.gvsig.gui.beans;
73

    
74
import javax.swing.JButton;
75
import javax.swing.JDialog;
76
import javax.swing.JLabel;
77
import javax.swing.JProgressBar;
78

    
79
/** 
80
 * It is aimed to have an easy way to show a progres bar dialog. 
81
 * Unfortunatelly, it is not finished. Next step would be to
82
 * let ProgressDialog implement ProgressListener, to completely
83
 * encapsulate the component. Until then, the user has to call
84
 * setProgress(int) to make the bar grow up.
85
 * 
86
 * @author jaume dominguez faus - jaume.dominguez@iver.es
87
 *
88
 */
89
public class ProgressDialog extends JDialog {  
90

    
91
        private static final long serialVersionUID = 7965716414139989293L;
92
        private JProgressBar jProgressBar = null;
93
        private JButton btnCancel = null;
94
        private JLabel lblStatus = null;
95
        private JLabel lblTask = null;
96
        private String textMessage;
97
        private CancellableComponent cc;
98

    
99
        public ProgressDialog(CancellableComponent owner, String jobName, int stepAmount) {
100
                this(owner, jobName, jobName, stepAmount);
101
        }
102
        
103
        public ProgressDialog(CancellableComponent owner, String jobName, String textMessage, int stepAmount) {
104
                super();
105
                setTitle(jobName);
106
                this.textMessage = textMessage;
107
                getJProgressBar().setMinimum(0);
108
                getJProgressBar().setMaximum(stepAmount);
109
                cc = owner;
110
                initialize();
111
        }
112

    
113
        /**
114
         * This method initializes this
115
         * 
116
         * @return void
117
         */
118
        private void initialize() {
119
                lblTask = new JLabel();
120
                lblTask.setBounds(10, 12, 280, 20);
121
                lblTask.setFont(new java.awt.Font("MS Sans Serif", java.awt.Font.BOLD, 11));
122
                lblTask.setText(textMessage);
123
                lblStatus = new JLabel();
124
                lblStatus.setBounds(10, 63, 280, 20);
125
                this.getContentPane().setLayout(null);
126
                this.setSize(308, 168);
127
                this.getContentPane().add(getJProgressBar(), null);
128
                this.getContentPane().add(getBtnCancel(), null);
129
                this.getContentPane().add(lblStatus, null);
130
                this.getContentPane().add(lblTask, null);
131
        }
132

    
133
        /**
134
         * This method initializes jProgressBar        
135
         *         
136
         * @return javax.swing.JProgressBar        
137
         */    
138
        private JProgressBar getJProgressBar() {
139
                if (jProgressBar == null) {
140
                        jProgressBar = new JProgressBar();
141
                        jProgressBar.setBounds(10, 38, 280, 20);
142
                }
143
                return jProgressBar;
144
        }
145

    
146
        /**
147
         * This method initializes btnCancel        
148
         *         
149
         * @return javax.swing.JButton        
150
         */    
151
        private JButton getBtnCancel() {
152
                if (btnCancel == null) {
153
                        btnCancel = new JButton();
154
                        btnCancel.setBounds(210, 96, 80, 20);
155
                        btnCancel.addActionListener(new java.awt.event.ActionListener() { 
156
                                public void actionPerformed(java.awt.event.ActionEvent e) {
157
                                        //NotificationManager.addInfo("The job was cancelled", null);
158
                                        if (cc!=null)
159
                                                cc.cancel();
160
                                }
161
                        });
162
                        btnCancel.setText(Messages.getText("cancel"));
163
                }
164
                return btnCancel;
165
        }
166
        
167
        public void setProgress(int step) {
168
                jProgressBar.setValue(step);
169
        }
170
        
171
        public void setStatusMessage(String message) {
172
                lblStatus.setText(message);
173
        }
174

    
175
}  //  @jve:decl-index=0:visual-constraint="10,10"