package extractor.ui.servletUI;

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

import java.util.*;

public class ServletMethodTFUI extends JPanel implements ActionListener
{
	JPanel textGroupPane;
	JComboBox methodCombo;	
	JTextField nameField;
	JScrollPane nameFieldPane;
	JTextArea methodBody;
	JScrollPane methodBodyPane;


	JTextArea paraField;
	JScrollPane paraFieldPane;
	JTextArea returnField;
	JScrollPane returnFieldPane;
	JTextArea resultField;
	JScrollPane resultFieldPane;
	
	JPanel btnPane;
	JButton nextBtn;
	JButton doneBtn;

	
	
	
	public ServletMethodTFUI()
	{
		setLayout(new BorderLayout());
		
		textGroupPane = new JPanel();		
		textGroupPane.setLayout(new BoxLayout(textGroupPane, BoxLayout.Y_AXIS));
		textGroupPane.setBorder(BorderFactory.createTitledBorder("서블릿 메소드를 바꿉니다"));		
		

	//for test		
		Vector listValues = new Vector();
		listValues.add("value 1");
		listValues.add("value 2");
		listValues.add("value 3");
		listValues.add("value 4");
		listValues.add("value 5"); 
		listValues.add("value 6");
		listValues.add("value 7");
		listValues.add("value 8");
		
				
		methodCombo = new JComboBox(listValues);
		methodCombo.addActionListener(this);
		
		nameField = new JTextField();
		nameFieldPane = new JScrollPane(nameField);
		nameFieldPane.setPreferredSize(new Dimension(200, 60));
		nameFieldPane.setBorder(BorderFactory.createTitledBorder("메소드 이름 : "));
		
		methodBody = new JTextArea();
		methodBodyPane = new JScrollPane(methodBody);
		methodBodyPane.setPreferredSize(new Dimension(200, 500));
		methodBodyPane.setBorder(BorderFactory.createTitledBorder("메소드 구현 : "));			

		paraField = new JTextArea();
		paraFieldPane = new JScrollPane(paraField);
		paraFieldPane.setBorder(BorderFactory.createTitledBorder("패러미터 : "));			
		
		returnField = new JTextArea();
		returnFieldPane = new JScrollPane(returnField);
		returnFieldPane.setBorder(BorderFactory.createTitledBorder("리턴 변수 : "));			

		resultField = new JTextArea();		
		resultFieldPane = new JScrollPane(resultField);
		resultFieldPane.setBorder(BorderFactory.createTitledBorder("변환 결과 : "));			
		
		textGroupPane.add(methodCombo);		
		textGroupPane.add(nameFieldPane);
		textGroupPane.add(Box.createRigidArea(new Dimension(0,5)));
		textGroupPane.add(methodBodyPane);
		
		//textGroupPane.add(paraFieldPane);
		//textGroupPane.add(Box.createRigidArea(new Dimension(0,5)));
		//textGroupPane.add(returnFieldPane);
		//textGroupPane.add(resultFieldPane);
		
		btnPane = new JPanel();
		nextBtn = new JButton("Next method");
		doneBtn = new JButton("Done");
		nextBtn.addActionListener(this);
		doneBtn.addActionListener(this);
		btnPane.add(nextBtn);
		btnPane.add(doneBtn);
		
		add(textGroupPane, BorderLayout.CENTER);		
		//add(btnPane, BorderLayout.SOUTH);
		
		setSize(100, 50);
	}

	public void actionPerformed(ActionEvent e) 
	{
		Object obj = e.getSource();
		if(obj == nextBtn)
		{
			
		}
		else if(e.getSource() == methodCombo)
		{
       		String method = (String)methodCombo.getSelectedItem();
       		nameField.setText(method);
       		methodBody.setText(method);
	   	}
	}
	
	
	public static void main(String[] arg)
	{
		JFrame f = new JFrame();
		ServletMethodTFUI sName = new ServletMethodTFUI();
		f.getContentPane().add(sName);
		f.setVisible(true);
		f.pack();
	}
	
}