@@ -31,6 +31,7 @@ import com.intellij.openapi.ui.OptionAction
31
31
import com.intellij.openapi.ui.ValidationInfo
32
32
import com.intellij.openapi.ui.popup.IconButton
33
33
import com.intellij.openapi.util.Computable
34
+ import com.intellij.openapi.util.text.StringUtil
34
35
import com.intellij.openapi.vfs.StandardFileSystems
35
36
import com.intellij.openapi.vfs.VfsUtil
36
37
import com.intellij.openapi.vfs.VfsUtilCore.urlToPath
@@ -149,9 +150,11 @@ import org.utbot.intellij.plugin.ui.utils.testRootType
149
150
import org.utbot.intellij.plugin.util.IntelliJApiHelper
150
151
import org.utbot.intellij.plugin.util.extractFirstLevelMembers
151
152
import org.utbot.intellij.plugin.util.findSdkVersion
153
+ import java.awt.Component
152
154
import java.time.LocalDateTime
153
155
import java.time.format.DateTimeFormatter
154
156
import java.util.*
157
+ import javax.swing.DefaultListCellRenderer
155
158
156
159
private const val RECENTS_KEY = " org.utbot.recents"
157
160
@@ -188,7 +191,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
188
191
private val testFrameworks = createComboBox(TestFramework .allItems.toTypedArray())
189
192
190
193
private val modelSpringConfigs = (listOf (NO_SPRING_CONFIGURATION_OPTION ) + model.getSortedSpringConfigurationClasses()).toTypedArray()
191
- private val springConfig = ComboBox (modelSpringConfigs)
194
+ private val springConfig = createComboBox (modelSpringConfigs)
192
195
193
196
private val mockStrategies = createComboBox(MockStrategyApi .values())
194
197
private val staticsMocking = JCheckBox (" Mock static methods" )
@@ -229,6 +232,28 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
229
232
}
230
233
}
231
234
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
+
232
257
private fun createHelpLabel (commonTooltip : String? = null) = JBLabel (AllIcons .General .ContextHelp ).apply {
233
258
if (! commonTooltip.isNullOrEmpty()) toolTipText = commonTooltip
234
259
}
0 commit comments