<commit_before>package edu.usfca.vas.graphics.fa;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import javax.swing.*;

import edu.usfca.xj.appkit.frame.XJFrame;
import edu.usfca.xj.appkit.gview.object.GElement;
import edu.usfca.xj.appkit.gview.object.GLink;
import Query.*;
import connection.Step;

public class GElementFANickName extends JPanel implements ActionListener {
	
	private static final long serialVersionUID = -511482713793989551L;
	//hold the links stuff (for links)
	ArrayList<GLink> glinks = new ArrayList<GLink>();
	ArrayList<JLabel> labels = new ArrayList<JLabel>();
	ArrayList<JPanel> panels = new ArrayList<JPanel>();
	ArrayList<JTextField> textfields = new ArrayList<JTextField>();
	//hold the elements stuff (for states)
	ArrayList<GElement> gelements = new ArrayList<GElement>();
	ArrayList<JLabel> Elabels = new ArrayList<JLabel>();
	ArrayList<JPanel> Epanels = new ArrayList<JPanel>();
	ArrayList<JTextField> Etextfields = new ArrayList<JTextField>();
	//present active states
	JLabel activeStateLabel = new JLabel();	
	//JPanel linkPanel;
	//JPanel elementPanel;
	//JPanel executionPanel;
	public static JPanel queryPanel;
	JPanel queryEditPanel;
	JTabbedPane tabs;
	GViewFAMachine mac;

	DefaultComboBoxModel model  = new DefaultComboBoxModel();
	DefaultComboBoxModel destinationModel = new DefaultComboBoxModel();

	JComboBox contextList = new JComboBox(model);
	JComboBox destinationList = new JComboBox(destinationModel);
	String condition = "";
	String set = "";
	ArrayList<String> states = new ArrayList<String>();
	HashMap<String,JButton> buttonCache = new HashMap<String,JButton>();
	TextField setFill = new TextField("Leave this blank for transition query (delete this comment)", 20);
	TextField conditionFill = new TextField("Press enter to submit command", 20);
	static HashMap<String, LinkedList<Query>> database = new HashMap();
	static String currentDisplayName = "";

	//creates the naming panel
	public GElementFANickName() {
		super();
		this.tabs = new JTabbedPane();
		tabs.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
		tabs.setPreferredSize(new Dimension(1980, 180));
		//this.add(tabs);
		this.queryPanel  = new JPanel();
		this.queryEditPanel = new JPanel();

		makeQueryStuff();
		//tabs.addTab("New Tab", null);
		tabs.setVisible(true);
		setVisible(true);
		JScrollPane scroll = new JScrollPane(tabs, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); // TODO Check
		scroll.setPreferredSize(new Dimension(950, 190));
		this.add(scroll);

		//this.setSize(new Dimension(600, 100));
		//return namingPanel;

	}
	
	public static void putPertainingQueriesIn(String label){
		if(database.get(label) != null){
			if(!currentDisplayName.equals(label) && false){
				GElementFANickName.queryPanel.removeAll();
				currentDisplayName = label;
			}
			//System.out.println(label + "Being displayed");
			for(Query que: database.get(label)){
			JLabel name = new JLabel(que.queryInfo());
			//System.out.println("It should be doing stuff rn with this query: " + que.queryInfo());
			//if(GElementFANickName.queryPanel.get(name) == null)
			for(Component pan: GElementFANickName.queryPanel.getComponents()){
				if(((JLabel)pan).getText().equals(name.getText())){
					return;
				}
			}
			GElementFANickName.queryPanel.add(name);
		}
	}
}
	
