root / branches / v2_0_0_prep / libraries / libUIComponent / src / org / gvsig / gui / beans / ProgressDialog.java @ 22756
History | View | Annotate | Download (4.99 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 22756 2008-08-07 09:49:05Z vcaballero $
|
45 |
* $Log$
|
46 |
* Revision 1.2 2007-09-12 16:28:23 bsanchez
|
47 |
* *** empty log message ***
|
48 |
*
|
49 |
* Revision 1.1 2007/08/20 08:34:45 evercher
|
50 |
* He fusionado LibUI con LibUIComponents
|
51 |
*
|
52 |
* Revision 1.6 2006/11/28 13:00:54 jmvivo
|
53 |
* quitadas dependencias de andami
|
54 |
*
|
55 |
* Revision 1.5 2006/09/14 08:31:58 cesar
|
56 |
* Replace PluginServices.getText by the new Messages bridge class from libUI
|
57 |
*
|
58 |
* Revision 1.4.2.1 2006/09/13 13:13:19 cesar
|
59 |
* Replace PluginServices.getText by the new Messages bridge class from libUI
|
60 |
*
|
61 |
* Revision 1.4 2006/08/29 07:56:08 cesar
|
62 |
* Rename the *View* family of classes to *Window* (ie: SingletonView to SingletonWindow, ViewInfo to WindowInfo, etc)
|
63 |
*
|
64 |
* Revision 1.3 2006/06/15 15:47:25 jaume
|
65 |
* *** empty log message ***
|
66 |
*
|
67 |
* Revision 1.2 2006/05/19 06:27:09 jaume
|
68 |
* *** empty log message ***
|
69 |
*
|
70 |
* Revision 1.1 2006/05/17 17:20:11 jaume
|
71 |
* *** empty log message ***
|
72 |
*
|
73 |
*
|
74 |
*/
|
75 |
package org.gvsig.gui.beans; |
76 |
|
77 |
import javax.swing.JButton; |
78 |
import javax.swing.JDialog; |
79 |
import javax.swing.JLabel; |
80 |
import javax.swing.JProgressBar; |
81 |
|
82 |
/**
|
83 |
* It is aimed to have an easy way to show a progres bar dialog.
|
84 |
* Unfortunatelly, it is not finished. Next step would be to
|
85 |
* let ProgressDialog implement ProgressListener, to completely
|
86 |
* encapsulate the component. Until then, the user has to call
|
87 |
* setProgress(int) to make the bar grow up.
|
88 |
*
|
89 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
90 |
*
|
91 |
*/
|
92 |
public class ProgressDialog extends JDialog { |
93 |
private static final long serialVersionUID = 2325230864829072756L; |
94 |
private JProgressBar jProgressBar = null; |
95 |
private JButton btnCancel = null; |
96 |
private JLabel lblStatus = null; |
97 |
private JLabel lblTask = null; |
98 |
private String jobName; |
99 |
private CancellableComponent cc;
|
100 |
private String textMessage; |
101 |
|
102 |
public ProgressDialog(CancellableComponent owner, String jobName, int stepAmount) { |
103 |
this(owner, jobName, jobName, stepAmount);
|
104 |
} |
105 |
|
106 |
public ProgressDialog(CancellableComponent owner, String jobName, String textMessage, int stepAmount) { |
107 |
super();
|
108 |
setTitle(jobName); |
109 |
this.textMessage = textMessage;
|
110 |
getJProgressBar().setMinimum(0);
|
111 |
getJProgressBar().setMaximum(stepAmount); |
112 |
cc = owner; |
113 |
initialize(); |
114 |
} |
115 |
|
116 |
/**
|
117 |
* This method initializes this
|
118 |
*
|
119 |
* @return void
|
120 |
*/
|
121 |
private void initialize() { |
122 |
lblTask = new JLabel(); |
123 |
lblTask.setBounds(10, 12, 280, 20); |
124 |
lblTask.setFont(new java.awt.Font("MS Sans Serif", java.awt.Font.BOLD, 11)); |
125 |
lblTask.setText(textMessage); |
126 |
lblStatus = new JLabel(); |
127 |
lblStatus.setBounds(10, 63, 280, 20); |
128 |
this.getContentPane().setLayout(null); |
129 |
this.setSize(308, 168); |
130 |
this.getContentPane().add(getJProgressBar(), null); |
131 |
this.getContentPane().add(getBtnCancel(), null); |
132 |
this.getContentPane().add(lblStatus, null); |
133 |
this.getContentPane().add(lblTask, null); |
134 |
} |
135 |
|
136 |
/**
|
137 |
* This method initializes jProgressBar
|
138 |
*
|
139 |
* @return javax.swing.JProgressBar
|
140 |
*/
|
141 |
private JProgressBar getJProgressBar() { |
142 |
if (jProgressBar == null) { |
143 |
jProgressBar = new JProgressBar(); |
144 |
jProgressBar.setBounds(10, 38, 280, 20); |
145 |
} |
146 |
return jProgressBar;
|
147 |
} |
148 |
|
149 |
/**
|
150 |
* This method initializes btnCancel
|
151 |
*
|
152 |
* @return javax.swing.JButton
|
153 |
*/
|
154 |
private JButton getBtnCancel() { |
155 |
if (btnCancel == null) { |
156 |
btnCancel = new JButton(); |
157 |
btnCancel.setBounds(210, 96, 80, 20); |
158 |
btnCancel.addActionListener(new java.awt.event.ActionListener() {
|
159 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
160 |
//NotificationManager.addInfo("The job was cancelled", null);
|
161 |
if (cc!=null) |
162 |
cc.cancel(); |
163 |
} |
164 |
}); |
165 |
btnCancel.setText(Messages.getText("cancel"));
|
166 |
} |
167 |
return btnCancel;
|
168 |
} |
169 |
|
170 |
public void setProgress(int step) { |
171 |
jProgressBar.setValue(step); |
172 |
} |
173 |
|
174 |
public void setStatusMessage(String message) { |
175 |
lblStatus.setText(message); |
176 |
} |
177 |
|
178 |
} // @jve:decl-index=0:visual-constraint="10,10"
|