21 |
21 |
*/
|
22 |
22 |
package org.gvsig.andami.ui.mdiFrame;
|
23 |
23 |
|
24 |
|
import java.awt.BorderLayout;
|
25 |
24 |
import java.awt.Component;
|
26 |
25 |
import java.awt.Dimension;
|
27 |
26 |
import java.awt.FlowLayout;
|
|
27 |
import java.awt.LayoutManager;
|
28 |
28 |
import java.util.HashMap;
|
|
29 |
import java.util.Map;
|
29 |
30 |
|
30 |
31 |
import javax.swing.BorderFactory;
|
31 |
32 |
import javax.swing.ImageIcon;
|
... | ... | |
81 |
82 |
private ImageIcon errorIcon;
|
82 |
83 |
private int estado;
|
83 |
84 |
private JProgressBar progressBar = null;
|
84 |
|
private HashMap idLabel = new HashMap();
|
|
85 |
private Map<String, JLabel> idLabel = new HashMap<String, JLabel>();
|
85 |
86 |
private int[] widthlabels = null;
|
86 |
|
private HashMap controls = new HashMap();
|
|
87 |
private Map<String, Component> controls = new HashMap<String, Component>();
|
87 |
88 |
private JPanel controlContainer;
|
88 |
89 |
private JTasksStatus tasksStatus = null;
|
89 |
90 |
|
... | ... | |
96 |
97 |
infoIcon = PluginServices.getIconTheme().get("info-icon");
|
97 |
98 |
warningIcon = PluginServices.getIconTheme().get("warning-icon");
|
98 |
99 |
errorIcon = PluginServices.getIconTheme().get("error-icon");
|
99 |
|
|
100 |
100 |
}
|
101 |
101 |
|
102 |
102 |
/**
|
... | ... | |
104 |
104 |
* containers and sets the layout.
|
105 |
105 |
*/
|
106 |
106 |
private void initialize() {
|
107 |
|
BorderLayout mainLayout = new BorderLayout();
|
|
107 |
LayoutManager mainLayout = new FlowLayout(FlowLayout.TRAILING, 0, 2);
|
108 |
108 |
this.setLayout(mainLayout);
|
109 |
109 |
|
110 |
|
JPanel panelRight = new JPanel();
|
111 |
|
panelRight.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
|
|
110 |
JPanel panelRight = new JPanel(new FlowLayout(FlowLayout.RIGHT, 1, 0));
|
112 |
111 |
|
113 |
|
controlContainer = new JPanel();
|
114 |
|
controlContainer.setLayout(new FlowLayout(FlowLayout.RIGHT, 1, 2));
|
|
112 |
controlContainer = new JPanel(new FlowLayout(FlowLayout.RIGHT, 1, 0));
|
115 |
113 |
panelRight.add(controlContainer);
|
116 |
114 |
panelRight.add(getTasksStatus());
|
117 |
115 |
|
118 |
|
this.setPreferredSize(new Dimension(183, 20));
|
119 |
|
this.setSize(new Dimension(183, 20));
|
120 |
116 |
lblIcon = new JLabel();
|
121 |
117 |
lblTexto = new JLabel();
|
122 |
118 |
lblTexto.setAlignmentX(JLabel.LEFT_ALIGNMENT);
|
123 |
119 |
lblTexto.setHorizontalAlignment(SwingConstants.LEFT);
|
124 |
120 |
lblTexto.setHorizontalTextPosition(SwingConstants.LEFT);
|
125 |
|
|
|
121 |
lblTexto.setVerticalAlignment(SwingConstants.CENTER);
|
|
122 |
lblTexto.setVerticalTextPosition(SwingConstants.CENTER);
|
126 |
123 |
lblIcon.setText("");
|
127 |
124 |
lblTexto.setText(Messages.getString("StatusBar.Aplicacion_iniciada"));
|
128 |
125 |
|
129 |
126 |
JPanel panelLeft = new JPanel();
|
130 |
|
panelLeft.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 2));
|
131 |
|
panelLeft.add(lblTexto, null);
|
132 |
|
panelLeft.add(lblIcon, null);
|
133 |
|
panelLeft.add(getProgressBar(), null);
|
|
127 |
panelLeft.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 0));
|
|
128 |
panelLeft.add(lblTexto);
|
|
129 |
panelLeft.add(lblIcon);
|
|
130 |
panelLeft.add(getProgressBar());
|
134 |
131 |
|
135 |
|
this.add(panelLeft, BorderLayout.CENTER);
|
136 |
|
this.add(panelRight, BorderLayout.EAST);
|
|
132 |
this.add(panelLeft);
|
|
133 |
this.add(panelRight);
|
|
134 |
// this.add(panelLeft, BorderLayout.CENTER);
|
|
135 |
// this.add(panelRight, BorderLayout.EAST);
|
137 |
136 |
}
|
138 |
137 |
|
139 |
138 |
/**
|
... | ... | |
353 |
352 |
idLabel.clear();
|
354 |
353 |
|
355 |
354 |
for (int i = 0; i < labels.length; i++) {
|
|
355 |
// Set an initial text so the getPreferredSize works as expected
|
356 |
356 |
JLabel lbl = new JLabel();
|
357 |
|
lbl.setPreferredSize(new Dimension(labels[i].getSize(), this
|
358 |
|
.getHeight() - 2));
|
359 |
|
lbl.setSize(new Dimension(labels[i].getSize(), this.getHeight() - 2));
|
|
357 |
// lbl.setPreferredSize(new Dimension(labels[i].getSize(), lbl
|
|
358 |
// .getPreferredSize().height + 2));
|
|
359 |
// Remove the initial text
|
|
360 |
// lbl.setText(" ");
|
360 |
361 |
lbl.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
|
361 |
362 |
lbl.setName(labels[i].getId());
|
362 |
363 |
controlContainer.add(lbl);
|
... | ... | |
377 |
378 |
widthlabels[i] = configlabels[i].getWidth();
|
378 |
379 |
}
|
379 |
380 |
|
380 |
|
this.repaint();
|
|
381 |
this.validate();
|
381 |
382 |
}
|
382 |
383 |
|
383 |
384 |
/**
|
... | ... | |
388 |
389 |
return;
|
389 |
390 |
}
|
390 |
391 |
|
391 |
|
int ws = this.getWidth();
|
392 |
|
|
393 |
392 |
JLabel[] labels = (JLabel[]) idLabel.values().toArray(new JLabel[0]);
|
394 |
393 |
|
395 |
394 |
/*
|
... | ... | |
402 |
401 |
* double p = (ws - lblTexto.getWidth() - 20) / total;
|
403 |
402 |
*/
|
404 |
403 |
for (int i = 0; i < labels.length; i++) {
|
405 |
|
// if (labels[i] instanceof JLabel){
|
406 |
404 |
JLabel label = (JLabel) labels[i];
|
407 |
405 |
|
408 |
406 |
if (label.getText().compareTo("") != 0) {
|
409 |
407 |
label.setVisible(true);
|
410 |
|
label.setPreferredSize(new Dimension((int) (widthlabels[i]),
|
411 |
|
this.getHeight() - 2));
|
412 |
408 |
} else {
|
413 |
409 |
label.setVisible(false);
|
414 |
|
|
415 |
|
// label.setPreferredSize(new Dimension(0,this.getHeight()));
|
416 |
410 |
}
|
417 |
|
|
418 |
|
// }
|
419 |
411 |
}
|
|
412 |
validate();
|
420 |
413 |
}
|
421 |
414 |
|
422 |
415 |
/**
|
... | ... | |
436 |
429 |
}
|
437 |
430 |
|
438 |
431 |
/**
|
439 |
|
* Removes all the controls (including labels) from the status bar.
|
440 |
|
*/
|
441 |
|
private void removeAllControls() {
|
442 |
|
Component[] controlArray = controlContainer.getComponents();
|
443 |
|
|
444 |
|
for (int i = 0; i < controlArray.length; i++) {
|
445 |
|
if ((controlArray[i] != lblIcon) && (controlArray[i] != lblTexto)) {
|
446 |
|
controlContainer.remove(controlArray[i]);
|
447 |
|
}
|
448 |
|
}
|
449 |
|
}
|
450 |
|
|
451 |
|
/**
|
452 |
432 |
* Sets the text of the provided label.
|
453 |
433 |
*
|
454 |
434 |
* @param id
|
... | ... | |
501 |
481 |
private JProgressBar getProgressBar() {
|
502 |
482 |
if (progressBar == null) {
|
503 |
483 |
progressBar = new JProgressBar();
|
504 |
|
progressBar.setPreferredSize(new java.awt.Dimension(100, 14));
|
|
484 |
// progressBar.setPreferredSize(new java.awt.Dimension(100, 14));
|
505 |
485 |
progressBar.setVisible(false);
|
506 |
486 |
progressBar.setMinimum(0);
|
507 |
487 |
progressBar.setMaximum(100);
|