protected final void setAutoResizeUntilToolbarNotFull(@NotNull Runnable resizeRunnable, Disposable disposable) {
    if (myToolbar == null) return;

    ContainerListener containerListener = new ContainerListener() {
      @Override
      public void componentAdded(ContainerEvent e) {
        resizeRunnable.run();
      }

      @Override
      public void componentRemoved(ContainerEvent e) {
        resizeRunnable.run();
      }
    };

    myToolbar.addContainerListener(containerListener);
    myToolbar.addListener(new ActionToolbarListener() {
      private boolean myActionsUpdatedOnce = false;

      @Override
      public void actionsUpdated() {
        if (myActionsUpdatedOnce) {
          myToolbar.removeContainerListener(containerListener);
        }
        myActionsUpdatedOnce = true;
      }
    }, disposable);
  }
protected final void setAutoResizeUntilToolbarNotFull(@NotNull Runnable resizeRunnable, Disposable disposable)