From ce73510eb1ff12b38e4906f8993f048c2c69e45c Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Fri, 11 Oct 2024 08:50:01 +0200 Subject: [PATCH] [platform] TestDialogManager.setTestDialog with disposable argument GitOrigin-RevId: 3f0ce6adc31aa7f4cd160c8d0cd299b0e64d0c27 --- platform/platform-api/api-dump-unreviewed.txt | 1 + .../src/com/intellij/openapi/ui/TestDialogManager.java | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/platform/platform-api/api-dump-unreviewed.txt b/platform/platform-api/api-dump-unreviewed.txt index 58784adeb520..1db2271d7da5 100644 --- a/platform/platform-api/api-dump-unreviewed.txt +++ b/platform/platform-api/api-dump-unreviewed.txt @@ -4447,6 +4447,7 @@ f:com.intellij.openapi.ui.TestDialogManager - s:getTestImplementation():com.intellij.openapi.ui.TestDialog - s:getTestInputImplementation():com.intellij.openapi.ui.TestInputDialog - s:setTestDialog(com.intellij.openapi.ui.TestDialog):com.intellij.openapi.ui.TestDialog +- s:setTestDialog(com.intellij.openapi.ui.TestDialog,com.intellij.openapi.Disposable):com.intellij.openapi.ui.TestDialog - s:setTestInputDialog(com.intellij.openapi.ui.TestInputDialog):com.intellij.openapi.ui.TestInputDialog com.intellij.openapi.ui.TestInputDialog - sf:DEFAULT:com.intellij.openapi.ui.TestInputDialog diff --git a/platform/platform-api/src/com/intellij/openapi/ui/TestDialogManager.java b/platform/platform-api/src/com/intellij/openapi/ui/TestDialogManager.java index 56be21e4aef7..a1072448494b 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/TestDialogManager.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/TestDialogManager.java @@ -1,9 +1,11 @@ // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.ui; +import com.intellij.openapi.Disposable; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.Disposer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; @@ -20,6 +22,13 @@ public final class TestDialogManager { return oldValue; } + @TestOnly + public static TestDialog setTestDialog(@Nullable TestDialog newValue, @NotNull Disposable disposable) { + TestDialog oldValue = setTestDialog(newValue); + Disposer.register(disposable, () -> implementation = oldValue); + return oldValue; + } + public static @NotNull TestDialog getTestImplementation() { TestDialog result = implementation; return result == null ? TestDialog.DEFAULT : result;