package data.swing;

import data.*;

import util.swing.*;

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

import java.util.*;

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

  /**
    * Create a new JCountingStockTable.
    *
    * @param cs the CountingStock 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 records are ordered by their
    * keys.
    * @param fShowZeros if false, rows containing '0' in the value column will be omitted from the table.
    * @param ted a TableEntryDescriptor that can split
    * {@link CountingStockTableModel.Record CountingStockTableModel records} into a table's cells.
    */
  public JCountingStockTable (CountingStock cs,
                              DataBasket db,
                              Comparator cmp,
                              boolean fShowZeros,
                              TableEntryDescriptor ted) {
    super (new CountingStockTableModel (cs, db, cmp, fShowZeros, ted));

    if (cs instanceof MoneyBag) {
      setDefaultRenderer (NumberValue.class,
                          new CurrencyRenderer ((Currency) cs.getCatalog (db)));
    }
  }
}