private @Nullable ToolWindow getWindow(@NotNull AnActionEvent event) {
    if (myWindow != null) {
      return myWindow;
    }

    Project project = event.getProject();
    if (project == null) {
      return null;
    }

    Component context = event.getData(PlatformCoreDataKeys.CONTEXT_COMPONENT);
    if (context == null) {
      return null;
    }

    ToolWindowManager manager = ToolWindowManager.getInstance(project);
    String toolWindowId = manager.getActiveToolWindowId();
    ToolWindow window = toolWindowId == null ? null : manager.getToolWindow(toolWindowId);
    if (window == null) {
      return null;
    }

    return SwingUtilities.isDescendingFrom(window.getComponent(), context) ? window : null;
  }
private @Nullable ToolWindow getWindow(@NotNull AnActionEvent event)