<commit_before>package nl.ekholabs.escode.app;

import nl.ekholabs.escode.action.SelectFileAction;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class EsCode {

  public static void main(String... args) {
    final JFrame frame = new JFrame("ES-Code");

    final SelectFileAction fileAction = new SelectFileAction(frame);
    final JButton openButton = new JButton(fileAction);
    openButton.setText("Open");

    frame.getContentPane().setLayout(new BorderLayout());

    final JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout(FlowLayout.LEFT));
    panel.add(openButton);

    frame.add(panel, BorderLayout.NORTH);

    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    frame.setVisible(true);
  }<commit_msg>Adds lambda usage to the EsCode class<commit_after>package nl.ekholabs.escode.app;

import nl.ekholabs.escode.action.GenerateEsCodeAction;
import nl.ekholabs.escode.action.SelectFileAction;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.io.File;
import java.util.Optional;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class EsCode {

  private final JFrame frame;
  private Optional<File> selectedFile;

  public EsCode() {
    frame = new JFrame("ES-Code");
  }

  public void setSelectedFile(Optional<File> selectedFile) {
    this.selectedFile = selectedFile;
  }

  public Optional<File> getSelectedFile() {
    return selectedFile;
  }

  public JFrame getFrame() {
    return frame;
  }

  public static void main(String... args) {
    final EsCode esCodeWindow = new EsCode();

    final JFrame frame = esCodeWindow.getFrame();

    final JButton generateButton = new JButton("Generate ES-Code...");
    final JButton parseButton = new JButton("Parse ES-Code...");

    generateButton.addActionListener(e -> {
      esCodeWindow.setSelectedFile(new SelectFileAction(frame).openFile());
      new GenerateEsCodeAction(esCodeWindow, esCodeWindow.getSelectedFile().get()).generateFile();
    });

    parseButton.addActionListener(e -> {
      JOptionPane.showMessageDialog(frame, "Not implemented yet.");
    });

    frame.getContentPane().setLayout(new BorderLayout());

    final JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout(FlowLayout.LEFT));
    panel.add(generateButton);
    panel.add(parseButton);

    frame.add(panel, BorderLayout.NORTH);

    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    frame.setVisible(true);
  }
{'fraction_non_alphanumeric': 0.11520233321181189, 'fraction_numerical': 0.0, 'mean_word_length': 4.359375, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 8, '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': '6953449', 'n_tokens_mistral': 859, 'n_tokens_neox': 834, 'n_words': 167}