svn-gvsig-desktop / tags / v1_1_Build_1015 / frameworks / _fwAndami / src / com / iver / andami / ui / mdiFrame / NewStatusBar.java @ 13679
History | View | Annotate | Download (14.9 KB)
1 | 1104 | fjp | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004 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 | 598 | fernando | package com.iver.andami.ui.mdiFrame; |
42 | |||
43 | 10404 | cesar | import java.awt.BorderLayout; |
44 | 663 | fernando | import java.awt.Component; |
45 | 598 | fernando | import java.awt.Dimension; |
46 | import java.awt.FlowLayout; |
||
47 | import java.util.HashMap; |
||
48 | |||
49 | import javax.swing.BorderFactory; |
||
50 | import javax.swing.ImageIcon; |
||
51 | import javax.swing.JLabel; |
||
52 | import javax.swing.JPanel; |
||
53 | import javax.swing.JProgressBar; |
||
54 | 10404 | cesar | import javax.swing.SwingConstants; |
55 | 663 | fernando | import javax.swing.border.BevelBorder; |
56 | 598 | fernando | |
57 | 5275 | jaume | import org.apache.log4j.Logger; |
58 | 6623 | cesar | import org.gvsig.gui.beans.controls.IControl; |
59 | 598 | fernando | |
60 | 5275 | jaume | import com.iver.andami.messages.Messages; |
61 | import com.iver.andami.plugins.config.generate.Label; |
||
62 | |||
63 | |||
64 | 598 | fernando | /**
|
65 | 12011 | cesar | * <p>This class contains the status bar. It contains the graphical component,
|
66 | * and the methods to manage it.
|
||
67 | * </p>
|
||
68 | *
|
||
69 | * <p>The status bar is divided in several areas. At the very left, there is
|
||
70 | * an icon and the main status text. There are three icons to show:
|
||
71 | * Info, Warning and Error icons. They can be set together with the main
|
||
72 | * status text using the methods <code>setInfoText()</code>,
|
||
73 | * <code>setWarningText()</code> and <code>setErrorText()</code> (and also with
|
||
74 | * <code>setInfoTextTemporal()</code>, etc). Then, there is a right area which
|
||
75 | * contains labels and other controls. Labels are set in the config.xml files
|
||
76 | * and are visible or not depending on the currently selected Andami window.
|
||
77 | * Controls are associated to extensions, and are enabled/disabled and
|
||
78 | * visible/hidden depending on the associated extension.
|
||
79 | * </p>
|
||
80 | *
|
||
81 | 598 | fernando | */
|
82 | public class NewStatusBar extends JPanel { |
||
83 | 1268 | vcaballero | private static Logger logger = Logger.getLogger(NewStatusBar.class.getName()); |
84 | private static final int INFO = 0; |
||
85 | private static final int WARNING = 1; |
||
86 | private static final int ERROR = 2; |
||
87 | private JLabel lblIcon = null; |
||
88 | private JLabel lblTexto = null; |
||
89 | private boolean contenidoTemporal; |
||
90 | private String textoAnterior; |
||
91 | private int estadoAnterior; |
||
92 | private ImageIcon infoIcon; |
||
93 | private ImageIcon warningIcon; |
||
94 | private ImageIcon errorIcon; |
||
95 | private int estado; |
||
96 | private JProgressBar progressBar = null; |
||
97 | private HashMap idLabel = new HashMap(); |
||
98 | private int[] widthlabels = null; |
||
99 | 6623 | cesar | private HashMap controls = new HashMap(); |
100 | 10404 | cesar | private JPanel controlContainer; |
101 | 598 | fernando | |
102 | 1268 | vcaballero | /**
|
103 | * This is the default constructor
|
||
104 | */
|
||
105 | public NewStatusBar() {
|
||
106 | super();
|
||
107 | initialize(); |
||
108 | infoIcon = new ImageIcon(NewStatusBar.class.getClassLoader() |
||
109 | .getResource("images/info.gif"));
|
||
110 | warningIcon = new ImageIcon(NewStatusBar.class.getClassLoader() |
||
111 | .getResource("images/warning.gif"));
|
||
112 | errorIcon = new ImageIcon(NewStatusBar.class.getClassLoader() |
||
113 | .getResource("images/error.gif"));
|
||
114 | } |
||
115 | 598 | fernando | |
116 | 1268 | vcaballero | /**
|
117 | 12011 | cesar | * This method initializes the status bar. It creates the required
|
118 | * containers and sets the layout.
|
||
119 | 1268 | vcaballero | */
|
120 | private void initialize() { |
||
121 | 10404 | cesar | BorderLayout mainLayout = new BorderLayout(); |
122 | this.setLayout(mainLayout);
|
||
123 | |||
124 | JPanel container1 = new JPanel(); |
||
125 | this.add(container1, BorderLayout.CENTER); |
||
126 | controlContainer = new JPanel(); |
||
127 | this.add(controlContainer, BorderLayout.EAST); |
||
128 | |||
129 | 7346 | maquerol | this.setPreferredSize(new java.awt.Dimension(183,20)); |
130 | this.setSize(new java.awt.Dimension(183,20)); |
||
131 | 1268 | vcaballero | lblIcon = new JLabel(); |
132 | lblTexto = new JLabel(); |
||
133 | 10404 | cesar | lblTexto.setAlignmentX(JLabel.LEFT_ALIGNMENT);
|
134 | lblTexto.setHorizontalAlignment(SwingConstants.LEFT);
|
||
135 | lblTexto.setHorizontalTextPosition(SwingConstants.LEFT);
|
||
136 | 2938 | fjp | |
137 | 10404 | cesar | FlowLayout rightLayout = new FlowLayout(); |
138 | controlContainer.setLayout(rightLayout); |
||
139 | rightLayout.setHgap(1);
|
||
140 | rightLayout.setVgap(2);
|
||
141 | rightLayout.setAlignment(java.awt.FlowLayout.RIGHT); |
||
142 | 1268 | vcaballero | lblIcon.setText("");
|
143 | 2938 | fjp | lblTexto.setText(Messages.getString("StatusBar.Aplicacion_iniciada"));
|
144 | 10404 | cesar | |
145 | FlowLayout leftLayout = new FlowLayout(FlowLayout.LEFT); |
||
146 | leftLayout.setHgap(1);
|
||
147 | leftLayout.setVgap(2);
|
||
148 | container1.setLayout(leftLayout); |
||
149 | container1.add(lblIcon, null);
|
||
150 | container1.add(getProgressBar(), null);
|
||
151 | container1.add(lblTexto, null);
|
||
152 | |||
153 | 1268 | vcaballero | } |
154 | 598 | fernando | |
155 | 1268 | vcaballero | /**
|
156 | 12011 | cesar | * Gets the status bar main text.
|
157 | 1268 | vcaballero | *
|
158 | 12011 | cesar | * @return The status bar main text.
|
159 | * @see #setInfoText(String)
|
||
160 | * @see #setWarningText(String)
|
||
161 | * @see #setErrorText(String)
|
||
162 | * @see #setInfoTextTemporal(String)
|
||
163 | * @see #setWarningTextTemporal(String)
|
||
164 | * @see #setErrorTextTemporal(String)
|
||
165 | 1268 | vcaballero | */
|
166 | public String getStatusText() { |
||
167 | return lblTexto.getText();
|
||
168 | } |
||
169 | 598 | fernando | |
170 | 1268 | vcaballero | /**
|
171 | 12011 | cesar | * Restores the previous contents in the status bar main text,
|
172 | * after the {@link #setInfoTextTemporal(String)}, {@link #setWarningTextTemporal(String)}
|
||
173 | * or {@link #setErrorTextTemporal(String)} have been called.
|
||
174 | *
|
||
175 | * @see #setInfoTextTemporal(String)
|
||
176 | * @see #setWarningTextTemporal(String)
|
||
177 | * @see #setErrorTextTemporal(String)
|
||
178 | 1268 | vcaballero | */
|
179 | public void restaurarTexto() { |
||
180 | contenidoTemporal = false;
|
||
181 | 598 | fernando | |
182 | 1268 | vcaballero | if (estadoAnterior == -1) { |
183 | return;
|
||
184 | } |
||
185 | 598 | fernando | |
186 | 1268 | vcaballero | switch (estadoAnterior) {
|
187 | case INFO:
|
||
188 | setInfoText(textoAnterior); |
||
189 | 598 | fernando | |
190 | 1268 | vcaballero | break;
|
191 | 598 | fernando | |
192 | 1268 | vcaballero | case WARNING:
|
193 | setWarningText(textoAnterior); |
||
194 | 598 | fernando | |
195 | 1268 | vcaballero | break;
|
196 | 598 | fernando | |
197 | 1268 | vcaballero | case ERROR:
|
198 | setErrorText(textoAnterior); |
||
199 | 598 | fernando | |
200 | 1268 | vcaballero | break;
|
201 | } |
||
202 | 598 | fernando | |
203 | 1268 | vcaballero | estadoAnterior = -1;
|
204 | textoAnterior = null;
|
||
205 | } |
||
206 | 598 | fernando | |
207 | 1268 | vcaballero | /**
|
208 | 12011 | cesar | * Sets a temporary information message in the status bar, and changes the
|
209 | * icon to an Info icon. The previous text and icon can be restored using
|
||
210 | * the {@link #restaurarTexto()} method.
|
||
211 | 1268 | vcaballero | *
|
212 | 12011 | cesar | * @param texto The text to set
|
213 | * @see #restaurarTexto()
|
||
214 | 1268 | vcaballero | */
|
215 | public void setInfoTextTemporal(String texto) { |
||
216 | contenidoTemporal = true;
|
||
217 | 598 | fernando | |
218 | 1268 | vcaballero | estadoAnterior = this.estado;
|
219 | this.estado = INFO;
|
||
220 | lblIcon.setIcon(infoIcon); |
||
221 | 598 | fernando | |
222 | 1268 | vcaballero | textoAnterior = getStatusText(); |
223 | lblTexto.setText(texto); |
||
224 | } |
||
225 | 598 | fernando | |
226 | 1268 | vcaballero | /**
|
227 | 12011 | cesar | * Sets a temporary warning message in the status bar, and changes the
|
228 | * icon to a Warning icon. The previous text and icon can be restored using
|
||
229 | * the {@link #restaurarTexto()} method.
|
||
230 | 1268 | vcaballero | *
|
231 | 12011 | cesar | * @param texto The text to set
|
232 | * @see #restaurarTexto()
|
||
233 | 1268 | vcaballero | */
|
234 | public void setWarningTextTemporal(String texto) { |
||
235 | contenidoTemporal = true;
|
||
236 | 598 | fernando | |
237 | 1268 | vcaballero | estadoAnterior = this.estado;
|
238 | this.estado = WARNING;
|
||
239 | lblIcon.setIcon(warningIcon); |
||
240 | 598 | fernando | |
241 | 1268 | vcaballero | textoAnterior = getStatusText(); |
242 | lblTexto.setText(texto); |
||
243 | } |
||
244 | 598 | fernando | |
245 | 1268 | vcaballero | /**
|
246 | 12011 | cesar | * Sets a temporary error message in the status bar, and changes the
|
247 | * icon to an Error icon. The previous text and icon can be restored using
|
||
248 | * the {@link #restaurarTexto()} method.
|
||
249 | 1268 | vcaballero | *
|
250 | 12011 | cesar | * @param texto The text to set
|
251 | * @see #restaurarTexto()
|
||
252 | 1268 | vcaballero | */
|
253 | public void setErrorTextTemporal(String texto) { |
||
254 | contenidoTemporal = true;
|
||
255 | 598 | fernando | |
256 | 1268 | vcaballero | estadoAnterior = this.estado;
|
257 | this.estado = ERROR;
|
||
258 | lblIcon.setIcon(errorIcon); |
||
259 | 598 | fernando | |
260 | 1268 | vcaballero | textoAnterior = getStatusText(); |
261 | lblTexto.setText(texto); |
||
262 | } |
||
263 | 598 | fernando | |
264 | 1268 | vcaballero | /**
|
265 | 12011 | cesar | * Sets a permanent info message in the status bar, and changes the
|
266 | * permanent icon to an Info icon. If there is a temporary message showing
|
||
267 | * at the moment, the message set now is not shown until
|
||
268 | * the {@link #restaurarTexto()} method is called.
|
||
269 | 1268 | vcaballero | *
|
270 | 12011 | cesar | * @param texto The permanent info message to set
|
271 | * @see #restaurarTexto()
|
||
272 | 1268 | vcaballero | */
|
273 | public void setInfoText(String texto) { |
||
274 | if (contenidoTemporal) {
|
||
275 | textoAnterior = texto; |
||
276 | estadoAnterior = INFO; |
||
277 | } else {
|
||
278 | lblTexto.setText(texto); |
||
279 | lblIcon.setIcon(infoIcon); |
||
280 | estado = INFO; |
||
281 | } |
||
282 | } |
||
283 | 2938 | fjp | |
284 | 1268 | vcaballero | /**
|
285 | 12011 | cesar | * Sets a permanent warning message in the status bar, and changes the
|
286 | * permanent icon to a Warning icon. If there is a temporary message showing
|
||
287 | * at the moment, the message set now is not shown until
|
||
288 | * the {@link #restaurarTexto()} method is called.
|
||
289 | 1268 | vcaballero | *
|
290 | 12011 | cesar | * @param texto The permanent warning message to set
|
291 | * @see #restaurarTexto()
|
||
292 | 1268 | vcaballero | */
|
293 | public void setWarningText(String texto) { |
||
294 | if (contenidoTemporal) {
|
||
295 | textoAnterior = texto; |
||
296 | estadoAnterior = WARNING; |
||
297 | } else {
|
||
298 | lblTexto.setText(texto); |
||
299 | lblIcon.setIcon(warningIcon); |
||
300 | estado = WARNING; |
||
301 | } |
||
302 | } |
||
303 | 598 | fernando | |
304 | 1268 | vcaballero | /**
|
305 | 12011 | cesar | * Sets a permanent error message in the status bar, and changes the
|
306 | * permanent icon to an Error icon. If there is a temporary message showing
|
||
307 | * at the moment, the message set now is not shown until
|
||
308 | * the {@link #restaurarTexto()} method is called.
|
||
309 | 1268 | vcaballero | *
|
310 | 12011 | cesar | * @param texto The permanent info message to set
|
311 | * @see #restaurarTexto()
|
||
312 | 1268 | vcaballero | */
|
313 | public void setErrorText(String texto) { |
||
314 | if (contenidoTemporal) {
|
||
315 | textoAnterior = texto; |
||
316 | estadoAnterior = ERROR; |
||
317 | } else {
|
||
318 | lblTexto.setText(texto); |
||
319 | lblIcon.setIcon(errorIcon); |
||
320 | estado = ERROR; |
||
321 | } |
||
322 | } |
||
323 | 598 | fernando | |
324 | 1268 | vcaballero | /**
|
325 | 12011 | cesar | * If <code>p</code> is a value between 0 and 99, it shows a progress bar
|
326 | * in the left area of the status bar, and sets the specified progress.
|
||
327 | * If <code>p</code> is bigger than 99, it hides the progress bar.
|
||
328 | 1268 | vcaballero | *
|
329 | 12011 | cesar | * @param p The progress to set in the progress bar. If it is bigger
|
330 | * than 99, the task will be considered to be finished, and the
|
||
331 | * progress bar will be hidden.
|
||
332 | 1268 | vcaballero | */
|
333 | public void setProgress(int p) { |
||
334 | if (p < 100) { |
||
335 | getProgressBar().setValue(p); |
||
336 | getProgressBar().setVisible(true);
|
||
337 | } else {
|
||
338 | getProgressBar().setVisible(false);
|
||
339 | } |
||
340 | 598 | fernando | |
341 | 1268 | vcaballero | getProgressBar().repaint(); |
342 | } |
||
343 | 6860 | jaume | |
344 | 12011 | cesar | /**
|
345 | * Sets a label-set to be shown in the status bar. This method it is not
|
||
346 | * intended to be used directly, because the set will be overwritten when the selected
|
||
347 | * window changes. Use {@link MainFrame#setStatusBarLabels(Class, Label[])}
|
||
348 | * to permanently associate a label set with a window.
|
||
349 | *
|
||
350 | * @param labels The labels to set.
|
||
351 | * @see MainFrame#setStatusBarLabels(Class, Label[])
|
||
352 | */
|
||
353 | 1268 | vcaballero | public void setLabelSet(Label[] labels) { |
354 | 6614 | cesar | removeAllLabels(); |
355 | 1268 | vcaballero | idLabel.clear(); |
356 | |||
357 | for (int i = 0; i < labels.length; i++) { |
||
358 | JLabel lbl = new JLabel(); |
||
359 | lbl.setPreferredSize(new Dimension(labels[i].getSize(), |
||
360 | 7346 | maquerol | this.getHeight() - 2)); |
361 | lbl.setSize(new Dimension(labels[i].getSize(), this.getHeight() - 2)); |
||
362 | 1268 | vcaballero | lbl.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); |
363 | 10404 | cesar | controlContainer.add(lbl); |
364 | 1268 | vcaballero | |
365 | /* if (i != labels.length - 1){
|
||
366 | this.add(new JSeparator(JSeparator.VERTICAL));
|
||
367 | }
|
||
368 | */
|
||
369 | idLabel.put(labels[i].getId(), lbl); |
||
370 | } |
||
371 | |||
372 | JLabel[] configlabels = (JLabel[]) idLabel.values().toArray(new JLabel[0]); |
||
373 | widthlabels = new int[configlabels.length]; |
||
374 | |||
375 | for (int i = 0; i < labels.length; i++) { |
||
376 | widthlabels[i] = configlabels[i].getWidth(); |
||
377 | } |
||
378 | 6614 | cesar | |
379 | this.repaint();
|
||
380 | 1268 | vcaballero | } |
381 | 6860 | jaume | |
382 | 1268 | vcaballero | /**
|
383 | 12011 | cesar | * Hides the empty labels and adjust the space in the bar.
|
384 | 1268 | vcaballero | */
|
385 | public void ajustar() { |
||
386 | if (widthlabels == null) { |
||
387 | return;
|
||
388 | } |
||
389 | |||
390 | int ws = this.getWidth(); |
||
391 | |||
392 | JLabel[] labels = (JLabel[]) idLabel.values().toArray(new JLabel[0]); |
||
393 | |||
394 | /* double total = 1;
|
||
395 | for (int i = 0; i < widthlabels.length; i++) {
|
||
396 | if (labels[i].getText().compareTo("") != 0) {
|
||
397 | total += widthlabels[i];
|
||
398 | }
|
||
399 | }
|
||
400 | double p = (ws - lblTexto.getWidth() - 20) / total;
|
||
401 | */
|
||
402 | for (int i = 0; i < labels.length; i++) { |
||
403 | //if (labels[i] instanceof JLabel){
|
||
404 | JLabel label = (JLabel) labels[i]; |
||
405 | |||
406 | if (label.getText().compareTo("") != 0) { |
||
407 | label.setVisible(true);
|
||
408 | label.setPreferredSize(new Dimension((int) (widthlabels[i]), |
||
409 | 7346 | maquerol | this.getHeight() - 2)); |
410 | 1268 | vcaballero | } else {
|
411 | label.setVisible(false);
|
||
412 | |||
413 | //label.setPreferredSize(new Dimension(0,this.getHeight()));
|
||
414 | } |
||
415 | |||
416 | //}
|
||
417 | } |
||
418 | } |
||
419 | |||
420 | /**
|
||
421 | 12011 | cesar | * Removes all the labels from the status bar. It does not remove the
|
422 | * controls.
|
||
423 | 1268 | vcaballero | */
|
424 | 6614 | cesar | private void removeAllLabels() { |
425 | 10404 | cesar | Component[] controlArray = controlContainer.getComponents(); |
426 | 6614 | cesar | |
427 | for (int i = 0; i < controlArray.length; i++) { |
||
428 | 11099 | cesar | if ((controlArray[i] != lblIcon) && (controlArray[i] != lblTexto) && !(controlArray[i] instanceof IControl) && (controlArray[i] instanceof JLabel)) { |
429 | 10404 | cesar | controlContainer.remove(controlArray[i]); |
430 | 6614 | cesar | } |
431 | } |
||
432 | } |
||
433 | 6860 | jaume | |
434 | |||
435 | 6614 | cesar | /**
|
436 | * Removes all the controls (including labels) from the status bar.
|
||
437 | */
|
||
438 | 6588 | cesar | private void removeAllControls() { |
439 | 10404 | cesar | Component[] controlArray = controlContainer.getComponents(); |
440 | 1268 | vcaballero | |
441 | 6588 | cesar | for (int i = 0; i < controlArray.length; i++) { |
442 | if ((controlArray[i] != lblIcon) && (controlArray[i] != lblTexto)) {
|
||
443 | 10404 | cesar | controlContainer.remove(controlArray[i]); |
444 | 663 | fernando | } |
445 | } |
||
446 | } |
||
447 | |||
448 | /**
|
||
449 | 12011 | cesar | * Sets the text of the provided label.
|
450 | 1268 | vcaballero | *
|
451 | 12011 | cesar | * @param id The ID of the label to modify. It is defined in the
|
452 | * config.xml file
|
||
453 | * @param msg The message to show in the label
|
||
454 | 1268 | vcaballero | */
|
455 | public void setMessage(String id, String msg) { |
||
456 | JLabel lbl = (JLabel) idLabel.get(id); |
||
457 | 598 | fernando | |
458 | 1268 | vcaballero | if (lbl == null) { |
459 | 9490 | fjp | // logger.debug("no label called " + id);
|
460 | 10485 | cesar | // try with controls
|
461 | try {
|
||
462 | IControl control = (IControl) controls.get(id); |
||
463 | if (control!=null) control.setValue(msg); |
||
464 | } |
||
465 | catch (ClassCastException ex) {} |
||
466 | 1268 | vcaballero | } else {
|
467 | lbl.setText(msg); |
||
468 | } |
||
469 | ajustar(); |
||
470 | } |
||
471 | 6860 | jaume | |
472 | 6623 | cesar | /**
|
473 | * Sets the control identified by 'id' with the provided value.
|
||
474 | 6860 | jaume | *
|
475 | 12011 | cesar | * @param id The ID of the control to modify
|
476 | * @param value The value to set in the control
|
||
477 | 6623 | cesar | */
|
478 | public void setControlValue(String id, String value) { |
||
479 | IControl control = (IControl) controls.get(id); |
||
480 | if (control!=null) { |
||
481 | control.setValue(value); |
||
482 | } |
||
483 | else {
|
||
484 | logger.debug("NewStatusBar -- no control called " + id);
|
||
485 | } |
||
486 | } |
||
487 | 598 | fernando | |
488 | 1268 | vcaballero | /**
|
489 | 12011 | cesar | * This method initializes the progressBar and gets it.
|
490 | 1268 | vcaballero | *
|
491 | * @return javax.swing.JProgressBar
|
||
492 | */
|
||
493 | private JProgressBar getProgressBar() { |
||
494 | if (progressBar == null) { |
||
495 | progressBar = new JProgressBar(); |
||
496 | 2112 | fernando | progressBar.setPreferredSize(new java.awt.Dimension(100, 14)); |
497 | 1268 | vcaballero | progressBar.setVisible(false);
|
498 | progressBar.setMinimum(0);
|
||
499 | progressBar.setMaximum(100);
|
||
500 | 2112 | fernando | progressBar.setValue(50);
|
501 | 1268 | vcaballero | } |
502 | 598 | fernando | |
503 | 1268 | vcaballero | return progressBar;
|
504 | } |
||
505 | |||
506 | 598 | fernando | /**
|
507 | 1268 | vcaballero | * DOCUMENT ME!
|
508 | *
|
||
509 | 598 | fernando | * @param d
|
510 | 12011 | cesar | * @deprecated
|
511 | 598 | fernando | */
|
512 | public void setFixedLabelWidth(double d) { |
||
513 | 10404 | cesar | // lblTexto.setPreferredSize(new Dimension((int) d, lblTexto.getHeight()));
|
514 | 598 | fernando | } |
515 | 6860 | jaume | |
516 | 6623 | cesar | /**
|
517 | * Adds a control to the status bar
|
||
518 | 12011 | cesar | *
|
519 | * @param id The ID of the control, useful to later retrive it or set its value
|
||
520 | * @param control The control to add
|
||
521 | 6623 | cesar | */
|
522 | public void addControl(String id, Component control) { |
||
523 | 10404 | cesar | controlContainer.add(control); |
524 | 6623 | cesar | if (!controls.containsKey(control.getName()))
|
525 | controls.put(control.getName(), control); |
||
526 | else
|
||
527 | logger.debug("NewStatusBar.addControl -- control 'id' already exists"+ id);
|
||
528 | } |
||
529 | 6860 | jaume | |
530 | 6623 | cesar | /**
|
531 | * Gets a control from the status bar
|
||
532 | 12011 | cesar | *
|
533 | * @param id The ID of the control to get
|
||
534 | 6623 | cesar | */
|
535 | public Component getControl(String id, Component control) { |
||
536 | return (Component) controls.get(id); |
||
537 | } |
||
538 | 598 | fernando | } // @jve:decl-index=0:visual-constraint="10,10" |