View Javadoc

1   // %1126721452119:hoplugins.trainingExperience.ui%
2   package hoplugins.trainingExperience.ui;
3   
4   import hoplugins.trainingExperience.ui.component.IntensityComboBox;
5   import hoplugins.trainingExperience.ui.component.TrainingComboBox;
6   
7   import plugins.IHOMiniModel;
8   
9   import javax.swing.DefaultCellEditor;
10  import javax.swing.JComboBox;
11  import javax.swing.JTable;
12  import javax.swing.table.TableColumn;
13  import javax.swing.table.TableModel;
14  
15  
16  /***
17   * JTable class for past and future trainings table
18   */
19  public class TrainingTable extends JTable {
20      //~ Instance fields ----------------------------------------------------------------------------
21  
22      private IHOMiniModel p_IHMM_HOMiniModel;
23  
24      //~ Constructors -------------------------------------------------------------------------------
25  
26      /***
27       * Creates a new TrainingTable object.
28       *
29       * @param arg0 tableModel
30       * @param miniModel HO MOdel
31       */
32      public TrainingTable(TableModel arg0, IHOMiniModel miniModel) {
33          super(arg0);
34          p_IHMM_HOMiniModel = null;
35          p_IHMM_HOMiniModel = miniModel;
36          setComboBoxEditor();
37      }
38  
39      //~ Methods ------------------------------------------------------------------------------------
40  
41      /***
42       * Initiates combo box and editor
43       */
44      private void setComboBoxEditor() {
45          // Sets the combo box for selecting the training type
46          JComboBox comboBox = new TrainingComboBox();
47          TableColumn column = getColumnModel().getColumn(2);
48  
49          column.setCellEditor(new DefaultCellEditor(comboBox));
50          column.setPreferredWidth(120);
51  
52          //		Sets the combo box for selecting the intensity
53          JComboBox intensiBox = new IntensityComboBox();
54          TableColumn column2 = getColumnModel().getColumn(3);
55  
56          column2.setCellEditor(new DefaultCellEditor(intensiBox));
57          column2.setPreferredWidth(50);
58  
59          // Disable column resize 
60          getColumnModel().getColumn(0).setResizable(false);
61          getColumnModel().getColumn(1).setResizable(false);
62          getColumnModel().getColumn(2).setResizable(false);
63          getColumnModel().getColumn(3).setResizable(false);
64      }
65  }