<commit_before>// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.github.pullrequest.ui.changes

import com.intellij.ide.DataManager
import com.intellij.openapi.Disposable
import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.actionSystem.ex.ActionUtil
import com.intellij.openapi.project.Project
import com.intellij.openapi.vcs.changes.ui.ChangesTree
import com.intellij.openapi.vcs.changes.ui.TreeActionsToolbarPanel
import com.intellij.ui.ScrollPaneFactory
import com.intellij.ui.SideBorder
import com.intellij.util.ui.components.BorderLayoutPanel
import org.jetbrains.annotations.Nls
import org.jetbrains.plugins.github.i18n.GithubBundle
import org.jetbrains.plugins.github.pullrequest.action.GHPRReviewSubmitAction
import org.jetbrains.plugins.github.pullrequest.action.GHPRShowDiffAction
import org.jetbrains.plugins.github.pullrequest.ui.GHLoadingModel
import org.jetbrains.plugins.github.pullrequest.ui.GHLoadingPanel
import javax.swing.JComponent
import javax.swing.JPanel

object GHPRChangesBrowser {

  fun create(project: Project,
             changesModel: GHPRChangesModel,
             diffHelper: GHPRChangesDiffHelper,
             @Nls(capitalization = Nls.Capitalization.Sentence) panelEmptyText: String,
             disposable: Disposable): JComponent {

    val actionManager = ActionManager.getInstance()

    val diffAction = GHPRShowDiffAction().apply {
      ActionUtil.copyFrom(this, IdeActions.ACTION_SHOW_DIFF_COMMON)
    }
    val reloadAction = actionManager.getAction("Github.PullRequest.Changes.Reload")

    val changesTreePanel = GHPRChangesTree.createLazyTreePanel(changesModel) {
      createTree(project, changesModel, diffAction, diffHelper, reloadAction, it, disposable).apply {
        emptyText.text = panelEmptyText
      }
    }.apply {
      emptyText.text = panelEmptyText
    }

    val toolbar = createToolbar(actionManager, diffAction, changesTreePanel)
    val scrollPane = ScrollPaneFactory.createScrollPane(changesTreePanel, SideBorder.TOP)

    return BorderLayoutPanel().andTransparent()
      .addToTop(toolbar)
      .addToCenter(scrollPane)
  }

  private fun createToolbar(actionManager: ActionManager, diffAction: GHPRShowDiffAction, target: JComponent)
    : TreeActionsToolbarPanel {<commit_msg>[github] Fix PR commit changes background<commit_after>// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.github.pullrequest.ui.changes

import com.intellij.ide.DataManager
import com.intellij.openapi.Disposable
import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.actionSystem.ex.ActionUtil
import com.intellij.openapi.project.Project
import com.intellij.openapi.vcs.changes.ui.ChangesTree
import com.intellij.openapi.vcs.changes.ui.TreeActionsToolbarPanel
import com.intellij.ui.ScrollPaneFactory
import com.intellij.ui.SideBorder
import com.intellij.util.ui.components.BorderLayoutPanel
import org.jetbrains.annotations.Nls
import org.jetbrains.plugins.github.i18n.GithubBundle
import org.jetbrains.plugins.github.pullrequest.action.GHPRReviewSubmitAction
import org.jetbrains.plugins.github.pullrequest.action.GHPRShowDiffAction
import org.jetbrains.plugins.github.pullrequest.ui.GHLoadingModel
import org.jetbrains.plugins.github.pullrequest.ui.GHLoadingPanel
import javax.swing.JComponent
import javax.swing.JPanel

object GHPRChangesBrowser {

  fun create(project: Project,
             changesModel: GHPRChangesModel,
             diffHelper: GHPRChangesDiffHelper,
             @Nls(capitalization = Nls.Capitalization.Sentence) panelEmptyText: String,
             disposable: Disposable): JComponent {

    val actionManager = ActionManager.getInstance()

    val diffAction = GHPRShowDiffAction().apply {
      ActionUtil.copyFrom(this, IdeActions.ACTION_SHOW_DIFF_COMMON)
    }
    val reloadAction = actionManager.getAction("Github.PullRequest.Changes.Reload")

    val changesTreePanel = GHPRChangesTree.createLazyTreePanel(changesModel) {
      createTree(project, changesModel, diffAction, diffHelper, reloadAction, it, disposable).apply {
        emptyText.text = panelEmptyText
      }
    }.apply {
      emptyText.text = panelEmptyText
    }

    val toolbar = createToolbar(actionManager, diffAction, changesTreePanel)
    val scrollPane = ScrollPaneFactory.createScrollPane(changesTreePanel, SideBorder.TOP).apply {
      isOpaque = false
      viewport.isOpaque = false
    }

    return BorderLayoutPanel().andTransparent()
      .addToTop(toolbar)
      .addToCenter(scrollPane)
  }

  private fun createToolbar(actionManager: ActionManager, diffAction: GHPRShowDiffAction, target: JComponent)
    : TreeActionsToolbarPanel {
{'fraction_non_alphanumeric': 0.08191685439279131, 'fraction_numerical': 0.004915011263567479, 'mean_word_length': 4.67906976744186, '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': '6126998', 'n_tokens_mistral': 1478, 'n_tokens_neox': 1396, 'n_words': 263}