@@ -2,6 +2,7 @@ package org.utbot.intellij.plugin.settings
2
2
3
3
import com.intellij.openapi.components.service
4
4
import com.intellij.openapi.project.Project
5
+ import com.intellij.openapi.ui.ComboBox
5
6
import com.intellij.openapi.ui.DialogPanel
6
7
import com.intellij.ui.ContextHelpLabel
7
8
import com.intellij.ui.components.JBLabel
@@ -10,6 +11,7 @@ import com.intellij.ui.layout.LayoutBuilder
10
11
import com.intellij.ui.layout.PropertyBinding
11
12
import com.intellij.ui.layout.labelTable
12
13
import com.intellij.ui.layout.panel
14
+ import com.intellij.ui.layout.selectedValueMatches
13
15
import com.intellij.ui.layout.slider
14
16
import com.intellij.ui.layout.withValueBinding
15
17
import com.intellij.util.castSafelyTo
@@ -29,27 +31,42 @@ import org.utbot.framework.plugin.api.JavaDocCommentStyle
29
31
import org.utbot.framework.plugin.api.TreatOverflowAsError
30
32
import org.utbot.intellij.plugin.ui.components.CodeGenerationSettingItemRenderer
31
33
import javax.swing.JSlider
34
+ import org.utbot.framework.plugin.api.isSummarizationCompatible
32
35
33
36
class SettingsWindow (val project : Project ) {
34
37
private val settings = project.service<Settings >()
35
38
36
39
// TODO it is better to use something like SearchEverywhere for classes but it is complicated to implement
40
+ private lateinit var codegenLanguageCombo: ComboBox <CodegenLanguage >
37
41
private val excludeTable = MockAlwaysClassesTable (project)
38
42
private lateinit var runInspectionAfterTestGenerationCheckBox: JCheckBox
39
43
private lateinit var forceMockCheckBox: JCheckBox
40
44
private lateinit var enableSummarizationGenerationCheckBox: JCheckBox
41
45
42
46
val panel: JPanel = panel {
47
+ row(" Generated test language:" ) {
48
+ cell {
49
+ codegenLanguageCombo = comboBox(
50
+ DefaultComboBoxModel (CodegenLanguage .values()),
51
+ getter = { settings.providerNameByServiceLoader(CodegenLanguage ::class ) as CodegenLanguage },
52
+ setter = { settings.setProviderByLoader(CodegenLanguage ::class , it as CodeGenerationSettingItem ) }
53
+ ).apply {
54
+ component.renderer = CodeGenerationSettingItemRenderer ()
55
+ ContextHelpLabel .create(" You can generate test methods in Java or Kotlin regardless of your source code language." )
56
+ }.component
57
+ codegenLanguageCombo.addActionListener {
58
+ if (! codegenLanguageCombo.item.isSummarizationCompatible()) {
59
+ enableSummarizationGenerationCheckBox.isSelected = false
60
+ }
61
+ }
62
+ }
63
+ }
43
64
val valuesComboBox: LayoutBuilder .(KClass <* >, Array <* >) -> Unit = { loader, values ->
44
65
val serviceLabels = mapOf (
45
- CodegenLanguage ::class to "Generated test language:",
46
66
RuntimeExceptionTestsBehaviour ::class to "Tests with exceptions:",
47
67
TreatOverflowAsError ::class to "Overflow detection:",
48
68
JavaDocCommentStyle ::class to "Javadoc comment style:"
49
69
)
50
- val tooltipLabels = mapOf (
51
- CodegenLanguage ::class to "You can generate test methods in Java or Kotlin regardless of your source code language."
52
- )
53
70
54
71
row(serviceLabels[loader] ? : error(" Unknown service loader: $loader " )) {
55
72
cell {
@@ -59,14 +76,11 @@ class SettingsWindow(val project: Project) {
59
76
setter = { settings.setProviderByLoader(loader, it as CodeGenerationSettingItem ) },
60
77
).apply {
61
78
component.renderer = CodeGenerationSettingItemRenderer ()
62
- ContextHelpLabel .create(tooltipLabels[loader] ? : return @apply)()
63
79
}
64
80
}
65
81
}
66
82
}
67
83
68
- valuesComboBox(CodegenLanguage ::class , CodegenLanguage .values())
69
-
70
84
row(" Hanging test timeout:" ) {
71
85
cell {
72
86
spinner(
@@ -129,6 +143,7 @@ class SettingsWindow(val project: Project) {
129
143
.onIsModified {
130
144
enableSummarizationGenerationCheckBox.isSelected xor settings.state.enableSummariesGeneration
131
145
}
146
+ .enableIf(codegenLanguageCombo.selectedValueMatches(CodegenLanguage ? ::isSummarizationCompatible))
132
147
.component
133
148
}
134
149
}
0 commit comments