From dbd10380ee5a93f286c2403543627258fd11c42f Mon Sep 17 00:00:00 2001 From: Dmitry Gridin Date: Thu, 28 May 2020 09:28:52 +0700 Subject: [PATCH] Code style settings: fix top border in UI #KT-39180 --- .../idea/formatter/KotlinOtherSettingsPanel.kt | 7 ++++--- .../kotlin/idea/formatter/KotlinSaveStylePanel.kt | 15 ++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinOtherSettingsPanel.kt b/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinOtherSettingsPanel.kt index 9dc6926b18a..e7c2ee48e2b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinOtherSettingsPanel.kt +++ b/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinOtherSettingsPanel.kt @@ -15,8 +15,8 @@ import com.intellij.util.ui.JBUI import com.intellij.util.ui.UIUtil import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.KotlinLanguage -import java.awt.BorderLayout import javax.swing.BorderFactory +import javax.swing.BoxLayout import javax.swing.JCheckBox import javax.swing.JPanel @@ -47,11 +47,12 @@ class KotlinOtherSettingsPanel(settings: CodeStyleSettings) : CodeStyleAbstractP override fun getTabTitle(): String = KotlinBundle.message("formatter.title.other") - private val jPanel = JPanel(BorderLayout()).apply { + private val jPanel = JPanel().apply { + layout = BoxLayout(this, BoxLayout.Y_AXIS) add( JBScrollPane( JPanel(VerticalLayout(JBUI.scale(5))).apply { - border = BorderFactory.createEmptyBorder(UIUtil.DEFAULT_VGAP, 10, UIUtil.DEFAULT_VGAP, 10) + border = BorderFactory.createEmptyBorder(0, UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP, UIUtil.DEFAULT_HGAP) add( OptionGroup(KotlinBundle.message("formatter.title.trailing.comma")).apply { add(cbTrailingComma) diff --git a/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinSaveStylePanel.kt b/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinSaveStylePanel.kt index eefcc968687..c5b63e1c6c6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinSaveStylePanel.kt +++ b/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinSaveStylePanel.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2000-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -9,7 +9,7 @@ import com.intellij.application.options.CodeStyleAbstractPanel import com.intellij.openapi.editor.colors.EditorColorsScheme import com.intellij.openapi.ui.ComboBox import com.intellij.psi.codeStyle.CodeStyleSettings -import com.intellij.ui.ListCellRendererWrapper +import com.intellij.ui.SimpleListCellRenderer import com.intellij.ui.components.JBScrollPane import com.intellij.ui.components.panels.HorizontalLayout import com.intellij.ui.components.panels.VerticalLayout @@ -20,7 +20,6 @@ import org.jetbrains.kotlin.idea.KotlinLanguage import java.awt.BorderLayout import javax.swing.BorderFactory import javax.swing.JLabel -import javax.swing.JList import javax.swing.JPanel class KotlinSaveStylePanel(settings: CodeStyleSettings) : CodeStyleAbstractPanel(KotlinLanguage.INSTANCE, null, settings) { @@ -53,17 +52,15 @@ class KotlinSaveStylePanel(settings: CodeStyleSettings) : CodeStyleAbstractPanel add( JBScrollPane( JPanel(VerticalLayout(JBUI.scale(5))).apply { - border = BorderFactory.createEmptyBorder(UIUtil.DEFAULT_VGAP, 10, UIUtil.DEFAULT_VGAP, 10) + border = BorderFactory.createEmptyBorder(0, UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP, UIUtil.DEFAULT_HGAP) add(JPanel(HorizontalLayout(JBUI.scale(5))).apply { saveDefaultsItems.forEach { saveDefaultsComboBox.addItem(it) } - saveDefaultsComboBox.setRenderer(object : ListCellRendererWrapper() { - override fun customize(list: JList<*>?, value: SaveItem, index: Int, selected: Boolean, hasFocus: Boolean) { - setText(value.label) - } - }) + saveDefaultsComboBox.renderer = SimpleListCellRenderer.create("") { + it.label + } add(JLabel(KotlinBundle.message("formatter.text.use.defaults.from"))) add(saveDefaultsComboBox)