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

import java.util.ArrayList;

import cz.neubauer.tomas.hazardanalysis.model.components.Component;
import cz.neubauer.tomas.hazardanalysis.model.dangers.DangerVariant;

/**
 * @author Tomáš Neubauer
 */
public class ComponentDangerVariantTableModel extends DangerVariantTableModel {

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

	private Component component;

	/**
	 * @param componentDangerVariantFrame
	 * @param variants
	 */
	public ComponentDangerVariantTableModel(Component component,
			ArrayList<DangerVariant> variants) {
		super(variants);
		this.component = component;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see rizika.gui.DangerVariantTableModel#getValueAt(int, int)
	 */
	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		DangerVariant currentVariant = getDangerVariants().get(rowIndex);
		switch (columnIndex) {
		case 0:
			return currentVariant.getDescription();
		case 1:
			return currentVariant.isSelected();// component.hasDangerVariant(currentVariant);
		default:
			return null;
		}
	}

	public Component getComponent() {
		return component;
	}

	public void setComponent(Component component) {
		this.component = component;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see rizika.gui.DangerVariantTableModel#getColumnName(int)
	 */
	@Override
	public String getColumnName(int column) {
		switch (column) {
		case 0:
			return "Popis nebezpečí";
		case 1:
			return "";
		default:
			return null;
		}
	}
}
