package org.jetbrains.plugins.ipnb.editor.panels.code;

import com.intellij.openapi.editor.colors.EditorColorsManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.ipnb.editor.IpnbEditorUtil;
import org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel;
import org.jetbrains.plugins.ipnb.editor.panels.IpnbPanel;
import org.jetbrains.plugins.ipnb.format.cells.output.IpnbOutputCell;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;

public class IpnbCodeOutputPanel<K extends IpnbOutputCell> extends IpnbPanel<JComponent, K> {
  protected final IpnbFilePanel myParent;

  public IpnbCodeOutputPanel(@NotNull final K cell, @Nullable final IpnbFilePanel parent, @NotNull final MouseAdapter hideOutputAdapter) {
    super(cell, new BorderLayout());
    myParent = parent;
    myViewPanel = createViewPanel();
    add(myViewPanel);
    addHideOutputListener(hideOutputAdapter);
  }

  protected JComponent createViewPanel() {
    JTextArea textArea = new JTextArea(myCell.getSourceAsString());
    textArea.setLineWrap(true);
    textArea.setEditable(false);
    final Font font = textArea.getFont();
    final Font newFont = new Font(font.getName(), font.getStyle(), EditorColorsManager.getInstance().getGlobalScheme().getEditorFontSize());
    textArea.setFont(newFont);
    textArea.setBackground(IpnbEditorUtil.getBackground());
    return textArea;
  }
  
  public void addHideOutputListener(@NotNull final MouseAdapter mouseAdapter) {
    myViewPanel.addMouseListener(mouseAdapter);
  }
}

package org.jetbrains.plugins.ipnb.editor.panels.code;

import com.intellij.openapi.editor.colors.EditorColorsManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.ipnb.editor.IpnbEditorUtil;
import org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel;
import org.jetbrains.plugins.ipnb.editor.panels.IpnbPanel;
import org.jetbrains.plugins.ipnb.format.cells.output.IpnbOutputCell;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseListener;

public class IpnbCodeOutputPanel<K extends IpnbOutputCell> extends IpnbPanel<JComponent, K> {
  protected final IpnbFilePanel myParent;

  public IpnbCodeOutputPanel(@NotNull final K cell, @Nullable final IpnbFilePanel parent, @Nullable final MouseListener hideOutputAdapter) {
    super(cell, new BorderLayout());
    myParent = parent;
    myViewPanel = createViewPanel();
    add(myViewPanel);
    addHideOutputListener(hideOutputAdapter);
  }

  protected JComponent createViewPanel() {
    JTextArea textArea = new JTextArea(myCell.getSourceAsString());
    textArea.setLineWrap(true);
    textArea.setEditable(false);
    final Font font = textArea.getFont();
    final Font newFont = new Font(font.getName(), font.getStyle(), EditorColorsManager.getInstance().getGlobalScheme().getEditorFontSize());
    textArea.setFont(newFont);
    textArea.setBackground(IpnbEditorUtil.getBackground());
    return textArea;
  }
  
  public void addHideOutputListener(@Nullable final MouseListener mouseAdapter) {
    myViewPanel.addMouseListener(mouseAdapter);
  }
}

Fix PY-14096 Minor Make mouse listener nullable