<commit_before>package ui;

import controller.StudentCardFrameController;
import stage1.elements.GeneralElementStage1;

import javax.swing.*;
import javax.swing.border.EtchedBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.*;
import java.util.List;

/**
 *
 */
public class StudentCardFrame implements StudentCardFrameController.StudentCardFrameCallback {

	public static final String TXT_STUDENT_CARD = "Карточка студента";
	public static final String TXT_MAIN_ELEMENTS = "Основные элементы:";
	public static final String TXT_ACCESSORY_ELEMENTS = "Дополнительные элементы:";
	public static final String TXT_USER_FIRST_NAME = "Имя: ";
	public static final String TXT_USER_MIDDLE_NAME = "Отчество: ";
	public static final String TXT_USER_LAST_NAME = "Фамилия: ";
	public static final String TXT_USER_NUM_OF_REC_BOOK = "Номер группы: ";
	public static final String TXT_STAGE_1_MAIN_PANEL_NAME = "Химический состав элементов";
	public static final String TXT_TAB_1_NAME = "Задача 1";
	public static final String TXT_TAB_1_TOOL_TIP = "Расчет процессов испарения металлов при сварке плавлением";

	private JFrame studentCardFrame = new JFrame(TXT_STUDENT_CARD);
	private StudentCardFrameController controller;

	private List<GeneralElementStage1> basicElementsStage1;
	private List<GeneralElementStage1> accessoryElementsStage1;

	private JPanel jpUserData = new JPanel();
	private JPanel jpElementsStage1 = new JPanel();
	private JPanel jpDirection = new JPanel();
	private JButton jbtnOk = new JButton("Ok");
	private JButton jbtnCancel = new JButton("Cancel");
	private JLabel jlMsg = new JLabel();

	private java.util.List<JTextField> jtfAlloyComWeightsStage1 = new ArrayList<>();


	public StudentCardFrame() {
		controller = new StudentCardFrameController(studentCardFrame, this);

		studentCardFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		addComponentToPane(studentCardFrame.getContentPane());
		studentCardFrame.setPreferredSize(new Dimension(500, 500));
		studentCardFrame.pack();
		studentCardFrame.setLocationRelativeTo(null);
		studentCardFrame.setVisible(true);
	}

