private @NotNull Pair<List<Pair<String, Icon>>, Integer> calculateLongPresentation(@NotNull List<? extends RefGroup> refGroups,
                                                                                     @NotNull List<VcsBookmarkRef> bookmarks,
                                                                                     @NotNull FontMetrics fontMetrics,
                                                                                     @NotNull Color background,
                                                                                     int availableWidth) {
    List<Pair<String, Icon>> labels = new ArrayList<>();
    int width = LEFT_PADDING.get() + RIGHT_PADDING.get();
    int height = fontMetrics.getHeight();

    for (VcsBookmarkRef bookmark : bookmarks) {
      Icon icon = new BookmarkIcon(myComponent, height, background, bookmark);
      boolean isLast = refGroups.isEmpty() && bookmark == ContainerUtil.getLastItem(bookmarks);
      int newWidth = width + icon.getIconWidth() + (isLast ? 0 : MIDDLE_PADDING.get());
      labels.add(Pair.create("", icon));
      width = newWidth;
    }

    for (int i = 0; i < refGroups.size(); i++) {
      RefGroup group = refGroups.get(i);

      int doNotFitWidth = 0;
      if (i < refGroups.size() - 1) {
        LabelIcon lastIcon = getIcon(height, background, getColors(refGroups.subList(i + 1, refGroups.size())));
        doNotFitWidth = lastIcon.getIconWidth();
      }

      List<Color> colors = group.getColors();
      LabelIcon labelIcon = getIcon(height, background, colors);
      boolean isLast = i == refGroups.size() - 1;
      int newWidth = width + labelIcon.getIconWidth() + (isLast ? 0 : MIDDLE_PADDING.get());

      String text = getGroupText(group, fontMetrics, availableWidth - newWidth - doNotFitWidth);
      newWidth += fontMetrics.stringWidth(text);
      newWidth += getIconTextPadding();

      if (availableWidth - newWidth - doNotFitWidth < 0) {
        LabelIcon lastIcon = getIcon(height, background, getColors(refGroups.subList(i, refGroups.size())));
        String name = labels.isEmpty() ? text : "";
        labels.add(Pair.create(name, lastIcon));
        width += fontMetrics.stringWidth(name) + lastIcon.getIconWidth();
        break;
      }
      else {
        labels.add(Pair.create(text, labelIcon));
        width = newWidth;
      }
    }

    return Pair.create(labels, width);
  }
private @NotNull Pair<List<Pair<String, Icon>>, Integer> calculateLongPresentation(@NotNull List<? extends RefGroup> refGroups,
                                                                                     @NotNull List<VcsBookmarkRef> bookmarks,
                                                                                     @NotNull FontMetrics fontMetrics,
                                                                                     @NotNull Color background,
                                                                                     int availableWidth)