<commit_before>package com.example.components;

import com.example.Dialogs;
import com.example.FileListContainer;
import com.example.FileListWatcher;
import com.example.Icon;
import com.example.filelist.FileList;
import com.example.filelist.FileListModel;
import com.example.utils.AbstractListDataListener;

import javax.swing.*;
import javax.swing.event.ListDataEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author innokenty
 */
public class GoUpButton extends JButton {

    public GoUpButton(final FileListContainer container) {
        super(Icon.UP.build());
        super.setToolTipText("go up one folder");
        super.setEnabled(false);
        initActionListener(container);
        initListChangedListener(container);
    }

    private void initActionListener(final FileListContainer container) {
        super.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    if (!container.getFileList().getModel().goUp()) {
                        Dialogs.sorryBro(
                                "This is the top-level folder already!",
                                container.getFileList()
                        );
                    }
                } catch (Exception ex) {
                    Dialogs.unexpectedError(ex, container.getFileList());
                }
            }
        });
    }

    private void initListChangedListener(FileListContainer container) {
        final AbstractListDataListener canGoUpListener
                = buildCanGoUpListener(container);

        container.onFileListChanged(new FileListWatcher() {
            @Override
            public void onFileListChanged(FileList newFileList) {
                GoUpButton.super.setEnabled(newFileList.getModel().canGoUp());
                FileListModel model = newFileList.getModel();
                model.removeListDataListener(canGoUpListener);
                model.addListDataListener(canGoUpListener);<commit_msg>ref - insignificant changes<commit_after>package com.example.components;

import com.example.Dialogs;
import com.example.FileListContainer;
import com.example.FileListWatcher;
import com.example.Icon;
import com.example.filelist.FileList;
import com.example.filelist.FileListModel;
import com.example.utils.AbstractListDataListener;

import javax.swing.*;
import javax.swing.event.ListDataEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author innokenty
 */
public class GoUpButton extends JButton {

    public GoUpButton(final FileListContainer container) {
        super(Icon.UP.build());
        super.setToolTipText("go up one folder");
        super.setEnabled(false);
        initActionListener(container);
        initListChangedListener(container);
    }

    private void initActionListener(final FileListContainer container) {
        super.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    if (!container.getFileList().getModel().goUp()) {
                        Dialogs.sorryBro(
                                "This is the top-level folder already! " +
                                        "Or something's broken...",
                                container.getFileList()
                        );
                    }
                } catch (Exception ex) {
                    Dialogs.unexpectedError(ex, container.getFileList());
                }
            }
        });
    }

    private void initListChangedListener(FileListContainer container) {
        final AbstractListDataListener canGoUpListener
                = buildCanGoUpListener(container);

        container.onFileListChanged(new FileListWatcher() {
            @Override
            public void onFileListChanged(FileList newFileList) {
                GoUpButton.super.setEnabled(newFileList.getModel().canGoUp());
                FileListModel model = newFileList.getModel();
                model.removeListDataListener(canGoUpListener);
                model.addListDataListener(canGoUpListener);
{'fraction_non_alphanumeric': 0.0862968231389284, 'fraction_numerical': 0.0, 'mean_word_length': 2.2181540808543097, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5826367', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1014, 'n_words': 188}