private static @NotNull PopupHandler installConditionalPopup(@NotNull JComponent component,
                                                                @NotNull ActionGroup group,
                                                                @NotNull String place,
                                                                @Nullable ActionManager actionManager,
                                                                @NotNull ShowPopupPredicate condition) {
    if (ApplicationManager.getApplication() == null) {
      return EMPTY_HANDLER;
    }

    PopupHandler handler = new PopupHandler() {
      @Override
      public void invokePopup(Component comp, int x, int y) {
        if (condition.shouldShowPopup(comp, x, y)) {
          ActionManager manager = actionManager == null ? ActionManager.getInstance() : actionManager;
          ActionPopupMenu popupMenu = manager.createActionPopupMenu(place, group);
          popupMenu.getComponent().show(comp, x, y);
        }
      }
    };
    component.addMouseListener(handler);
    return handler;
  }
private static @NotNull PopupHandler installConditionalPopup(@NotNull JComponent component,
                                                                @NotNull ActionGroup group,
                                                                @NotNull String place,
                                                                @Nullable ActionManager actionManager,
                                                                @NotNull ShowPopupPredicate condition)