package data.swing; /** * A {@link util.swing.TableEntryDescriptor} that can be used with a {@link CountingStockTableModel}. * * <p>There will be three columns: "Name", "Value" and "Count". The first will * display the items' names, the secind their values and the third will show how many items of a sort are * actually in the Stock.</p> * * @author Steffen Zschaler * @version 2.0 23/08/1999 * @since v2.0 */ public class DefaultCountingStockItemTED extends DefaultCatalogItemTED { /** * Create a new DefaultCountingStockItemTED. */ public DefaultCountingStockItemTED() { super(); } /** * @return 3. * @override Sometimes */ public int getColumnCount() { return 3; } /** * @return "Name" for the first, "Value" for the second and "Count" for the * third column. * @override Sometimes */ public String getColumnName (int nIdx) { if (nIdx == 2) { return "Count"; } else { return super.getColumnName (nIdx); } } /** * @return <code>String.class</code> for the first, <code>{@link data.Value}.class</code> for the second and * <code>Integer.class</code> for the third column. * @override Sometimes */ public Class getColumnClass (int nIdx) { if (nIdx == 2) { return Integer.class; } else { return super.getColumnClass (nIdx); } } /** * @return the item's name for the first, its value for the second and the number of items for the third * column. * @override Sometimes */ public Object getValueAt (Object oData, int nIdx) { CountingStockTableModel.Record r = (CountingStockTableModel.Record) oData; if (nIdx == 2) { return new Integer (r.getCount()); } else { return super.getValueAt (r.getDescriptor(), nIdx); } } }