Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / main / java / org / gvsig / gui / beans / ProgressDialog.java @ 40561

History | View | Annotate | Download (4.79 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
/* CVS MESSAGES:
25
 *
26
 * $Id: ProgressDialog.java 22756 2008-08-07 09:49:05Z vcaballero $
27
 * $Log$
28
 * Revision 1.2  2007-09-12 16:28:23  bsanchez
29
 * *** empty log message ***
30
 *
31
 * Revision 1.1  2007/08/20 08:34:45  evercher
32
 * He fusionado LibUI con LibUIComponents
33
 *
34
 * Revision 1.6  2006/11/28 13:00:54  jmvivo
35
 * quitadas dependencias de andami
36
 *
37
 * Revision 1.5  2006/09/14 08:31:58  cesar
38
 * Replace PluginServices.getText by the new Messages bridge class from libUI
39
 *
40
 * Revision 1.4.2.1  2006/09/13 13:13:19  cesar
41
 * Replace PluginServices.getText by the new Messages bridge class from libUI
42
 *
43
 * Revision 1.4  2006/08/29 07:56:08  cesar
44
 * Rename the *View* family of classes to *Window* (ie: SingletonView to SingletonWindow, ViewInfo to WindowInfo, etc)
45
 *
46
 * Revision 1.3  2006/06/15 15:47:25  jaume
47
 * *** empty log message ***
48
 *
49
 * Revision 1.2  2006/05/19 06:27:09  jaume
50
 * *** empty log message ***
51
 *
52
 * Revision 1.1  2006/05/17 17:20:11  jaume
53
 * *** empty log message ***
54
 *
55
 *
56
 */
57
package org.gvsig.gui.beans;
58

    
59
import javax.swing.JButton;
60
import javax.swing.JDialog;
61
import javax.swing.JLabel;
62
import javax.swing.JProgressBar;
63

    
64
/** 
65
 * It is aimed to have an easy way to show a progres bar dialog. 
66
 * Unfortunatelly, it is not finished. Next step would be to
67
 * let ProgressDialog implement ProgressListener, to completely
68
 * encapsulate the component. Until then, the user has to call
69
 * setProgress(int) to make the bar grow up.
70
 * 
71
 * @author jaume dominguez faus - jaume.dominguez@iver.es
72
 *
73
 */
74
public class ProgressDialog extends JDialog {  
75
  private static final long serialVersionUID = 2325230864829072756L;
76
        private JProgressBar jProgressBar = null;
77
        private JButton btnCancel = null;
78
        private JLabel lblStatus = null;
79
        private JLabel lblTask = null;
80
        private String jobName;
81
        private CancellableComponent cc;
82
        private String textMessage;
83

    
84
        public ProgressDialog(CancellableComponent owner, String jobName, int stepAmount) {
85
                this(owner, jobName, jobName, stepAmount);
86
        }
87
        
88
        public ProgressDialog(CancellableComponent owner, String jobName, String textMessage, int stepAmount) {
89
                super();
90
                setTitle(jobName);
91
                this.textMessage = textMessage;
92
                getJProgressBar().setMinimum(0);
93
                getJProgressBar().setMaximum(stepAmount);
94
                cc = owner;
95
                initialize();
96
        }
97

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

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

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

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