1
2 package hoplugins.teamAnalyzer.ui.component;
3
4 import hoplugins.Commons;
5
6 import hoplugins.commons.ui.NumberTextField;
7 import hoplugins.commons.utils.PluginProperty;
8
9 import plugins.IMatchDetails;
10
11 import java.awt.BorderLayout;
12 import java.awt.event.ActionEvent;
13 import java.awt.event.ActionListener;
14
15 import javax.swing.JButton;
16 import javax.swing.JLabel;
17 import javax.swing.JPanel;
18
19
20 /***
21 * A panel that allows the user to download a new match from HO
22 *
23 * @author <a href=mailto:draghetto@users.sourceforge.net>Massimiliano Amato</a>
24 */
25 public class DownloadPanel extends JPanel {
26
27
28 /*** Download Button */
29 JButton downloadButton = new JButton(PluginProperty.getString("Download"));
30
31 /*** Description label */
32 JLabel jLabel1 = new JLabel();
33
34 /*** Status label */
35 JLabel status = new JLabel();
36
37 /*** The matchid text field */
38 NumberTextField matchId = new NumberTextField(8);
39
40
41
42 /***
43 * Constructs a new instance.
44 */
45 public DownloadPanel() {
46 jbInit();
47 }
48
49
50
51 /***
52 * Initializes the state of this instance.
53 */
54 private void jbInit() {
55 jLabel1.setText(PluginProperty.getString("Download.Desc"));
56 setLayout(new BorderLayout());
57 add(jLabel1, BorderLayout.NORTH);
58 add(downloadButton, BorderLayout.CENTER);
59 add(matchId, BorderLayout.WEST);
60 add(status, BorderLayout.SOUTH);
61
62 downloadButton.addActionListener(new ActionListener() {
63 public void actionPerformed(ActionEvent e) {
64 int id = matchId.getValue();
65
66 if (id == 0) {
67 status.setText(PluginProperty.getString("Download.Error"));
68
69 return;
70 }
71
72 Commons.getModel().getHelper().downloadMatchData(id);
73
74 IMatchDetails md = Commons.getModel().getMatchDetails(id);
75
76 if (md.getFetchDatum() != null) {
77 status.setText(PluginProperty.getString("Download.Ok"));
78 matchId.setText("");
79 } else {
80 status.setText(PluginProperty.getString("Download.Error"));
81 }
82 }
83 });
84 }
85 }