]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/load/FileExtractTableModel.java
Version 1, September 2006
[GpsPrune.git] / tim / prune / load / FileExtractTableModel.java
1 package tim.prune.load;
2
3 import javax.swing.table.AbstractTableModel;
4
5 /**
6  * Class to hold the table model for the file extract table
7  */
8 public class FileExtractTableModel extends AbstractTableModel
9 {
10
11         private int _numRows = 0;
12         private Object[][] _tableData = null;
13
14         /**
15          * Get the column count
16          */
17         public int getColumnCount()
18         {
19                 if (_tableData == null)
20                         return 2;
21                 return _tableData[0].length;
22         }
23
24         /**
25          * Get the name of the column, in this case just the number
26          */
27         public String getColumnName(int inColNum)
28         {
29                 return "" + (inColNum + 1);
30         }
31
32         /**
33          * Get the row count
34          */
35         public int getRowCount()
36         {
37                 if (_tableData == null)
38                         return 2;
39                 return _numRows;
40         }
41
42         /**
43          * Get the value of the specified cell
44          */
45         public Object getValueAt(int rowIndex, int columnIndex)
46         {
47                 if (_tableData == null) return "";
48                 return _tableData[rowIndex][columnIndex];
49         }
50
51         /**
52          * Make sure table data is not editable
53          */
54         public boolean isCellEditable(int rowIndex, int columnIndex)
55         {
56                 return false;
57         }
58
59         /**
60          * Update the data
61          * @param inData 2-dimensional Object array containing the data
62          */
63         public void updateData(Object[][] inData)
64         {
65                 _tableData = inData;
66                 if (_tableData != null)
67                 {
68                         _numRows = _tableData.length;
69                 }
70                 fireTableStructureChanged();
71         }
72
73
74         /**
75          * @return Object array of data
76          */
77         public Object[][] getData()
78         {
79                 return _tableData;
80         }
81 }