package vermilion;

import javax.swing.table.DefaultTableModel;

/**
 * A table model used to implement the tracker area.
 */
public class JPatternTableModel extends DefaultTableModel
{
    /**
     * The columns currently showing in the table.
     */
    public JTrackerColumn[] columns;

    /**
     * Constructs the model given the number of columns and rows.
     */
    JPatternTableModel(int cols, int rows)
    {
        super(cols, rows);
    }

    /**
     * Returns false to prevent cell editing - we intercept keypresses and do
     * the editing ourselves.
     */
    @Override
    public boolean isCellEditable(int row, int column) {
        //if (column == 0) return false;
        //return true;
        return false;
    }

    /**
     * Passes the getValue request straight to the column allowing us to use
     * column subtypes to handle the different parameter and column types.
     */
    @Override
    public Object getValueAt(int row, int column)
    {
        if (columns == null) return "";
        return columns[column].getEntry(row);
    }
}
