001 package util.swing; 002 003 import javax.swing.table.*; 004 005 import java.util.Comparator; 006 007 /** 008 * <i>Abstract</i> base implementation of {@link TableEntryDescriptor}. 009 * 010 * <p>This base implementations is useful when you want to define a TableEntryDescriptor that describes rows 011 * that are non-editable and use the default renderer for each cell, based on the cell value's class. 012 * 013 * @see util.swing.AbstractTableModel 014 * 015 * @author Steffen Zschaler 016 * @version 2.0 27/07/1999 017 * @since v2.0 018 */ 019 public abstract class AbstractTableEntryDescriptor extends Object implements TableEntryDescriptor { 020 021 /** 022 * Dummy constructor, does nothing but call <code>super()</code>. 023 */ 024 public AbstractTableEntryDescriptor() { 025 super(); 026 } 027 028 /** 029 * Returns <code>null</code> to indicate that the default cell renderer is to be used based on the cell 030 * value's class. 031 * 032 * @override Sometimes Override this method if you want to define specialized cell renderers for certain 033 * columns. 034 */ 035 public TableCellRenderer getCellRenderer(int nIdx) { 036 return null; 037 } 038 039 /** 040 * Returns <code>null</code> to indicate that the default cell editor is to be used based on the cell 041 * value's class. 042 * 043 * @override Sometimes Override this method if you want to define specialized cell editors for certain 044 * columns. Note that you will also have to override {@link #isElementEditable} and {@link #setValueAt} 045 * for complete editing support. 046 */ 047 public TableCellEditor getCellEditor(int nIdx) { 048 return null; 049 } 050 051 /** 052 * Returns <code>false</code> to indicate that no cell is editable in the entire table. 053 * 054 * @override Sometimes Override this method if you want to allow editing for certain cells. The actual class 055 * of the record passed as <code>oRecord</code> depends on the {@link util.swing.AbstractTableModel TableModel} 056 * with which you work. See {@link util.swing.AbstractTableModel#getRecord} in the concrete TableModel for a 057 * description. 058 * Note that you will also have to override {@link #setValueAt} for complete editing support. It is also 059 * recommended that you override {@link #getCellEditor} if you override this method. 060 */ 061 public boolean isElementEditable(Object oRecord, int nIdx) { 062 return false; 063 } 064 065 /** 066 * Does nothing because AbstractTableEntryDescriptor does not allow editing by default. 067 * 068 * @override Sometimes Override this method if you want to allow editing for certain cells. The actual class 069 * of the record passed as <code>oRecord</code> depends on the {@link util.swing.AbstractTableModel TableModel} 070 * with which you work. See {@link util.swing.AbstractTableModel#getRecord} in the concrete TableModel for a 071 * description. 072 * Note that you will also have to override {@link #isElementEditable} for complete editing support. It is 073 * also recommended that you override {@link #getCellEditor} if you override this method. 074 */ 075 public void setValueAt(Object oRecord, int nIdx, Object oValue) {} 076 077 /** 078 * Returns false because AbstractTableEntryDescriptor does not allow sorting by column by default. 079 * 080 * @param nIdx the index of the column concerned. 081 * 082 * @return whether or not records can be sorted by the specified column. 083 * 084 * @override Sometimes Override this method if you want to support sorting by column 085 */ 086 public boolean canSortByColumn(int nIdx) { 087 return false; 088 } 089 090 /** 091 * Returns <code>null</code> because AbstractTableEntryDescriptor does not allow sorting by column by default. 092 * 093 * @param nIdx the index of the column concerned. 094 * 095 * @override Sometimes Override this method if you want to support sorting by column 096 */ 097 public Comparator getColumnOrder(int nIdx) { 098 return null; 099 } 100 }