<commit_before>package cec.view;

import java.awt.BorderLayout;
import java.awt.Choice;
import java.awt.Dimension;
import java.awt.event.InputEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.UUID;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import javax.swing.KeyStroke;

import cec.config.CECConfigurator;
import cec.service.RuleService;
import cec.service.FolderService;

public class RuleFrame extends JFrame {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	JCheckBox from = new JCheckBox("From:        ");
	JCheckBox content = new JCheckBox("Containing:");
	JTextField fromField = new JTextField("", 40);
	JTextField contentField = new JTextField("", 40);
	Choice folderChoosed= new Choice();
	
	@SuppressWarnings("unused")
	private UUID id = null;
	private Validator emailValidator = new Validator();
	RuleService ruleService = new RuleService();
	RuleViewEntity ruleViewEntity;
	RuleSettings rs;
	
	public RuleFrame(){
		ruleViewEntity = new RuleViewEntity();
		id = UUID.randomUUID();
		initialize();
	}
	
	public RuleFrame(RuleViewEntity existingRule,RuleSettings rs){
		ruleViewEntity = existingRule;
		this.rs =rs;
		initialize();
		setRuleFields();
	}	
	
	private void initialize() {		
		setSize(460, 278);
		setLayout(new BorderLayout());
		setResizable(false);
		setVisible(true);
		setLocationRelativeTo(null);

		setupMenuBar();
		setupToolBar();
		setupEntryFields();
	}

	private void setupMenuBar() {
		JMenuItem saveItem = new JMenuItem("Save", KeyEvent.VK_S);
		JMenuItem exitItem = new JMenuItem("Exit");
		
		JMenuBar menuBar = new JMenuBar();<commit_msg>Java Doc<commit_after>package cec.view;

import java.awt.BorderLayout;
import java.awt.Choice;
import java.awt.Dimension;
import java.awt.event.InputEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.UUID;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import javax.swing.KeyStroke;

import cec.config.CECConfigurator;
import cec.service.RuleService;
import cec.service.FolderService;


/**
 * RuleFrame Class extends JFRAME <br>
 * show a graphic windows allowing user to create a new rule or edit existing rule .<br>
 * uses JTextField and JCheckBox components to set editable fields<br>
 * uses Choice component to display all the sub-folders in the inbox folder<br>
 * uses <code>JButtons</code> and <code>JMenuItem </code>to provides options:<br>
 * saveRule()<br>
 * To save a rule, at least one field has to be filled. The email field <br>
 * should never be filled with invalid email address<br>
 * <p>
 */
public class RuleFrame extends JFrame {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	JCheckBox from = new JCheckBox("From:        ");
	JCheckBox content = new JCheckBox("Containing:");
	JTextField fromField = new JTextField("", 40);
	JTextField contentField = new JTextField("", 40);
	Choice folderChoosed= new Choice();
	
	@SuppressWarnings("unused")
	private UUID id = null;
	private Validator emailValidator = new Validator();
	RuleService ruleService = new RuleService();
	RuleViewEntity ruleViewEntity;
	RuleSettings rs;
		
	public RuleFrame(){
		ruleViewEntity = new RuleViewEntity();
		id = UUID.randomUUID();
		initialize();
	}
	
	
	/**
	 * Parameterized constructor of the RuleFrame Class.
	 * <p>
	 * Provides non Empty and editable JFrame filled with existing rule<br> 
	 * <code>JTextField</code> with label "From:"<br>
	 * <code>JTextField</code> with label "Containing:"<br>
	 * <code>Choice</code> with label "Move to:"
	 * <p>
	 * 
	 * @param existingRule
	 *            a <code>RuleViewEntity</code> object that provides the <br>
	 *            values used to set the JFrame
	 * @param rs
	 * 			  a <code>RuleSettings</code> object that has to be updated <br>
	 * 					 after an existing rule is edited<br>
	 */
	public RuleFrame(RuleViewEntity existingRule,RuleSettings rs){
		ruleViewEntity = existingRule;
		this.rs =rs;
		initialize();
		setRuleFields();
	}	
	
	private void initialize() {		
		setSize(460, 278);
		setLayout(new BorderLayout());
		setResizable(false);
		setVisible(true);
		setLocationRelativeTo(null);

		setupMenuBar();
		setupToolBar();
		setupEntryFields();
	}

	private void setupMenuBar() {
		JMenuItem saveItem = new JMenuItem("Save", KeyEvent.VK_S);
		JMenuItem exitItem = new JMenuItem("Exit");
		
		JMenuBar menuBar = new JMenuBar();
{'fraction_non_alphanumeric': 0.11158219310079014, 'fraction_numerical': 0.004239737907111196, 'mean_word_length': 4.665938864628821, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, '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': '2962333', 'n_tokens_mistral': 1713, 'n_tokens_neox': 1602, 'n_words': 442}