	private void makeQueryStuff(){
		//Query Creation
		this.queryPanel = new JPanel();
		this.queryEditPanel = new JPanel();
		this.queryPanel.setLayout(new BoxLayout(queryPanel, BoxLayout.Y_AXIS));
		this.queryEditPanel.setLayout(new BoxLayout(queryEditPanel, BoxLayout.Y_AXIS));
		tabs.addTab("Pertaining Queries", this.queryPanel);
		tabs.addTab("Query Editor", this.queryEditPanel);

		//putPertainingQueriesIn();
		
		JLabel context = new JLabel("Context");
		JPanel contextPanel = new JPanel(); 
		//JButton addContext = new JButton("+");
		contextPanel.setLayout(new BoxLayout(contextPanel, BoxLayout.X_AXIS));
		contextPanel.add(Box.createRigidArea(new Dimension(5,0)));
		contextPanel.add(context);
		contextPanel.add(Box.createRigidArea(new Dimension(10,0)));
		contextPanel.add(contextList);
		contextPanel.add(Box.createRigidArea(new Dimension(10,0)));
		//contextPanel.add(addContext);
		contextPanel.add(Box.createRigidArea(new Dimension(700,0)));

		/*
		JLabel pertaining =  new JLabel("For");
		JComboBox pertainingList = new JComboBox();
		JButton addPertain = new JButton("+");
		JPanel pertainPanel = new JPanel();
		pertainPanel.setLayout(new BoxLayout(pertainPanel, BoxLayout.X_AXIS));
		pertainPanel.add(Box.createRigidArea(new Dimension(5,0)));
		pertainPanel.add(pertaining);
		pertainPanel.add(Box.createRigidArea(new Dimension(40,0)));
		pertainPanel.add(pertainingList);
		pertainPanel.add(Box.createRigidArea(new Dimension(10,0)));
		pertainPanel.add(addPertain);
		pertainPanel.add(Box.createRigidArea(new Dimension(700,0)));
		

		JPanel frequencyPanel = new JPanel();
		JLabel frequency = new JLabel("Frequency");
		JComboBox frequencyList = new JComboBox(new String[] {"once","continuous"});
		frequencyPanel.setLayout(new BoxLayout(frequencyPanel, BoxLayout.X_AXIS));
		frequencyPanel.add(Box.createRigidArea(new Dimension(5,0)));
		frequencyPanel.add(frequency);
		frequencyPanel.add(Box.createRigidArea(new Dimension(10,0)));
		frequencyPanel.add(frequencyList);
		frequencyPanel.add(Box.createRigidArea(new Dimension(700,0)));
*/
		
		JPanel conditionPanel = new JPanel();
		JLabel condition = new JLabel("Condition");
		conditionFill.addActionListener(this);
		conditionPanel.setLayout(new BoxLayout(conditionPanel, BoxLayout.X_AXIS));
		conditionPanel.add(Box.createRigidArea(new Dimension(5,0)));
		conditionPanel.add(condition);
		conditionPanel.add(Box.createRigidArea(new Dimension(5,0)));
		conditionPanel.add(conditionFill);
		conditionPanel.add(Box.createRigidArea(new Dimension(693,0)));

		JPanel setPanel = new JPanel();
		JLabel set = new JLabel("Set");
		setFill.addActionListener(this);
		setPanel.setLayout(new BoxLayout(setPanel, BoxLayout.X_AXIS));
		setPanel.add(Box.createRigidArea(new Dimension(5,0)));
		setPanel.add(set);
		setPanel.add(Box.createRigidArea(new Dimension(5,0)));
		setPanel.add(setFill);
		setPanel.add(Box.createRigidArea(new Dimension(656,0)));

		JPanel destinationPanel = new JPanel();
		JLabel destination = new JLabel("Destination");


		destinationPanel.setLayout(new BoxLayout(destinationPanel, BoxLayout.X_AXIS));
		destinationPanel.add(Box.createRigidArea(new Dimension(5,0)));
		destinationPanel.add(destination);<commit_msg>Made query tab pretty<commit_after>package edu.usfca.vas.graphics.fa;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import javax.swing.*;

import edu.usfca.xj.appkit.frame.XJFrame;
import edu.usfca.xj.appkit.gview.object.GElement;
import edu.usfca.xj.appkit.gview.object.GLink;
import Query.*;
import connection.Step;

public class GElementFANickName extends JPanel implements ActionListener {
	
	private static final long serialVersionUID = -511482713793989551L;
	//hold the links stuff (for links)
	ArrayList<GLink> glinks = new ArrayList<GLink>();
	ArrayList<JLabel> labels = new ArrayList<JLabel>();
	ArrayList<JPanel> panels = new ArrayList<JPanel>();
	ArrayList<JTextField> textfields = new ArrayList<JTextField>();
	//hold the elements stuff (for states)
	ArrayList<GElement> gelements = new ArrayList<GElement>();
	ArrayList<JLabel> Elabels = new ArrayList<JLabel>();
	ArrayList<JPanel> Epanels = new ArrayList<JPanel>();
	ArrayList<JTextField> Etextfields = new ArrayList<JTextField>();
	//present active states
	JLabel activeStateLabel = new JLabel();	
	//JPanel linkPanel;
	//JPanel elementPanel;
	//JPanel executionPanel;
	public static JPanel queryPanel;
	JPanel queryEditPanel;
	JTabbedPane tabs;
	GViewFAMachine mac;

	DefaultComboBoxModel model  = new DefaultComboBoxModel();
	DefaultComboBoxModel destinationModel = new DefaultComboBoxModel();

	JComboBox contextList = new JComboBox(model);
	JComboBox destinationList = new JComboBox(destinationModel);
	String condition = "";
	String set = "";
	ArrayList<String> states = new ArrayList<String>();
	HashMap<String,JButton> buttonCache = new HashMap<String,JButton>();
	TextField setFill = new TextField("Leave this blank for transition query (delete this comment)", 20);
	TextField conditionFill = new TextField("Press enter to submit command", 20);
	static HashMap<String, LinkedList<Query>> database = new HashMap();
	static String currentDisplayName = "";

	//creates the naming panel
	public GElementFANickName() {
		super();
		this.tabs = new JTabbedPane();
		tabs.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
		tabs.setPreferredSize(new Dimension(1980, 180));
		//this.add(tabs);
		this.queryPanel  = new JPanel();
		this.queryEditPanel = new JPanel();

		makeQueryStuff();
		//tabs.addTab("New Tab", null);
		tabs.setVisible(true);
		setVisible(true);
		JScrollPane scroll = new JScrollPane(tabs, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); // TODO Check
		scroll.setPreferredSize(new Dimension(950, 190));
		this.add(scroll);

		//this.setSize(new Dimension(600, 100));
		//return namingPanel;

	}
	
	public static void putPertainingQueriesIn(String label){
		if(database.get(label) != null){
			if(!currentDisplayName.equals(label) && false){
				GElementFANickName.queryPanel.removeAll();
				currentDisplayName = label;
			}
			//System.out.println(label + "Being displayed");
			for(Query que: database.get(label)){
			JLabel name = new JLabel(que.queryInfo());
			//System.out.println("It should be doing stuff rn with this query: " + que.queryInfo());
			//if(GElementFANickName.queryPanel.get(name) == null)
			for(Component pan: GElementFANickName.queryPanel.getComponents()){
				if(((JLabel)pan).getText().equals(name.getText())){
					return;
				}
			}
			GElementFANickName.queryPanel.add(name);
		}
	}
}
	
	private void makeQueryStuff(){
		//Query Creation
		this.queryPanel = new JPanel();
		this.queryEditPanel = new JPanel();
		this.queryPanel.setLayout(new BoxLayout(queryPanel, BoxLayout.Y_AXIS));
		this.queryEditPanel.setLayout(new BoxLayout(queryEditPanel, BoxLayout.Y_AXIS));
		tabs.addTab("Pertaining Queries", this.queryPanel);
		tabs.addTab("Query Editor", this.queryEditPanel);

		//putPertainingQueriesIn();
		
		JLabel context = new JLabel("Context");
		JPanel contextPanel = new JPanel(); 
		//JButton addContext = new JButton("+");
		contextPanel.setLayout(new BoxLayout(contextPanel, BoxLayout.X_AXIS));
		contextPanel.add(Box.createRigidArea(new Dimension(5,0)));
		contextPanel.add(context);
		contextPanel.add(Box.createRigidArea(new Dimension(33,0)));
		contextPanel.add(contextList);
		contextPanel.add(Box.createRigidArea(new Dimension(10,0)));
		//contextPanel.add(addContext);
		contextPanel.add(Box.createRigidArea(new Dimension(700,0)));

		/*
		JLabel pertaining =  new JLabel("For");
		JComboBox pertainingList = new JComboBox();
		JButton addPertain = new JButton("+");
		JPanel pertainPanel = new JPanel();
		pertainPanel.setLayout(new BoxLayout(pertainPanel, BoxLayout.X_AXIS));
		pertainPanel.add(Box.createRigidArea(new Dimension(5,0)));
		pertainPanel.add(pertaining);
		pertainPanel.add(Box.createRigidArea(new Dimension(40,0)));
		pertainPanel.add(pertainingList);
		pertainPanel.add(Box.createRigidArea(new Dimension(10,0)));
		pertainPanel.add(addPertain);
		pertainPanel.add(Box.createRigidArea(new Dimension(700,0)));
		

		JPanel frequencyPanel = new JPanel();
		JLabel frequency = new JLabel("Frequency");
		JComboBox frequencyList = new JComboBox(new String[] {"once","continuous"});
		frequencyPanel.setLayout(new BoxLayout(frequencyPanel, BoxLayout.X_AXIS));
		frequencyPanel.add(Box.createRigidArea(new Dimension(5,0)));
		frequencyPanel.add(frequency);
		frequencyPanel.add(Box.createRigidArea(new Dimension(10,0)));
		frequencyPanel.add(frequencyList);
		frequencyPanel.add(Box.createRigidArea(new Dimension(700,0)));
*/
		
		JPanel conditionPanel = new JPanel();
		JLabel condition = new JLabel("Condition");
		conditionFill.addActionListener(this);
		conditionPanel.setLayout(new BoxLayout(conditionPanel, BoxLayout.X_AXIS));
		conditionPanel.add(Box.createRigidArea(new Dimension(5,0)));
		conditionPanel.add(condition);
		conditionPanel.add(Box.createRigidArea(new Dimension(25,0)));
		conditionPanel.add(conditionFill);
		conditionPanel.add(Box.createRigidArea(new Dimension(600,0)));

		JPanel setPanel = new JPanel();
		JLabel set = new JLabel("Set");
		setFill.addActionListener(this);
		setPanel.setLayout(new BoxLayout(setPanel, BoxLayout.X_AXIS));
		setPanel.add(Box.createRigidArea(new Dimension(5,0)));
		setPanel.add(set);
		setPanel.add(Box.createRigidArea(new Dimension(68,0)));
		setPanel.add(setFill);
		setPanel.add(Box.createRigidArea(new Dimension(600,0))); //was 656

		JPanel destinationPanel = new JPanel();
		JLabel destination = new JLabel("Destination");
		destinationPanel.setLayout(new BoxLayout(destinationPanel, BoxLayout.X_AXIS));
		destinationPanel.add(Box.createRigidArea(new Dimension(5,0)));
		destinationPanel.add(destination);
{'fraction_non_alphanumeric': 0.13050644291279592, 'fraction_numerical': 0.014159424632903806, 'mean_word_length': 5.989005235602094, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1457357', 'n_tokens_mistral': 4695, 'n_tokens_neox': 4290, 'n_words': 820}