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

import java.util.*;

import javax.swing.*;

import javax.swing.border.*;

import java.awt.*;
import java.awt.event.*;

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



/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: </p>
 * <p>Company: </p>
 * @author not attributable
 * @version
 */
public class ATGrammarPane
  extends JPanel
  {
  protected static ATGrammarPane instance=null;

  public static ATGrammarPane getInstance()
    {
    return instance;
    }

  Grammar grammar_reference;

  GridLayout gridLayout1 = new GridLayout();

  ATGrammarEditorPane grammar_editor_pane;
  DictionaryPane dictionary_pane;
  AssignmentsTablePane assignments_table_pane;
  AttributesPane attributes_pane;

  public ATGrammarPane(Grammar grammar_reference)
    {
    this.grammar_reference=grammar_reference;

    grammar_editor_pane=new ATGrammarEditorPane(grammar_reference);
    assignments_table_pane=new AssignmentsTablePane();
    attributes_pane= new AttributesPane();
    dictionary_pane=new DictionaryPane(grammar_reference.getDictionary());


    try{
       jbInit();
       }
    catch(Exception e)
      {
      e.printStackTrace();
      }

    instance=this;
    }

  private void jbInit() throws Exception
    {
    gridLayout1.setColumns(2);
    gridLayout1.setHgap(5);
    gridLayout1.setRows(2);
    gridLayout1.setVgap(5);
    this.setLayout(gridLayout1);


    Border border=BorderFactory.createEtchedBorder();
    Border editor_titled_border=BorderFactory.createTitledBorder(border, "Правила грамматики");
    Border dictionary_titled_border=BorderFactory.createTitledBorder(border, "Словари грамматики");
    Border assignments_titled_border=BorderFactory.createTitledBorder(border, "Присваивания атрибутов");
    Border attributes_titled_border=BorderFactory.createTitledBorder(border, "Атрибуты");

    grammar_editor_pane.setBorder(editor_titled_border);
    dictionary_pane.setBorder(dictionary_titled_border);
    assignments_table_pane.setBorder(assignments_titled_border);
    attributes_pane.setBorder(attributes_titled_border);

    this.add(grammar_editor_pane, null);
    this.add(dictionary_pane, null);
    this.add(assignments_table_pane, null);
    this.add(attributes_pane, null);
    }

  public ATGrammarEditorPane getATGrammarEditorPane()
    {
    return grammar_editor_pane;
    }

  public DictionaryPane getDictionaryPane()
    {
    return dictionary_pane;
    }

  public AssignmentsTablePane getAssignmentsTablePane()
    {
    return assignments_table_pane;
    }

  public AttributesPane getAttributesPane()
    {
    return attributes_pane;
    }

  public void updateAll()
    {
    this.grammar_editor_pane.update();
    this.dictionary_pane.update();
    this.assignments_table_pane.repaint();
    this.attributes_pane.repaint();
    }


  }