Skip to content

Commit

Permalink
Empty tooltips are shown on Java plugin popup #420 (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vassiliy-Kudryashov authored Jul 11, 2022
1 parent 4fd423b commit 352c68a
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,15 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m

@Suppress("UNCHECKED_CAST")
private val itemsToHelpTooltip = hashMapOf(
(codegenLanguages as ComboBox<CodeGenerationSettingItem>) to ContextHelpLabel.create(""),
(testFrameworks as ComboBox<CodeGenerationSettingItem>) to ContextHelpLabel.create(""),
(mockStrategies as ComboBox<CodeGenerationSettingItem>) to ContextHelpLabel.create(""),
(staticsMocking as ComboBox<CodeGenerationSettingItem>) to ContextHelpLabel.create(""),
(parametrizedTestSources as ComboBox<CodeGenerationSettingItem>) to ContextHelpLabel.create("")
(codegenLanguages as ComboBox<CodeGenerationSettingItem>) to createHelpLabel(),
(testFrameworks as ComboBox<CodeGenerationSettingItem>) to createHelpLabel(),
(mockStrategies as ComboBox<CodeGenerationSettingItem>) to createHelpLabel(),
(staticsMocking as ComboBox<CodeGenerationSettingItem>) to createHelpLabel(),
(parametrizedTestSources as ComboBox<CodeGenerationSettingItem>) to createHelpLabel()
)

private fun createHelpLabel() = JBLabel(AllIcons.General.ContextHelp)

init {
title = "Generate tests with UtBot"
setResizable(false)
Expand Down Expand Up @@ -260,11 +262,11 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m

private fun Row.makePanelWithHelpTooltip(
mainComponent: JComponent,
contextHelpLabel: ContextHelpLabel?
label: JBLabel?
): CellBuilder<JPanel> =
component(Panel().apply {
add(mainComponent, BorderLayout.LINE_START)
contextHelpLabel?.let { add(it, BorderLayout.LINE_END) }
label?.let { add(it, BorderLayout.LINE_END) }
})

private fun findSdkVersion(): JavaVersion? {
Expand Down Expand Up @@ -987,7 +989,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
}
}

private fun ComboBox<CodeGenerationSettingItem>.setHelpTooltipTextChanger(helpLabel: ContextHelpLabel) {
private fun ComboBox<CodeGenerationSettingItem>.setHelpTooltipTextChanger(helpLabel: JBLabel) {
addActionListener { event ->
val comboBox = event.source as ComboBox<*>
val item = comboBox.item as CodeGenerationSettingItem
Expand Down

0 comments on commit 352c68a

Please sign in to comment.