001    package data.swing;
002    
003    import javax.swing.*;
004    
005    import java.util.Comparator;
006    
007    import data.*;
008    
009    import util.swing.*;
010    
011    /**
012     * A {@link JTable} for displaying and editing the contents of a {@link Catalog}.
013     *
014     * @author Steffen Zschaler
015     * @version 2.0 23/08/1999
016     * @since v2.0
017     */
018    public class JCatalogTable extends JAbstractTable {
019    
020        /**
021             * ID for serialization.
022             */
023            private static final long serialVersionUID = -4299691523381140835L;
024    
025            /**
026         * Create a new JCatalogTable.
027         *
028         * @param c the Catalog to be displayed.
029         * @param db the DataBasket to be used to determine visibility.
030         * @param cmp a Comparator defining the sort order. If <code>null</code>, the CatalogItems are ordered in
031         * their natural order.
032         * @param ted a TableEntryDescriptor that can split CatalogItems into a table's cells.
033         */
034        public JCatalogTable(Catalog c, DataBasket db, Comparator<CatalogItem> cmp, TableEntryDescriptor ted) {
035            super(new CatalogTableModel(c, db, cmp, ted));
036    
037            if (c instanceof Currency) {
038                setDefaultRenderer(NumberValue.class, new CurrencyRenderer((Currency)c));
039            }
040        }
041    }