package project;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionListener;
import java.util.Map;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.border.Border;

public class UIFactory {
	
	
	
	public static JTabbedPane createTabbedFormPanel(Map<String,GenericForm3> forms){
		
		GenericForm3 participantForm=forms.get("Participant");
		GenericForm3 relationshipForm=forms.get("Relationship");
		GenericForm3 interestForm=forms.get("Interests");
		
		
		JTabbedPane tabbedPane=new JTabbedPane();
		tabbedPane.setBorder(BorderFactory.createLineBorder(Color.GRAY,1));
		tabbedPane.setTabPlacement(JTabbedPane.RIGHT);
		
		JScrollPane sPane1=new JScrollPane(participantForm);
		JScrollPane sPane2=new JScrollPane(relationshipForm);
		JScrollPane sPane3=new JScrollPane(interestForm);
		sPane1.setBorder(null);
		sPane2.setBorder(null);
		sPane3.setBorder(null);
		
		tabbedPane.add("Participant", sPane1);
		tabbedPane.add("Relatioships", sPane2);
		tabbedPane.add("Interests", sPane3);
		return tabbedPane;
		
	}
	
	public static JTabbedPane createTabbedFormPanel1(Map<String,GenericForm3> forms){
		
		JTabbedPane tabbedPane=new JTabbedPane();
		tabbedPane.setBorder(BorderFactory.createLineBorder(Color.GRAY,1));
		tabbedPane.setTabPlacement(JTabbedPane.RIGHT);
		
		for (String key : forms.keySet()){
			GenericForm3 form=forms.get(key);
			JScrollPane sPane=new JScrollPane(form);
			sPane.setBorder(null);
			tabbedPane.add(key, sPane);
		}
		
		return tabbedPane;
		
	}
	
	
	public static   JPanel createTitlePanel(){
		
		JPanel  titlePanel=new JPanel();
		titlePanel.setPreferredSize(new Dimension(200,50));
		//titlePanel.setBackground(new Color(186,219,241));
		titlePanel.setBorder(new CustomBorder(2,Color.blue));
		titlePanel.setLayout(new GridBagLayout());
		GridBagConstraints gc=new GridBagConstraints();
		
		JLabel label=new JLabel("Please Enter Search Text");
		RoundedTextField searchField=new RoundedTextField("",300);
		searchField.setPreferredSize(new Dimension(300,20));
		JButton searchButton=new JButton("Search");
		searchButton.setForeground(new Color(255,255,255));
		searchButton.setBackground(new Color(0,0,255));
		
		gc.insets.set(12, 0, 10, 10);
		gc.weightx=0.5;
		gc.weighty=0.5;
		gc.anchor=GridBagConstraints.FIRST_LINE_END;
		
		gc.gridx=0;
		gc.gridy=0;
		titlePanel.add(label, gc);
		
		gc.insets.set(10, 0, 10, 0);
		gc.anchor=GridBagConstraints.FIRST_LINE_START;
		gc.fill=GridBagConstraints.HORIZONTAL;
		gc.gridx=1;
		gc.gridy=0;
		gc.weightx=5.0;
		titlePanel.add(searchField, gc);
		
		gc.insets.set(6, 0, 10, 0);
		gc.fill=GridBagConstraints.NONE;
		gc.anchor=GridBagConstraints.FIRST_LINE_START;
		gc.weightx=0.5;
		gc.gridx=2;
		gc.gridy=0;
		titlePanel.add(searchButton, gc);
		
		return titlePanel;
	}
	
	
	public static JPanel createNavigationPanel(ActionListener actionListner){
		
		JPanel  navPanel=new JPanel();
		navPanel.setPreferredSize(new Dimension(200,200));
		//navPanel.setBorder(BorderFactory.createLineBorder(Color.black,1));
		//navPanel.setBackground(new Color(186,219,241));
		navPanel.setBackground(new Color(225,232,237));
		navPanel.setBorder(new CustomBorder(2,Color.blue));
		navPanel.setLayout(new GridBagLayout());
		GridBagConstraints gc=new GridBagConstraints();
		
		JButton uploadButton=new JButton("Batch Upload");
		JButton viewAllButton=new JButton("Show All Pariticipants");
		JButton viewTop5Button=new JButton("Show Top5 Pariticipants");
		JButton viewTop10Button=new JButton("Show Top10 Pariticipants");
		JButton viewBottom5Button=new JButton("Show Bottom5 Pariticipants");
		JButton viewBottom10Button=new JButton("Show Bottom10 Pariticipants");
		JButton addParticipantButton=new JButton("ADD New Participant");
		addParticipantButton.setActionCommand("AddParticipant");
		addParticipantButton.addActionListener(actionListner);
		JButton removeParticipantButton=new JButton("Remove Participant");
		
		
		gc.insets.set(5, 5, 5, 5);
		gc.weightx=0.5;
		gc.weighty=0.5;
		gc.anchor=GridBagConstraints.CENTER;
		gc.fill=GridBagConstraints.HORIZONTAL;
		
		gc.gridx=0;
		gc.gridy=0;
		navPanel.add(uploadButton,gc);
		
		gc.gridx=0;
		gc.gridy=1;
		navPanel.add(viewAllButton,gc);
		
		gc.gridx=0;
		gc.gridy=2;
		navPanel.add(viewTop5Button,gc);
		
		gc.gridx=0;
		gc.gridy=3;
		navPanel.add(viewTop10Button,gc);
		
		gc.gridx=0;
		gc.gridy=4;
		navPanel.add(viewBottom5Button,gc);
		
		gc.gridx=0;
		gc.gridy=5;
		navPanel.add(viewBottom10Button,gc);
		
		gc.gridx=0;
		gc.gridy=6;
		navPanel.add(addParticipantButton,gc);
		
		gc.anchor=GridBagConstraints.PAGE_START;
		gc.weighty=50;
		gc.gridx=0;
		gc.gridy=7;
		navPanel.add(removeParticipantButton,gc);
	
		
		return navPanel;
	}

}
