<commit_before>/** @file
 
 Copyright (c) 2006, Intel Corporation
 All rights reserved. This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
 http://opensource.org/licenses/bsd-license.php
 
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 **/
package org.tianocore.migration;

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;

public final class FirstPanel extends JPanel implements ActionListener, ItemListener, UI {
	/**
	 *  Define class Serial Version UID
	 */
	private static final long serialVersionUID = 207759413522910399L;
	
	private String modulepath;
	private ModuleInfo mi;
	
	private JButton moduleButton, goButton, msaEditorButton, criticButton;
	private JTextField moduletext;
	private JTextArea log;
	private JFileChooser fc;
	private JCheckBox filebox, screenbox, mibox, criticbox, defaultpathbox;
	
	private boolean tofile = true, toscreen = true;
	private PrintWriter logfile;

	FirstPanel() throws Exception {
        GridBagLayout gridbag = new GridBagLayout();
        setLayout(gridbag);
        
		GridBagConstraints cst = new GridBagConstraints();
		
		goButton = new JButton("Go");
		goButton.addActionListener(this);
		goButton.setActionCommand("go");
		
		moduleButton = new JButton("Choose ModulePath");
		moduleButton.addActionListener(this);

		msaEditorButton = new JButton("MsaEditor");
		msaEditorButton.addActionListener(this);
		
		criticButton = new JButton("Critic");
		criticButton.addActionListener(this);
		
		moduletext = new JTextField(30);
		
		filebox = new JCheckBox("Output to logfile", true);
		filebox.addItemListener(this);
		
		screenbox = new JCheckBox("Specify logfile", false);
		screenbox.addItemListener(this);
		
		mibox = new JCheckBox("Print ModuleInfo", false);
		mibox.addItemListener(this);
		ModuleInfo.printModuleInfo = false;
		
		criticbox = new JCheckBox("Run Critic", true);
		criticbox.addItemListener(this);
		ModuleInfo.doCritic = true;
		
		defaultpathbox = new JCheckBox("Use Default Output Path", true);
		defaultpathbox.addItemListener(this);
		
        JPanel modulePanel = new JPanel();
        modulePanel.add(moduleButton);
        modulePanel.add(moduletext);
        modulePanel.add(goButton);
        //modulePanel.add(msaEditorButton);
        cst.gridx = 0;
        cst.gridy = 0;
        //cst.gridwidth = GridBagConstraints.REMAINDER;
        gridbag.setConstraints(modulePanel, cst);
        add(modulePanel);

        cst.gridx = 1;
        cst.gridy = 0;
        gridbag.setConstraints(criticButton, cst);
        //add(criticButton);
        
        JPanel checkboxPanel = new JPanel();
        checkboxPanel.setLayout(new BoxLayout(checkboxPanel, BoxLayout.Y_AXIS));
        checkboxPanel.add(filebox);
        checkboxPanel.add(screenbox);
        checkboxPanel.add(mibox);
        checkboxPanel.add(criticbox);
        checkboxPanel.add(defaultpathbox);
        cst.gridx = 1;
        cst.gridy = 1;
        //cst.gridheight = 2;
        gridbag.setConstraints(checkboxPanel, cst);
        add(checkboxPanel);
        
        log = new JTextArea(10,20);
        log.setMargin(new Insets(5,5,5,5));
        log.setEditable(false);
        JScrollPane logScrollPane = new JScrollPane(log);
        cst.gridx = 0;
        cst.gridy = 1;
        cst.fill = GridBagConstraints.BOTH;
        gridbag.setConstraints(logScrollPane, cst);
        add(logScrollPane);
        
		fc = new JFileChooser();
        fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
	}
	
	//---------------------------------------------------------------------------------------//
	
