001 package data.swing;
002
003 import data.*;
004
005 import util.swing.*;
006
007 /**
008 * A {@link TableEntryDescriptor} that can be used with a {@link DataBasketTableModel} modelling
009 * {@link DataBasketEntry DataBasketEntries} that describe operations on items in a {@link CountingStock}.
010 *
011 * <p>There will be two columns, headed "Name" and "Count". The first will give the item's
012 * name, the second the number of items of that sort available.</p>
013 *
014 * @author Steffen Zschaler
015 * @version 2.0 23/08/1999
016 * @since v2.0
017 */
018 public class DefaultCountingStockDBETableEntryDescriptor extends AbstractTableEntryDescriptor {
019
020 /**
021 * Create a new DefaultCountingStockDBETableEntryDescriptor.
022 */
023 public DefaultCountingStockDBETableEntryDescriptor() {
024 super();
025 }
026
027 /**
028 * @return 2.
029 * @override Sometimes
030 */
031 public int getColumnCount() {
032 return 2;
033 }
034
035 /**
036 * @return "Name" for the first and "Count" for the second column.
037 * @override Sometimes
038 */
039 public String getColumnName(int nIdx) {
040 String[] asNames = {
041 "Name", "Count"};
042 return asNames[nIdx];
043 }
044
045 /**
046 * @return <code>String.class</code> for the first and <code>Integer.class</code> for the second column.
047 * @override Sometimes
048 */
049 public Class getColumnClass(int nIdx) {
050 Class[] acClasses = {
051 String.class, Integer.class};
052 return acClasses[nIdx];
053 }
054
055 /**
056 * @return the item's name for the first and the number of available items for the second column.
057 * @override Sometimes
058 */
059 public Object getValueAt(Object oData, int nIdx) {
060 DataBasketEntry dbe = (DataBasketEntry)oData;
061
062 switch (nIdx) {
063 case 0:
064 return dbe.getSecondaryKey();
065 case 1:
066 return dbe.getValue();
067 }
068
069 return null;
070 }
071 }