View Javadoc

1   // %1126721045432:hoplugins.commons.ui%
2   package hoplugins.commons.ui;
3   
4   import javax.swing.table.DefaultTableModel;
5   
6   import java.util.Vector;
7   
8   /***
9    * Base TableModel that creates a not editable table and manage the rendering
10   *
11   * @author <a href=mailto:draghetto@users.sourceforge.net>Massimiliano Amato</a>
12   */
13  public class BaseTableModel extends DefaultTableModel {
14      /***
15       * Creates a new instance of BaseTableModel
16       */
17      public BaseTableModel() {
18          super();
19      }
20  
21      /***
22       * Creates a new BaseTableModel object.
23       *
24       * @param data Vector with the data to be used to fill the table
25       * @param columnNames Vector of column names
26       */
27      public BaseTableModel(Vector data, Vector columnNames) {
28          super(data, columnNames);
29      }
30  
31      /***
32       * Method that returns if the cell if editable, false by default
33       *
34       * @param row the row index of the cell
35       * @param column the column index of the cell
36       *
37       * @return true if editable, false if not
38       */
39      public boolean isCellEditable(int row, int column) {
40          return false;
41      }
42  
43      /***
44       * Method the return the column class type
45       *
46       * @param column the column we want to know the class type
47       *
48       * @return Object is column is empty, or the type of object we have in the column
49       */
50      public Class getColumnClass(int column) {
51          if (getValueAt(0, column) == null) {
52              return Object.class;
53          }
54          else {
55              return getValueAt(0, column).getClass();
56          }
57      }
58  }