@Override
  public CompletableFuture<?> show() {
    LOG.assertTrue(EventQueue.isDispatchThread(), "Access is allowed from event dispatch thread only");

    AnCancelAction anCancelAction = new AnCancelAction();
    JRootPane rootPane = getRootPane();
    ComponentUtil.decorateWindowHeader(rootPane);

    Window window = getWindow();
    if (window instanceof JDialog && !((JDialog)window).isUndecorated() && rootPane != null && LoadingState.COMPONENTS_LOADED.isOccurred()) {
      ToolbarService.Companion.getInstance().setTransparentTitleBar(window, rootPane, runnable -> {
        Disposer.register(myWrapper.getDisposable(), () -> runnable.run());
        return Unit.INSTANCE;
      });
    }

    Container contentPane = getContentPane();
    if (contentPane instanceof CustomFrameDialogContent) {
      ((CustomFrameDialogContent)contentPane).updateLayout();
    }

    Application app = LoadingState.COMPONENTS_LOADED.isOccurred() ? ApplicationManager.getApplication() : null;
    if (app != null && app.getServiceIfCreated(ActionManager.class) != null) {
      anCancelAction.registerCustomShortcutSet(ActionUtil.getShortcutSet(IdeActions.ACTION_EDITOR_ESCAPE), rootPane);
    }
    else {
      anCancelAction.registerCustomShortcutSet(CommonShortcuts.ESCAPE, rootPane);
    }

    if (rootPane != null) {
      myDisposeActions.add(() -> anCancelAction.unregisterCustomShortcutSet(rootPane));
    }

    if (app != null && !myCanBeParent) {
      WindowManagerEx windowManager = getWindowManager();
      if (windowManager != null) {
        windowManager.doNotSuggestAsParent(myDialog.getWindow());
      }
    }

    CommandProcessorEx commandProcessor = app == null ? null : (CommandProcessorEx)CommandProcessor.getInstance();
    boolean appStarted = commandProcessor != null;

    // ProgressWindow starts a modality state itself
    @SuppressWarnings("deprecation") boolean changeModalityState = appStarted && myDialog.isModal() && !isProgressDialog();
    Project project = myProject;

    boolean perProjectModality = changeModalityState &&
                                 project != null &&
                                 !ProjectManagerEx.IS_PER_PROJECT_INSTANCE_ENABLED &&
                                 Registry.is("ide.perProjectModality", false);
    if (changeModalityState) {
      commandProcessor.enterModal();
      if (perProjectModality) {
        LaterInvocator.enterModal(project, myDialog.getWindow());
      }
      else {
        LaterInvocator.enterModal(myDialog);
      }
    }

    if (appStarted) {
      hidePopupsIfNeeded();
    }

    if (SystemInfoRt.isMac) {
      final Disposable tb = TouchbarSupport.showWindowActions(myDialog.getContentPane());
      if (tb != null) {
        myDisposeActions.add(() -> Disposer.dispose(tb));
      }
    }

    Component componentToRestoreFocus = null;
    KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    if (UIUtil.isSimpleWindow(kfm.getFocusedWindow())) {
      // 'Simple' windows cannot be dialog owners, so focus won't return to them automatically on dialog closing
      componentToRestoreFocus = kfm.getPermanentFocusOwner();
    }

    CompletableFuture<Void> result = new CompletableFuture<>();
    SplashManagerKt.hideSplash();
    try (
      AccessToken ignore = SlowOperations.startSection(SlowOperations.RESET);
      AccessToken ignore2 = ThreadContext.resetThreadContext()
    ) {
      myDialog.show();
    }
    finally {
      if (changeModalityState) {
        commandProcessor.leaveModal();
        if (perProjectModality) {
          LaterInvocator.leaveModal(project, myDialog.getWindow());
        }
        else {
          LaterInvocator.leaveModal(myDialog);
        }
      }

      myDialog.getFocusManager().doWhenFocusSettlesDown(() -> result.complete(null));
    }

    if (componentToRestoreFocus != null) {
      componentToRestoreFocus.requestFocus();
    }

    return result;
  }
@Override
  public CompletableFuture<?> show()