@@ -57,13 +57,13 @@ import com.intellij.ui.SimpleTextAttributes
5757import com.intellij.ui.components.CheckBox
5858import com.intellij.ui.components.JBLabel
5959import com.intellij.ui.components.JBScrollPane
60+ import com.intellij.ui.components.JBTextField
6061import com.intellij.ui.components.panels.HorizontalLayout
6162import com.intellij.ui.components.panels.NonOpaquePanel
6263import com.intellij.ui.components.panels.OpaquePanel
6364import com.intellij.ui.dsl.builder.Align
64- import com.intellij.ui.layout.ComboBoxPredicate
6565import com.intellij.ui.dsl.builder.panel
66- import com.intellij.ui.layout.selected
66+ import com.intellij.ui.layout.ComboBoxPredicate
6767import com.intellij.util.IncorrectOperationException
6868import com.intellij.util.lang.JavaVersion
6969import com.intellij.util.ui.JBUI
@@ -74,43 +74,23 @@ import com.intellij.util.ui.JBUI.size
7474import com.intellij.util.ui.UIUtil
7575import com.intellij.util.ui.components.BorderLayoutPanel
7676import mu.KotlinLogging
77- import java.awt.BorderLayout
78- import java.awt.Color
79- import java.awt.Component
80- import java.awt.Dimension
81- import java.awt.event.ActionEvent
82- import java.nio.file.Files
83- import java.nio.file.Path
84- import java.nio.file.Paths
85- import java.text.ParseException
86- import java.util.concurrent.TimeUnit
87- import javax.swing.AbstractAction
88- import javax.swing.Action
89- import javax.swing.DefaultComboBoxModel
90- import javax.swing.JButton
91- import javax.swing.JCheckBox
92- import javax.swing.JComboBox
93- import javax.swing.JComponent
94- import javax.swing.JList
95- import javax.swing.JSpinner
96- import javax.swing.text.DefaultFormatter
9777import org.jetbrains.concurrency.Promise
9878import org.jetbrains.concurrency.thenRun
9979import org.utbot.common.PathUtil.toPath
10080import org.utbot.framework.UtSettings
101- import org.utbot.framework.codegen.domain.ProjectType
10281import org.utbot.framework.codegen.domain.DependencyInjectionFramework
10382import org.utbot.framework.codegen.domain.ForceStaticMocking
10483import org.utbot.framework.codegen.domain.Junit4
10584import org.utbot.framework.codegen.domain.Junit5
10685import org.utbot.framework.codegen.domain.MockitoStaticMocking
10786import org.utbot.framework.codegen.domain.NoStaticMocking
10887import org.utbot.framework.codegen.domain.ParametrizedTestSource
88+ import org.utbot.framework.codegen.domain.ProjectType
10989import org.utbot.framework.codegen.domain.SpringBeans
110- import org.utbot.framework.codegen.domain.TypeReplacementApproach
11190import org.utbot.framework.codegen.domain.StaticsMocking
11291import org.utbot.framework.codegen.domain.TestFramework
11392import org.utbot.framework.codegen.domain.TestNg
93+ import org.utbot.framework.codegen.domain.TypeReplacementApproach
11494import org.utbot.framework.plugin.api.CodeGenerationSettingItem
11595import org.utbot.framework.plugin.api.CodegenLanguage
11696import org.utbot.framework.plugin.api.MockFramework
@@ -150,12 +130,32 @@ import org.utbot.intellij.plugin.util.IntelliJApiHelper
150130import org.utbot.intellij.plugin.util.SpringConfigurationsHelper
151131import org.utbot.intellij.plugin.util.extractFirstLevelMembers
152132import org.utbot.intellij.plugin.util.findSdkVersion
133+ import java.awt.BorderLayout
134+ import java.awt.Color
135+ import java.awt.Component
136+ import java.awt.Dimension
137+ import java.awt.event.ActionEvent
153138import java.io.File
139+ import java.nio.file.Files
140+ import java.nio.file.Path
141+ import java.nio.file.Paths
142+ import java.text.ParseException
154143import java.time.LocalDateTime
155144import java.time.format.DateTimeFormatter
156- import javax.swing.JTextField
145+ import java.util.concurrent.TimeUnit
146+ import javax.swing.AbstractAction
147+ import javax.swing.Action
148+ import javax.swing.DefaultComboBoxModel
149+ import javax.swing.JButton
150+ import javax.swing.JCheckBox
151+ import javax.swing.JComboBox
152+ import javax.swing.JComponent
153+ import javax.swing.JList
154+ import javax.swing.JSpinner
155+ import javax.swing.text.DefaultFormatter
157156import kotlin.io.path.notExists
158157
158+
159159private const val RECENTS_KEY = " org.utbot.recents"
160160
161161private const val SAME_PACKAGE_LABEL = " same as for sources"
@@ -198,8 +198,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
198198 private val staticsMocking = JCheckBox (" Mock static methods" )
199199
200200 private val springConfig = createComboBoxWithSeparatorsForSpringConfigs(shortenConfigurationNames())
201- private val selectProfile = JCheckBox (" Select active profiles" )
202- private val profileExpression = JTextField (DEFAULT_SPRING_PROFILE_NAME , 23 )
201+ private val profileNames = JBTextField (23 ).apply { emptyText.text = DEFAULT_SPRING_PROFILE_NAME }
203202
204203 private val timeoutSpinner =
205204 JBIntSpinner (TimeUnit .MILLISECONDS .toSeconds(model.timeout).toInt(), 1 , Int .MAX_VALUE , 1 ).also {
@@ -394,6 +393,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
394393 row(" Testing framework:" ) {
395394 cell(testFrameworks)
396395 }
396+
397397 if (model.projectType == ProjectType .Spring ) {
398398 row(" Spring configuration:" ) {
399399 cell(springConfig)
@@ -404,23 +404,17 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
404404 " Mocks will be used when necessary."
405405 )
406406 }
407- row {
408- cell(selectProfile )
407+ row( " Active profile(s): " ) {
408+ cell(profileNames )
409409 contextHelp(
410- " Only selected profile will be active .<br>" +
411- " Otherwise, profile from the configuration class or default one is used. "
410+ " One or several comma-separated names .<br>" +
411+ " If all names are incorrect, default profile is used"
412412 )
413- }
414- indent {
415- row(" Profile name(s):" ) {
416- cell(profileExpression).align(Align .FILL )
417- contextHelp(
418- " Profile name or expression like \" prod|web\" may be passed here.<br>" +
419- " If expression is incorrect, default profile will be used"
420- )
421- }.enabledIf(selectProfile.selected)
422- }
413+ }.enabledIf(
414+ ComboBoxPredicate (springConfig) { springConfig.item != NO_SPRING_CONFIGURATION_OPTION }
415+ )
423416 }
417+
424418 row(" Mocking strategy:" ) {
425419 cell(mockStrategies)
426420 contextHelp(
@@ -664,7 +658,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
664658 TypeReplacementApproach .ReplaceIfPossible (fullConfigName)
665659 }
666660 }
667- model.profileExpression = profileExpression .text
661+ model.profileNames = profileNames .text. let { it.ifEmpty { DEFAULT_SPRING_PROFILE_NAME } }
668662
669663 val settings = model.project.service<Settings >()
670664 with (settings) {
@@ -1062,8 +1056,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
10621056 mockStrategies.isEnabled = false
10631057 updateMockStrategyListForConfigGuidedTypeReplacements()
10641058
1065- selectProfile.isEnabled = true
1066- selectProfile.isSelected = false
1059+ profileNames.isEnabled = true
10671060 } else {
10681061 mockStrategies.item = when (model.projectType) {
10691062 ProjectType .Spring -> MockStrategyApi .springDefaultItem
@@ -1072,15 +1065,11 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
10721065 mockStrategies.isEnabled = true
10731066 updateMockStrategyList()
10741067
1075- selectProfile .isEnabled = false
1076- selectProfile.isSelected = false
1068+ profileNames .isEnabled = false
1069+ profileNames.text = " "
10771070 }
10781071 }
10791072
1080- selectProfile.addActionListener { _ ->
1081- profileExpression.text = if (selectProfile.isSelected) " " else DEFAULT_SPRING_PROFILE_NAME
1082- }
1083-
10841073 cbSpecifyTestPackage.addActionListener {
10851074 val testPackageName = findTestPackageComboValue()
10861075 val packageNameIsNeeded = testPackageField.isEnabled || testPackageName != SAME_PACKAGE_LABEL
@@ -1157,8 +1146,6 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
11571146 private fun updateSpringConfigurationEnabled () {
11581147 // We check for > 1 because there is already extra-dummy NO_SPRING_CONFIGURATION_OPTION option
11591148 springConfig.isEnabled = model.projectType == ProjectType .Spring && springConfig.itemCount > 1
1160- selectProfile.isEnabled = false
1161- selectProfile.isSelected = false
11621149 }
11631150
11641151 private fun staticsMockingConfigured (): Boolean {
0 commit comments