/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ee.ut.math.tvt2008.salessystem.ui.model;

import ee.ut.math.tvt2008.salessystem.domain.data.Sale;
import ee.ut.math.tvt2008.salessystem.util.Translations;
import javax.swing.table.AbstractTableModel;

/**
 *
 */
public abstract class SaleInfoTableModel extends AbstractTableModel{
private static final long serialVersionUID = 1L;

        protected Sale sale;
        String headers[];
        
        public SaleInfoTableModel(){
            super();
            headers = new String[] {
				Translations.getString("main.id"),
				Translations.getString("main.name"),
				Translations.getString("main.quantity"),
                                Translations.getString("main.price"),
				Translations.getString("main.sum")};
        }
        
        public SaleInfoTableModel(Sale sale){
            this();
            this.sale = sale;
        }
        
    public int getRowCount() {
        if(sale!=null)
        return sale.getSoldItems().size();
        else return 0;
    }

    public int getColumnCount() {
        return headers.length;
    }
    
    	@Override
	public String getColumnName(final int columnIndex) {
		return headers[columnIndex];
	}
    
    public Sale getSale(){
        return sale;
    }
    public void setSale(Sale sale){
        this.sale = sale;
    }
}
