<commit_before>package org.petschko.rpgmakermv.decrypt;

import org.petschko.lib.Const;
import org.petschko.lib.Functions;
import org.petschko.lib.gui.JLabelWrap;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.GridLayout;

/**
 * Author: <NAME> [<EMAIL>]
 * Authors-Website: http://petschko.org/
 * Date: 28.12.2016
 * Time: 19:14
 * Update: -
 * Version: 0.0.1
 *
 * Notes: GUI Class
 */
class GUI {
	private JFrame mainWindow;
	private GUI_Menu mainMenu;
	private JPanel windowPanel = new JPanel(new GridLayout(1, 2));
	private JPanel projectFilesPanel = new JPanel();
	private JPanel fileList = new JPanel();
	private GUI_FileInfo fileInfo = new GUI_FileInfo();
	private RPGProject rpgProject;
	private String decryptKey = "";

	/**
	 * GUI Constructor
	 */
	GUI() {
		// Create and Setup components
		this.createMainWindow();
		this.createMainMenu();
		this.createWindowGUI();

		// Center Window and Display it
		this.mainWindow.setLocationRelativeTo(null);
		this.mainWindow.setVisible(true);
		this.mainWindow.pack();

		// Assign Listener
		this.assignMainMenuListener();
		// todo implement
	}

	/**
	 * Dispose the GUI
	 */
	void dispose() {
		mainWindow.dispose();
	}

	/**
	 * Creates and assign the MainFrame
	 */
	private void createMainWindow() {
		this.mainWindow = new JFrame(Config.programName + " by " + Const.creator + " " + Config.version);

		// Change close Action
		this.mainWindow.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		this.mainWindow.addWindowListener(GUI_ActionListener.closeButton());
	}

	/**
	 * Creates and assign the Main-Menu
	 */
	private void createMainMenu() {
		this.mainMenu = new GUI_Menu();
		this.mainWindow.add(this.mainMenu, BorderLayout.NORTH);

		// Set Menu-Settings
		if(Functions.strToBool(App.preferences.getConfig(Preferences.ignoreFakeHeader, "false")))
			this.mainMenu.ignoreFakeHeader.setState(true);

		if(Functions.strToBool(App.preferences.getConfig(Preferences.loadInvalidRPGDirs, "false")))
			this.mainMenu.loadInvalidRPGDirs.setState(true);

		if(Functions.strToBool(App.preferences.getConfig(Preferences.clearOutputDirBeforeDecrypt, "true")))
			this.mainMenu.clearOutputDir.setState(true);

		if(! this.mainMenu.clearOutputDir.isSelected())
			if(Functions.strToBool(App.preferences.getConfig(Preferences.overwriteFiles, "false")))
				this.mainMenu.overwriteExistingFiles.setState(true);
		else
			this.mainMenu.overwriteExistingFiles.setEnabled(false);
		this.mainMenu.enableOnRPGProject(false);
	}

	/**
	 * Creates all Components for the Window
	 */
	private void createWindowGUI() {
		JLabelWrap filesListText = new JLabelWrap("Please open a RPG-Maker MV Project (File -> Open)");
		filesListText.setRows(2);

		/*JScrollPane scrollPane = new JScrollPane(
				this.fileList,
				ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
				ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
		);*/

		// Design stuff
		this.projectFilesPanel.setLayout(new BorderLayout());
		this.projectFilesPanel.setBorder(BorderFactory.createTitledBorder("Project-Files"));
		this.windowPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

		// Assign to the main comps
		this.projectFilesPanel.add(filesListText, BorderLayout.CENTER);
		this.mainWindow.add(this.windowPanel, BorderLayout.CENTER);
		this.windowPanel.add(projectFilesPanel);
		this.windowPanel.add(this.fileInfo);
	}

