View Javadoc

1   // %1126721451323:hoplugins.trainingExperience.ui.model%
2   package hoplugins.trainingExperience.ui.model;
3   
4   import hoplugins.commons.utils.PluginProperty;
5   
6   import plugins.IHOMiniModel;
7   
8   import java.util.Vector;
9   
10  import javax.swing.table.AbstractTableModel;
11  
12  
13  /***
14   * Bast training table model
15   */
16  public abstract class AbstractTrainingsTableModel extends AbstractTableModel {
17      //~ Instance fields ----------------------------------------------------------------------------
18  
19      /*** HO Model */
20      protected IHOMiniModel p_IHMM_miniModel;
21  
22      /*** Vector of ITrainingPerPlayer object */
23      protected Vector p_V_data;
24  
25      /*** Vector of ITrainingPerWeek object */
26      protected Vector p_V_trainingsVector;
27      private String[] columnNames;
28  
29      //~ Constructors -------------------------------------------------------------------------------
30  
31      /***
32       * Creates a new AbstractTrainingsTableModel object.
33       *
34       * @param miniModel
35       */
36      public AbstractTrainingsTableModel(IHOMiniModel miniModel) {
37          p_V_data = new Vector();
38          p_V_trainingsVector = new Vector();
39          p_IHMM_miniModel = miniModel;
40          columnNames = new String[4];
41          columnNames[0] = PluginProperty.getString("Week"); //$NON-NLS-1$
42          columnNames[1] = miniModel.getResource().getProperty("Season"); //$NON-NLS-1$
43          columnNames[2] = PluginProperty.getString("Type"); //$NON-NLS-1$
44          columnNames[3] = miniModel.getResource().getProperty("Intensitaet"); //$NON-NLS-1$
45      }
46  
47      //~ Methods ------------------------------------------------------------------------------------
48  
49      /***
50       * Method that returns if a cell is editable or not
51       *
52       * @param row
53       * @param column
54       *
55       * @return
56       */
57      public boolean isCellEditable(int row, int column) {
58          return (column == 2) || (column == 3);
59      }
60  
61      /***
62       * DOCUMENT ME!
63       *
64       * @param column
65       *
66       * @return
67       */
68      public Class getColumnClass(int column) {
69          return getValueAt(0, column).getClass();
70      }
71  
72      /***
73       * Return number of columns
74       *
75       * @return
76       */
77      public int getColumnCount() {
78          return columnNames.length;
79      }
80  
81      /***
82       * Return header for the specified column
83       *
84       * @param column
85       *
86       * @return column header
87       */
88      public String getColumnName(int column) {
89          return columnNames[column];
90      }
91  
92      /***
93       * Returns row number
94       *
95       * @return
96       */
97      public int getRowCount() {
98          return p_V_data.size();
99      }
100 
101     /***
102      * Method that returns the Training vector
103      *
104      * @return actual training vector
105      */
106     public Vector getTrainingsData() {
107         return p_V_trainingsVector;
108     }
109 
110     /***
111      * Returns the cell value
112      *
113      * @param row
114      * @param column
115      *
116      * @return Object representing the cell value
117      */
118     public Object getValueAt(int row, int column) {
119         Object[] aobj = (Object[]) p_V_data.get(row);
120 
121         return aobj[column];
122     }
123 
124     /***
125      * Method to be called to populate the table with the data from HO API
126      */
127     public abstract void populate();
128 }