Statistics
| Revision:

svn-gvsig-desktop / tags / v10_RC2c / libraries / libUI / src / org / gvsig / gui / beans / ProgressDialog.java @ 8745

History | View | Annotate | Download (4.15 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 8745 2006-11-14 13:14:23Z  $
45
 * $Log$
46
 * Revision 1.4.2.1  2006-09-13 13:13:19  cesar
47
 * Replace PluginServices.getText by the new Messages bridge class from libUI
48
 *
49
 * Revision 1.4  2006/08/29 07:56:08  cesar
50
 * Rename the *View* family of classes to *Window* (ie: SingletonView to SingletonWindow, ViewInfo to WindowInfo, etc)
51
 *
52
 * Revision 1.3  2006/06/15 15:47:25  jaume
53
 * *** empty log message ***
54
 *
55
 * Revision 1.2  2006/05/19 06:27:09  jaume
56
 * *** empty log message ***
57
 *
58
 * Revision 1.1  2006/05/17 17:20:11  jaume
59
 * *** empty log message ***
60
 *
61
 *
62
 */
63
package org.gvsig.gui.beans;
64

    
65
import javax.swing.JButton;
66
import javax.swing.JDialog;
67
import javax.swing.JLabel;
68
import javax.swing.JProgressBar;
69

    
70
import com.iver.andami.messages.NotificationManager;
71
import com.iver.andami.ui.mdiManager.SingletonWindow;
72
/**
73
 * @author jaume
74
 *
75
 */
76
public class ProgressDialog extends JDialog {  
77

    
78
        private JProgressBar jProgressBar = null;
79
        private JButton btnCancel = null;
80
        private JLabel lblStatus = null;
81
        private JLabel lblTask = null;
82
        private String jobName;
83
        private CancellableComponent cc;
84

    
85
        /**
86
         * This is the default constructor
87
         */
88
        public ProgressDialog(CancellableComponent owner, String jobName, int stepAmount) {
89
                super();
90
                this.jobName = jobName;
91
                getJProgressBar().setMinimum(0);
92
                getJProgressBar().setMaximum(stepAmount);
93
                cc = owner;
94
                initialize();
95
        }
96

    
97
        /**
98
         * This method initializes this
99
         * 
100
         * @return void
101
         */
102
        private void initialize() {
103
                lblTask = new JLabel();
104
                lblTask.setBounds(10, 12, 280, 20);
105
                lblTask.setFont(new java.awt.Font("MS Sans Serif", java.awt.Font.BOLD, 11));
106
                lblTask.setText(jobName);
107
                lblStatus = new JLabel();
108
                lblStatus.setBounds(10, 63, 280, 20);
109
                this.getContentPane().setLayout(null);
110
                this.setSize(308, 168);
111
                this.getContentPane().add(getJProgressBar(), null);
112
                this.getContentPane().add(getBtnCancel(), null);
113
                this.getContentPane().add(lblStatus, null);
114
                this.getContentPane().add(lblTask, null);
115
        }
116

    
117
        /**
118
         * This method initializes jProgressBar        
119
         *         
120
         * @return javax.swing.JProgressBar        
121
         */    
122
        private JProgressBar getJProgressBar() {
123
                if (jProgressBar == null) {
124
                        jProgressBar = new JProgressBar();
125
                        jProgressBar.setBounds(10, 38, 280, 20);
126
                }
127
                return jProgressBar;
128
        }
129

    
130
        /**
131
         * This method initializes btnCancel        
132
         *         
133
         * @return javax.swing.JButton        
134
         */    
135
        private JButton getBtnCancel() {
136
                if (btnCancel == null) {
137
                        btnCancel = new JButton();
138
                        btnCancel.setBounds(210, 96, 80, 20);
139
                        btnCancel.addActionListener(new java.awt.event.ActionListener() { 
140
                                public void actionPerformed(java.awt.event.ActionEvent e) {
141
                                        NotificationManager.addInfo("The job was cancelled", null);
142
                                        if (cc!=null)
143
                                                cc.cancel();
144
                                }
145
                        });
146
                        btnCancel.setText(Messages.getText("cancel"));
147
                }
148
                return btnCancel;
149
        }
150
        
151
        public void setProgress(int step) {
152
                jProgressBar.setValue(step);
153
        }
154
        
155
        public void setStatusMessage(String message) {
156
                lblStatus.setText(message);
157
        }
158

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