<commit_before>package org.ensembl.healthcheck.eg_gui;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.swing.Box;

import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import org.ensembl.healthcheck.DatabaseRegistryEntry;
import org.ensembl.healthcheck.ReportLine;
import org.ensembl.healthcheck.Reporter;
import org.ensembl.healthcheck.eg_gui.Constants;
import org.ensembl.healthcheck.eg_gui.JPopupTextArea;
import org.ensembl.healthcheck.eg_gui.ReportPanel;
import org.ensembl.healthcheck.testcase.EnsTestCase;

public class GuiReporterTab extends JPanel implements Reporter {
	
	final protected TestClassList               testList;
	final protected JScrollPane                 testListScrollPane;
	final protected TestClassListModel          listModel;
	final protected ReportPanel                 reportPanel;
	final protected TestCaseColoredCellRenderer testCaseCellRenderer;
	
	protected boolean userClickedOnList = false;
	
	final protected Map<Class<? extends EnsTestCase>,GuiReportPanelData> reportData;
	
	public void selectDefaultListItem() {
		
		if (!userClickedOnList) {
			selectLastListItem();
		}
	}
	
	/**
	 * Selects the last item in the list and scrolls to that position.
	 */
	public void selectLastListItem() {
		
		if (listModel.getSize()>0) {
			
			int indexOfLastComponentInList =listModel.getSize()-1; 
			
			testList.setSelectedIndex(indexOfLastComponentInList);
			testList.ensureIndexIsVisible(indexOfLastComponentInList);
		}
	}
	
	public GuiReporterTab() {

		this.setBorder(GuiTestRunnerFrameComponentBuilder.defaultEmptyBorder);
		
		reportData  = new HashMap<Class<? extends EnsTestCase>,GuiReportPanelData>();
		
		testList    = new TestClassList(TestClassList.TestClassListToolTipType.CLASS);		
		listModel   = new TestClassListModel();
		reportPanel = new ReportPanel();
		
		testList.setModel(listModel);
		
		testCaseCellRenderer = new TestCaseColoredCellRenderer();
		
		testList.setCellRenderer(testCaseCellRenderer);
		
		testList.addMouseListener(new MouseListener() {

			// We want to know, when as soon as the user clicks somewhere on 
			// the list so we can stop selecting the last item in the list.
			//
			@Override public void mouseClicked(MouseEvent arg0) {
				userClickedOnList = true;
			}

			@Override public void mouseEntered (MouseEvent arg0) {}
			@Override public void mouseExited  (MouseEvent arg0) {}
			@Override public void mousePressed (MouseEvent arg0) {}
			@Override public void mouseReleased(MouseEvent arg0) {}
			
		});
		
		// Setting the preferred size causes the scrollbars to not be adapted 
		// to the list changing size when items are added later on, so 
		// commented out.
		//
		//	testList.setPreferredSize(
		//		new Dimension(
		//			Constants.INITIAL_APPLICATION_WINDOW_WIDTH  / 3, 
		//			Constants.INITIAL_APPLICATION_WINDOW_HEIGHT / 3 * 2
		//		)
		//	);
		
		setLayout(new BorderLayout());
		
		testListScrollPane = new JScrollPane(testList);
		
		add(
			new JSplitPane(
				JSplitPane.HORIZONTAL_SPLIT, 
				testListScrollPane, 
				reportPanel
			), BorderLayout.CENTER
		);
		
		testList.addListSelectionListener(
			new ListSelectionListener() {

				@Override
				public void valueChanged(ListSelectionEvent arg0) {
					
					if (!arg0.getValueIsAdjusting()) {
						reportPanel.setData(
							reportData.get(
								( (TestClassListItem) listModel.getElementAt(testList.getSelectedIndex()) ).getTestClass()
							)
						);
					}
				}
			}
		);
	}
	
