<commit_before>package org.robockets.runqueue.client.views;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import org.robockets.runqueue.client.controllers.Controllers;
import org.robockets.runqueue.client.models.QueueModel;

public class MainView implements ActionListener {
	private final int WIDTH = 500, HEIGHT = 280;
	private final int ROWS = 2, COLUMNS = 1;
	private final int BUTTON_WIDTH = 100;
	private final int SECOND_LINE_OFFSET = 50;
	
	private String[] priorities = {"Critical", "High", "Medium", "Low"};
	
	private JFrame jFrame;
	public JButton enableButton, disableButton;
	public JComboBox<String> priorityDropdown;
	private Font font = new Font("Arial", Font.PLAIN, 30);
	public JLabel usernameLabel, positionLabel;
	
	private QueueModel queueModel;
		
	public MainView (QueueModel queueModel) {
		this.queueModel = queueModel;
		this.jFrame = this.setupJFrame();
		this.setupWindow();
	}
	
	/**
	 * Create the JFrame to be used for this view
	 * 
	 * @return the JFrame
	 */
	private JFrame setupJFrame () {
		JFrame jFrame = new JFrame("Run-Queue Client");
		jFrame.setResizable(false);
		jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jFrame.setLayout(new GridLayout(ROWS, COLUMNS));
		
		return jFrame;
	}
	
	/**
	 * Setup all the components to be displayed in this view
	 */
	private void setupWindow () {		
		// Top half of the screen
		JPanel topPanel = new JPanel();
		topPanel.setMaximumSize(new Dimension(WIDTH, HEIGHT));
		topPanel.setLayout(new GridBagLayout());
		
		GridBagConstraints c = new GridBagConstraints();
		
		positionLabel = new JLabel("Position: 1/1");
		font = font.deriveFont(30f);
		positionLabel.setFont(font);
		c.gridx = 0;
		c.gridy = 0;
		c.ipadx = 100;
		c.anchor = GridBagConstraints.LINE_START;
	    topPanel.add(positionLabel, c);
		
	    usernameLabel = new JLabel("USERNAME");
	    font = font.deriveFont(40f);
	    usernameLabel.setFont(font);
		c.gridx = 3;
		c.gridy = 0;
		c.ipadx = 2;
		c.anchor = GridBagConstraints.LINE_END;
	    topPanel.add(usernameLabel, c);
	    
	    enableButton = new JButton("Enable");
	    enableButton.setEnabled(true);
	    enableButton.setActionCommand("ENABLE_BUTTON");
	    enableButton.addActionListener(this);
	    c.gridx = 0;
	    c.gridy = 3;
	    c.ipadx = BUTTON_WIDTH / 3;
	    c.anchor = GridBagConstraints.LINE_START;
	    c.insets = new Insets(SECOND_LINE_OFFSET, 0, 0, 0);
	    topPanel.add(enableButton, c);
	    
	    disableButton = new JButton("Disable");
	    disableButton.setEnabled(false);
	    disableButton.setActionCommand("DISABLE_BUTTON");
	    disableButton.addActionListener(this);
	    c.gridx = 0;<commit_msg>On mouse over usernameLabel turns into a textbox<commit_after>package org.robockets.runqueue.client.views;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;

import org.robockets.runqueue.client.controllers.Controllers;
import org.robockets.runqueue.client.models.QueueModel;

public class MainView implements ActionListener {
	private final int WIDTH = 500, HEIGHT = 280;
	private final int ROWS = 2, COLUMNS = 1;
	private final int BUTTON_WIDTH = 100;
	private final int SECOND_LINE_OFFSET = 50;
	
	private String[] priorities = {"Critical", "High", "Medium", "Low"};
	
	private JFrame jFrame;
	public JButton enableButton, disableButton;
	public JComboBox<String> priorityDropdown;
	private Font font = new Font("Arial", Font.PLAIN, 30);
	public JLabel usernameLabel, positionLabel;
	public JTextField usernameField;
	
	private QueueModel queueModel;
		
	public MainView (QueueModel queueModel) {
		this.queueModel = queueModel;
		this.jFrame = this.setupJFrame();
		this.setupWindow();
	}
	
	/**
	 * Create the JFrame to be used for this view
	 * 
	 * @return the JFrame
	 */
	private JFrame setupJFrame () {
		JFrame jFrame = new JFrame("Run-Queue Client");
		jFrame.setResizable(false);
		jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jFrame.setLayout(new GridLayout(ROWS, COLUMNS));
		
		return jFrame;
	}
	
	/**
	 * Setup all the components to be displayed in this view
	 */
	private void setupWindow () {		
		// Top half of the screen
		JPanel topPanel = new JPanel();
		topPanel.setMaximumSize(new Dimension(WIDTH, HEIGHT));
		topPanel.setLayout(new GridBagLayout());
		
		GridBagConstraints c = new GridBagConstraints();
		
		positionLabel = new JLabel("Position: 1/1");
		font = font.deriveFont(30f);
		positionLabel.setFont(font);
		c.gridx = 0;
		c.gridy = 0;
		c.ipadx = 100;
		c.anchor = GridBagConstraints.LINE_START;
	    topPanel.add(positionLabel, c);
		
	    usernameField = new JTextField("USERNAME", 20);
	    font = font.deriveFont(40f);
	    usernameField.setFont(font);
	    usernameField.setMinimumSize(new Dimension(225, 47));
	    usernameField.setVisible(false);
	    usernameField.addMouseListener(new MouseAdapter () {
	    	public final void mouseExited (MouseEvent e) {
	    		String text = usernameField.getText();
	    		usernameLabel.setText(text);
	    		usernameLabel.setVisible(true);
	    		usernameField.setVisible(false);
	    		Controllers.main.updateUsername(text);
	    	}
	    });
	    c.gridx = 3;
		c.gridy = 0;
		c.ipadx = 2;
		c.anchor = GridBagConstraints.LINE_END;
	    topPanel.add(usernameField, c);
	    
	    usernameLabel = new JLabel("USERNAME");
	    font = font.deriveFont(40f);
	    usernameLabel.setFont(font);
	    usernameLabel.addMouseListener(new MouseAdapter () {
	    	public final void mouseEntered (MouseEvent e) {
	    		usernameField.setText(usernameLabel.getText());
	    		usernameLabel.setVisible(false);
	    		usernameField.setVisible(true);
	    	}
	    });
		c.gridx = 3;
		c.gridy = 0;
		c.ipadx = 2;
		c.anchor = GridBagConstraints.LINE_END;
	    topPanel.add(usernameLabel, c);
	    
	    enableButton = new JButton("Enable");
	    enableButton.setEnabled(true);
	    enableButton.setActionCommand("ENABLE_BUTTON");
	    enableButton.addActionListener(this);
	    c.gridx = 0;
	    c.gridy = 3;
	    c.ipadx = BUTTON_WIDTH / 3;
	    c.anchor = GridBagConstraints.LINE_START;
	    c.insets = new Insets(SECOND_LINE_OFFSET, 0, 0, 0);
	    topPanel.add(enableButton, c);
	    
	    disableButton = new JButton("Disable");
	    disableButton.setEnabled(false);
	    disableButton.setActionCommand("DISABLE_BUTTON");
	    disableButton.addActionListener(this);
	    c.gridx = 0;
{'fraction_non_alphanumeric': 0.11057091262675371, 'fraction_numerical': 0.011668287262119739, 'mean_word_length': 3.968944099378882, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1374186', 'n_tokens_mistral': 2545, 'n_tokens_neox': 2291, 'n_words': 516}