void initToolWindow(@NotNull ToolWindowEx toolWindow) {
    if (myToolWindow != null) {
      LOG.error("Terminal tool window already initialized");
      return;
    }
    myToolWindow = toolWindow;

    toolWindow.setTabActions(ActionManager.getInstance().getAction("TerminalToolwindowActionGroup"));
    toolWindow.setTabDoubleClickActions(Collections.singletonList(new RenameTerminalSessionAction()));

    myProject.getMessageBus().connect(toolWindow.getDisposable())
      .subscribe(ToolWindowManagerListener.TOPIC, new ToolWindowManagerListener() {
        @Override
        public void toolWindowShown(@NotNull ToolWindow toolWindow) {
          if (isTerminalToolWindow(toolWindow) && myToolWindow == toolWindow &&
              toolWindow.isVisible() && toolWindow.getContentManager().isEmpty()) {
            // open a new session if all tabs were closed manually
            createNewSession(myTerminalRunner, null, true, true);
          }
        }
      });

    if (myDockContainer == null) {
      myDockContainer = new TerminalDockContainer();
      DockManager.getInstance(myProject).register(myDockContainer, toolWindow.getDisposable());
    }
  }
void initToolWindow(@NotNull ToolWindowEx toolWindow)