001 package data.swing; 002 003 /** 004 * A {@link util.swing.TableEntryDescriptor} that can be used with a {@link CountingStockTableModel}. 005 * 006 * <p>There will be three columns: "Name", "Value" and "Count". The first will 007 * display the items' names, the secind their values and the third will show how many items of a sort are 008 * actually in the Stock.</p> 009 * 010 * @author Steffen Zschaler 011 * @version 2.0 23/08/1999 012 * @since v2.0 013 */ 014 public class DefaultCountingStockItemTED extends DefaultCatalogItemTED { 015 016 /** 017 * ID for serialization. 018 */ 019 private static final long serialVersionUID = -1233135389551949136L; 020 021 /** 022 * Create a new DefaultCountingStockItemTED. 023 */ 024 public DefaultCountingStockItemTED() { 025 super(); 026 } 027 028 /** 029 * @return 3. 030 * @override Sometimes 031 */ 032 public int getColumnCount() { 033 return 3; 034 } 035 036 /** 037 * @return "Name" for the first, "Value" for the second and "Count" for the 038 * third column. 039 * @override Sometimes 040 */ 041 public String getColumnName(int nIdx) { 042 if (nIdx == 2) { 043 return "Count"; 044 } else { 045 return super.getColumnName(nIdx); 046 } 047 } 048 049 /** 050 * @return <code>String.class</code> for the first, <code>{@link data.Value}.class</code> for the second and 051 * <code>Integer.class</code> for the third column. 052 * @override Sometimes 053 */ 054 public Class<?> getColumnClass(int nIdx) { 055 if (nIdx == 2) { 056 return Integer.class; 057 } else { 058 return super.getColumnClass(nIdx); 059 } 060 } 061 062 /** 063 * @return the item's name for the first, its value for the second and the number of items for the third 064 * column. 065 * @override Sometimes 066 */ 067 public Object getValueAt(Object oData, int nIdx) { 068 CountingStockTableModel.Record r = (CountingStockTableModel.Record)oData; 069 070 if (nIdx == 2) { 071 return new Integer(r.getCount()); 072 } else { 073 return super.getValueAt(r.getDescriptor(), nIdx); 074 } 075 } 076 }