	private void addComponentToPane(final Container contentPane) {
		JPanel jpMsg = new JPanel(new FlowLayout(FlowLayout.LEFT));
		JPanel jpFirstName = new JPanel(new FlowLayout(FlowLayout.LEFT));
		JPanel jpMiddleName = new JPanel(new FlowLayout(FlowLayout.LEFT));
		JPanel jpLastName = new JPanel(new FlowLayout(FlowLayout.LEFT));
		JPanel jpNumOfRecBook = new JPanel(new FlowLayout(FlowLayout.LEFT));

		final JTextField jtfFirstName = new JTextField(10); // Имя
		final JTextField jtfMiddleName = new JTextField(12); // Отчество
		final JTextField jtfLastName = new JTextField(12); // Фамилия
		final JTextField jtfNumOfRecBook = new JTextField(10);

		jtfFirstName.setName(TXT_USER_FIRST_NAME);
		jtfMiddleName.setName(TXT_USER_MIDDLE_NAME);
		jtfLastName.setName(TXT_USER_LAST_NAME);
		jtfNumOfRecBook.setName(TXT_USER_NUM_OF_REC_BOOK);

		jpMsg.add(jlMsg);
		jpFirstName.add(new JLabel(TXT_USER_FIRST_NAME));
		jpFirstName.add(jtfFirstName);
		jpMiddleName.add(new JLabel(TXT_USER_MIDDLE_NAME));
		jpMiddleName.add(jtfMiddleName);
		jpLastName.add(new JLabel(TXT_USER_LAST_NAME));
		jpLastName.add(jtfLastName);
		jpNumOfRecBook.add(new JLabel(TXT_USER_NUM_OF_REC_BOOK));
		jpNumOfRecBook.add(jtfNumOfRecBook);

		jpUserData.setLayout(new BoxLayout(jpUserData, BoxLayout.Y_AXIS));
		jpUserData.add(jpMsg);
		jpUserData.add(jpLastName);
		jpUserData.add(jpMiddleName);
		jpUserData.add(jpFirstName);
		jpUserData.add(jpNumOfRecBook);


		JPanel jpRows = new JPanel();
		jpRows.setLayout(new BoxLayout(jpRows, BoxLayout.Y_AXIS));

		jpRows.add(new JLabel(TXT_MAIN_ELEMENTS));
		for (GeneralElementStage1 el : basicElementsStage1) {
			addRowsToPanel(jpRows, el);
		}

		jpRows.add(new JLabel(TXT_ACCESSORY_ELEMENTS));
		for (GeneralElementStage1 el : accessoryElementsStage1) {
			addRowsToPanel(jpRows, el);
		}


		jpElementsStage1.setLayout(new FlowLayout());
		jpElementsStage1.add(jpRows);

		jpDirection.setLayout(new FlowLayout());
		jpDirection.add(jbtnOk);
		jpDirection.add(jbtnCancel);

		jbtnOk.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				for (JTextField jtf : jtfAlloyComWeightsStage1) {
					System.out.println(jtf.getName() + " : " + jtf.getText());
				}

				if (isShowWarning(controller.validateInputData(jtfLastName, StudentCardFrameController.ValidatorVariant.IS_TEXT)))
					return;
				if (isShowWarning(controller.validateInputData(jtfFirstName, StudentCardFrameController.ValidatorVariant.IS_TEXT)))
					return;
				if (isShowWarning(controller.validateInputData(jtfMiddleName, StudentCardFrameController.ValidatorVariant.IS_TEXT)))
					return;
				if (isShowWarning(controller.validateInputData(jtfNumOfRecBook, StudentCardFrameController.ValidatorVariant.IS_NUMBER)))
					return;

				for (JTextField jtf : jtfAlloyComWeightsStage1) {
					if (isShowWarning(controller.validateInputData(jtf, StudentCardFrameController.ValidatorVariant.IS_NUMBER))) return;
				}
				System.out.println("start tasks frame");
			}
		});

		jbtnCancel.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				closeThisWindow();
				new StartFrame();
			}
		});

		// set settings for created panels
		jpElementsStage1.setBorder(BorderFactory.createTitledBorder(
			BorderFactory.createEtchedBorder(EtchedBorder.RAISED), TXT_STAGE_1_MAIN_PANEL_NAME
		));
<commit_msg>In StudentCard add extra input data.<commit_after>package ui;

import controller.StudentCardFrameController;
import stage1.elements.GeneralElementStage1;

import javax.swing.*;
import javax.swing.border.EtchedBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.*;
import java.util.List;

/**
 *
 */
public class StudentCardFrame implements StudentCardFrameController.StudentCardFrameCallback {

	public static final String TXT_STUDENT_CARD = "Карточка студента";
	public static final String TXT_MAIN_ELEMENTS = "Основные элементы:";
	public static final String TXT_ACCESSORY_ELEMENTS = "Дополнительные элементы:";
	public static final String TXT_USER_FIRST_NAME = "Имя: ";
	public static final String TXT_USER_MIDDLE_NAME = "Отчество: ";
	public static final String TXT_USER_LAST_NAME = "Фамилия: ";
	public static final String TXT_USER_NUM_OF_REC_BOOK = "Номер группы: ";
	public static final String TXT_STAGE_1_MAIN_PANEL_NAME = "Химический состав элементов";
	public static final String TXT_TAB_1_NAME = "Задача 1";
	public static final String TXT_TAB_1_TOOL_TIP = "Расчет процессов испарения металлов при сварке плавлением";
	public static final String TXT_PRESSURE_ENV = "Давление окружающей среды (Па): ";
	public static final String TXT_SURFACE_WELD_AREA = "Площадь свободной поверхности сварочной ванны (см2): ";
	public static final String TXT_WEIGHT_MOLTEN_METAL = "Масса расплавленного металла (гр.): ";
	public static final String TXT_TEMPERATURE = "Температура расчета (град. Цельсия °C): ";
	public static final String TXT_TIME = "Время нахождения сплава в жидком состоянии (c): ";

