/**
 * 
 */
package cz.neubauer.tomas.hazardanalysis.model.tablemodels;

import java.util.ArrayList;

import javax.swing.table.AbstractTableModel;

import cz.neubauer.tomas.hazardanalysis.model.dangers.DangerGroup;

/**
 * @author Tomáš Neubauer
 */
public class DangerGroupTableModel extends AbstractTableModel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3268299641216543824L;

	private ArrayList<DangerGroup> data;

	private String[] columnNames = new String[] { "Název skupiny nebezpečí" };

	public DangerGroupTableModel(ArrayList<DangerGroup> data) {
		this.data = data;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.swing.table.TableModel#getColumnCount()
	 */
	@Override
	public int getColumnCount() {
		return 1;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.swing.table.TableModel#getRowCount()
	 */
	@Override
	public int getRowCount() {
		return data.size();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.swing.table.TableModel#getValueAt(int, int)
	 */
	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		DangerGroup current = data.get(rowIndex);
		switch (columnIndex) {
		case 0:
			return current.getName();
		default:
			return null;
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.swing.table.AbstractTableModel#getColumnName(int)
	 */
	@Override
	public String getColumnName(int column) {
		return columnNames[column];
	}

	public ArrayList<DangerGroup> getData() {
		return data;
	}

	public void setData(ArrayList<DangerGroup> data) {
		this.data = data;
	}

}
