svn-gvsig-desktop / trunk / libraries / libIverUtiles / src / com / iver / utiles / swing / threads / UndefinedProgressMonitor.java @ 4419
History | View | Annotate | Download (6.11 KB)
1 |
/*
|
---|---|
2 |
* Created on 10-mar-2006
|
3 |
*
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
21 |
*
|
22 |
* For more information, contact:
|
23 |
*
|
24 |
* Generalitat Valenciana
|
25 |
* Conselleria d'Infraestructures i Transport
|
26 |
* Av. Blasco Ib??ez, 50
|
27 |
* 46010 VALENCIA
|
28 |
* SPAIN
|
29 |
*
|
30 |
* +34 963862235
|
31 |
* gvsig@gva.es
|
32 |
* www.gvsig.gva.es
|
33 |
*
|
34 |
* or
|
35 |
*
|
36 |
* IVER T.I. S.A
|
37 |
* Salamanca 50
|
38 |
* 46005 Valencia
|
39 |
* Spain
|
40 |
*
|
41 |
* +34 963163400
|
42 |
* dac@iver.es
|
43 |
*/
|
44 |
/* CVS MESSAGES:
|
45 |
*
|
46 |
* $Id: UndefinedProgressMonitor.java 4419 2006-03-14 19:35:13Z azabala $
|
47 |
* $Log$
|
48 |
* Revision 1.1 2006-03-14 19:23:58 azabala
|
49 |
* *** empty log message ***
|
50 |
*
|
51 |
*
|
52 |
*/
|
53 |
package com.iver.utiles.swing.threads; |
54 |
|
55 |
import java.awt.Frame; |
56 |
import java.awt.GridBagConstraints; |
57 |
import java.awt.GridBagLayout; |
58 |
|
59 |
import javax.swing.JButton; |
60 |
import javax.swing.JDialog; |
61 |
import javax.swing.JLabel; |
62 |
import javax.swing.JPanel; |
63 |
import javax.swing.JProgressBar; |
64 |
|
65 |
|
66 |
public class UndefinedProgressMonitor extends JDialog |
67 |
implements IProgressMonitorIF{
|
68 |
|
69 |
|
70 |
private static final long serialVersionUID = 8776505862813807891L; |
71 |
private JPanel jContentPane = null; |
72 |
private JLabel mainTitleLabel = null; |
73 |
private JLabel noteLabel = null; |
74 |
private JProgressBar jProgressBar = null; |
75 |
private JButton cancelButton = null; |
76 |
private JButton backgroundButton = null; |
77 |
|
78 |
boolean canceled = false; |
79 |
|
80 |
/**
|
81 |
* This is the default constructor
|
82 |
*/
|
83 |
public UndefinedProgressMonitor() {
|
84 |
super();
|
85 |
initialize(); |
86 |
} |
87 |
|
88 |
public UndefinedProgressMonitor(Frame parent){ |
89 |
//quiz?s lo de run in background ponga el dialogo a
|
90 |
//no modal -> modal
|
91 |
super(parent, false); |
92 |
initialize(); |
93 |
} |
94 |
|
95 |
/**
|
96 |
* This method initializes this
|
97 |
*
|
98 |
* @return void
|
99 |
*
|
100 |
* FIXME Internationalize this
|
101 |
*/
|
102 |
private void initialize() { |
103 |
this.setSize(280, 181); |
104 |
this.setTitle("Processing..."); |
105 |
this.setContentPane(getJContentPane());
|
106 |
} |
107 |
|
108 |
/**
|
109 |
* This method initializes jContentPane
|
110 |
*
|
111 |
* @return javax.swing.JPanel
|
112 |
*/
|
113 |
private JPanel getJContentPane() { |
114 |
if (jContentPane == null) { |
115 |
noteLabel = new JLabel(); |
116 |
noteLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12)); |
117 |
noteLabel.setBounds(new java.awt.Rectangle(47,54,198,14)); |
118 |
noteLabel.setText("noteLabel");
|
119 |
mainTitleLabel = new JLabel(); |
120 |
mainTitleLabel.setText("mainTittleLabel");
|
121 |
mainTitleLabel.setBounds(new java.awt.Rectangle(45,10,202,27)); |
122 |
mainTitleLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 12)); |
123 |
jContentPane = new JPanel(); |
124 |
jContentPane.setLayout(null);
|
125 |
jContentPane.add(mainTitleLabel, null);
|
126 |
jContentPane.add(noteLabel, null);
|
127 |
jContentPane.add(getJProgressBar(), null);
|
128 |
jContentPane.add(getCancelButton(), null);
|
129 |
jContentPane.add(getBackgroundButton(), null);
|
130 |
} |
131 |
return jContentPane;
|
132 |
} |
133 |
|
134 |
/**
|
135 |
* This method initializes jProgressBar
|
136 |
*
|
137 |
* @return javax.swing.JProgressBar
|
138 |
*/
|
139 |
private JProgressBar getJProgressBar() { |
140 |
if (jProgressBar == null) { |
141 |
jProgressBar = new JProgressBar(); |
142 |
jProgressBar.setBounds(new java.awt.Rectangle(43,85,204,18)); |
143 |
} |
144 |
return jProgressBar;
|
145 |
} |
146 |
|
147 |
/**
|
148 |
* This method initializes cancelButton
|
149 |
*
|
150 |
* @return javax.swing.JButton
|
151 |
*/
|
152 |
private JButton getCancelButton() { |
153 |
if (cancelButton == null) { |
154 |
cancelButton = new JButton(); |
155 |
cancelButton.setText("cancelar");
|
156 |
cancelButton.setBounds(new java.awt.Rectangle(23,114,88,22)); |
157 |
cancelButton.addActionListener(new java.awt.event.ActionListener() {
|
158 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
159 |
cancel(); |
160 |
} |
161 |
}); |
162 |
cancelButton.addActionListener(new java.awt.event.ActionListener() {
|
163 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
164 |
cancel(); |
165 |
} |
166 |
}); |
167 |
} |
168 |
return cancelButton;
|
169 |
} |
170 |
|
171 |
/**
|
172 |
* This method initializes backgroundButton
|
173 |
*
|
174 |
* @return javax.swing.JButton
|
175 |
*/
|
176 |
private JButton getBackgroundButton() { |
177 |
if (backgroundButton == null) { |
178 |
backgroundButton = new JButton(); |
179 |
backgroundButton.setText("segundo plano");
|
180 |
backgroundButton.setBounds(new java.awt.Rectangle(131,113,133,22)); |
181 |
backgroundButton.addActionListener(new java.awt.event.ActionListener() {
|
182 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
183 |
taskInBackground(); |
184 |
} |
185 |
|
186 |
}); |
187 |
} |
188 |
return backgroundButton;
|
189 |
} |
190 |
|
191 |
public void setInitialStep(int step) { |
192 |
jProgressBar.setMinimum(step); |
193 |
} |
194 |
|
195 |
public void setLastStep(int step) { |
196 |
jProgressBar.setMaximum(step); |
197 |
} |
198 |
|
199 |
public void setCurrentStep(int step) { |
200 |
jProgressBar.setValue(step); |
201 |
} |
202 |
|
203 |
public int getInitialStep() { |
204 |
return jProgressBar.getMinimum();
|
205 |
} |
206 |
|
207 |
public int getLastStep() { |
208 |
return jProgressBar.getMaximum();
|
209 |
} |
210 |
|
211 |
public int getCurrentStep() { |
212 |
return jProgressBar.getValue();
|
213 |
} |
214 |
|
215 |
public void setIndeterminated(boolean indeterminated) { |
216 |
jProgressBar.setIndeterminate(indeterminated); |
217 |
} |
218 |
|
219 |
public boolean isIndeterminated() { |
220 |
return jProgressBar.isIndeterminate();
|
221 |
} |
222 |
|
223 |
public void setBarStringDrawed(boolean stringDrawed) { |
224 |
jProgressBar.setStringPainted(stringDrawed); |
225 |
} |
226 |
|
227 |
public void setBarString(String barString) { |
228 |
jProgressBar.setString(barString); |
229 |
} |
230 |
|
231 |
public void setMainTitleLabel(String text) { |
232 |
mainTitleLabel.setText(text); |
233 |
} |
234 |
|
235 |
public void setNote(String note) { |
236 |
noteLabel.setText(note); |
237 |
} |
238 |
|
239 |
public void cancel() { |
240 |
canceled = true;
|
241 |
} |
242 |
|
243 |
public void taskInBackground() { |
244 |
} |
245 |
|
246 |
public boolean isCanceled() { |
247 |
return canceled == true; |
248 |
} |
249 |
|
250 |
public void close() { |
251 |
this.dispose();
|
252 |
} |
253 |
|
254 |
public void open() { |
255 |
this.setVisible(true); |
256 |
} |
257 |
|
258 |
} // @jve:decl-index=0:visual-constraint="30,10"
|