1
2
3
4
5
6
7
8
9
10
11
12 package ca.spaz.cron.summary;
13
14 import java.awt.*;
15 import java.util.*;
16 import java.util.List;
17
18 import javax.swing.*;
19
20 import com.aimedia.ui.*;
21
22
23 /***
24 * @deprecated No longer needed for UI
25 * @author Chris Rose
26 */
27 public class SimpleSummaryContent extends JPanel implements IValueListUser {
28
29 private int columns;
30 private GridBagConstraints gclbl;
31 private GridBagConstraints gcval;
32 private SummaryPanel data;
33
34 public SimpleSummaryContent(SummaryPanel dataSource) {
35 super();
36 this.data = dataSource;
37 setLayout(new GridBagLayout());
38 gclbl = new GridBagConstraints();
39 gcval = new GridBagConstraints();
40 gclbl.ipadx=4;
41 gcval.ipadx=4;
42 gclbl.insets=new Insets(2,2,2,6);
43 gcval.insets=new Insets(2,2,6,2);
44 gclbl.anchor=GridBagConstraints.WEST;
45 gcval.anchor=GridBagConstraints.EAST;
46 gclbl.weightx=1;
47 gcval.weightx=0.9;
48 }
49
50
51
52
53 public void setValueList(List valueNames) {
54 columns = valueNames.size() > 12 ? 3 : 2;
55 int numlbls = valueNames.size();
56 int nrows = numlbls / columns;
57 if ((numlbls % columns) != 0) {
58 nrows++;
59 }
60 int col = 0;
61 gclbl.gridy = 0;
62 gcval.gridy = 0;
63 removeAll();
64 for (Iterator iter = valueNames.iterator(); iter.hasNext();) {
65 String valueName = (String) iter.next();
66 JLabel vlbl = new JLabel();
67 vlbl.setAlignmentX(JLabel.RIGHT_ALIGNMENT);
68 vlbl.setText(data.getValueText(valueName));
69 add(makeRLabel(valueName), gclbl);
70 add(vlbl, gcval);
71 col+=2;
72 if (col % (2 * columns) == 0) {
73 gcval.gridy++;
74 gclbl.gridy++;
75 }
76 }
77 revalidate();
78 }
79
80 /***
81 * @param key
82 * @return
83 */
84 private JLabel makeRLabel(String key) {
85 String ltxt = data.getLabelText(key);
86 return UIPartFactory.createFieldLabel(ltxt + ":", true);
87 }
88
89 }