Code style settings: fix top border in UI

#KT-39180
This commit is contained in:
Dmitry Gridin
2020-05-28 09:28:52 +07:00
parent d115a1ff9c
commit dbd10380ee
2 changed files with 10 additions and 12 deletions
@@ -15,8 +15,8 @@ import com.intellij.util.ui.JBUI
import com.intellij.util.ui.UIUtil import com.intellij.util.ui.UIUtil
import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.KotlinLanguage import org.jetbrains.kotlin.idea.KotlinLanguage
import java.awt.BorderLayout
import javax.swing.BorderFactory import javax.swing.BorderFactory
import javax.swing.BoxLayout
import javax.swing.JCheckBox import javax.swing.JCheckBox
import javax.swing.JPanel import javax.swing.JPanel
@@ -47,11 +47,12 @@ class KotlinOtherSettingsPanel(settings: CodeStyleSettings) : CodeStyleAbstractP
override fun getTabTitle(): String = KotlinBundle.message("formatter.title.other") 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( add(
JBScrollPane( JBScrollPane(
JPanel(VerticalLayout(JBUI.scale(5))).apply { 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( add(
OptionGroup(KotlinBundle.message("formatter.title.trailing.comma")).apply { OptionGroup(KotlinBundle.message("formatter.title.trailing.comma")).apply {
add(cbTrailingComma) add(cbTrailingComma)
@@ -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. * 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.editor.colors.EditorColorsScheme
import com.intellij.openapi.ui.ComboBox import com.intellij.openapi.ui.ComboBox
import com.intellij.psi.codeStyle.CodeStyleSettings 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.JBScrollPane
import com.intellij.ui.components.panels.HorizontalLayout import com.intellij.ui.components.panels.HorizontalLayout
import com.intellij.ui.components.panels.VerticalLayout import com.intellij.ui.components.panels.VerticalLayout
@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.idea.KotlinLanguage
import java.awt.BorderLayout import java.awt.BorderLayout
import javax.swing.BorderFactory import javax.swing.BorderFactory
import javax.swing.JLabel import javax.swing.JLabel
import javax.swing.JList
import javax.swing.JPanel import javax.swing.JPanel
class KotlinSaveStylePanel(settings: CodeStyleSettings) : CodeStyleAbstractPanel(KotlinLanguage.INSTANCE, null, settings) { class KotlinSaveStylePanel(settings: CodeStyleSettings) : CodeStyleAbstractPanel(KotlinLanguage.INSTANCE, null, settings) {
@@ -53,17 +52,15 @@ class KotlinSaveStylePanel(settings: CodeStyleSettings) : CodeStyleAbstractPanel
add( add(
JBScrollPane( JBScrollPane(
JPanel(VerticalLayout(JBUI.scale(5))).apply { 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 { add(JPanel(HorizontalLayout(JBUI.scale(5))).apply {
saveDefaultsItems.forEach { saveDefaultsItems.forEach {
saveDefaultsComboBox.addItem(it) saveDefaultsComboBox.addItem(it)
} }
saveDefaultsComboBox.setRenderer(object : ListCellRendererWrapper<SaveItem>() { saveDefaultsComboBox.renderer = SimpleListCellRenderer.create("") {
override fun customize(list: JList<*>?, value: SaveItem, index: Int, selected: Boolean, hasFocus: Boolean) { it.label
setText(value.label) }
}
})
add(JLabel(KotlinBundle.message("formatter.text.use.defaults.from"))) add(JLabel(KotlinBundle.message("formatter.text.use.defaults.from")))
add(saveDefaultsComboBox) add(saveDefaultsComboBox)