public static void invokeAndWait(final Project project, @NotNull final Runnable runnable, ModalityState state) {
    if (project != null) {
      ApplicationManager.getApplication().invokeAndWait(() -> {
        if (!project.isDisposed()) {
          runnable.run();
        }
      }, state);
    }
  }
public static void invokeAndWait(final Project project, @NotNull final Runnable runnable, ModalityState state)