public static @NotNull ModalityState getDefaultModality() {
    Application app = ApplicationManager.getApplication();
    return app == null ? ModalityState.nonModal() : app.getDefaultModalityState();
  }
public static @NotNull ModalityState getDefaultModality()