@@ -31,6 +31,7 @@ import com.intellij.openapi.ui.OptionAction
3131import com.intellij.openapi.ui.ValidationInfo
3232import com.intellij.openapi.ui.popup.IconButton
3333import com.intellij.openapi.util.Computable
34+ import com.intellij.openapi.util.text.StringUtil
3435import com.intellij.openapi.vfs.StandardFileSystems
3536import com.intellij.openapi.vfs.VfsUtil
3637import com.intellij.openapi.vfs.VfsUtilCore.urlToPath
@@ -149,9 +150,11 @@ import org.utbot.intellij.plugin.ui.utils.testRootType
149150import org.utbot.intellij.plugin.util.IntelliJApiHelper
150151import org.utbot.intellij.plugin.util.extractFirstLevelMembers
151152import org.utbot.intellij.plugin.util.findSdkVersion
153+ import java.awt.Component
152154import java.time.LocalDateTime
153155import java.time.format.DateTimeFormatter
154156import java.util.*
157+ import javax.swing.DefaultListCellRenderer
155158
156159private const val RECENTS_KEY = " org.utbot.recents"
157160
@@ -188,7 +191,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
188191 private val testFrameworks = createComboBox(TestFramework .allItems.toTypedArray())
189192
190193 private val modelSpringConfigs = (listOf (NO_SPRING_CONFIGURATION_OPTION ) + model.getSortedSpringConfigurationClasses()).toTypedArray()
191- private val springConfig = ComboBox (modelSpringConfigs)
194+ private val springConfig = createComboBox (modelSpringConfigs)
192195
193196 private val mockStrategies = createComboBox(MockStrategyApi .values())
194197 private val staticsMocking = JCheckBox (" Mock static methods" )
@@ -229,6 +232,28 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
229232 }
230233 }
231234
235+ private fun <T > createComboBox (values : Array <T >): ComboBox <T > {
236+ val comboBoxWidth = 300
237+ val maxComboBoxElementLength = 50
238+ return object : ComboBox <T >(DefaultComboBoxModel (values), comboBoxWidth) {}.also {
239+ it.renderer = object : DefaultListCellRenderer () {
240+ override fun getListCellRendererComponent (
241+ list : JList <* >? ,
242+ value : Any? ,
243+ index : Int ,
244+ isSelected : Boolean ,
245+ cellHasFocus : Boolean
246+ ): Component {
247+ val label =
248+ super .getListCellRendererComponent(list, value, index, isSelected, cellHasFocus)
249+ text = StringUtil .trimMiddle(value.toString(), maxComboBoxElementLength)
250+ return label
251+ }
252+ }
253+ }
254+ }
255+
256+
232257 private fun createHelpLabel (commonTooltip : String? = null) = JBLabel (AllIcons .General .ContextHelp ).apply {
233258 if (! commonTooltip.isNullOrEmpty()) toolTipText = commonTooltip
234259 }
0 commit comments