diff --git a/platform/credential-store/src/PasswordSafeConfigurable.kt b/platform/credential-store/src/PasswordSafeConfigurable.kt index d2e7d64d5074..91aa515a3b77 100644 --- a/platform/credential-store/src/PasswordSafeConfigurable.kt +++ b/platform/credential-store/src/PasswordSafeConfigurable.kt @@ -57,15 +57,14 @@ class PasswordSafeConfigurableUi : ConfigurableUi { row { rememberPasswordsUntilClosing() } } - if (!passwordSafe.isNativeCredentialStoreUsed) - row { - right { - button("Clear Passwords") { event -> - passwordSafe.clearPasswords() - Messages.showInfoMessage(event.source as Component, "Passwords were cleared", "Clear Passwords") - } + if (!passwordSafe.isNativeCredentialStoreUsed) { + row(separated = true) { + button("Clear Passwords") { event -> + passwordSafe.clearPasswords() + Messages.showInfoMessage(event.source as Component, "Passwords were cleared", "Clear Passwords") } } + } } private fun getProviderType(): ProviderType { diff --git a/platform/platform-impl/src/com/intellij/ui/layout/LayoutBuilder.kt b/platform/platform-impl/src/com/intellij/ui/layout/LayoutBuilder.kt index 752c26f29574..2fbb07fd3b20 100644 --- a/platform/platform-impl/src/com/intellij/ui/layout/LayoutBuilder.kt +++ b/platform/platform-impl/src/com/intellij/ui/layout/LayoutBuilder.kt @@ -21,11 +21,11 @@ import javax.swing.JLabel class LayoutBuilder(val `$`: LayoutBuilderImpl, val buttonGroup: ButtonGroup? = null) { inline fun row(label: String, init: Row.() -> Unit) { - row(Label(label), init) + row(label = Label(label), init = init) } - inline fun row(label: JLabel? = null, init: Row.() -> Unit) { - `$`.newRow(label, buttonGroup).init() + inline fun row(label: JLabel? = null, separated: Boolean = false, init: Row.() -> Unit) { + `$`.newRow(label, buttonGroup, separated).init() } /** diff --git a/platform/platform-impl/src/com/intellij/ui/layout/MigLayoutBuilder.kt b/platform/platform-impl/src/com/intellij/ui/layout/MigLayoutBuilder.kt index 22f9202780f9..233112163e2b 100644 --- a/platform/platform-impl/src/com/intellij/ui/layout/MigLayoutBuilder.kt +++ b/platform/platform-impl/src/com/intellij/ui/layout/MigLayoutBuilder.kt @@ -20,6 +20,8 @@ import com.intellij.openapi.actionSystem.ActionToolbar import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.ToggleAction import com.intellij.openapi.project.DumbAware +import com.intellij.openapi.ui.OnePixelDivider +import com.intellij.ui.SeparatorComponent import com.intellij.ui.components.noteComponent import com.intellij.util.SmartList import net.miginfocom.layout.* @@ -38,7 +40,13 @@ internal class MigLayoutBuilder : LayoutBuilderImpl { private val componentConstraints: MutableMap = SmartHashMap() - override fun newRow(label: JLabel?, buttonGroup: ButtonGroup?): Row { + override fun newRow(label: JLabel?, buttonGroup: ButtonGroup?, separated: Boolean): Row { + if (separated) { + val row = MigLayoutRow(componentConstraints, noGrid = true, separated = true) + rows.add(row) + row.apply { SeparatorComponent(0, OnePixelDivider.BACKGROUND, null)() } + } + val row = MigLayoutRow(componentConstraints, label != null, buttonGroup = buttonGroup) rows.add(row) @@ -48,7 +56,7 @@ internal class MigLayoutBuilder : LayoutBuilderImpl { } override fun noteRow(text: String) { - // add empty row + // add empty row as top gap newRow() val row = MigLayoutRow(componentConstraints, noGrid = true) @@ -106,6 +114,10 @@ internal class MigLayoutBuilder : LayoutBuilderImpl { if (component === row.components.first()) { // rowConstraints.noGrid() doesn't work correctly cc.spanX() + if (row.separated) { + cc.vertical.gapBefore = gapToBoundSize(VERTICAL_GAP * 3, false) + cc.vertical.gapAfter = gapToBoundSize(VERTICAL_GAP * 2, false) + } } } else { @@ -135,7 +147,7 @@ internal class MigLayoutBuilder : LayoutBuilderImpl { } private fun addGrowIfNeed(cc: CC, component: Component) { - if (component is JTextComponent) { + if (component is JTextComponent || component is SeparatorComponent) { cc.growX() } else if (component is JPanel && component.componentCount == 1 && @@ -144,7 +156,7 @@ private fun addGrowIfNeed(cc: CC, component: Component) { } } -private class MigLayoutRow(private val componentConstraints: MutableMap, val labeled: Boolean = false, val noGrid: Boolean = false, private val buttonGroup: ButtonGroup? = null) : Row() { +private class MigLayoutRow(private val componentConstraints: MutableMap, val labeled: Boolean = false, val noGrid: Boolean = false, private val buttonGroup: ButtonGroup? = null, val separated: Boolean = false) : Row() { val components = SmartList() var rightIndex = Int.MAX_VALUE diff --git a/platform/platform-impl/src/com/intellij/ui/layout/layoutImpl.kt b/platform/platform-impl/src/com/intellij/ui/layout/layoutImpl.kt index 68162d9c6876..a0aff8543335 100644 --- a/platform/platform-impl/src/com/intellij/ui/layout/layoutImpl.kt +++ b/platform/platform-impl/src/com/intellij/ui/layout/layoutImpl.kt @@ -32,7 +32,7 @@ fun createLayoutBuilder() = LayoutBuilder(MigLayoutBuilder()) // "When a protected member is accessed from an inline function, a public accessor method is created to provide an access to that protected member from the outside of the class where the function will be inlined to." // (https://youtrack.jetbrains.com/issue/KT-12215) interface LayoutBuilderImpl { - fun newRow(label: JLabel? = null, buttonGroup: ButtonGroup? = null): Row + fun newRow(label: JLabel? = null, buttonGroup: ButtonGroup? = null, separated: Boolean = false): Row fun build(container: Container, layoutConstraints: Array)