	@Override<commit_msg>The split in the GuiReporter can be moved in both directions now.<commit_after>package org.ensembl.healthcheck.eg_gui;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.swing.Box;

import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import org.ensembl.healthcheck.DatabaseRegistryEntry;
import org.ensembl.healthcheck.ReportLine;
import org.ensembl.healthcheck.Reporter;
import org.ensembl.healthcheck.eg_gui.Constants;
import org.ensembl.healthcheck.eg_gui.JPopupTextArea;
import org.ensembl.healthcheck.eg_gui.ReportPanel;
import org.ensembl.healthcheck.testcase.EnsTestCase;

public class GuiReporterTab extends JPanel implements Reporter {
	
	final protected TestClassList               testList;
	final protected JScrollPane                 testListScrollPane;
	final protected TestClassListModel          listModel;
	final protected ReportPanel                 reportPanel;
	final protected TestCaseColoredCellRenderer testCaseCellRenderer;
	
	protected boolean userClickedOnList = false;
	
	final protected Map<Class<? extends EnsTestCase>,GuiReportPanelData> reportData;
	
	public void selectDefaultListItem() {
		
		if (!userClickedOnList) {
			selectLastListItem();
		}
	}
	
	/**
	 * Selects the last item in the list and scrolls to that position.
	 */
	public void selectLastListItem() {
		
		if (listModel.getSize()>0) {
			
			int indexOfLastComponentInList =listModel.getSize()-1; 
			
			testList.setSelectedIndex(indexOfLastComponentInList);
			testList.ensureIndexIsVisible(indexOfLastComponentInList);
		}
	}
	
	public GuiReporterTab() {

		this.setBorder(GuiTestRunnerFrameComponentBuilder.defaultEmptyBorder);
		
		reportData  = new HashMap<Class<? extends EnsTestCase>,GuiReportPanelData>();
		
		testList    = new TestClassList(TestClassList.TestClassListToolTipType.CLASS);		
		listModel   = new TestClassListModel();
		reportPanel = new ReportPanel();
		
		testList.setModel(listModel);
		
		testCaseCellRenderer = new TestCaseColoredCellRenderer();
		
		testList.setCellRenderer(testCaseCellRenderer);
		
		testList.addMouseListener(new MouseListener() {

			// We want to know, when as soon as the user clicks somewhere on 
			// the list so we can stop selecting the last item in the list.
			//
			@Override public void mouseClicked(MouseEvent arg0) {
				userClickedOnList = true;
			}

			@Override public void mouseEntered (MouseEvent arg0) {}
			@Override public void mouseExited  (MouseEvent arg0) {}
			@Override public void mousePressed (MouseEvent arg0) {}
			@Override public void mouseReleased(MouseEvent arg0) {}
			
		});
		
		// Setting the preferred size causes the scrollbars to not be adapted 
		// to the list changing size when items are added later on, so 
		// commented out.
		//
		//	testList.setPreferredSize(
		//		new Dimension(
		//			Constants.INITIAL_APPLICATION_WINDOW_WIDTH  / 3, 
		//			Constants.INITIAL_APPLICATION_WINDOW_HEIGHT / 3 * 2
		//		)
		//	);
		
		setLayout(new BorderLayout());
		
		testListScrollPane = new JScrollPane(testList);
		
		add(
			new JSplitPane(
				JSplitPane.HORIZONTAL_SPLIT, 
				testListScrollPane, 
				new JScrollPane(reportPanel)
			), BorderLayout.CENTER
		);
		
		testList.addListSelectionListener(
			new ListSelectionListener() {

				@Override
				public void valueChanged(ListSelectionEvent arg0) {
					
					if (!arg0.getValueIsAdjusting()) {
						reportPanel.setData(
							reportData.get(
								( (TestClassListItem) listModel.getElementAt(testList.getSelectedIndex()) ).getTestClass()
							)
						);
					}
				}
			}
		);
	}
	
	@Override
{'fraction_non_alphanumeric': 0.08688783570300158, 'fraction_numerical': 0.002916514764855997, 'mean_word_length': 3.9638118214716527, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '1787190', 'n_tokens_mistral': 2845, 'n_tokens_neox': 2428, 'n_words': 543}