package extractor.ui;

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


public class EInputUI extends JPanel
{
  	
  	JLabel jLabel1 = new JLabel();
  	JTextField jTextArea1 = new JTextField();
  	JLabel jLabel2 = new JLabel();
  	JTextField jTextArea2 = new JTextField();
  	JLabel jLabel3 = new JLabel();
  	JTextField jTextArea3 = new JTextField();
  	JLabel jLabel4 = new JLabel();
  	JTextField jTextArea4 = new JTextField();
  	JButton jButton1 = new JButton();
  	JButton jButton2 = new JButton();
  	String valueObject = null;
  	ExtractResultsPanel ejbName = null;
  
  	/**Construct the frame*/
  	public EInputUI(ExtractResultsPanel ejbName) 
  	{
  		this.ejbName = ejbName;
    		try 
    		{
      			jbInit();
    		}
    		catch(Exception e) 
    		{
      			e.printStackTrace();
    		}
  	}
  
  	/**Component initialization*/
  	private void jbInit() throws Exception  
  	{
    		jLabel1.setFont(new java.awt.Font("Serif", 1, 16));
    		jLabel1.setText("Bean Name :");
    		jLabel1.setBounds(new Rectangle(30, 35, 227, 31));


    		setLayout(null);

    		jTextArea1.setText("BoardBean");
    		jTextArea1.setFont(new java.awt.Font("SansSerif", 0, 16));
    		jTextArea1.setBounds(new Rectangle(131, 38, 312, 35));
    		jLabel2.setFont(new java.awt.Font("Serif", 1, 16));
    		jLabel2.setText("Home Interface Name :");
    		jLabel2.setBounds(new Rectangle(19, 99, 159, 45));
    		jTextArea2.setText("BoardHome");
    		jTextArea2.setFont(new java.awt.Font("SansSerif", 0, 16));
    		jTextArea2.setBounds(new Rectangle(187, 107, 254, 33));
    		jLabel3.setFont(new java.awt.Font("Serif", 1, 16));
    		jLabel3.setText("Remote Interface Name :");
    		jLabel3.setBounds(new Rectangle(20, 165, 188, 45));
    		jTextArea3.setText("Board");
    		jTextArea3.setFont(new java.awt.Font("SansSerif", 0, 16));
    		jTextArea3.setBounds(new Rectangle(192, 175, 253, 35));
    		jLabel4.setFont(new java.awt.Font("Serif", 1, 16));
    		jLabel4.setText("Value Object Name :");
    		jLabel4.setBounds(new Rectangle(26, 240, 145, 41));
    		jTextArea4.setText("BoardData bData");
    		jTextArea4.setFont(new java.awt.Font("SansSerif", 0, 16));
    		jTextArea4.setBounds(new Rectangle(167, 248, 200, 33));
    		jButton1.setText("CANCEL");
    		jButton1.setBounds(new Rectangle(283, 367, 88, 32));
    		
    		add(jTextArea1, null);
    		add(jTextArea2, null);
    		add(jLabel2, null);
    		add(jLabel1, null);
    		add(jTextArea4, null);
    		JButton jb = new JButton("..");
  
   
          	final JFileChooser fc = new JFileChooser();

        	JButton openButton = new JButton("Choose");
        	openButton.addActionListener(new ActionListener() 
        	{
            		public void actionPerformed(ActionEvent e) 
            		{
                		int returnVal = fc.showOpenDialog(null);

                		if (returnVal == JFileChooser.APPROVE_OPTION) 
                		{
                    			File file = fc.getSelectedFile();
                    			//this is where a real application would open the file.
                    			System.out.println("Opening: " + file.getName());
                    			valueObject = file.getName();
                    			valueObject = valueObject.substring(0, valueObject.indexOf("."));
                    			jTextArea4.setText(valueObject);
                    			System.out.println("valueObject: " + valueObject);
                		} 
                		else 
                		{
                    			//log.append("Open command cancelled by user." + newline);
                		}
            		}
        	});
  		
  		openButton.setBounds(new Rectangle(390, 248, 70, 33));
    		//contentPane.add(jb, null);
  		add(openButton, null);
    		add(jTextArea3, null);
    		add(jLabel3, null);
    		add(jLabel4, null);
  	}

  	public void execute() 
  	{//OK
  		Vector value = new Vector();
  		value.clear();
		value.addElement(jTextArea1.getText());
		value.addElement(jTextArea2.getText());
		value.addElement(jTextArea3.getText());
		value.addElement(jTextArea4.getText());
		
		
		System.out.println(value);
		//EntityBeanExtractor ex = new EntityBeanExtractor(value);
  	}
}
