private static boolean isEnoughSpaceToShowPopup() {
    DialogWrapper currentDialog = DialogWrapper.findInstanceFromFocus();
    if (currentDialog != null && (currentDialog.getWindow().getWidth() < 500 || currentDialog.getWindow().getHeight() < 500)) {
      return false;
    }
    return true;
  }
private static boolean isEnoughSpaceToShowPopup()