	private JFrame studentCardFrame = new JFrame(TXT_STUDENT_CARD);
	private StudentCardFrameController controller;

	private List<GeneralElementStage1> basicElementsStage1;
	private List<GeneralElementStage1> accessoryElementsStage1;

	private JPanel jpUserData = new JPanel();
	private JPanel jpElementsStage1 = new JPanel();
	private JPanel jpDirection = new JPanel();
	private JButton jbtnOk = new JButton("Ok");
	private JButton jbtnCancel = new JButton("Cancel");
	private JLabel jlMsg = new JLabel();

	private java.util.List<JTextField> jtfAlloyComWeightsStage1 = new ArrayList<>();


	public StudentCardFrame() {
		controller = new StudentCardFrameController(studentCardFrame, this);

		studentCardFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		addComponentToPane(studentCardFrame.getContentPane());
		studentCardFrame.setPreferredSize(new Dimension(500, 500));
		studentCardFrame.pack();
		studentCardFrame.setLocationRelativeTo(null);
		studentCardFrame.setVisible(true);
	}

	private void addComponentToPane(final Container contentPane) {
		JPanel jpMsg = new JPanel(new FlowLayout(FlowLayout.LEFT));
		JPanel jpFirstName = new JPanel(new FlowLayout(FlowLayout.LEFT));
		JPanel jpMiddleName = new JPanel(new FlowLayout(FlowLayout.LEFT));
		JPanel jpLastName = new JPanel(new FlowLayout(FlowLayout.LEFT));
		JPanel jpNumOfRecBook = new JPanel(new FlowLayout(FlowLayout.LEFT));

		final JTextField jtfFirstName = new JTextField(10); // Имя
		final JTextField jtfMiddleName = new JTextField(12); // Отчество
		final JTextField jtfLastName = new JTextField(12); // Фамилия
		final JTextField jtfNumOfRecBook = new JTextField(10);

		jtfFirstName.setName(TXT_USER_FIRST_NAME);
		jtfMiddleName.setName(TXT_USER_MIDDLE_NAME);
		jtfLastName.setName(TXT_USER_LAST_NAME);
		jtfNumOfRecBook.setName(TXT_USER_NUM_OF_REC_BOOK);

		jpMsg.add(jlMsg);
		jpFirstName.add(new JLabel(TXT_USER_FIRST_NAME));
		jpFirstName.add(jtfFirstName);
		jpMiddleName.add(new JLabel(TXT_USER_MIDDLE_NAME));
		jpMiddleName.add(jtfMiddleName);
		jpLastName.add(new JLabel(TXT_USER_LAST_NAME));
		jpLastName.add(jtfLastName);
		jpNumOfRecBook.add(new JLabel(TXT_USER_NUM_OF_REC_BOOK));
		jpNumOfRecBook.add(jtfNumOfRecBook);

		jpUserData.setLayout(new BoxLayout(jpUserData, BoxLayout.Y_AXIS));
		jpUserData.add(jpMsg);
		jpUserData.add(jpLastName);
		jpUserData.add(jpMiddleName);
		jpUserData.add(jpFirstName);
		jpUserData.add(jpNumOfRecBook);


		JPanel jpRows = new JPanel();
		jpRows.setLayout(new BoxLayout(jpRows, BoxLayout.Y_AXIS));

		jpRows.add(new JLabel(TXT_MAIN_ELEMENTS));
		for (GeneralElementStage1 el : basicElementsStage1) {
			addRowsToPanel(jpRows, el);
		}

		jpRows.add(new JLabel(TXT_ACCESSORY_ELEMENTS));
		for (GeneralElementStage1 el : accessoryElementsStage1) {
			addRowsToPanel(jpRows, el);
		}


		JPanel jpPressureEnv = new JPanel();
		JPanel jpSurfaceWeldArea = new JPanel();
		JPanel jpWeightMoltenMetal = new JPanel();
		JPanel jpTemperature = new JPanel();
		JPanel jpTime = new JPanel();

		final JTextField jtfPressureEnv = new JTextField(4);
		JTextField jtfSurfaceWeldArea = new JTextField(4);
		JTextField jtfWeightMoltenMetal = new JTextField(4);
		JTextField jtfTemperature = new JTextField(4);
		JTextField jtfTime = new JTextField(4);

		jtfPressureEnv.setName(TXT_PRESSURE_ENV);
		jtfSurfaceWeldArea.setName(TXT_SURFACE_WELD_AREA);
		jtfWeightMoltenMetal.setName(TXT_WEIGHT_MOLTEN_METAL);
		jtfTemperature.setName(TXT_TEMPERATURE);
		jtfTime.setName(TXT_TIME);

		jpPressureEnv.add(new JLabel(TXT_PRESSURE_ENV));
		jpPressureEnv.add(jtfPressureEnv);
		jpSurfaceWeldArea.add(new JLabel(TXT_SURFACE_WELD_AREA));
		jpSurfaceWeldArea.add(jtfSurfaceWeldArea);
		jpWeightMoltenMetal.add(new JLabel(TXT_WEIGHT_MOLTEN_METAL));
		jpWeightMoltenMetal.add(jtfWeightMoltenMetal);
		jpTemperature.add(new JLabel(TXT_TEMPERATURE));
		jpTemperature.add(jtfTemperature);
		jpTime.add(new JLabel(TXT_TIME));
		jpTime.add(jtfTime);

		JPanel jpExtraInputData = new JPanel();
		jpExtraInputData.setLayout(new BoxLayout(jpExtraInputData, BoxLayout.Y_AXIS));
		jpExtraInputData.add(jpPressureEnv);
		jpExtraInputData.add(jpSurfaceWeldArea);
		jpExtraInputData.add(jpWeightMoltenMetal);
		jpExtraInputData.add(jpTemperature);
		jpExtraInputData.add(jpTime);


		jpElementsStage1.setLayout(new FlowLayout());
		jpElementsStage1.add(jpRows);
		jpElementsStage1.add(jpExtraInputData);

		jpDirection.setLayout(new FlowLayout());
		jpDirection.add(jbtnOk);
		jpDirection.add(jbtnCancel);

		jbtnOk.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				for (JTextField jtf : jtfAlloyComWeightsStage1) {
					System.out.println(jtf.getName() + " : " + jtf.getText());
				}

				if (isShowWarning(controller.validateInputData(jtfLastName, StudentCardFrameController.ValidatorVariant.IS_TEXT)))
					return;
				if (isShowWarning(controller.validateInputData(jtfFirstName, StudentCardFrameController.ValidatorVariant.IS_TEXT)))
					return;
				if (isShowWarning(controller.validateInputData(jtfMiddleName, StudentCardFrameController.ValidatorVariant.IS_TEXT)))
					return;
				if (isShowWarning(controller.validateInputData(jtfNumOfRecBook, StudentCardFrameController.ValidatorVariant.IS_NUMBER)))
					return;

				for (JTextField jtf : jtfAlloyComWeightsStage1) {
					if (isShowWarning(controller.validateInputData(jtf, StudentCardFrameController.ValidatorVariant.IS_NUMBER))) return;
				}

				if (isShowWarning(controller.validateInputData(jtfPressureEnv, StudentCardFrameController.ValidatorVariant.IS_NUMBER)))
					return;
				System.out.println("start tasks frame");
			}
		});

		jbtnCancel.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				closeThisWindow();
				new StartFrame();
			}
		});

		// set settings for created panels
		jpElementsStage1.setBorder(BorderFactory.createTitledBorder(
			BorderFactory.createEtchedBorder(EtchedBorder.RAISED), TXT_STAGE_1_MAIN_PANEL_NAME
		));

{'fraction_non_alphanumeric': 0.09433819638672614, 'fraction_numerical': 0.005971728777685388, 'mean_word_length': 6.358175750834261, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '1772735', 'n_tokens_mistral': 4928, 'n_tokens_neox': 4487, 'n_words': 788}