View Javadoc

1   // %2597556203:hoplugins.trainingExperience.ui.model%
2   package hoplugins.trainingExperience.ui.model;
3   
4   import hoplugins.Commons;
5   
6   import hoplugins.commons.utils.PluginProperty;
7   
8   import hoplugins.trainingExperience.vo.SkillChange;
9   
10  import java.util.List;
11  
12  import javax.swing.table.AbstractTableModel;
13  
14  
15  /***
16   * TableModel representing skill changes for individual players.
17   *
18   * @author NetHyperon
19   *
20   * @see hoplugins.trainingExperience.vo.SkillChange
21   */
22  public class ChangesTableModel extends AbstractTableModel {
23      //~ Instance fields ----------------------------------------------------------------------------
24  
25      private List values;
26      private String[] colNames = new String[7];
27  
28      //~ Constructors -------------------------------------------------------------------------------
29  
30      /***
31       * Creates a new ChangesTableModel object.
32       *
33       * @param values List of values to show in table.
34       */
35      public ChangesTableModel(List values) {
36          super();
37          this.colNames[0] = PluginProperty.getString("Week"); //$NON-NLS-1$
38          this.colNames[1] = Commons.getModel().getResource().getProperty("Season"); //$NON-NLS-1$
39          this.colNames[2] = Commons.getModel().getResource().getProperty("Spieler"); //$NON-NLS-1$
40          this.colNames[3] = PluginProperty.getString("Skill"); //$NON-NLS-1$
41          this.colNames[4] = PluginProperty.getString("TO"); //$NON-NLS-1$
42          this.colNames[5] = "isOld"; //$NON-NLS-1$
43          this.colNames[6] = "playerId"; //$NON-NLS-1$
44  
45          this.values = values;
46      }
47  
48      //~ Methods ------------------------------------------------------------------------------------
49  
50      /***
51       * @see javax.swing.table.TableModel#getColumnCount()
52       */
53      public int getColumnCount() {
54          return colNames.length;
55      }
56  
57      /***
58       * @see javax.swing.table.TableModel#getColumnName(int)
59       */
60      public String getColumnName(int column) {
61          return colNames[column];
62      }
63  
64      /***
65       * @see javax.swing.table.TableModel#getRowCount()
66       */
67      public int getRowCount() {
68          return values.size();
69      }
70  
71      /***
72       * @see javax.swing.table.TableModel#getValueAt(int, int)
73       */
74      public Object getValueAt(int rowIndex, int columnIndex) {
75          SkillChange change = (SkillChange) values.get(rowIndex);
76  
77          switch (columnIndex) {
78              case 0:
79                  return Integer.toString(change.getSkillup().getHtWeek());
80  
81              case 1:
82                  return Integer.toString(change.getSkillup().getHtSeason());
83  
84              case 2:
85                  return change.getPlayer().getName();
86  
87              case 3:
88                  return Integer.toString(change.getSkillup().getType());
89  
90              case 4:
91                  return Commons.getModel().getHelper().getNameForSkill(change.getSkillup().getValue(),
92                                                                        true);
93  
94              case 5:
95                  return Boolean.valueOf(change.getPlayer().isOld());
96  
97              case 6:
98                  return Integer.toString(change.getPlayer().getSpielerID());
99  
100             default:
101                 return ""; //$NON-NLS-1$
102         }
103     }
104 }