package oats;

/**
 * Title:  Tool.java
 * Description: This integrates the various OATS GUI classes
 * Copyright:    Copyright (c)
 * Company: mctest
 * @author John D. McGregor
 * @version 1.0
 */

/*
The OATS Orthognal Array Test Design Tool
Copyright (C) 2000  McTest

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/


import java.util.*;
import java.io.*;
import javabook2.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;

public class tool extends JFrame
    implements ActionListener{

  /**
  * This method constructs the instance of the tool class
  */
  public tool() {
    setTitle("Orthogonal Array Testing Tool");
    setSize(500,500);
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    functionMenu = new JMenu("Functions");
    oaItem = new JMenuItem("Build general orthogonal array");
    mappedItem = new JMenuItem("Build problem arrays");
    exitItem = new JMenuItem("Exit");
    oaItem.addActionListener(this);
    mappedItem.addActionListener(this);
    exitItem.addActionListener(this);
    functionMenu.add(mappedItem);
    functionMenu.add(oaItem);
    functionMenu.add(exitItem);
    menuBar.add(functionMenu);
  }

  /**
   * This method fires off the individual menu items
   * @param evt
   */
  public void actionPerformed(ActionEvent evt){
    String arg = evt.getActionCommand();
    Object source = evt.getSource();
    if(arg.equals("Build general orthogonal array"))
      this.general();
    if(arg.equals("Build problem arrays"))
      this.mapped();
    else if(arg.equals("Exit"))
      System.exit(0);
  }

  /**
  * This method starts the GUI for putting general orthogonal arrays
  * into the format used by the OATS tool
  */
  private void general(){
    GUIOrthogonalArray goa = new GUIOrthogonalArray();
    goa.show();
  }

  /**
  * This method starts the GUI for constructing problem-specific arrays
  */
  private void mapped(){
    GUIMappedArray goa = new GUIMappedArray();
    goa.show();
  }

  /**
  * This main method is the start for teh OATS tool
  */
  public static void main(String[] args){
    tool t1 = new tool();
    t1.setVisible(true);
  }

  private JMenuBar menuBar;
  private JMenuItem oaItem;
  private JMenuItem mappedItem;
  private JMenuItem exitItem;
  private JMenu functionMenu;
}