<commit_before>package main.demo.gui;

import gx.realtime.CollaborativeMap;
import gx.realtime.Document;
import gx.realtime.EventType;
import gx.realtime.ValueChangedEvent;

import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;

/**
 * Swing panel that handles the display and interaction with the Realtime library
 */
public class RealtimePanel extends JPanel
{
    private RealtimeTableModel model;

    public RealtimePanel(CollaborativeMap collabMap)
    {
        model = new RealtimeTableModel(collabMap);

        // Listen for ValueChangedEvents to update the UI
        collabMap.addEventListener(EventType.VALUE_CHANGED, (ValueChangedEvent event) -> {
            model.updateValue(event.getProperty(), (String) event.getNewValue());
            eventLogArea.append(event.toString() + "\n");
        });

        // Init the components
        initComponents();

        // Put a selection listener on the table to prefill the key/value fields
        table.getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
            keyField.setText((String) model.getValueAt(e.getFirstIndex(), 0));
            valueField.setText((String) model.getValueAt(e.getFirstIndex(), 1));
        });
    }

    /**
     * Method that creates the frame and handles some of the final setup actions.
     *
     * @param document
     * @param collabMap
     */
    public static void createUI(Document document, CollaborativeMap collabMap)
    {
        JFrame frame = new JFrame("Demo Realtime Gx Application");

        RealtimePanel newContentPane = new RealtimePanel(collabMap);
        newContentPane.setOpaque(true);
        frame.setContentPane(newContentPane);

        frame.pack();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.addWindowStateListener((WindowEvent e) -> {
            if (e.getNewState() == WindowEvent.WINDOW_CLOSED) {<commit_msg>Altered the GUI app to include some more logging<commit_after>package main.demo.gui;

import gx.realtime.CollaborativeMap;
import gx.realtime.Document;
import gx.realtime.EventType;
import gx.realtime.ValueChangedEvent;

import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;

/**
 * Swing panel that handles the display and interaction with the Realtime library
 */
public class RealtimePanel extends JPanel
{
    private RealtimeTableModel model;

    public RealtimePanel(CollaborativeMap collabMap)
    {
        model = new RealtimeTableModel(collabMap);

        // Listen for ValueChangedEvents to update the UI
        collabMap.addEventListener(EventType.VALUE_CHANGED, (ValueChangedEvent event) -> {
            System.out.println("Received event for key " + event.getProperty());
            model.updateValue(event.getProperty(), (String) event.getNewValue());
            eventLogArea.append(event.toString() + "\n");
        });

        // Init the components
        initComponents();

        // Put a selection listener on the table to prefill the key/value fields
        table.getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
            keyField.setText((String) model.getValueAt(e.getFirstIndex(), 0));
            valueField.setText((String) model.getValueAt(e.getFirstIndex(), 1));
        });
    }

    /**
     * Method that creates the frame and handles some of the final setup actions.
     *
     * @param document
     * @param collabMap
     */
    public static void createUI(Document document, CollaborativeMap collabMap)
    {
        JFrame frame = new JFrame("Demo Realtime Gx Application");

        RealtimePanel newContentPane = new RealtimePanel(collabMap);
        newContentPane.setOpaque(true);
        frame.setContentPane(newContentPane);

        frame.pack();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.addWindowStateListener((WindowEvent e) -> {
            System.out.println("Received WindowEvent " + e + ", should be politely closing now");
            if (e.getNewState() == WindowEvent.WINDOW_CLOSED) {
{'fraction_non_alphanumeric': 0.09854186265286924, 'fraction_numerical': 0.0009407337723424271, 'mean_word_length': 3.2318407960199007, 'pattern_counts': {'":': 0, '<': 3, '<?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': '112687', 'n_tokens_mistral': 1162, 'n_tokens_neox': 1144, 'n_words': 279}