package osa.tabs;

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

import osa.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: </p>
 * <p>Company: </p>
 * @author not attributable
 * @version
 */

public class MyTab
  extends JPanel
  {
  protected MainFrame main_frame_instance;


  private class MyButtonListener
    implements ActionListener
    {

    public void actionPerformed(ActionEvent e)
      {
      // getting simple OSA grammr
      Grammar grammar=main_frame_instance.getGrammar();

      // constructing attribute_grammar

      osa.attribute.atgrammar.grammar.Grammar attribute_grammar;
      attribute_grammar=osa.attribute.atgrammar.grammar.Grammar.get


      osa.attribute.atgrammar.gui.panels.atgrammar_panels.ATGrammarEditorPane grammar_pane;

      grammar_pane=new osa.attribute.atgrammar.gui.panels.atgrammar_panels.ATGrammarEditorPane
          (attribute_grammar);

      grammar_panel.add(grammar_pane,BorderLayout.CENTER);
      grammar_panel.revalidate();


      ArrayList[] rules=grammar.RT.m_rules;
      ArrayList temp_rule;

      System.out.println("Size="+attribute_grammar.getProductionsCount());
      System.out.println(attribute_grammar.toString());

/*      System.out.println("Size="+grammar.RT.m_size);
      for(int i=0;i<grammar.RT.m_size;i++)
         {
         temp_rule=rules[i];
         for(int j=0;j<temp_rule.size();j++)
            {
            System.out.print(temp_rule.get(j).toString());
            System.out.print(temp_rule.get(j).getClass().toString());
            }
         System.out.println("");
         }*/


      }
    }

  JButton MyButton = new JButton();
  JPanel grammar_panel = new JPanel();
  BorderLayout borderLayout1 = new BorderLayout();
  BorderLayout borderLayout2 = new BorderLayout();
  public MyTab(MainFrame main_frame_instance)
    {
    this.main_frame_instance=main_frame_instance;
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
    }
  private void jbInit() throws Exception{
    MyButton.setText("jButton1");
    MyButton.addActionListener(new MyButtonListener());
    this.setLayout(borderLayout1);
    grammar_panel.setLayout(borderLayout2);
    this.add(MyButton, BorderLayout.NORTH);
    this.add(grammar_panel, BorderLayout.CENTER);
  }



  }