001    package data.swing;
002    
003    import data.*;
004    
005    import util.swing.*;
006    
007    import javax.swing.*;
008    import javax.swing.table.*;
009    
010    import java.util.*;
011    
012    /**
013     * A {@link JTable} for displaying and editing the contents of a {@link CountingStock}.
014     *
015     * @author Steffen Zschaler
016     * @version 2.0 23/08/1999
017     * @since v2.0
018     */
019    public class JCountingStockTable extends JAbstractTable {
020    
021        /**
022         * Create a new JCountingStockTable.
023         *
024         * @param cs the CountingStock to be displayed.
025         * @param db the DataBasket to be used to determine visibility.
026         * @param cmp a Comparator defining the sort order. If <code>null</code>, the records are ordered by their
027         * keys.
028         * @param fShowZeros if false, rows containing '0' in the value column will be omitted from the table.
029         * @param ted a TableEntryDescriptor that can split
030         * {@link CountingStockTableModel.Record CountingStockTableModel records} into a table's cells.
031         */
032        public JCountingStockTable(CountingStock cs, DataBasket db, Comparator cmp, boolean fShowZeros,
033                TableEntryDescriptor ted) {
034            super(new CountingStockTableModel(cs, db, cmp, fShowZeros, ted));
035    
036            if (cs instanceof MoneyBag) {
037                setDefaultRenderer(NumberValue.class, new CurrencyRenderer((data.Currency)cs.getCatalog(db)));
038            }
039        }
040    }