import java.awt.*;

public class CPDTableController extends TableController
{
	public CPDTableController(TableRepresentation t, TableView v, Label m)
	{
		super(t, v, m);
	}
	public CPDTableController(Label m)
	{
		super(m);
	}
	
    public void cellChanged(int x, int y, Relation r)
    {
    	if (r.equals(table.cell[x][y]))
    		return;
    	else if (!table.cell[x][y].includes(r))
    	{
    		message.setText(r.toString() + 
    			" is not included in " + table.cell[x][y].toString() +
    			". Old value restored.");
    		super.cellChanged(x, y, table.cell[x][y]);
    	}
    	else if (!r.isDeterminate())
    	{
    		message.setText(r.toString() + 
    			" is not determinate. Old value restored.");
    		super.cellChanged(x, y, table.cell[x][y]);
    	}
    	else
    	{
    		super.cellChanged(x, y, r);
    		message.setText("Propagating constraints");
    		table.determinatePropagate(x, y);
    		message.setText("Constraints propagated.");
    		view.update();
    	}
    }

}