001 package log.swing; 002 003 import log.*; 004 005 import util.swing.*; 006 007 import java.util.*; 008 009 /** 010 * TableEntryDescriptor that can be used to display {@link LogEntry LogEntries}. 011 * 012 * <p>LogEntries will be displayed using two columns. The first column will have the heading "Date" 013 * and will show the LogEntry's {@link LogEntry#getLogDate log date}. The second column will show the return 014 * of the LogEntry's {@link Object#toString} method under the heading "Description". Both columns 015 * are not editable.</p> 016 * 017 * @author Steffen Zschaler 018 * @version 2.0 14/07/1999 019 * @since v2.0 020 */ 021 public class DefaultLogEntryTED extends AbstractTableEntryDescriptor { 022 023 /** 024 * There are two columns. 025 */ 026 public int getColumnCount() { 027 return 2; 028 } 029 030 /** 031 * The column name of the first column is "Date", that of the second column is 032 * "Description". 033 */ 034 public String getColumnName(int nIdx) { 035 String[] asNames = { 036 "Date", "Description"}; 037 038 return asNames[nIdx]; 039 } 040 041 /** 042 * The column class of the first column is <code>Date.class</code>, that of the second column is 043 * <code>String.class</code>. 044 */ 045 public Class getColumnClass(int nIdx) { 046 Class[] acClasses = { 047 Date.class, String.class}; 048 049 return acClasses[nIdx]; 050 } 051 052 /** 053 * The object is assumed to be a {@link LogEntry}; the value of the first column is the 054 * {@link LogEntry#getLogDate log date} that of the second column is the result of the object's 055 * {@link Object#toString} method. 056 */ 057 public Object getValueAt(Object oData, int nIdx) { 058 switch (nIdx) { 059 case 0: 060 return ((LogEntry)oData).getLogDate(); 061 default: 062 return oData.toString(); 063 } 064 } 065 }