	/**
	 * Assigns ActionListener to the Main-Menu parts
	 */
	private void assignMainMenuListener() {
		// -- File
		this.mainMenu.exit.addActionListener(GUI_ActionListener.closeMenu());
		// -- Options
		this.mainMenu.ignoreFakeHeader.addActionListener(GUI_ActionListener.switchSetting(Preferences.ignoreFakeHeader));
		this.mainMenu.loadInvalidRPGDirs.addActionListener(GUI_ActionListener.switchSetting(Preferences.loadInvalidRPGDirs));<commit_msg>Added missing braces<commit_after>package org.petschko.rpgmakermv.decrypt;

import org.petschko.lib.Const;
import org.petschko.lib.Functions;
import org.petschko.lib.gui.JLabelWrap;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.GridLayout;

/**
 * Author: <NAME> [<EMAIL>]
 * Authors-Website: http://petschko.org/
 * Date: 28.12.2016
 * Time: 19:14
 * Update: -
 * Version: 0.0.1
 *
 * Notes: GUI Class
 */
class GUI {
	private JFrame mainWindow;
	private GUI_Menu mainMenu;
	private JPanel windowPanel = new JPanel(new GridLayout(1, 2));
	private JPanel projectFilesPanel = new JPanel();
	private JPanel fileList = new JPanel();
	private GUI_FileInfo fileInfo = new GUI_FileInfo();
	private RPGProject rpgProject;
	private String decryptKey = "";

	/**
	 * GUI Constructor
	 */
	GUI() {
		// Create and Setup components
		this.createMainWindow();
		this.createMainMenu();
		this.createWindowGUI();

		// Center Window and Display it
		this.mainWindow.setLocationRelativeTo(null);
		this.mainWindow.setVisible(true);
		this.mainWindow.pack();

		// Assign Listener
		this.assignMainMenuListener();
		// todo implement
	}

	/**
	 * Dispose the GUI
	 */
	void dispose() {
		mainWindow.dispose();
	}

	/**
	 * Creates and assign the MainFrame
	 */
	private void createMainWindow() {
		this.mainWindow = new JFrame(Config.programName + " by " + Const.creator + " " + Config.version);

		// Change close Action
		this.mainWindow.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		this.mainWindow.addWindowListener(GUI_ActionListener.closeButton());
	}

	/**
	 * Creates and assign the Main-Menu
	 */
	private void createMainMenu() {
		this.mainMenu = new GUI_Menu();
		this.mainWindow.add(this.mainMenu, BorderLayout.NORTH);

		// Set Menu-Settings
		if(Functions.strToBool(App.preferences.getConfig(Preferences.ignoreFakeHeader, "false")))
			this.mainMenu.ignoreFakeHeader.setState(true);

		if(Functions.strToBool(App.preferences.getConfig(Preferences.loadInvalidRPGDirs, "false")))
			this.mainMenu.loadInvalidRPGDirs.setState(true);

		if(Functions.strToBool(App.preferences.getConfig(Preferences.clearOutputDirBeforeDecrypt, "true")))
			this.mainMenu.clearOutputDir.setState(true);

		if(! this.mainMenu.clearOutputDir.isSelected()) {
			if(Functions.strToBool(App.preferences.getConfig(Preferences.overwriteFiles, "false")))
				this.mainMenu.overwriteExistingFiles.setState(true);
		} else
			this.mainMenu.overwriteExistingFiles.setEnabled(false);
		this.mainMenu.enableOnRPGProject(false);
	}

	/**
	 * Creates all Components for the Window
	 */
	private void createWindowGUI() {
		JLabelWrap filesListText = new JLabelWrap("Please open a RPG-Maker MV Project (File -> Open)");
		filesListText.setColumns(20);

		/*JScrollPane scrollPane = new JScrollPane(
				this.fileList,
				ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
				ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
		);*/

		// Design stuff
		this.projectFilesPanel.setLayout(new BorderLayout());
		this.projectFilesPanel.setBorder(BorderFactory.createTitledBorder("Project-Files"));
		this.windowPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

		// Assign to the main comps
		this.projectFilesPanel.add(filesListText, BorderLayout.NORTH);
		this.mainWindow.add(this.windowPanel, BorderLayout.CENTER);
		this.windowPanel.add(projectFilesPanel);
		this.windowPanel.add(this.fileInfo);
	}

	/**
	 * Assigns ActionListener to the Main-Menu parts
	 */
	private void assignMainMenuListener() {
		// -- File
		this.mainMenu.exit.addActionListener(GUI_ActionListener.closeMenu());
		// -- Options
		this.mainMenu.ignoreFakeHeader.addActionListener(GUI_ActionListener.switchSetting(Preferences.ignoreFakeHeader));
		this.mainMenu.loadInvalidRPGDirs.addActionListener(GUI_ActionListener.switchSetting(Preferences.loadInvalidRPGDirs));
{'fraction_non_alphanumeric': 0.12080880470949577, 'fraction_numerical': 0.006782697722037369, 'mean_word_length': 4.933940774487471, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '1877767', 'n_tokens_mistral': 2742, 'n_tokens_neox': 2481, 'n_words': 423}