<commit_before>package com.intellij.localvcs.integration.ui.views;

import com.intellij.localvcs.ILocalVcs;
import com.intellij.localvcs.integration.ui.models.DirectoryDifferenceModel;
import com.intellij.localvcs.integration.ui.models.DirectoryHistoryDialogModel;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.diff.DiffManager;
import com.intellij.openapi.diff.DiffRequest;
import com.intellij.openapi.diff.ex.DiffStatusBar;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vcs.ui.impl.checkinProjectPanel.CheckinPanelTreeTable;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.ui.tree.TreeUtil;

import javax.swing.*;
import javax.swing.tree.TreePath;
import java.awt.*;

public class DirectoryHistoryDialog extends HistoryDialog<DirectoryHistoryDialogModel> {
  private CheckinPanelTreeTable myDiffTree;

  public DirectoryHistoryDialog(VirtualFile f, Project p) {
    super(f, p);
    setTitle(myModel.getTitle());
  }

  @Override
  protected DirectoryHistoryDialogModel createModelFor(VirtualFile f, ILocalVcs vcs) {
    return new DirectoryHistoryDialogModel(f, vcs);
  }

  @Override
  protected JComponent createDiffPanel() {
    initDiffTree();

    JPanel p = new JPanel(new BorderLayout());

    p.add(new DiffStatusBar(DiffStatusBar.DEFAULT_TYPES), BorderLayout.SOUTH);
    p.add(ScrollPaneFactory.createScrollPane(myDiffTree), BorderLayout.CENTER);

    ActionToolbar tb = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, createActionGroup(), true);
    p.add(tb.getComponent(), BorderLayout.NORTH);

    return p;
  }

  private void initDiffTree() {
    DirectoryDifferenceModel m = myModel.getRootDifferenceNodeModel();
    DirectoryDifferenceNode n = new DirectoryDifferenceNode(m);

    myDiffTree = CheckinPanelTreeTable.createOn(myProject, n);

    myDiffTree.getFirstTreeColumn().setName(n.getPresentableText(0));
    myDiffTree.getSecondTreeColumn().setName(n.getPresentableText(1));

    TreeUtil.expandAll(myDiffTree.getTree());
    addPopupMenuToComponent(myDiffTree, createActionGroup());
  }

  private ActionGroup createActionGroup() {
    DefaultActionGroup result = new DefaultActionGroup();
    result.add(new ShowDifferenceAction());
    return result;
  }

  @Override
  protected void updateDiffs() {
    mySplitter.setFirstComponent(createDiffPanel());
    mySplitter.revalidate();
  }

  private DirectoryDifferenceNode getSelectedNode() {
    if (myDiffTree.getTree().isSelectionEmpty()) return null;
    TreePath path = myDiffTree.getTree().getSelectionPaths()[0];
    return (DirectoryDifferenceNode)path.getLastPathComponent();<commit_msg>-directory history dialog<commit_after>package com.intellij.localvcs.integration.ui.views;

import com.intellij.localvcs.ILocalVcs;
import com.intellij.localvcs.integration.ui.models.DirectoryDifferenceModel;
import com.intellij.localvcs.integration.ui.models.DirectoryHistoryDialogModel;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.diff.DiffManager;
import com.intellij.openapi.diff.DiffRequest;
import com.intellij.openapi.diff.ex.DiffStatusBar;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vcs.ui.impl.checkinProjectPanel.CheckinPanelTreeTable;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.ui.tree.TreeUtil;

import javax.swing.*;
import javax.swing.tree.TreePath;
import java.awt.*;

public class DirectoryHistoryDialog extends HistoryDialog<DirectoryHistoryDialogModel> {
  private CheckinPanelTreeTable myDiffTree;

  public DirectoryHistoryDialog(VirtualFile f, Project p) {
    super(f, p);
    setTitle(myModel.getTitle());
  }

  @Override
  protected DirectoryHistoryDialogModel createModelFor(VirtualFile f, ILocalVcs vcs) {
    return new DirectoryHistoryDialogModel(f, vcs);
  }

  @Override
  protected JComponent createDiffPanel() {
    initDiffTree();

    JPanel p = new JPanel(new BorderLayout());

    p.add(new DiffStatusBar(DiffStatusBar.DEFAULT_TYPES), BorderLayout.SOUTH);
    p.add(ScrollPaneFactory.createScrollPane(myDiffTree), BorderLayout.CENTER);

    ActionToolbar tb = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, createActionGroup(), true);
    p.add(tb.getComponent(), BorderLayout.NORTH);

    return p;
  }

  private void initDiffTree() {
    DirectoryDifferenceModel m = myModel.getRootDifferenceNodeModel();
    DirectoryDifferenceNode n = new DirectoryDifferenceNode(m);

    myDiffTree = CheckinPanelTreeTable.createOn(myProject, n);

    myDiffTree.getFirstTreeColumn().setName(n.getPresentableText(0));
    myDiffTree.getSecondTreeColumn().setName(n.getPresentableText(1));

    TreeUtil.expandAll(myDiffTree.getTree());
    addPopupMenuToComponent(myDiffTree, createActionGroup());
    new ShowDifferenceAction().registerCustomShortcutSet(CommonShortcuts.DOUBLE_CLICK_1, myDiffTree);
  }

  private ActionGroup createActionGroup() {
    DefaultActionGroup result = new DefaultActionGroup();
    result.add(new ShowDifferenceAction());
    return result;
  }

  @Override
  protected void updateDiffs() {
    mySplitter.setFirstComponent(createDiffPanel());
    mySplitter.revalidate();
  }

  private DirectoryDifferenceNode getSelectedNode() {
    if (myDiffTree.getTree().isSelectionEmpty()) return null;
    TreePath path = myDiffTree.getTree().getSelectionPaths()[0];
    return (DirectoryDifferenceNode)path.getLastPathComponent();
{'fraction_non_alphanumeric': 0.10387073863636363, 'fraction_numerical': 0.0012428977272727273, 'mean_word_length': 5.844471445929526, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '683217', 'n_tokens_mistral': 1738, 'n_tokens_neox': 1686, 'n_words': 268}