Skip to content

Commit e7848cd

Browse files
committed
Small hotfixes
1 parent 85de597 commit e7848cd

File tree

3 files changed

+8
-41
lines changed

3 files changed

+8
-41
lines changed

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/js/JsActionMethods.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ object JsActionMethods {
4848
val editor = e.getData(CommonDataKeys.EDITOR) ?: return null
4949
val file = e.getData(CommonDataKeys.PSI_FILE) as? JSFile ?: return null
5050
val element = findPsiElement(file, editor) ?: return null
51+
val kek = element.module
5152
val module = element.module ?: return null
5253
val focusedMethod = getContainingMethod(element)
5354
containingClass(element)?.let {

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/js/JsDialogWindow.kt

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,74 +2,49 @@ package org.utbot.intellij.plugin.js
22

33
import com.intellij.lang.javascript.refactoring.ui.JSMemberSelectionTable
44
import com.intellij.lang.javascript.refactoring.util.JSMemberInfo
5-
import com.intellij.openapi.ui.ComboBox
65
import com.intellij.openapi.ui.DialogPanel
76
import com.intellij.openapi.ui.DialogWrapper
8-
import com.intellij.ui.ContextHelpLabel
9-
import com.intellij.ui.components.Panel
10-
import com.intellij.ui.layout.CellBuilder
11-
import com.intellij.ui.layout.Row
127
import com.intellij.ui.layout.panel
138
import com.intellij.util.ui.JBUI
14-
import org.utbot.framework.codegen.TestFramework
15-
import org.utbot.framework.plugin.api.CodeGenerationSettingItem
169
import org.utbot.intellij.plugin.ui.components.TestFolderComboWithBrowseButton
17-
import java.awt.BorderLayout
18-
import javax.swing.DefaultComboBoxModel
1910
import javax.swing.JComponent
20-
import javax.swing.JPanel
11+
2112

2213
class JsDialogWindow(val model: JsTestsModel): DialogWrapper(model.project) {
2314

2415
private val items = model.fileMethods
2516

2617
private val functionsTable = JSMemberSelectionTable(items, null, null).apply {
27-
items?.let {
28-
val height = this.rowHeight * (items.size.coerceAtMost(12) + 1)
29-
this.preferredScrollableViewportSize = JBUI.size(-1, height)
30-
}
18+
val height = this.rowHeight * (items.size.coerceAtMost(12) + 1)
19+
this.preferredScrollableViewportSize = JBUI.size(-1, height)
3120
}
3221

3322
private val testSourceFolderField = TestFolderComboWithBrowseButton(model)
3423

35-
private val testFrameworks = ComboBox(DefaultComboBoxModel(TestFramework.allItems.toTypedArray()))
36-
3724
private lateinit var panel: DialogPanel
3825

39-
@Suppress("UNCHECKED_CAST")
40-
private val itemsToHelpTooltip = hashMapOf(
41-
(testFrameworks as ComboBox<CodeGenerationSettingItem>) to ContextHelpLabel.create(""),
42-
)
43-
4426
init {
4527
title = "Generate tests with UtBot"
4628
setResizable(false)
4729
init()
4830
}
4931

50-
@Suppress("UNCHECKED_CAST")
5132
override fun createCenterPanel(): JComponent {
5233
panel = panel {
5334
row("Test source root:") {
5435
component(testSourceFolderField)
5536
}
56-
row("Test framework:") {
57-
makePanelWithHelpTooltip(
58-
testFrameworks as ComboBox<CodeGenerationSettingItem>,
59-
itemsToHelpTooltip[testFrameworks]
60-
)
61-
}
6237
row("Generate test methods for:") {}
6338
row {
6439
scrollPane(functionsTable)
6540
}
6641
}
67-
checkBoxUpdate()
42+
updateMembersTable()
6843
return panel
6944
}
7045

71-
private fun checkBoxUpdate() {
72-
if (items == null) return
46+
private fun updateMembersTable() {
47+
if (items.isEmpty()) isOKActionEnabled = false
7348
val focusedNames = model.focusedMethod?.map { it.name }
7449
val selectedMethods = items.filter {
7550
focusedNames?.contains(it.member.name) ?: false
@@ -82,13 +57,4 @@ class JsDialogWindow(val model: JsTestsModel): DialogWrapper(model.project) {
8257
}
8358

8459
private fun checkMembers(members: Collection<JSMemberInfo>) = members.forEach { it.isChecked = true }
85-
86-
private fun Row.makePanelWithHelpTooltip(
87-
mainComponent: JComponent,
88-
contextHelpLabel: ContextHelpLabel?
89-
): CellBuilder<JPanel> =
90-
component(Panel().apply {
91-
add(mainComponent, BorderLayout.LINE_START)
92-
contextHelpLabel?.let { add(it, BorderLayout.LINE_END) }
93-
})
9460
}

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/js/JsTestsModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class JsTestsModel(
1212
project: Project,
1313
srcModule: Module,
1414
testModule: Module,
15-
val fileMethods: Set<JSMemberInfo>?,
15+
val fileMethods: Set<JSMemberInfo>,
1616
val focusedMethod: Set<JSFunction>?,
1717
) : BaseTestsModel(
1818
project,

0 commit comments

Comments
 (0)