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

import javax.swing.table.AbstractTableModel;

import cz.neubauer.tomas.hazardanalysis.model.stages.Phase;
import cz.neubauer.tomas.hazardanalysis.model.stages.Stage;

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

	/**
	 * 
	 */
	private static final long serialVersionUID = -6201047093071879816L;

	private Stage stage;

	private String[] columnNames = new String[] { "Fáze životního cyklu",
			"Typy nebezpečí", "Kódy nebezpečí", "Popis nebezpečí", "Upřesnit" };

	public StageTableModel(Stage stage) {
		this.stage = stage;
	}

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

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

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.swing.table.TableModel#getValueAt(int, int)
	 */
	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		Phase p = stage.getPhase(rowIndex);
		switch (columnIndex) {
		case 0:
			return p.getName();
		case 1:
			return p.getDangerTypesAsString();
		case 2:
			return p.getDangerTypeCodesAsString();
		case 3:
			return p.getDangerVarantDescriptionsAsString();
		case 4:
			return "upřesnit...";
		default:
			return null;

		}
	}

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