package data.swing;

import javax.swing.table.*;
import javax.swing.*;

import java.util.Comparator;

import data.*;

import util.swing.*;

/**
  * A {@link JTable} for displaying and editing the contents of a {@link Catalog}.
  *
  * @author Steffen Zschaler
  * @version 2.0 23/08/1999
  * @since v2.0
  */
public class JCatalogTable extends JAbstractTable {

  /**
    * Create a new JCatalogTable.
    *
    * @param c the Catalog to be displayed.
    * @param db the DataBasket to be used to determine visibility.
    * @param cmp a Comparator defining the sort order. If <code>null</code>, the CatalogItems are ordered in
    * their natural order.
    * @param ted a TableEntryDescriptor that can split CatalogItems into a table's cells.
    */
  public JCatalogTable (Catalog c,
                        DataBasket db,
                        Comparator cmp,
                        TableEntryDescriptor ted) {
    super (new CatalogTableModel (c, db, cmp, ted));

    if (c instanceof Currency) {
      setDefaultRenderer (NumberValue.class,
                          new CurrencyRenderer ((Currency) c));
    }
  }
}