11package org.utbot.intellij.plugin.language.python
22
3+ import com.intellij.openapi.components.service
34import com.intellij.openapi.project.Project
4- import com.intellij.openapi.ui.ComboBox
5- import com.intellij.openapi.ui.DialogPanel
6- import com.intellij.openapi.ui.DialogWrapper
7- import com.intellij.openapi.ui.ValidationInfo
5+ import com.intellij.openapi.ui.*
86import com.intellij.ui.ContextHelpLabel
97import com.intellij.ui.JBIntSpinner
108import com.intellij.ui.components.Panel
@@ -17,15 +15,18 @@ import com.jetbrains.python.refactoring.classes.PyMemberInfoStorage
1715import com.jetbrains.python.refactoring.classes.membersManager.PyMemberInfo
1816import com.jetbrains.python.refactoring.classes.ui.PyMemberSelectionTable
1917import org.utbot.framework.UtSettings
18+ import org.utbot.intellij.plugin.settings.Settings
2019import java.awt.BorderLayout
2120import java.util.concurrent.TimeUnit
2221import org.utbot.intellij.plugin.ui.components.TestSourceDirectoryChooser
2322import org.utbot.intellij.plugin.ui.utils.createTestFrameworksRenderer
23+ import java.awt.event.ActionEvent
2424import javax.swing.*
2525
2626
2727private const val WILL_BE_INSTALLED_LABEL = " (will be installed)"
2828private const val MINIMUM_TIMEOUT_VALUE_IN_SECONDS = 1
29+ private const val ACTION_GENERATE = " Generate Tests"
2930
3031class PythonDialogWindow (val model : PythonTestsModel ) : DialogWrapper(model.project) {
3132
@@ -38,13 +39,6 @@ class PythonDialogWindow(val model: PythonTestsModel) : DialogWrapper(model.proj
3839 Int .MAX_VALUE ,
3940 MINIMUM_TIMEOUT_VALUE_IN_SECONDS
4041 )
41- private val timeoutSpinnerForOneRun =
42- JBIntSpinner (
43- TimeUnit .MILLISECONDS .toSeconds(DEFAULT_TIMEOUT_FOR_RUN_IN_MILLIS ).toInt(),
44- MINIMUM_TIMEOUT_VALUE_IN_SECONDS ,
45- Int .MAX_VALUE ,
46- MINIMUM_TIMEOUT_VALUE_IN_SECONDS
47- )
4842 private val testFrameworks =
4943 ComboBox (DefaultComboBoxModel (model.cgLanguageAssistant.getLanguageTestFrameworkManager().testFrameworks.toTypedArray()))
5044
@@ -64,7 +58,7 @@ class PythonDialogWindow(val model: PythonTestsModel) : DialogWrapper(model.proj
6458 override fun createCenterPanel (): JComponent {
6559
6660 panel = panel {
67- row(" Test source root:" ) {
61+ row(" Test sources root:" ) {
6862 component(testSourceFolderField)
6963 }
7064 row(" Test framework:" ) {
@@ -80,13 +74,6 @@ class PythonDialogWindow(val model: PythonTestsModel) : DialogWrapper(model.proj
8074 component(ContextHelpLabel .create(" Set the timeout for all test generation processes." ))
8175 }
8276 }
83- row(" Timeout for one function run:" ) {
84- cell {
85- component(timeoutSpinnerForOneRun)
86- label(" seconds" )
87- component(ContextHelpLabel .create(" Set the timeout for one function execution." ))
88- }
89- }
9077 row(" Generate test methods for:" ) {}
9178 row {
9279 scrollPane(functionsTable)
@@ -165,14 +152,31 @@ class PythonDialogWindow(val model: PythonTestsModel) : DialogWrapper(model.proj
165152 contextHelpLabel?.let { add(it, BorderLayout .LINE_END ) }
166153 })
167154
155+ class OKOptionAction (private val okAction : Action ) : AbstractAction(ACTION_GENERATE ) {
156+ init {
157+ putValue(DEFAULT_ACTION , java.lang.Boolean .TRUE )
158+ putValue(FOCUSED_ACTION , java.lang.Boolean .TRUE )
159+ }
160+ override fun actionPerformed (e : ActionEvent ? ) {
161+ okAction.actionPerformed(e)
162+ }
163+ }
164+
165+ private val okOptionAction: OKOptionAction get() = OKOptionAction (super .getOKAction())
166+ override fun getOKAction () = okOptionAction
167+
168168 override fun doOKAction () {
169169 val selectedMembers = functionsTable.selectedMemberInfos
170170 model.selectedFunctions = selectedMembers.mapNotNull { it.member as ? PyFunction }.toSet()
171171 model.testFramework = testFrameworks.item
172172 model.timeout = TimeUnit .SECONDS .toMillis(timeoutSpinnerForTotalTimeout.number.toLong())
173- model.timeoutForRun = TimeUnit .SECONDS .toMillis(timeoutSpinnerForOneRun.number.toLong())
174173 model.testSourceRootPath = testSourceFolderField.text
175174
175+ val settings = model.project.service<Settings >()
176+ with (settings) {
177+ model.timeoutForRun = hangingTestsTimeout.timeoutMs
178+ }
179+
176180 super .doOKAction()
177181 }
178182
0 commit comments