package osa.attribute.atgrammar.gui.tables.assignments_table;

import javax.swing.table.TableCellRenderer;
import java.awt.*;
import javax.swing.JTable;



import osa.attribute.atgrammar.grammar.*;
import osa.attribute.atgrammar.grammar.symbols.*;

import javax.swing.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2005</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class AssignmentsTCR
  implements TableCellRenderer
  {
  public AssignmentsTCR()
    {
    }
  public Component getTableCellRendererComponent
    (JTable table,
     Object value,
     boolean isSelected,
     boolean hasFocus,
     int row,
     int column)
    {
    JPanel cell_pane=new JPanel();
    JLabel value_label=new JLabel();
    cell_pane.setLayout(new FlowLayout(FlowLayout.LEFT));

    if(value instanceof SimpleAssignment)
      {
      SimpleAssignment simple_assignment;
      simple_assignment=(SimpleAssignment)value;

      switch(column)
            {
            case 0:
              value_label.setText(new Integer(row+1).toString());
              break;
            case 1:
              value_label.setText(simple_assignment.getRecipientSymbolLabel());
              break;
            case 2:
              value_label.setText(" . ");
              break;
            case 3:
              value_label.setText(simple_assignment.getRecipientAttributeLabel());
              break;
            case 4:
              value_label.setText(" := ");
              break;
            case 5:
              value_label.setText(simple_assignment.getSourceSymbolLabel());
              break;
            case 6:
              value_label.setText(" . ");
              break;
            case 7:
              value_label.setText(simple_assignment.getSourceAttributeLabel());
              break;
            default:
              value_label.setText("Error!");
            }
      }
    else
      {
      value_label.setText("Error!");
      }
    cell_pane.add(value_label);

    return new JLabel("000000");
//    return cell_pane;

    }
  }