1 7 8 package org.gjt.jclasslib.browser.detail.attributes; 9 10 import org.gjt.jclasslib.browser.detail.ListDetailPane.ColumnCache; 11 import org.gjt.jclasslib.structures.AttributeInfo; 12 13 import javax.swing.table.AbstractTableModel ; 14 import javax.swing.table.TableColumnModel ; 15 16 23 public abstract class AbstractAttributeTableModel extends AbstractTableModel { 24 25 28 protected static final int BASE_COLUMN_COUNT = 1; 29 30 33 protected AttributeInfo attribute; 34 35 private ColumnCache columnCache; 36 private TableColumnModel tableColumnModel; 37 38 43 protected AbstractAttributeTableModel(AttributeInfo attribute) { 44 this.attribute = attribute; 45 } 46 47 public boolean isCellEditable(int rowIndex, int columnIndex) { 48 return false; 49 } 50 51 public String getColumnName(int column) { 52 if (column == 0) { 53 return "Nr."; 54 } else { 55 return doGetColumnName(column); 56 } 57 } 58 59 public Class getColumnClass(int column) { 60 if (column == 0) { 61 return Number .class; 62 } else { 63 return doGetColumnClass(column); 64 } 65 } 66 67 public Object getValueAt(int row, int column) { 68 69 if (column == 0) { 70 return String.valueOf(row); 71 } else { 72 if (columnCache == null) { 73 columnCache = new ColumnCache(getRowCount(), getColumnCount() - 1); 74 } 75 Object value = columnCache.getValueAt(row, column - 1); 76 if (value == null) { 77 value = doGetValueAt(row, column); 78 columnCache.setValueAt(row, column - 1, value); 79 } 80 81 return value; 82 } 83 } 84 85 90 public TableColumnModel getTableColumnModel() { 91 return tableColumnModel; 92 } 93 94 99 public void setTableColumnModel(TableColumnModel tableColumnModel) { 100 this.tableColumnModel = tableColumnModel; 101 } 102 103 109 public abstract int getColumnWidth(int column); 110 111 118 protected abstract Object doGetValueAt(int row, int column); 119 120 126 protected abstract String doGetColumnName(int column); 127 128 134 protected abstract Class doGetColumnClass(int column); 135 136 137 144 public void link(int row, int column) { 145 } 146 147 } 148 | Popular Tags |