<commit_before>package com.intellij.openapi.fileEditor.impl;

import com.intellij.Patches;
import com.intellij.ide.ui.UISettings;
import com.intellij.ide.ui.customization.CustomizableActionsSchemas;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.PopupHandler;
import com.intellij.ui.TabbedPaneWrapper;
import com.intellij.ui.plaf.beg.BegTabbedPaneUI;

import javax.swing.*;
import javax.swing.plaf.TabbedPaneUI;
import javax.swing.plaf.basic.BasicTabbedPaneUI;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

/**
 * @author <NAME>
 * @author <NAME>
 */
final class EditorTabbedContainer extends TabbedPaneWrapper {
  private final EditorWindow myWindow;
  private final Project myProject;
  private final FileEditorManagerImpl myEditorManager;

  EditorTabbedContainer(final EditorWindow window, Project project, int tabPlacement, FileEditorManagerImpl editorManager) {
    super(tabPlacement);
    myWindow = window;
    myProject = project;
    myEditorManager = editorManager;
  }

  protected TabbedPane createTabbedPane(int tabPlacement) {
    return new MyTabbedPane(tabPlacement);

  }

  protected TabbedPaneHolder createTabbedPaneHolder() {
    return new MyTabbedPaneHolder();
  }

  private final class MyTabbedPane extends TabbedPaneWrapper.TabbedPane {
    private final MyTabbedPanePopupHandler myTabbedPanePopupHandler;

    public MyTabbedPane(int tabPlacement) {
      super(tabPlacement);
      enableEvents(MouseEvent.MOUSE_EVENT_MASK);
      setOpaque(true);
      myTabbedPanePopupHandler = new MyTabbedPanePopupHandler();
      putClientProperty("TabbedPane.paintContentBorder", Boolean.FALSE);
      updateUI();
    }

    /**
     * Actually all this stuff should be placed into updateUI method.
     * But due to this method replaces the current UI of the tabbed pane
     * this code exists here. One I [vova] placed it into updateUI and
     * middle mouse button stop working in SCROLL_TAB_LAYOUT.
     */
    public void setTabLayoutPolicy(int tabLayoutPolicy) {
      super.setTabLayoutPolicy(tabLayoutPolicy);
      if (Patches.SUN_BUG_ID_4620537) {
        TabbedPaneUI tabbedPaneUI = getUI();
        if (!(tabbedPaneUI instanceof BasicTabbedPaneUI)) {
          return;
        }
        for (int i = 0; i < getComponentCount(); i++) {
          Component c = getComponent(i);
          if (!(c instanceof JViewport)) {
            continue;
          }
          JPanel panel = (JPanel)((JViewport)c).getView();
          panel.setBackground(UIManager.getColor("TabbedPane.background"));

          MouseListener[] listeners = (MouseListener[])panel.getListeners(MouseListener.class);
          for (int j = 0; j < listeners.length; j++) {
            panel.removeMouseListener(listeners[j]);<commit_msg>Fixes for intention action focus problems under Mac.<commit_after>package com.intellij.openapi.fileEditor.impl;

import com.intellij.Patches;
import com.intellij.ide.ui.UISettings;
import com.intellij.ide.ui.customization.CustomizableActionsSchemas;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.PopupHandler;
import com.intellij.ui.TabbedPaneWrapper;
import com.intellij.ui.plaf.beg.BegTabbedPaneUI;

import javax.swing.*;
import javax.swing.plaf.TabbedPaneUI;
import javax.swing.plaf.basic.BasicTabbedPaneUI;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

/**
 * @author <NAME>
 * @author <NAME>
 */
final class EditorTabbedContainer extends TabbedPaneWrapper {
  private final EditorWindow myWindow;
  private final Project myProject;
  private final FileEditorManagerImpl myEditorManager;

  EditorTabbedContainer(final EditorWindow window, Project project, int tabPlacement, FileEditorManagerImpl editorManager) {
    super(tabPlacement);
    myWindow = window;
    myProject = project;
    myEditorManager = editorManager;
  }

  protected TabbedPane createTabbedPane(int tabPlacement) {
    return new MyTabbedPane(tabPlacement);

  }

  protected TabbedPaneHolder createTabbedPaneHolder() {
    return new MyTabbedPaneHolder();
  }

  private final class MyTabbedPane extends TabbedPaneWrapper.TabbedPane {
    private final MyTabbedPanePopupHandler myTabbedPanePopupHandler;

    public MyTabbedPane(int tabPlacement) {
      super(tabPlacement);
      enableEvents(MouseEvent.MOUSE_EVENT_MASK);
      setOpaque(true);
      myTabbedPanePopupHandler = new MyTabbedPanePopupHandler();
      putClientProperty("TabbedPane.paintContentBorder", Boolean.FALSE);
      setFocusable(false);
      updateUI();
    }

    /**
     * Actually all this stuff should be placed into updateUI method.
     * But due to this method replaces the current UI of the tabbed pane
     * this code exists here. One I [vova] placed it into updateUI and
     * middle mouse button stop working in SCROLL_TAB_LAYOUT.
     */
    public void setTabLayoutPolicy(int tabLayoutPolicy) {
      super.setTabLayoutPolicy(tabLayoutPolicy);
      if (Patches.SUN_BUG_ID_4620537) {
        TabbedPaneUI tabbedPaneUI = getUI();
        if (!(tabbedPaneUI instanceof BasicTabbedPaneUI)) {
          return;
        }
        for (int i = 0; i < getComponentCount(); i++) {
          Component c = getComponent(i);
          if (!(c instanceof JViewport)) {
            continue;
          }
          JPanel panel = (JPanel)((JViewport)c).getView();
          panel.setBackground(UIManager.getColor("TabbedPane.background"));

          MouseListener[] listeners = (MouseListener[])panel.getListeners(MouseListener.class);
          for (int j = 0; j < listeners.length; j++) {
            panel.removeMouseListener(listeners[j]);
{'fraction_non_alphanumeric': 0.09171890465193006, 'fraction_numerical': 0.0029693170570768723, 'mean_word_length': 3.9372964169381106, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '5013431', 'n_tokens_mistral': 1801, 'n_tokens_neox': 1786, 'n_words': 397}