package osa.attribute.atgrammar.gui.panels.atgrammar_panels;

import javax.swing.*;
import java.awt.*;

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

import osa.attribute.atgrammar.gui.tables.assignments_table.*;

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

public class AssignmentsTablePane
  extends JPanel
  {
  protected AssignmentsTable assignments_table;

  protected GrammarProduction production;

  BorderLayout borderLayout1 = new BorderLayout(5,5);
  JScrollPane table_scroll_pane = new JScrollPane();
  JPanel buttons_panel = new JPanel();
  GridLayout gridLayout1 = new GridLayout();
  Component component1;
  Component component2;
  JButton remove_btn = new JButton();
  JButton add_btn = new JButton();

  public void setGrammarProductionToView(GrammarProduction production)
    {
    this.production=production;
    assignments_table.setModel(new AssignmentsTM(production));
    }


  public AssignmentsTablePane()
    {
    assignments_table=new AssignmentsTable();
    assignments_table.setModel(new AssignmentsTM(null));
    table_scroll_pane.setViewportView(assignments_table);

    try{
       jbInit();
       }
    catch(Exception e)
      {
      e.printStackTrace();
      }
    }
  private void jbInit() throws Exception
    {
    component1 = Box.createHorizontalStrut(8);
    component2 = Box.createHorizontalStrut(8);
    this.setLayout(borderLayout1);
    buttons_panel.setLayout(gridLayout1);
    gridLayout1.setColumns(4);
    gridLayout1.setHgap(5);
    gridLayout1.setRows(1);
    gridLayout1.setVgap(5);
    remove_btn.setText("Remove");
    add_btn.setText("Add");
    this.add(table_scroll_pane, BorderLayout.CENTER);
    this.add(buttons_panel, BorderLayout.SOUTH);
    buttons_panel.add(component1, null);
    buttons_panel.add(component2, null);
    buttons_panel.add(add_btn, null);
    buttons_panel.add(remove_btn, null);
    }
  }