1
2
3
4
5
6
7
8 package hoplugins.seriesstats.ui;
9
10 import hoplugins.Commons;
11 import hoplugins.SeriesStats;
12
13 import hoplugins.seriesstats.RatingsPanel;
14
15 import plugins.ITabellenVerlaufEintrag;
16
17 import java.awt.BorderLayout;
18 import java.awt.Dimension;
19 import java.awt.GridBagConstraints;
20 import java.awt.GridBagLayout;
21 import java.awt.Insets;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24
25 import java.util.Collections;
26 import java.util.Enumeration;
27 import java.util.Vector;
28
29 import javax.swing.JComboBox;
30 import javax.swing.JPanel;
31
32
33 /***
34 * DOCUMENT ME!
35 *
36 * @author Mirtillo To change the template for this generated type comment go to
37 * Window>Preferences>Java>Code Generation>Code and Comments
38 */
39 public class RatingPanelTab extends JPanel implements ActionListener {
40
41
42 private JComboBox JCBDate1;
43 private JComboBox JCBDate2;
44
45
46 private JComboBox JCBTeam1;
47 private JComboBox JCBTeam2;
48 private RatingsPanel RatingRatings;
49
50
51
52 /***
53 * Creates a new RatingPanelTab object.
54 */
55 public RatingPanelTab() {
56 JPanel jPanel1 = Commons.getModel().getGUI().createImagePanel();
57
58 GridBagLayout jPanel1Layout = new GridBagLayout();
59 jPanel1Layout.columnWidths = new int[]{1, 1, 1, 1, 1, 1};
60 jPanel1Layout.rowHeights = new int[]{1, 1, 1, 1, 1, 1};
61 jPanel1Layout.columnWeights = new double[]{0.05, 0.2, 0.01, 0.01, 0.2, 0.05};
62 jPanel1Layout.rowWeights = new double[]{0.01, 0.01, 0.01, 0.05, 0.001, 0.25};
63
64 jPanel1.setLayout(jPanel1Layout);
65
66 this.JCBTeam1 = new JComboBox();
67 this.JCBTeam1.setMaximumRowCount(8);
68 this.JCBTeam1.setPreferredSize(new Dimension(200, 25));
69 this.JCBTeam1.addActionListener(this);
70 jPanel1.add(this.JCBTeam1,
71 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTH,
72 GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0),
73 0, 0));
74
75 this.JCBTeam2 = new JComboBox();
76 this.JCBTeam2.setMaximumRowCount(8);
77 this.JCBTeam2.setPreferredSize(new Dimension(200, 25));
78 this.JCBTeam2.addActionListener(this);
79 jPanel1.add(this.JCBTeam2,
80 new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTH,
81 GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0),
82 0, 0));
83
84 this.JCBDate1 = new JComboBox();
85 this.JCBDate1.setMaximumRowCount(8);
86 this.JCBDate1.setPreferredSize(new Dimension(200, 25));
87 this.JCBDate1.addActionListener(this);
88 jPanel1.add(this.JCBDate1,
89 new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH,
90 GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0),
91 0, 0));
92
93 this.JCBDate2 = new JComboBox();
94 this.JCBDate2.setMaximumRowCount(8);
95 this.JCBDate2.setPreferredSize(new Dimension(200, 25));
96 this.JCBDate2.addActionListener(this);
97 jPanel1.add(this.JCBDate2,
98 new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH,
99 GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0),
100 0, 0));
101
102 this.RatingRatings = new RatingsPanel(Commons.getModel());
103 jPanel1.add(this.RatingRatings.getPanel(),
104 new GridBagConstraints(1, 4, 4, 1, 0.0, 0.0, GridBagConstraints.CENTER,
105 GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
106
107 setLayout(new BorderLayout());
108 add(jPanel1, BorderLayout.CENTER);
109
110 RefreshTeamBox();
111 }
112
113
114
115 /***
116 * DOCUMENT ME!
117 *
118 * @param event
119 */
120 public void actionPerformed(ActionEvent event) {
121 if (event.getSource().equals(JCBTeam1) || event.getSource().equals(JCBTeam2)) {
122 updateDateCombos();
123 refreshPanelBewertung();
124 }
125
126 if ((event.getSource().equals(JCBDate1) || event.getSource().equals(JCBDate2))
127 && (JCBDate1.getItemCount() > 1)
128 && (JCBDate2.getItemCount() > 1)) {
129 refreshPanelBewertung();
130 }
131 }
132
133 /***
134 * TODO Missing Method Documentation
135 */
136 private void RefreshTeamBox() {
137 try {
138 this.JCBTeam1.removeActionListener(this);
139 this.JCBTeam2.removeActionListener(this);
140
141
142 this.JCBTeam1.removeAllItems();
143 this.JCBTeam2.removeAllItems();
144
145
146 int ligaId = Commons.getModel().getXtraDaten().getLeagueLevelUnitID();
147 int season = Commons.getModel().getBasics().getSeason();
148
149 System.out.println(ligaId + " " + season);
150
151 ITabellenVerlaufEintrag[] dummy = Commons.getModel().getSpielplan(ligaId, season)
152 .getVerlauf().getEintraege();
153
154
155 Vector data = new Vector();
156
157 for (int i = 0; i < dummy.length; i++) {
158 data.add(new String(dummy[i].getTeamName()));
159 }
160
161 Collections.sort(data);
162
163
164 for (Enumeration e = data.elements(); e.hasMoreElements();) {
165 String TeamName = (String) e.nextElement();
166 this.JCBTeam1.addItem(TeamName);
167 this.JCBTeam2.addItem(TeamName);
168 }
169
170 this.JCBTeam1.addActionListener(this);
171 this.JCBTeam2.addActionListener(this);
172 } catch (Exception e) {
173 if (true) {
174 SeriesStats.getIDB().append("---ooo---");
175 SeriesStats.getIDB().append(e);
176 }
177 }
178 }
179
180 /***
181 * TODO Missing Method Documentation
182 */
183 private void refreshPanelBewertung() {
184
185 System.out.println("Repainting Called");
186 }
187
188 /***
189 * TODO Missing Method Documentation
190 */
191 private void updateDateCombos() {
192 String d1 = "";
193 String d2 = "";
194
195 if ((JCBDate1.getItemCount() > 0) && (JCBDate2.getItemCount() > 0)) {
196 d1 = JCBDate1.getSelectedItem().toString();
197 d2 = JCBDate2.getSelectedItem().toString();
198 }
199
200 if ((JCBTeam1.getItemCount() > 0) && (JCBTeam2.getItemCount() > 0)) {
201 JCBDate1.removeAllItems();
202 JCBDate2.removeAllItems();
203
204
205
206 Vector tmd = new Vector();
207
208 for (int i = 0; (tmd != null) && (i < tmd.size()); i++) {
209 Vector v = (Vector) tmd.elementAt(i);
210 JCBDate1.addItem(v.elementAt(0));
211 }
212
213 JCBDate1.addItem("(" + Commons.getModel().getResource().getProperty("Durchschnitt")
214 + ")");
215 JCBDate1.addItem("(" + Commons.getModel().getResource().getProperty("Minimal") + ")");
216 JCBDate1.addItem("(" + Commons.getModel().getResource().getProperty("Maximal") + ")");
217
218
219 tmd = new Vector();
220
221 for (int i = 0; (tmd != null) && (i < tmd.size()); i++) {
222 Vector v = (Vector) tmd.elementAt(i);
223 JCBDate2.addItem(v.elementAt(0));
224 }
225
226 JCBDate2.addItem("(" + Commons.getModel().getResource().getProperty("Durchschnitt")
227 + ")");
228 JCBDate2.addItem("(" + Commons.getModel().getResource().getProperty("Maximal") + ")");
229 JCBDate2.addItem("(" + Commons.getModel().getResource().getProperty("Minimal") + ")");
230
231 if ((JCBDate1.getItemCount() > 0) && (JCBDate2.getItemCount() > 0)) {
232 JCBDate1.setSelectedItem(d1);
233 JCBDate2.setSelectedItem(d2);
234 }
235 }
236 }
237 }