	public boolean yesOrNo(String question) {
		return JOptionPane.showConfirmDialog(this, question, "Yes or No", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
	}
	
	public void print(String message) {
		if (toscreen == true) {
	        log.append(message);
	        System.out.print(message);
		}
		if (tofile == true) {
			logfile.append(message);
		}
	}
	
	public void println(String message) {
		print(message + "\n");
	}

	public void println(Set<String> hash) {
		if (toscreen == true) {<commit_msg>Only allow to choose directory when choosing old code.<commit_after>/** @file
 
 Copyright (c) 2006, Intel Corporation
 All rights reserved. This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
 http://opensource.org/licenses/bsd-license.php
 
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 **/
package org.tianocore.migration;

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;

public final class FirstPanel extends JPanel implements ActionListener, ItemListener, UI {
	/**
	 *  Define class Serial Version UID
	 */
	private static final long serialVersionUID = 207759413522910399L;
	
	private String modulepath;
	private ModuleInfo mi;
	
	private JButton moduleButton, goButton, msaEditorButton, criticButton;
	private JTextField moduletext;
	private JTextArea log;
	private JFileChooser fc;
	private JCheckBox filebox, screenbox, mibox, criticbox, defaultpathbox;
	
	private boolean tofile = true, toscreen = true;
	private PrintWriter logfile;

	FirstPanel() throws Exception {
        GridBagLayout gridbag = new GridBagLayout();
        setLayout(gridbag);
        
		GridBagConstraints cst = new GridBagConstraints();
		
		goButton = new JButton("Go");
		goButton.addActionListener(this);
		goButton.setActionCommand("go");
		
		moduleButton = new JButton("Choose ModulePath");
		moduleButton.addActionListener(this);

		msaEditorButton = new JButton("MsaEditor");
		msaEditorButton.addActionListener(this);
		
		criticButton = new JButton("Critic");
		criticButton.addActionListener(this);
		
		moduletext = new JTextField(30);
		
		filebox = new JCheckBox("Output to logfile", true);
		filebox.addItemListener(this);
		
		screenbox = new JCheckBox("Specify logfile", false);
		screenbox.addItemListener(this);
		
		mibox = new JCheckBox("Print ModuleInfo", false);
		mibox.addItemListener(this);
		ModuleInfo.printModuleInfo = false;
		
		criticbox = new JCheckBox("Run Critic", true);
		criticbox.addItemListener(this);
		ModuleInfo.doCritic = true;
		
		defaultpathbox = new JCheckBox("Use Default Output Path", true);
		defaultpathbox.addItemListener(this);
		
        JPanel modulePanel = new JPanel();
        modulePanel.add(moduleButton);
        modulePanel.add(moduletext);
        modulePanel.add(goButton);
        //modulePanel.add(msaEditorButton);
        cst.gridx = 0;
        cst.gridy = 0;
        //cst.gridwidth = GridBagConstraints.REMAINDER;
        gridbag.setConstraints(modulePanel, cst);
        add(modulePanel);

        cst.gridx = 1;
        cst.gridy = 0;
        gridbag.setConstraints(criticButton, cst);
        //add(criticButton);
        
        JPanel checkboxPanel = new JPanel();
        checkboxPanel.setLayout(new BoxLayout(checkboxPanel, BoxLayout.Y_AXIS));
        checkboxPanel.add(filebox);
        checkboxPanel.add(screenbox);
        checkboxPanel.add(mibox);
        checkboxPanel.add(criticbox);
        checkboxPanel.add(defaultpathbox);
        cst.gridx = 1;
        cst.gridy = 1;
        //cst.gridheight = 2;
        gridbag.setConstraints(checkboxPanel, cst);
        add(checkboxPanel);
        
        log = new JTextArea(10,20);
        log.setMargin(new Insets(5,5,5,5));
        log.setEditable(false);
        JScrollPane logScrollPane = new JScrollPane(log);
        cst.gridx = 0;
        cst.gridy = 1;
        cst.fill = GridBagConstraints.BOTH;
        gridbag.setConstraints(logScrollPane, cst);
        add(logScrollPane);
        
		fc = new JFileChooser();
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
     	}
	
	//---------------------------------------------------------------------------------------//
	
	public boolean yesOrNo(String question) {
		return JOptionPane.showConfirmDialog(this, question, "Yes or No", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
	}
	
	public void print(String message) {
		if (toscreen == true) {
	        log.append(message);
	        System.out.print(message);
		}
		if (tofile == true) {
			logfile.append(message);
		}
	}
	
	public void println(String message) {
		print(message + "\n");
	}

	public void println(Set<String> hash) {
		if (toscreen == true) {
{'fraction_non_alphanumeric': 0.11902870759105866, 'fraction_numerical': 0.009304436627709066, 'mean_word_length': 3.112925804946337, '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': '3956626', 'n_tokens_mistral': 2849, 'n_tokens_neox': 2575, 'n_words': 638}