package extractor.ui;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import extractor.classToEjb.classToSession.*;
import extractor.classToEjb.classToEntity.*;
import ui.*;

public class SeInputUI extends JPanel
{
  	JPanel contentPane;
  	String[] patternExamples = null;

  	JComboBox jComboBox1 = null;
  	JTextField jTextField1 = new JTextField(20);
  	JTextField jTextField2 = new JTextField(20);
  	JTextField jTextField3 = new JTextField(20);
  	JLabel jLabel1 = new JLabel();
  	JLabel jLabel2 = new JLabel();
  	JLabel jLabel3 = new JLabel();
  	JLabel jLabel4 = new JLabel();
  	JButton jButton1 = new JButton();
  	JButton jButton2 = new JButton();
  	ExtractResultsPanel ejbName = null;
  
  	Vector v = new Vector();
  	/**Construct the frame*/
  
  	public SeInputUI(Vector session, ExtractResultsPanel ejbName) 
  	{
  	 	String[] ex = new String[10];
  	 	for(int k=0; k<session.size(); k++)
  	 	{
  	 		ex[0] = "Select me !!!";
  	 		ex[k+1] = (String)session.get(k);
  	 	}
  	 
  	 	this.patternExamples = ex;
  	 	this.ejbName = ejbName;
  	 	jComboBox1 = new JComboBox(patternExamples);

    		try 
    		{
      			jbInit();
    		}
    		catch(Exception e) 
    		{
      			e.printStackTrace();
    		}
  	}
  
  	/**Component initialization*/
  	private void jbInit() throws Exception  
  	{
  		setLayout(null);
    		//setIconImage(Toolkit.getDefaultToolkit().createImage(SeInputUI.class.getResource("[Your Icon]")));
    		jComboBox1.setBounds(new Rectangle(173, 75, 245, 33));
    		jComboBox1.addActionListener(new java.awt.event.ActionListener() 
    		{
      			public void actionPerformed(ActionEvent e) 
      			{
        			jComboBox1_actionPerformed(e);
      			}
    		});
    
    		//jTextField1.setText("");
    		jTextField1.setBounds(new Rectangle(173, 147, 247, 35));
    		//jTextField2.setText("");
    		jTextField2.setBounds(new Rectangle(190, 211, 228, 36));
    		//jTextField3.setText("");
    		jTextField3.setBounds(new Rectangle(189, 274, 228, 36));
    		jLabel1.setFont(new java.awt.Font("Dialog", 1, 14));
    		jLabel1.setToolTipText("");
    		jLabel1.setText("Select a class :");
    		jLabel1.setBounds(new Rectangle(60, 74, 109, 36));
    		jLabel2.setFont(new java.awt.Font("Dialog", 1, 14));
    		jLabel2.setText("Bean name : ");
    		jLabel2.setBounds(new Rectangle(70, 151, 101, 31));
    		jLabel3.setFont(new java.awt.Font("Dialog", 1, 14));
    		jLabel3.setText("Home interface name : ");
    		jLabel3.setBounds(new Rectangle(19, 220, 164, 27));
    		jLabel4.setFont(new java.awt.Font("Dialog", 1, 14));
    		jLabel4.setText("Remote interface name : ");
    		jLabel4.setBounds(new Rectangle(14, 273, 192, 40));
    		jButton1.setText("OK");
    		jButton1.setBounds(new Rectangle(127, 362, 88, 33));

    		add(jTextField1, null);
    		add(jTextField2, null);
    		add(jTextField3, null);
    		add(jComboBox1, null);
    		add(jLabel4, null);
    		add(jLabel3, null);
    		add(jLabel1, null);
    		add(jLabel2, null);

  	}

  	void jComboBox1_actionPerformed(ActionEvent e) 
  	{
    		String newSelection = (String)jComboBox1.getSelectedItem();
    		jTextField1.setText(newSelection + "Bean");
	 	jTextField2.setText(newSelection + "Home");
    		jTextField3.setText(newSelection);
    
    		int p = jComboBox1.getSelectedIndex();
    		System.out.println("p = " + p);
    		String val = jComboBox1.getItemAt(p) + "|" + jTextField1.getText() + "|" + jTextField2.getText() + "|" + jTextField3.getText();
    		v.addElement(val);
  	}


  	public void execute() 
  	{
    		System.out.println(v);
    		
    		for(int k=0; k<v.size(); k++)
    		{
    			String str = (String)v.get(k);
    			//SessionBeanExtractor se = new SessionBeanExtractor(str);
    		}
	 
	 	System.out.println("EMetaforUI.beanName = " + EMetaforUI.beanName);
	 	System.out.println("SEMetaforUI.beanName = " + SEMetaforUI.beanName);
	 	System.out.println("SEMetaforUI.homeName = " + SEMetaforUI.homeName);
	 	
	 	Vector temp = new Vector();
	 	for(int i=0; i<EMetaforUI.beanName.size(); i++)
	 	{
	 		temp.add(EMetaforUI.beanName.get(i));
	 	}
	 	for(int i=0; i<SEMetaforUI.beanName.size(); i++)
	 	{
	 		temp.add(SEMetaforUI.beanName.get(i));
	 	}
	 	
	 	ejbName.setTreeNode(temp);
    
    		//new EInputMain();
	 	//new SEendMain();
	 	JOptionPane.showMessageDialog(this,"Session bean 추출을 완료합니다!","Message",JOptionPane.INFORMATION_MESSAGE);	
  	}
}