View Javadoc

1   // %1955470492:hoplugins.teamAnalyzer.ui%
2   /*
3    * AutoFilterPanel.java
4    *
5    * Created on 20 settembre 2004, 16.12
6    */
7   package hoplugins.teamAnalyzer.ui;
8   
9   import hoplugins.Commons;
10  
11  import hoplugins.commons.ui.NumberTextField;
12  import hoplugins.commons.utils.PluginProperty;
13  
14  import hoplugins.teamAnalyzer.SystemManager;
15  
16  import java.awt.BorderLayout;
17  import java.awt.GridLayout;
18  
19  import javax.swing.JCheckBox;
20  import javax.swing.JLabel;
21  import javax.swing.JPanel;
22  
23  
24  /***
25   * DOCUMENT ME!
26   *
27   * @author samuele.peli
28   */
29  public class AutoFilterPanel extends JPanel {
30      //~ Instance fields ----------------------------------------------------------------------------
31  
32      private JCheckBox awayGames = new JCheckBox();
33      private JCheckBox cup = new JCheckBox();
34      private JCheckBox defeat = new JCheckBox();
35      private JCheckBox draw = new JCheckBox();
36      private JCheckBox friendly = new JCheckBox();
37  
38      //  Filter filter = SystemManager.getFilter();
39      private JCheckBox homeGames = new JCheckBox();
40      private JCheckBox league = new JCheckBox();
41      private JCheckBox qualifier = new JCheckBox();
42      private JCheckBox win = new JCheckBox();
43      private NumberTextField number = new NumberTextField(2);
44  
45      //~ Constructors -------------------------------------------------------------------------------
46  
47      /***
48       * Creates a new instance of AutoFilterPanel
49       */
50      public AutoFilterPanel() {
51          jbInit();
52      }
53  
54      //~ Methods ------------------------------------------------------------------------------------
55  
56      /***
57       * TODO Missing Method Documentation
58       */
59      public void reload() {
60          homeGames.setSelected(SystemManager.getFilter().isHomeGames());
61          awayGames.setSelected(SystemManager.getFilter().isAwayGames());
62          win.setSelected(SystemManager.getFilter().isWin());
63          draw.setSelected(SystemManager.getFilter().isDraw());
64          defeat.setSelected(SystemManager.getFilter().isDefeat());
65          number.setText(SystemManager.getFilter().getNumber() + "");
66          league.setSelected(SystemManager.getFilter().isLeague());
67          cup.setSelected(SystemManager.getFilter().isCup());
68          qualifier.setSelected(SystemManager.getFilter().isQualifier());
69          friendly.setSelected(SystemManager.getFilter().isFriendly());
70      }
71  
72      /***
73       * TODO Missing Method Documentation
74       */
75      protected void setFilter() {
76          SystemManager.getFilter().setAwayGames(awayGames.isSelected());
77          SystemManager.getFilter().setHomeGames(homeGames.isSelected());
78          SystemManager.getFilter().setWin(win.isSelected());
79          SystemManager.getFilter().setDefeat(defeat.isSelected());
80          SystemManager.getFilter().setDraw(draw.isSelected());
81          SystemManager.getFilter().setLeague(league.isSelected());
82          SystemManager.getFilter().setCup(cup.isSelected());
83          SystemManager.getFilter().setFriendly(friendly.isSelected());
84          SystemManager.getFilter().setQualifier(qualifier.isSelected());
85          SystemManager.getFilter().setNumber(number.getValue());
86      }
87  
88      /***
89       * TODO Missing Method Documentation
90       */
91      private void jbInit() {
92          JPanel main = Commons.getModel().getGUI().createImagePanel();
93  
94          main.setLayout(new BorderLayout());
95          setLayout(new BorderLayout());
96          setOpaque(false);
97  
98          JPanel filters = Commons.getModel().getGUI().createImagePanel();
99  
100         filters.setLayout(new GridLayout(11, 2));
101         filters.add(new JLabel(PluginProperty.getString("AutoFilterPanel.Home_Games"))); //$NON-NLS-1$
102         homeGames.setSelected(SystemManager.getFilter().isHomeGames());
103         homeGames.setOpaque(false);
104         filters.add(homeGames);
105 
106         filters.add(new JLabel(PluginProperty.getString("AutoFilterPanel.Away_Games"))); //$NON-NLS-1$
107         awayGames.setSelected(SystemManager.getFilter().isAwayGames());
108         awayGames.setOpaque(false);
109         filters.add(awayGames);
110 
111         filters.add(new JLabel(PluginProperty.getString("AutoFilterPanel.Win_Games"))); //$NON-NLS-1$
112         win.setSelected(SystemManager.getFilter().isWin());
113         win.setOpaque(false);
114         filters.add(win);
115 
116         filters.add(new JLabel(PluginProperty.getString("AutoFilterPanel.Draw_Games"))); //$NON-NLS-1$
117         draw.setSelected(SystemManager.getFilter().isDraw());
118         draw.setOpaque(false);
119         filters.add(draw);
120 
121         filters.add(new JLabel(PluginProperty.getString("AutoFilterPanel.Defeat_Games"))); //$NON-NLS-1$
122         defeat.setSelected(SystemManager.getFilter().isDefeat());
123         defeat.setOpaque(false);
124         filters.add(defeat);
125 
126         filters.add(new JLabel(PluginProperty.getString("AutoFilterPanel.LeagueGame"))); //$NON-NLS-1$
127         league.setSelected(SystemManager.getFilter().isLeague());
128         league.setOpaque(false);
129         filters.add(league);
130 
131         filters.add(new JLabel(PluginProperty.getString("AutoFilterPanel.CupGame"))); //$NON-NLS-1$
132         cup.setSelected(SystemManager.getFilter().isCup());
133         cup.setOpaque(false);
134         filters.add(cup);
135 
136         filters.add(new JLabel(PluginProperty.getString("AutoFilterPanel.FriendlyGame"))); //$NON-NLS-1$
137         friendly.setSelected(SystemManager.getFilter().isFriendly());
138         friendly.setOpaque(false);
139         filters.add(friendly);
140 
141         filters.add(new JLabel(PluginProperty.getString("AutoFilterPanel.QualifierGame"))); //$NON-NLS-1$
142         qualifier.setSelected(SystemManager.getFilter().isQualifier());
143         qualifier.setOpaque(false);
144         filters.add(qualifier);
145 
146         filters.add(new JLabel(PluginProperty.getString("AutoFilterPanel.Max_Number"))); //$NON-NLS-1$
147         number.setText(SystemManager.getFilter().getNumber() + "");
148         filters.add(number);
149 
150         main.add(filters, BorderLayout.NORTH);
151         add(main);
152         reload();
153     }
154 }