From 552b07a96a5b1c384134319886cb80f046db7818 Mon Sep 17 00:00:00 2001 From: Egor Kulikov Date: Tue, 12 Jul 2022 09:26:51 +0300 Subject: [PATCH] Make specify checkbox option invisible --- .../plugin/ui/GenerateTestsDialogWindow.kt | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt index 3edbecac89..a13c791b96 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt @@ -238,10 +238,11 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m } row { component(cbSpecifyTestPackage) - } + }.apply { visible = false } row("Destination package:") { component(testPackageField) - } + }.apply { visible = false } + row("Generate test methods for:") {} row { scrollPane(membersTable) @@ -465,11 +466,6 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m } - if (cbSpecifyTestPackage.isSelected && testPackageField.text.isEmpty()) { - showTestPackageAbsenceErrorMessage() - return - } - configureJvmTargetIfRequired() configureTestFrameworkIfRequired() configureMockFrameworkIfRequired() @@ -531,12 +527,6 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m "Generation error" ) - private fun showTestPackageAbsenceErrorMessage() = - Messages.showErrorDialog( - "Specify a package to store tests in.", - "Generation error" - ) - private fun findReadOnlyContentEntry(testSourceRoot: VirtualFile?): ContentEntry? { if (testSourceRoot == null) return null if (testSourceRoot is FakeVirtualFile) { @@ -866,14 +856,10 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m cbSpecifyTestPackage.addActionListener { val testPackageName = findTestPackageComboValue() + val packageNameIsNeeded = testPackageField.isEnabled || testPackageName != SAME_PACKAGE_LABEL - if (testPackageField.isEnabled) { - testPackageField.isEnabled = false - testPackageField.text = testPackageName - } else { - testPackageField.isEnabled = true - testPackageField.text = if (testPackageName != SAME_PACKAGE_LABEL) testPackageName else "" - } + testPackageField.text = if (packageNameIsNeeded) testPackageName else "" + testPackageField.isEnabled = !testPackageField.isEnabled } }