@NotNull
 public ModalityState getDefaultModalityState() {
   if (EventQueue.isDispatchThread()) {
     return getCurrentModalityState();
   } else {
     ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
     return progress == null ? getNoneModalityState() : progress.getModalityState();
   }
 }
  private static void assertIsDispatchThread(String message) {
    if (ShutDownTracker.isShutdownHookRunning()) return;
    final Thread currentThread = Thread.currentThread();
    if (ourDispatchThread == currentThread) return;

    if (EventQueue.isDispatchThread()) {
      ourDispatchThread = currentThread;
    }
    if (ourDispatchThread == currentThread) return;

    Integer safeCounter = ourEdtSafe.get();
    if (safeCounter != null && safeCounter > 0) return;

    LOG.error(
        message,
        "Current thread: " + describe(Thread.currentThread()),
        "Our dispatch thread:" + describe(ourDispatchThread),
        "SystemEventQueueThread: " + describe(getEventQueueThread()));
  }
 public boolean isDispatchThread() {
   return EventQueue.isDispatchThread();
 }