private boolean replaceButtonsForNewActionInstances(@NotNull List<? extends AnAction> newVisibleActions) {
    if (newVisibleActions.size() != myVisibleActions.size()) return false;
    Component[] components = getComponents();
    ArrayList<Pair<Integer, AnAction>> pairs = new ArrayList<>();
    for (int count = 0, size = myVisibleActions.size(), buttonIndex = 0; count < size; count++) {
      AnAction prev = myVisibleActions.get(count);
      AnAction next = newVisibleActions.get(count);
      if (next == prev) continue;
      if (next.getClass() != prev.getClass()) return false;
      Pair<Integer, AnAction> pair = null;
      for (; buttonIndex < components.length && pair == null; buttonIndex++) {
        Component component = components[buttonIndex];
        AnAction action =
          component instanceof ActionButton o ? o.getAction() :
          prev instanceof CustomComponentAction ? ClientProperty.get(component, CustomComponentAction.ACTION_KEY) : null;
        if (action == prev) {
          pair = Pair.create(buttonIndex, next);
        }
      }
      if (pair == null) return false;
      pairs.add(pair);
    }
    if (pairs.size() == newVisibleActions.size()) return false;
    myVisibleActions = newVisibleActions;
    for (Pair<Integer, AnAction> pair : pairs) {
      int index = pair.first;
      remove(index);
      addActionButtonImpl(pair.second, index);
      Component button = getComponent(index);
      button.setBounds(components[index].getBounds());
      button.validate();
    }
    return true;
  }
private boolean replaceButtonsForNewActionInstances(@NotNull List<? extends AnAction> newVisibleActions)