<commit_before>// -*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
// @homepage@

package example;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import javax.swing.*;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;

public final class MainPanel extends JPanel {
  private final RowDataModel model = new RowDataModel();
  private final JTable table = new JTable(model);

  public MainPanel() {
    super(new BorderLayout());

    JTableHeader header = table.getTableHeader();
    header.setDefaultRenderer(new SortButtonRenderer());
    header.addMouseListener(new HeaderMouseListener());
    table.setRowSelectionAllowed(true);
    table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    // header.setReorderingAllowed(false);

    TableColumn col = table.getColumnModel().getColumn(0);
    col.setMinWidth(80);
    col.setMaxWidth(80);

    model.addRowData(new RowData("Name 1", "comment..."));
    model.addRowData(new RowData("Name 2", "Test"));
    model.addRowData(new RowData("Name d", "ee"));
    model.addRowData(new RowData("Name c", "Test cc"));
    model.addRowData(new RowData("Name b", "Test bb"));
    model.addRowData(new RowData("Name a", "ff"));
    model.addRowData(new RowData("Name 0", "Test aa"));

    table.setFillsViewportHeight(true);
    table.setComponentPopupMenu(new TablePopupMenu(table));
    add(new JScrollPane(table));
    add(makeToolBar(), BorderLayout.NORTH);
    setPreferredSize(new Dimension(320, 240));
  }

  private JToolBar makeToolBar() {
    JToolBar tb = new JToolBar("Sort by my order");
    tb.setFloatable(true);
    tb.add(makeToolButton(new UpAction("▲", table)));
    tb.add(makeToolButton(new DownAction("▼", table)));
    tb.add(Box.createHorizontalGlue());
    tb.add(makeToolButton(new InitAction("OK", table)));
    return tb;
  }

  private static JButton makeToolButton(Action action) {
    JButton b = new JButton(action);
    b.setFocusable(false);
    return b;
  }

  public static void main(String[] args) {
    EventQueue.invokeLater(MainPanel::createAndShowGui);
  }

  private static void createAndShowGui() {<commit_msg>refactor: field can be converted to a local variable<commit_after>// -*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
// @homepage@

package example;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import javax.swing.*;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;

public final class MainPanel extends JPanel {
  private MainPanel() {
    super(new BorderLayout());
    JTable table = new JTable(makeModel());
    table.setFillsViewportHeight(true);
    table.setRowSelectionAllowed(true);
    table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    table.setComponentPopupMenu(new TablePopupMenu(table));

    JTableHeader header = table.getTableHeader();
    header.setDefaultRenderer(new SortButtonRenderer());
    header.addMouseListener(new HeaderMouseListener());
    // header.setReorderingAllowed(false);

    TableColumn col = table.getColumnModel().getColumn(0);
    col.setMinWidth(80);
    col.setMaxWidth(80);

    add(new JScrollPane(table));
    add(makeToolBar(table), BorderLayout.NORTH);
    setPreferredSize(new Dimension(320, 240));
  }

  private static TableModel makeModel() {
    RowDataModel model = new RowDataModel();
    model.addRowData(new RowData("Name 1", "comment..."));
    model.addRowData(new RowData("Name 2", "Test"));
    model.addRowData(new RowData("Name d", "ee"));
    model.addRowData(new RowData("Name c", "Test cc"));
    model.addRowData(new RowData("Name b", "Test bb"));
    model.addRowData(new RowData("Name a", "ff"));
    model.addRowData(new RowData("Name 0", "Test aa"));
    return model;
  }

  private static JToolBar makeToolBar(JTable table) {
    JToolBar tb = new JToolBar();
    tb.setFloatable(true);
    tb.add(makeToolButton(new UpAction("▲", table)));
    tb.add(makeToolButton(new DownAction("▼", table)));
    tb.add(Box.createHorizontalGlue());
    tb.add(makeToolButton(new InitAction("OK", table)));
    return tb;
  }

  private static JButton makeToolButton(Action action) {
    JButton b = new JButton(action);
    b.setFocusable(false);
    return b;
  }

  public static void main(String[] args) {
    EventQueue.invokeLater(MainPanel::createAndShowGui);
  }

  private static void createAndShowGui() {
{'fraction_non_alphanumeric': 0.13779863481228669, 'fraction_numerical': 0.006825938566552901, 'mean_word_length': 4.622302158273381, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5436110', 'n_tokens_mistral': 1494, 'n_tokens_neox': 1460, 'n_words': 309}