// import java libraries
//
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.tree.*;
import java.awt.datatransfer.*;
import java.io.*;
import javax.swing.text.*;

/**
 * Config class used to mainly to handle a configuration vector
 */
class Config {

    /**
     * default class constructor, empty implementation
     */
    public Config() {

    }
    /**
     * Creates a vector of names consisting of the names in the Query pulldown
     * menu
     * @return Vector of String names in the Query pulldown menu
     */
    public Vector create_names() {

	Vector names = new Vector(12,2);
	names.add("Owner");
	names.add("Database");
	names.add("Class");
	names.add("Priority");
	names.add("Severity");
	names.add("Due");
	names.add("Resolution");
	names.add("Inspected By");
	names.add("Environment");
	names.add("Test Case");
	names.add("Component");
	names.add("Review Date");

	return names;
    }

    /**
     * Creates the enums vector using a configuration vector
     *
     * @param configVector Vector which has some data to be put into the
     *                     enums vector
     * @return enums Vector that is used in other classes
     */
     public Vector create_enums(Vector configVector) {

	 Vector titles = new Vector(12, 2);
	 Vector strings = new Vector(12, 2);

	 Vector enums = new Vector(12,2);
	 Vector enum_item[] = new Vector[12];
	 String values[] = new String[12]; 
	 
	
	 // run through the config vector pulling put titles and data strings
	 //
	 for(int i=0; i < configVector.size(); i++) {
	     titles.add(((Vector)configVector.get(i)).get(0));
	     strings.add(((Vector)configVector.get(i)).get(1));
	 }
	
	 // initialize all the string values
	 //
	 for (int i = 0; i < 12; i++ ) {
	     values[i] = new String("");
	 }
	

	 values[0] = (String)strings.get(titles.indexOf("Owner"));
	 values[1] = (String)strings.get(titles.indexOf("DBase"));
	 values[2] = (String)strings.get(titles.indexOf("Class"));
	 values[3] = (String)strings.get(titles.indexOf("Priority"));
	 values[4] = (String)strings.get(titles.indexOf("Severity"));
	 values[5] = (String)strings.get(titles.indexOf("Due"));
	 values[6] = (String)strings.get(titles.indexOf("Resolution"));
	 
	 
	 // this is to get the insepected by field, but this allows only
	 // one field to be maintained in the dbase rather than two
	 //
	 values[7] = (String)strings.get(titles.indexOf("Owner"));
	
	 values[8] = (String)strings.get(titles.indexOf("Environment"));
	 values[9] = (String)strings.get(titles.indexOf("TestCase"));
	 //values[10] = (String)strings.get(titles.indexOf("Component"));
	 values[11] = (String)strings.get(titles.indexOf("ReviewDate"));

	
	 for (int i = 0; i < 12; i++ ) {
	    
	     // create the vector to hold each of the enum values
	     //
	     enum_item[i] = new Vector(5,5);
	     
	     
	     // create a blanks value to be the default value
	     //
	     enum_item[i].add("unspecified");
	     // tokenize the string containing the values with comma as the
	     // delimiter
	     //
	     StringTokenizer tokenizer = new StringTokenizer(values[i], ",");
	     
	     // run through and add each token to the enum_items vector
	     //
	     while (tokenizer.hasMoreTokens()) {
		 
		 String line = (String)tokenizer.nextToken();
		 enum_item[i].add(line.trim());
	     }
	     
	     enums.add(enum_item[i]);
	 }
	 return enums;
     }
    
}



