@Override
    public void layoutContainer(Container parent) {
      int top = myLayoutData.configuration.topSpaceHeight;
      int width = parent.getWidth();
      Dimension centeredSize = myCenteredComponent == null ? new Dimension() : myCenteredComponent.getPreferredSize();
      boolean isActions = myActionPanel != null || (myExpandAction != null && !myLayoutData.showMinSize);

      if (myTitleComponent != null) {
        int titleHeight = myTitleComponent.getPreferredSize().height;
        myTitleComponent.setBounds(0, top, width - myLayoutData.configuration.closeOffset, titleHeight);
        top += titleHeight;

        if (myCenteredComponent != null) {
          top += myLayoutData.configuration.titleContentSpaceHeight;
        }
        else if (isActions) {
          top += myLayoutData.configuration.titleActionsSpaceHeight;
        }
      }

      if (myCenteredComponent != null) {
        int centeredWidth = width;
        if (!myLayoutData.showFullContent && !myLayoutData.showMinSize && myLayoutData.fullHeight != myLayoutData.maxScrollHeight) {
          centeredWidth--;
        }
        myCenteredComponent.setBounds(0, top, centeredWidth, centeredSize.height);
        myCenteredComponent.revalidate();
      }

      if (myExpandAction != null) {
        Dimension size = myExpandAction.getPreferredSize();
        int x = width - size.width - Objects.requireNonNull(myLayoutData.configuration.rightActionsOffset).width;

        if (myLayoutData.showMinSize) {
          Point location = getCollapsedTextEndLocation(myText, myLayoutData);
          if (location == null) {
            location = new Point(10, myText.getHeight() - size.height);
          }
          int y = SwingUtilities.convertPoint(myText, location.x, location.y, parent).y;
          myExpandAction.setBounds(x, y, size.width, size.height);
        }
        else {
          int y = parent.getHeight() - size.height - myLayoutData.configuration.bottomSpaceHeight;
          myExpandAction.setBounds(x, y, size.width, size.height);
        }
      }

      if (myActionPanel != null) {
        int expandWidth = myExpandAction == null || myLayoutData.showMinSize ? 0 : myExpandAction.getPreferredSize().width;
        width -= myLayoutData.configuration.actionGap + expandWidth;

        if (myActionPanel.checkActionWidth && myActionPanel.getPreferredSize().width - width > 0 && width > 0) {
          Component component0 = myActionPanel.getComponent(0);
          Component component1 = myActionPanel.getComponent(1);
          Dimension size0 = component0.getPreferredSize();
          Dimension size1 = component1.getPreferredSize();
          int halfWidth = width / 2;

          if (size0.width > halfWidth && size1.width > halfWidth) {
            cutWidth(component0, size0, halfWidth);
            cutWidth(component1, size1, halfWidth);
          }
          else if (size0.width > halfWidth) {
            cutWidth(component0, size0, size0.width - myActionPanel.getPreferredSize().width + width);
          }
          else {
            cutWidth(component1, size1, size1.width - myActionPanel.getPreferredSize().width + width);
          }

          myActionPanel.checkActionWidth = false;
          myActionPanel.doLayout();
        }

        if (myActionPanel.actionLinks.size() > 1) {
          myActionPanel.groupedActionsLink.setVisible(false);
          for (LinkLabel<AnAction> link : myActionPanel.actionLinks) {
            link.setVisible(true);
          }
          myActionPanel.doLayout();

          boolean keepRightmost = myActionPanel.collapseActionsDirection == Notification.CollapseActionsDirection.KEEP_RIGHTMOST;
          int collapseStart = keepRightmost ? 0 : myActionPanel.actionLinks.size() - 1;
          int collapseDelta = keepRightmost ? 1 : -1;
          int collapseIndex = collapseStart;
          if (myActionPanel.getPreferredSize().width > width) {
            myActionPanel.groupedActionsLink.setVisible(true);
            myActionPanel.actionLinks.get(collapseIndex).setVisible(false);
            collapseIndex += collapseDelta;
            myActionPanel.doLayout();
            while (myActionPanel.getPreferredSize().width > width &&
                   collapseIndex >= 0 &&
                   collapseIndex < myActionPanel.actionLinks.size()) {
              myActionPanel.actionLinks.get(collapseIndex).setVisible(false);
              collapseIndex += collapseDelta;
              myActionPanel.doLayout();
            }
          }
        }

        Dimension size = myActionPanel.getPreferredSize();
        int y = parent.getHeight() - size.height - myLayoutData.configuration.bottomSpaceHeight;
        myActionPanel.setBounds(0, y, width, size.height);
      }
    }
@Override
    public void layoutContainer(Container parent)